lib/change_agent/client.rb in change_agent-0.1.0 vs lib/change_agent/client.rb in change_agent-0.2.0
- old
+ new
@@ -1,8 +1,9 @@
module ChangeAgent
class Client
+ include ChangeAgent::Sync
attr_accessor :directory
def initialize(directory=nil, remote=nil)
@directory = File.expand_path(directory || Dir.pwd)
@remote = remote
@@ -10,18 +11,19 @@
def repo
if @remote.nil?
@repo ||= Rugged::Repository.init_at directory
else
- @repo ||= Rugged::Repository.clone_at @remote, directory
+ @repo ||= Rugged::Repository.clone_at @remote, directory, {:credentials => credentials}
end
end
def set(key, value)
document = Document.new(key, self)
document.contents = value
- document.write
+ return unless document.changed?
+ document.save
document
end
def get(key)
get_document(key).contents
@@ -36,7 +38,8 @@
end
def inspect
"#<ChangeAgent::Client repo=\"#{directory}\">"
end
+
end
end