Class: SSH::Manager::Database
- Inherits:
-
Object
- Object
- SSH::Manager::Database
- Defined in:
- lib/ssh/manager/db.rb
Constant Summary collapse
- DATABASE =
TODO make group a n:m relation to extra table
Sequel.sqlite(@database_file)
Instance Attribute Summary collapse
-
#connections ⇒ Object
Returns the value of attribute connections.
Instance Method Summary collapse
- #add_new_connection(connection) ⇒ Object
- #delete_connection(id) ⇒ Object
- #get_connection_by_id(id) ⇒ Object
- #get_connection_data ⇒ Object
-
#initialize ⇒ Database
constructor
A new instance of Database.
- #search_for(term) ⇒ Object
- #update_connection(connection) ⇒ Object
Constructor Details
Instance Attribute Details
#connections ⇒ Object
Returns the value of attribute connections.
37 38 39 |
# File 'lib/ssh/manager/db.rb', line 37 def connections @connections end |
Instance Method Details
#add_new_connection(connection) ⇒ Object
51 52 53 |
# File 'lib/ssh/manager/db.rb', line 51 def add_new_connection(connection) @connections.insert(connection) end |
#delete_connection(id) ⇒ Object
55 56 57 |
# File 'lib/ssh/manager/db.rb', line 55 def delete_connection(id) @connections.where(:id => id).delete end |
#get_connection_by_id(id) ⇒ Object
43 44 45 |
# File 'lib/ssh/manager/db.rb', line 43 def get_connection_by_id(id) @connections[:id => id].to_hash end |
#get_connection_data ⇒ Object
47 48 49 |
# File 'lib/ssh/manager/db.rb', line 47 def get_connection_data @connections.all end |
#search_for(term) ⇒ Object
63 64 65 66 |
# File 'lib/ssh/manager/db.rb', line 63 def search_for(term) # check online: search for 'contains' not for complete matching return @connections.where(:ip => term), @connections.where(:user => term), @connections.where(:hostname => term), @connections.where(:port => term), @connections.where(:note => term), @connections.where(:group => term), @connections.where(:options => term) end |
#update_connection(connection) ⇒ Object
59 60 61 |
# File 'lib/ssh/manager/db.rb', line 59 def update_connection(connection) @connections.where(:id => connection[:id]).update(connection) end |