Class: Pwsafe::Agent::Driver
- Inherits:
-
Object
- Object
- Pwsafe::Agent::Driver
- Defined in:
- lib/pwsafe-agent/driver.rb
Instance Method Summary collapse
- #blank_password? ⇒ Boolean
- #flush ⇒ Object
- #get ⇒ Object
-
#initialize ⇒ Driver
constructor
A new instance of Driver.
- #set ⇒ Object
Constructor Details
#initialize ⇒ Driver
Returns a new instance of Driver.
4 5 6 |
# File 'lib/pwsafe-agent/driver.rb', line 4 def initialize @password = nil end |
Instance Method Details
#blank_password? ⇒ Boolean
32 33 34 |
# File 'lib/pwsafe-agent/driver.rb', line 32 def blank_password? @password == '' end |
#flush ⇒ Object
25 26 27 28 29 30 |
# File 'lib/pwsafe-agent/driver.rb', line 25 def flush UNIXSocket.open(SOCKET_PATH) do |sock| sock.write "FLUSH" sock.close end end |
#get ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pwsafe-agent/driver.rb', line 36 def get UNIXSocket.open(SOCKET_PATH) do |sock| sock.write 'GET' sock.close_write @password = sock.read sock.close end set if blank_password? @password end |
#set ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pwsafe-agent/driver.rb', line 8 def set UNIXSocket.open(SOCKET_PATH) do |sock| puts "type password" begin system 'stty -echo' password = STDIN.gets.chomp ensure system 'stty echo' end sock.write "SET=#{password}" sock.close_write @password = sock.read sock.close end end |