class Remotes
Public Class Methods
get_db(url, name, pass)
click to toggle source
# File lib/africompta/entities/remote.rb, line 18 def self.get_db(url, name, pass) vers = Net::HTTP.get(URI.parse("#{url}/merge/version/#{name},#{pass}")) if vers != $VERSION.to_s return (vers =~ /not known/) ? 'User and/or password wrong' : 'Version mismatch' end db = Net::HTTP.get(URI.parse("#{url}/merge/get_db/#{name},#{pass}")) SQLite.dbs_close_all # All accounting-stuff is stored in the same database IO.write(Accounts.storage[:SQLiteAC].db_file, db) IO.write('/tmp/compta.db', db) SQLite.dbs_open_load_migrate # Delete all users except for the 'local' who needs a new id Users.search_all_.each { |u| if u.name == 'local' u.reset_id else u.delete end } # Delete all other remotes and add ourselves Remotes.search_all_.each { |r| r.delete } remote = Remotes.create(url: url, name: name, pass: pass) # Update all indexes ret = remote.do_copied if ret == true remote else ret end end
Public Instance Methods
create(d)
click to toggle source
Calls superclass method
# File lib/africompta/entities/remote.rb, line 3 def create(d) r = super(d) d.has_key?(:account_index) || r.account_index = 0 d.has_key?(:movement_index) || r.movement_index = 0 r end
setup_data()
click to toggle source
# File lib/africompta/entities/remote.rb, line 10 def setup_data value_str :url value_str :name value_str :pass value_int :account_index value_int :movement_index end