Module: Googletastic::Sync
- Defined in:
- lib/googletastic/sync.rb
Defined Under Namespace
Class Method Summary collapse
- .cleanup(syncables, options) ⇒ Object
-
.post(options = {}) ⇒ Object
POSTs to your registered application.
- .push(username, password, options = {}) ⇒ Object
- .sync_documents(documents, options = {}, &block) ⇒ Object
- .sync_forms(forms, options = {}, &block) ⇒ Object
Class Method Details
.cleanup(syncables, options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/googletastic/sync.rb', line 28 def cleanup(syncables, ) syncables.each do |syncable| syncable.synced_at = Time.now syncable.save! path = File.join([:folder], syncable.title) path += [:ext] if .has_key?(:ext) begin File.delete(path) rescue Exception => e end end end |
.post(options = {}) ⇒ Object
POSTs to your registered application
18 19 20 21 22 23 24 25 26 |
# File 'lib/googletastic/sync.rb', line 18 def post( = {}) url = URI.parse([:url]) # POST update to registered application http = Net::HTTP.new(url.host, url.port) header = [:header] || {} header.merge!('Content-Type' =>'application/json') data = [:data].to_json response = http.post([:path], data, header) end |
.push(username, password, options = {}) ⇒ Object
13 14 15 |
# File 'lib/googletastic/sync.rb', line 13 def push(username, password, = {}) Googletastic.client_for(:app_engine).push(username, password, ) end |
.sync_documents(documents, options = {}, &block) ⇒ Object
5 6 7 |
# File 'lib/googletastic/sync.rb', line 5 def sync_documents(documents, = {}, &block) Googletastic::Document.sync(documents, , &block) end |
.sync_forms(forms, options = {}, &block) ⇒ Object
9 10 11 |
# File 'lib/googletastic/sync.rb', line 9 def sync_forms(forms, = {}, &block) Googletastic::Form.sync(forms, , &block) end |