lib/ssh/manager/db.rb in ssh-manager-0.0.6 vs lib/ssh/manager/db.rb in ssh-manager-0.0.7

- old
+ new

@@ -3,12 +3,12 @@ module SSH module Manager class Database - FileUtils.cp ("#{File.dirname(__FILE__)}/../../../config/sshm.db"), ("#{File.join(Dir.home)}" + '/.config/sshm/') unless File.exists?(("#{File.join(Dir.home)}" + '/.config/sshm/sshm.db')) FileUtils.mkdir_p("#{File.join(ENV['HOME'])}/.config/sshm/") unless Dir.exists?("#{ENV['HOME']}/.config/sshm") + FileUtils.cp ("#{File.dirname(__FILE__)}/../../../config/sshm.db"), ("#{File.join(Dir.home)}" + '/.config/sshm/') unless File.exists?(("#{File.join(Dir.home)}" + '/.config/sshm/sshm.db')) @path = "#{File.join(ENV['HOME'])}/.config/sshm" DATABASE = Sequel.connect("sqlite://#{@path}/sshm.db") attr_accessor :connections @@ -16,16 +16,15 @@ def initialize @connections= DATABASE.from(:connection) end def get_connection_data - @connections.map([:ip, :user, :hostname, :port, :note]) + @connections.map([:ip, :user, :hostname, :port, :note, :group]) end - def add_new_connection(ip, user='root', hostname='', port=22, note='') - # default params are currently useless FIXME - @connections.insert(:ip => ip, :user => user, :hostname => hostname, :port => port, :note => note) + def add_new_connection(ip, user='root', hostname='', port=22, note='', created_at, option, count, group, last_time) + @connections.insert(:ip => ip, :user => user, :hostname => hostname, :port => port, :note => note, :created_at => created_at, :options => option, :group => group, :count => count, :last_time => last_time) end def delete_connection(ip) # add && :user => user to ensure deletion @connections.where(:ip => ip).delete @@ -35,11 +34,12 @@ @connections.where(:ip => ip).update(:user => user, :hostname => hostname, :port => port, :note => note) end 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) + 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 + end end end