restforce-db 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36ac82d6b0fe9d4374bfe7ee11b60fd36278b4ba
4
- data.tar.gz: 934bdb3ef457e51ac31bc1a80e101f789f803bf2
3
+ metadata.gz: 1841b09cb85809cd87a0f6ae83a6447054b882a6
4
+ data.tar.gz: 625a699341da7e4291c50ccb93fa20d2a0b03b0f
5
5
  SHA512:
6
- metadata.gz: ad9bea1820a4bfc48caa95dfbaf24860a3564a69d9d7598eae02478c98a764f9252273495e51a48a897c3466b0281a13b4bb95596567fa17f5145eace8ea9ca1
7
- data.tar.gz: 21188a40abaef043ada3c41bf197e1da4b4502e516e980e89fe9001d0f710dffd0170fcb7846aa1f0feba121e88fc1614124f60e2a0e9c419ed6f562b02f0c86
6
+ metadata.gz: 1f8500084cc35f4bd96f51e0f9d8c5f3403c65affd1912bb96053ccc3f36c4191fabd449bcb20c6c4a00fb97c41b5dfcecd4384ccf4926985e18223eb5ebadc0
7
+ data.tar.gz: 3b1d6678aa40b3959540454c3cf8c0f5cccc63a62fd3e59cbe2e2ad1800e5b1f9d88773be23da7db9203be048255f1811501e64731c68045838866fc98369032
data/README.md CHANGED
@@ -173,6 +173,21 @@ In the above example, `Dish__c` is a Salesforce object type which references the
173
173
  __NOTE__: Unlike `has_one` associations, `has_many` associations do not currently support multiple lookups from the same model. The Lookup is assumed
174
174
  to always refer to the `Id` of the parent object.
175
175
 
176
+ ### Seed your data
177
+
178
+ To populate your database with existing information from Salesforce (or vice-versa), you _could_ manually update each of the records you care about, and expect the Restforce::DB daemon to automatically pick them up when it runs. However, for any record type you need/want to _fully_ synchronize, this can be a very tedious process.
179
+
180
+ In these cases, you can run the `seed` rake task to synchronize the initial records between both systems.
181
+
182
+ $ bundle exec rake restforce:seed[<model>,<start_time>,<end_time>,<config>]
183
+
184
+ The task takes several arguments, most of which are optional:
185
+
186
+ - `model`: The name of the ActiveRecord model you wish to sync. This can be any model you've defined a mapping for in your application.
187
+ - `start_time` (optional): The earliest point in time for which records should be gathered.
188
+ - `end_time` (optional): The latest point in time for which records should be gathered.
189
+ - `config` (optional): The path to the file containing your Restforce::DB credentials. If not explicitly provided, the default installation file path (see above) will be used.
190
+
176
191
  ### Run the daemon
177
192
 
178
193
  To actually perform this system synchronization, you'll want to run the binstub installed through the generator (see above). This will daemonize a process which loops repeatedly to continuously synchronize your database and your Salesforce account, according to the established mappings.
@@ -0,0 +1,19 @@
1
+ module Restforce
2
+
3
+ module DB
4
+
5
+ # Restforce::DB::Railtie makes Restforce::DB's rake tasks available to any
6
+ # Rails application which requires the gem.
7
+ class Railtie < Rails::Railtie
8
+
9
+ railtie_name :"restforce-db"
10
+
11
+ rake_tasks do
12
+ load "tasks/restforce.rake"
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -7,7 +7,8 @@ module Restforce
7
7
  # modified records within the context of a specific Mapping.
8
8
  class Runner
9
9
 
10
- attr_reader :last_run, :before, :after
10
+ attr_reader :last_run
11
+ attr_accessor :before, :after
11
12
 
12
13
  # Public: Initialize a new Restforce::DB::Runner.
13
14
  #
@@ -3,7 +3,7 @@ module Restforce
3
3
  # :nodoc:
4
4
  module DB
5
5
 
6
- VERSION = "1.2.5"
6
+ VERSION = "1.2.6"
7
7
 
8
8
  end
9
9
 
data/lib/restforce/db.rb CHANGED
@@ -39,6 +39,8 @@ require "restforce/db/synchronizer"
39
39
  require "restforce/db/tracker"
40
40
  require "restforce/db/worker"
41
41
 
42
+ require "restforce/db/railtie" if defined?(Rails)
43
+
42
44
  module Restforce
43
45
 
44
46
  # Restforce::DB exposes basic Restforce client configuration methods for use
@@ -0,0 +1,20 @@
1
+ namespace :restforce do
2
+ desc "Populate all records for a specific model within the specified timespan"
3
+ task :seed, [:model, :start_time, :end_time, :config] => :environment do |_, args|
4
+ raise ArgumentError, "the name of an ActiveRecord model must be supplied" unless args[:model]
5
+
6
+ config_file = args[:config] || Rails.root.join("config", "restforce-db.yml")
7
+ Restforce::DB.configure { |config| config.parse(config_file) }
8
+
9
+ runner = Restforce::DB::Runner.new
10
+ runner.after = Time.parse(args[:start_time]) if args[:start_time].present?
11
+ runner.before = Time.parse(args[:end_time]) if args[:end_time].present?
12
+
13
+ target_class = args[:model].constantize
14
+ Restforce::DB::Registry[target_class].each do |mapping|
15
+ puts "SYNCHRONIZING between #{mapping.database_model.name} and #{mapping.salesforce_model}"
16
+ Restforce::DB::Initializer.new(mapping, runner).run
17
+ puts "DONE"
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Horner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -224,6 +224,7 @@ files:
224
224
  - lib/restforce/db/instances/salesforce.rb
225
225
  - lib/restforce/db/mapping.rb
226
226
  - lib/restforce/db/model.rb
227
+ - lib/restforce/db/railtie.rb
227
228
  - lib/restforce/db/record_types/active_record.rb
228
229
  - lib/restforce/db/record_types/base.rb
229
230
  - lib/restforce/db/record_types/salesforce.rb
@@ -238,6 +239,7 @@ files:
238
239
  - lib/restforce/db/version.rb
239
240
  - lib/restforce/db/worker.rb
240
241
  - lib/restforce/extensions.rb
242
+ - lib/tasks/restforce.rake
241
243
  - restforce-db.gemspec
242
244
  - test/cassettes/Restforce_DB/accessing_Salesforce/uses_the_configured_credentials.yml
243
245
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/returns_an_associated_record_populated_with_the_Salesforce_attributes.yml