active_force 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -2
- data/CHANGELOG.md +6 -0
- data/README.md +43 -41
- data/active_force.gemspec +1 -1
- data/lib/active_attr/dirty.rb +0 -5
- data/lib/active_force/active_query.rb +66 -7
- data/lib/active_force/association/association.rb +4 -0
- data/lib/active_force/association/belongs_to_association.rb +11 -3
- data/lib/active_force/association/has_many_association.rb +6 -4
- data/lib/active_force/query.rb +5 -0
- data/lib/active_force/sobject.rb +45 -32
- data/lib/active_force/standard_types.rb +357 -0
- data/lib/active_force/table.rb +33 -0
- data/lib/active_force/version.rb +1 -1
- data/lib/generators/active_force/{active_force_model → model}/USAGE +0 -0
- data/lib/generators/active_force/model/model_generator.rb +61 -0
- data/lib/generators/active_force/model/templates/model.rb.erb +7 -0
- data/spec/active_force/active_query_spec.rb +79 -12
- data/spec/active_force/association_spec.rb +94 -16
- data/spec/active_force/callbacks_spec.rb +42 -0
- data/spec/active_force/query_spec.rb +10 -0
- data/spec/active_force/sobject/table_name_spec.rb +15 -4
- data/spec/active_force/sobject_spec.rb +72 -3
- data/spec/active_force/table_spec.rb +28 -0
- metadata +13 -8
- data/lib/generators/active_force/active_force_model/active_force_model_generator.rb +0 -47
- data/lib/generators/active_force/active_force_model/templates/model.rb.erb +0 -11
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'active_force/table'
|
3
|
+
|
4
|
+
describe ActiveForce::Table do
|
5
|
+
describe '#table_name' do
|
6
|
+
|
7
|
+
let(:table) { ActiveForce::Table }
|
8
|
+
|
9
|
+
it 'Use the class name adding "__c"' do
|
10
|
+
expect(table.new('Custom').name).to eq('Custom__c')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'with standard SObject types it does not add the "__c"' do
|
14
|
+
expect(table.new('Account').name).to eq('Account')
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with a namespace' do
|
18
|
+
it "the namespace is not included" do
|
19
|
+
expect(table.new('Foo::Bar').name).to eq('Bar__c')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'standard types are inferred correctly' do
|
23
|
+
expect(table.new('Foo::Account').name).to eq('Account')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_force
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Espinaco
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: active_attr
|
@@ -121,15 +121,19 @@ files:
|
|
121
121
|
- lib/active_force/association/has_many_association.rb
|
122
122
|
- lib/active_force/query.rb
|
123
123
|
- lib/active_force/sobject.rb
|
124
|
+
- lib/active_force/standard_types.rb
|
125
|
+
- lib/active_force/table.rb
|
124
126
|
- lib/active_force/version.rb
|
125
|
-
- lib/generators/active_force/
|
126
|
-
- lib/generators/active_force/
|
127
|
-
- lib/generators/active_force/
|
127
|
+
- lib/generators/active_force/model/USAGE
|
128
|
+
- lib/generators/active_force/model/model_generator.rb
|
129
|
+
- lib/generators/active_force/model/templates/model.rb.erb
|
128
130
|
- spec/active_force/active_query_spec.rb
|
129
131
|
- spec/active_force/association_spec.rb
|
132
|
+
- spec/active_force/callbacks_spec.rb
|
130
133
|
- spec/active_force/query_spec.rb
|
131
134
|
- spec/active_force/sobject/table_name_spec.rb
|
132
135
|
- spec/active_force/sobject_spec.rb
|
136
|
+
- spec/active_force/table_spec.rb
|
133
137
|
- spec/active_force_spec.rb
|
134
138
|
- spec/fixtures/sobject/single_sobject_hash.yml
|
135
139
|
- spec/spec_helper.rb
|
@@ -145,9 +149,9 @@ require_paths:
|
|
145
149
|
- lib
|
146
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
147
151
|
requirements:
|
148
|
-
- - "
|
152
|
+
- - ">="
|
149
153
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
154
|
+
version: 1.9.3
|
151
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
156
|
requirements:
|
153
157
|
- - ">="
|
@@ -162,12 +166,13 @@ summary: Help you implement models persisting on Sales Force within Rails using
|
|
162
166
|
test_files:
|
163
167
|
- spec/active_force/active_query_spec.rb
|
164
168
|
- spec/active_force/association_spec.rb
|
169
|
+
- spec/active_force/callbacks_spec.rb
|
165
170
|
- spec/active_force/query_spec.rb
|
166
171
|
- spec/active_force/sobject/table_name_spec.rb
|
167
172
|
- spec/active_force/sobject_spec.rb
|
173
|
+
- spec/active_force/table_spec.rb
|
168
174
|
- spec/active_force_spec.rb
|
169
175
|
- spec/fixtures/sobject/single_sobject_hash.yml
|
170
176
|
- spec/spec_helper.rb
|
171
177
|
- spec/support/fixture_helpers.rb
|
172
178
|
- spec/support/whizbang.rb
|
173
|
-
has_rdoc:
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module ActiveForce
|
2
|
-
class ActiveForceModelGenerator < Rails::Generators::NamedBase
|
3
|
-
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
def create_model_file
|
7
|
-
|
8
|
-
sf_field_names = list_field_names file_name.capitalize
|
9
|
-
@attributes = create_attributes sf_field_names
|
10
|
-
|
11
|
-
template "model.rb.erb", "app/models/#{file_name}.rb"
|
12
|
-
end
|
13
|
-
|
14
|
-
protected
|
15
|
-
|
16
|
-
Attribute = Struct.new(:local_name, :remote_name)
|
17
|
-
|
18
|
-
def create_attributes sf_field_names
|
19
|
-
sf_field_names.map do |field|
|
20
|
-
Attribute.new( sf_name_to_symbol(field) ,field)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def list_field_names table_name
|
25
|
-
Client.describe(table_name).fields.map do |field|
|
26
|
-
field.name
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def sf_name_to_symbol sf_name
|
31
|
-
sf_name = sf_name.underscore
|
32
|
-
sf_name = sf_name[0..-4] if sf_name.include? "__c"
|
33
|
-
sf_name.to_sym
|
34
|
-
end
|
35
|
-
|
36
|
-
class String
|
37
|
-
def underscore
|
38
|
-
self.gsub(/::/, '/').
|
39
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
40
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
41
|
-
tr("-", "_").
|
42
|
-
downcase
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'active_force/sobject'
|
2
|
-
|
3
|
-
class <%= class_name %> < ActiveForce::SObject
|
4
|
-
|
5
|
-
<% @attributes.each do |attribute| -%>
|
6
|
-
field :<%= attribute.local_name %>, from: '<%= attribute.remote_name %>',
|
7
|
-
<% end -%>
|
8
|
-
|
9
|
-
self.table_name = '<%= class_name %>'
|
10
|
-
|
11
|
-
end
|