activeforce 2.1.1 → 3.0.0

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: e5be44027a755de63755da1855edef9cccbebf72
4
- data.tar.gz: e398c3a9ca3121b9d643e6f87f7af917c2daeb4e
3
+ metadata.gz: 9c74adafa6a11b9d1b31c13c34a27b7a14d3ab10
4
+ data.tar.gz: 5214ab5fea572a978b9faa040955d7cbc155e0de
5
5
  SHA512:
6
- metadata.gz: 787dd1eb72b321b27fc03eae2e0983b4c1f7b4d647ae1cf49830478d23e460b91095d3f5be4dae97a3862927b7a3d1ceae64c71c01b969b6b3b34c8db36fd2d3
7
- data.tar.gz: 3202443653176e1f775b1a0d7251a39ef590bc2e54e2c6e5c491eb55b9e9039c60acbd9e01db18f1e86110e97d8ae49a2392e1129940e77fc0617242193e76f5
6
+ metadata.gz: '0272659f78f50c7bcb40f19d340be86eceb25df3c4dc776b0f3c28dacb9ff9d683e37e895df42b0f9ac01ba6d7154437e41e3888605c790113fc4fe3fd0ff4ce'
7
+ data.tar.gz: 0efd4ca37a8c0e55da57a11666a4d1e6ddfa2ca09ebbc7376d6d6903fba815595e6154cf7883adc6aeac444e95fb03b18b7f066427591fb88e643c672c48f67f
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ _yardoc
18
18
  doc/
19
19
 
20
20
  Gemfile.lock
21
+ gemfiles/*.lock
@@ -1,9 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.1
3
+ - 2.3.3
4
4
  - 2.2.3
5
- - 2.1.4
6
- - 2.0.0
7
5
  - ruby-head
8
6
 
9
7
  sudo: false
@@ -16,3 +14,4 @@ gemfile:
16
14
  - gemfiles/4.0.gemfile
17
15
  - gemfiles/4.1.gemfile
18
16
  - gemfiles/4.2.gemfile
17
+ - gemfiles/5.0.gemfile
data/Appraisals CHANGED
@@ -7,5 +7,9 @@ appraise "4.1" do
7
7
  end
8
8
 
9
9
  appraise "4.2" do
10
- gem "rails", "~> 4.2"
10
+ gem "rails", "~> 4.2.0"
11
+ end
12
+
13
+ appraise "5.0" do
14
+ gem "rails", "~> 5.0.0"
11
15
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.required_ruby_version = ">= 2.0"
23
23
  s.summary = "A Simple gem to interact with the Salesforce REST API"
24
24
 
25
- s.add_dependency(%q<rails>, [">= 4.0", "< 5.0"])
25
+ s.add_dependency(%q<rails>, [">= 4.0", "< 5.1"])
26
26
  s.add_dependency(%q<savon>, ["~> 2.11"])
27
27
  s.add_dependency(%q<blockenspiel>, [">= 0"])
28
28
  s.add_dependency(%q<rest-client>, [">= 0", '< 2.0'])
@@ -3,7 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "mocha", "0.14.0", :require => false
6
+ gem "mocha", "0.14.0", require: false
7
7
  gem "rails", "~> 4.0.0"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -3,7 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "mocha", "0.14.0", :require => false
6
+ gem "mocha", "0.14.0", require: false
7
7
  gem "rails", "~> 4.1.0"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -3,7 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal"
6
- gem "mocha", "0.14.0", :require => false
7
- gem "rails", "~> 4.2"
6
+ gem "mocha", "0.14.0", require: false
7
+ gem "rails", "~> 4.2.0"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "mocha", "0.14.0", require: false
7
+ gem "rails", "~> 5.0.0"
8
+
9
+ gemspec path: "../"
@@ -1,3 +1,3 @@
1
1
  module Activeforce
2
- VERSION = '2.1.1'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
@@ -7,18 +7,18 @@ module Salesforce
7
7
  class Batch
8
8
  Result = Struct.new :id, :success, :created, :error
9
9
  include ::Salesforce::Attributes
10
-
10
+
11
11
  attr_accessor :id, :job, :number_records_failed, :number_records_processed, :state, :state_message, :total_time_processed, :filename, :csv
12
12
 
13
13
  include Blockenspiel::DSL
14
-
14
+
15
15
  def initialize(job)
16
16
  self.job = job
17
17
  self.filename = temporary_csv_file
18
18
  self.csv = CSVLib.open(self.filename, 'w+')
19
19
  self.csv << csv_header
20
20
  end
21
-
21
+
22
22
  def record(record)
23
23
  if record.is_a?(Hash)
24
24
  self.csv << ordered_values(record)
@@ -26,56 +26,56 @@ module Salesforce
26
26
  self.csv << ordered_values(record.attributes)
27
27
  end
28
28
  end
29
-
29
+
30
30
  def ordered_values(record)
31
31
  job.csv_columns.map do |col|
32
32
  raw_value = record[col.name.to_sym]
33
33
  Column.to_csv_value Column.typecast(col.type, raw_value)
34
34
  end
35
35
  end
36
-
36
+
37
37
  def create!
38
38
  self.csv.close
39
39
  response = ::Salesforce.connection.async_post("job/#{job.id}/batch", File.read(self.filename), :format => :xml, :content_type => 'text/csv')
40
40
  assign_attributes!(response)
41
41
  end
42
-
42
+
43
43
  def update_status
44
44
  return state if completed?
45
45
  response = ::Salesforce.connection.async_get("job/#{job.id}/batch/#{id}", :format => :xml)
46
46
  self.state = response[:state]
47
47
  end
48
-
48
+
49
49
  def results
50
50
  parse_csv_results ::Salesforce.connection.async_get("job/#{job.id}/batch/#{id}/result")
51
51
  end
52
-
52
+
53
53
  [ :queued, :in_progress, :completed, :failed, :not_processed ].each do |status|
54
54
  define_method "#{status}?" do
55
55
  self.state == status.to_s.titleize
56
56
  end
57
57
  end
58
-
58
+
59
59
  def temporary_csv_file
60
- if Object.const_defined?(:Rails) && Rails.root.present?
60
+ if Object.const_defined?(:Rails) && Rails.respond_to?(:root) && Rails.root.present?
61
61
  Rails.root.join('tmp', 'files', "#{ Time.now.to_i}#{rand(10000)}.csv")
62
62
  else
63
63
  File.join("/tmp/#{ Time.now.to_i}#{rand(10000)}.csv")
64
64
  end
65
65
  end
66
-
66
+
67
67
  private
68
-
68
+
69
69
  def parse_csv_results(results)
70
70
  parsed_results = CSVLib.parse(results)
71
71
  parsed_results[1..-1].map { |row| Result.new(*row) }
72
72
  end
73
-
73
+
74
74
  def csv_header
75
75
  self.job.csv_columns.map(&:original_name)
76
76
  end
77
-
78
-
77
+
78
+
79
79
  end
80
80
  end
81
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tushar Ranka
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: '4.0'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '5.0'
23
+ version: '5.1'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: '4.0'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '5.1'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: savon
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -148,6 +148,7 @@ files:
148
148
  - gemfiles/4.0.gemfile
149
149
  - gemfiles/4.1.gemfile
150
150
  - gemfiles/4.2.gemfile
151
+ - gemfiles/5.0.gemfile
151
152
  - lib/activeforce.rb
152
153
  - lib/activeforce/version.rb
153
154
  - lib/ruby_187_range_extension.rb
@@ -203,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
204
  version: '0'
204
205
  requirements: []
205
206
  rubyforge_project:
206
- rubygems_version: 2.6.9
207
+ rubygems_version: 2.6.14
207
208
  signing_key:
208
209
  specification_version: 4
209
210
  summary: A Simple gem to interact with the Salesforce REST API