gd_salesforce 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Salesforce
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/salesforce.rb CHANGED
@@ -35,7 +35,7 @@ module Salesforce
35
35
  fields.map {|f| f[:name]}
36
36
  end
37
37
 
38
- def grab(options)
38
+ def grab(options={})
39
39
  sf_module = options[:module] || fail("Specify SFDC module")
40
40
  fields = options[:fields]
41
41
  rforce_binding = @rforce_binding
@@ -54,14 +54,16 @@ module Salesforce
54
54
  query(query, options.merge(:values => values))
55
55
  end
56
56
 
57
- def query(query, options)
57
+ def query(query, options={})
58
58
  values = options[:values]
59
59
  as_hash = options[:as_hash]
60
60
  counter = 1
61
- fail "If you want to return array you need to specify fields in values key" if !as_hash && values.nil?
62
-
61
+ as_hash = true if !as_hash && values.nil?
62
+
63
63
  rforce_binding = @rforce_binding
64
- output = options[:output]
64
+
65
+ output = options[:output] || []
66
+
65
67
  begin
66
68
  answer = rforce_binding.query({:queryString => query, :batchSize => 2000})
67
69
  rescue Timeout::Error => e
@@ -73,7 +75,7 @@ module Salesforce
73
75
  fail answer[:Fault][:faultstring] if answer[:Fault] && answer[:Fault][:faultstring]
74
76
  fail "An unknown error occured while querying salesforce."
75
77
  end
76
-
78
+
77
79
  answer[:queryResponse][:result][:records].each {|row| output << (as_hash ? row : row.values_at(*values))} if answer[:queryResponse][:result][:size].to_i > 0
78
80
 
79
81
  more_locator = answer[:queryResponse][:result][:queryLocator]
@@ -85,6 +87,7 @@ module Salesforce
85
87
  end
86
88
  more_locator = answer_more[:queryMoreResponse][:result][:queryLocator]
87
89
  end
90
+ output
88
91
  end
89
92
 
90
93
  def get_deleted(options={})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gd_salesforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-02 00:00:00.000000000 Z
12
+ date: 2013-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rforce