restforce-db 0.1.5 → 0.1.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 +4 -4
- data/README.md +13 -4
- data/lib/generators/restforce/install_generator.rb +23 -0
- data/lib/generators/restforce/migration_generator.rb +17 -0
- data/lib/generators/templates/migration.rb.tt +10 -0
- data/lib/restforce/db/version.rb +1 -1
- metadata +4 -2
- data/lib/generators/restforce_generator.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a376fa3d3ec57765c0d869be30dbd381e637559
|
4
|
+
data.tar.gz: 686f7970d90cb52377daeefab21f6e0b91c2d03c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
41
|
+
class MyModel < ActiveRecord::Base
|
33
42
|
|
34
43
|
include Restforce::DB::Model
|
35
44
|
|
36
|
-
map_to "
|
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.
|
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
|
data/lib/restforce/db/version.rb
CHANGED
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.
|
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/
|
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
|