restforce-db 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5c876e8802d8d0c563d8229ea3ebcfaa79347ce
4
- data.tar.gz: c74173bd30c5d1994091bf2ab832ad214403c9ed
3
+ metadata.gz: 2a376fa3d3ec57765c0d869be30dbd381e637559
4
+ data.tar.gz: 686f7970d90cb52377daeefab21f6e0b91c2d03c
5
5
  SHA512:
6
- metadata.gz: 54721e2987733bd681aeda548e188438c0905771870820b38fa115a7c490dbfd8ee5d63691448384951649a2df23b34410bb877c4d14d013d6247c54d5c956b7
7
- data.tar.gz: d7949e0760680a8433b5f9c6019a75c09e5862bc0013062403e2ae7d12ff70017aeed8eb8b1e585bd8c5bff507778000f30efa2e3e5a8a3ad4298c945f5f8674
6
+ metadata.gz: f377bfbcc127e815625f81908d2ab4ac509c6bce489552808dfcf11af3236ec8abdd299661c58fec0fe84ec0fcb3824678fe41ee51aaed274522fc03147b10ef
7
+ data.tar.gz: aeafbb041eef87730d18558bb897e5606cf54b4f8dbb379bcb4b08e7d3a789a703a3da99c9c22669588c6d78f59624344b0d88236c3629c02b0c5f1dadd6a0f8
data/README.md CHANGED
@@ -22,23 +22,32 @@ Or install it yourself as:
22
22
 
23
23
  First, you'll want to install the default bin and configuration files, which is handled by the included Rails generator:
24
24
 
25
- $ bundle exec rails g restforce
25
+ $ bundle exec rails g restforce:install
26
26
 
27
27
  This gem assumes that you're running Rails 4 or greater, therefore the `bin` file should be checked into the repository with the rest of your code. The `config/restforce-db.yml` file should be managed the same way you manage your secrets files, and probably not checked into the repository.
28
28
 
29
+ ### Update your model schema
30
+
31
+ In order to keep your database records in sync with Salesforce, the table will need to store a reference to its associated Salesforce record. A generator is included to trivially add this `salesforce_id` column to your tables:
32
+
33
+ $ bundle exec rails g restforce:migration MyModel
34
+ $ bundle exec rake db:migrate
35
+
36
+ ### Register a mapping
37
+
29
38
  To register a Salesforce mapping in an `ActiveRecord` model, you need to add a few lines of DSL-style code to your class definition:
30
39
 
31
40
  ```ruby
32
- class LineCook < ActiveRecord::Base
41
+ class MyModel < ActiveRecord::Base
33
42
 
34
43
  include Restforce::DB::Model
35
44
 
36
- map_to "Line_Cook__c", name: "Name", specialty: "Favorite_Food__c"
45
+ map_to "Object__c", name: "Name", color: "Color__c"
37
46
 
38
47
  end
39
48
  ```
40
49
 
41
- This will automatically register the model with an entry in the `Restforce::DB::RecordType` collection. Your schema **must** contain a `salesforce_id` column for each table you wish to synchronize with a record type in Salesforce.
50
+ This will automatically register the model with an entry in the `Restforce::DB::RecordType` collection.
42
51
 
43
52
  To run the worker, you'll want to run the binstub installed through the generator (see above). Then you can run the self-daemonizing executable.
44
53
 
@@ -0,0 +1,23 @@
1
+ require "rails/generators/base"
2
+
3
+ module Restforce
4
+
5
+ # :nodoc:
6
+ class InstallGenerator < Rails::Generators::Base
7
+
8
+ source_root File.expand_path("../../templates", __FILE__)
9
+
10
+ # :nodoc:
11
+ def create_config_file
12
+ template "config.yml", "config/restforce-db.yml"
13
+ end
14
+
15
+ # :nodoc:
16
+ def create_executable_file
17
+ template "script", "bin/restforce-db"
18
+ chmod "bin/restforce-db", 0755
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,17 @@
1
+ require "rails/generators/active_record"
2
+
3
+ module Restforce
4
+
5
+ # :nodoc:
6
+ class MigrationGenerator < ActiveRecord::Generators::Base
7
+
8
+ source_root File.expand_path("../../templates", __FILE__)
9
+
10
+ # :nodoc:
11
+ def create_migration_file
12
+ migration_template "migration.rb", "db/migrate/add_#{singular_name}_salesforce_binding.rb"
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,10 @@
1
+ # :nodoc:
2
+ class Add<%= class_name %>SalesforceBinding < ActiveRecord::Migration
3
+
4
+ # :nodoc:
5
+ def change
6
+ add_column :<%= table_name %>, :salesforce_id, :string
7
+ add_index :<%= table_name %>, :salesforce_id, unique: true
8
+ end
9
+
10
+ end
@@ -3,7 +3,7 @@ module Restforce
3
3
  # :nodoc:
4
4
  module DB
5
5
 
6
- VERSION = "0.1.5"
6
+ VERSION = "0.1.6"
7
7
 
8
8
  end
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Horner
@@ -214,8 +214,10 @@ files:
214
214
  - Rakefile
215
215
  - bin/console
216
216
  - bin/setup
217
- - lib/generators/restforce_generator.rb
217
+ - lib/generators/restforce/install_generator.rb
218
+ - lib/generators/restforce/migration_generator.rb
218
219
  - lib/generators/templates/config.yml
220
+ - lib/generators/templates/migration.rb.tt
219
221
  - lib/generators/templates/script
220
222
  - lib/restforce/db.rb
221
223
  - lib/restforce/db/command.rb
@@ -1,19 +0,0 @@
1
- require "rails/generators/base"
2
-
3
- # :nodoc:
4
- class RestforceGenerator < Rails::Generators::Base
5
-
6
- source_root File.expand_path("../templates", __FILE__)
7
-
8
- # :nodoc:
9
- def create_config_file
10
- template "config.yml", "config/restforce-db.yml"
11
- end
12
-
13
- # :nodoc:
14
- def create_executable_file
15
- template "script", "bin/restforce-db"
16
- chmod "bin/restforce-db", 0755
17
- end
18
-
19
- end