salesforce_bulk_query 0.0.3 → 0.0.4
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 +5 -13
- data/README.md +44 -42
- data/lib/salesforce_bulk_query.rb +5 -0
- data/lib/salesforce_bulk_query/query.rb +2 -1
- data/lib/salesforce_bulk_query/version.rb +1 -1
- data/spec/salesforce_bulk_query_spec.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NGM4Y2ZmZTM3ODUwYjk4OGVmZjgwNmY0OTQzNjc5MTk0YWFiYTIyMA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a35d7475e79ba07b3fa4670c7883efc70a1be3b0
|
4
|
+
data.tar.gz: f2234bbc4b5689aa3e9953092cacc89dc6a1c0fa
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZGZiYjBmMmVmYTU2OWFkZGEwODIzOWRlN2I0MTYyNGFiODQwZWU3MTNiOTI3
|
11
|
-
ZmUxMWVkMmZmZWUwMTJhMzUzZWU1ODViZmY3YTUxY2M0MjBhZDE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZTViZTk4M2Y5MTg0ZTI2M2ViYmIxYzQ5ZDg1NzJjZGI4ZmRiMjJhNzczZTRk
|
14
|
-
OGI0YmYzY2I4OWVhNzA5ZWJjOWQwOThkYTYwMGFmZDlkMjVmYmFiZjQ5MTU1
|
15
|
-
YTQ0ZWFlYzA5NWY1OTJmODA4Y2FmMjQ2YjBkNzIyZmIxYTg0ZDE=
|
6
|
+
metadata.gz: 41e48bada843cc5c2b1a8bb4a9335bc767a6b36258005d745540673361be303790dbc6fe6a14dacbb90554c6d6069f0539f307b55ea471997c323f1512cc6591
|
7
|
+
data.tar.gz: 39bef5c6e5b77745a14490faa7c860c550bce86026bf3f7b7420b6b41ad1a3c7100c496cd6efea5ad9c30d011543b6b0471b9e08ef33253783049fb1228cc64b
|
data/README.md
CHANGED
@@ -21,47 +21,49 @@ You will also need a Salesforce connected app for the `client_id` and `client_se
|
|
21
21
|
|
22
22
|
For doing most of the API calls, the library uses [Restforce](https://github.com/ejholmes/restforce) Code example:
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
24
|
+
```ruby
|
25
|
+
require 'restforce'
|
26
|
+
require 'salesforce_bulk_query'
|
27
|
+
|
28
|
+
# Create a restforce client instance
|
29
|
+
# with basic auth
|
30
|
+
restforce = Restforce.new(
|
31
|
+
:username => 'me',
|
32
|
+
:password => 'password',
|
33
|
+
:security_token => 'token',
|
34
|
+
:client_id => "my sfdc app client id",
|
35
|
+
:client_secret => "my sfdc app client secret"
|
36
|
+
)
|
37
|
+
|
38
|
+
# or OAuth
|
39
|
+
restforce = Restforce.new(
|
40
|
+
:refresh_token => "xyz",
|
41
|
+
:client_id => "my sfdc app client id",
|
42
|
+
:client_secret => "my sfdc app client secret"
|
43
|
+
)
|
44
|
+
|
45
|
+
bulk_api = SalesforceBulkQuery::Api.new(restforce)
|
46
|
+
|
47
|
+
# query the api
|
48
|
+
result = bulk_api.query("Task", "SELECT Id, Name FROM Task")
|
49
|
+
|
50
|
+
# the result is files
|
51
|
+
puts "All the downloaded stuff is in csvs: #{result[:filenames]}"
|
52
|
+
|
53
|
+
# query is a blocking call and can take several hours
|
54
|
+
# if you want to just start the query asynchronously, use
|
55
|
+
query = start_query("Task", "SELECT Id, Name FROM Task")
|
56
|
+
|
57
|
+
# get a cofee
|
58
|
+
sleep(1234)
|
59
|
+
|
60
|
+
# check the status
|
61
|
+
status = query.check_status
|
62
|
+
if status[:finished]
|
63
|
+
result = query.get_results
|
64
|
+
puts "All the downloaded stuff is in csvs: #{result[:filenames]}"
|
65
|
+
end
|
66
|
+
```
|
65
67
|
|
66
68
|
## How it works
|
67
69
|
|
@@ -100,7 +102,7 @@ See specs for exact usage.
|
|
100
102
|
# switch off logging in Restforce so you don't get every message twice
|
101
103
|
Restforce.log = false
|
102
104
|
|
103
|
-
If you're using Restforce as a client (which you probably are) and you want to do logging, Salesforce Bulk Query will use a custom logging middleware for Restforce. This is because the original logging middleware puts all API responses to log, which is not something you would like to do for a few gigabytes CSVs. When you use the :logger parameter it's recommended you
|
105
|
+
If you're using Restforce as a client (which you probably are) and you want to do logging, Salesforce Bulk Query will use a custom logging middleware for Restforce. This is because the original logging middleware puts all API responses to log, which is not something you would like to do for a few gigabytes CSVs. When you use the :logger parameter it's recommended you switch off the default logging in Restforce, otherwise you'll get all messages twice.
|
104
106
|
|
105
107
|
## Copyright
|
106
108
|
|
@@ -84,6 +84,11 @@ module SalesforceBulkQuery
|
|
84
84
|
sleep(check_interval)
|
85
85
|
end
|
86
86
|
|
87
|
+
# nice list of files to log
|
88
|
+
if @logger && ! results[:filenames].empty?
|
89
|
+
@logger.info "Download finished. Downloaded files in #{File.dirname(results[:filenames][0])}. Filename size:"
|
90
|
+
@logger.info "\n" + results[:filenames].sort.map{|f| "#{File.basename(f)} #{File.size(f)}"}.join("\n")
|
91
|
+
end
|
87
92
|
return results
|
88
93
|
end
|
89
94
|
|
@@ -39,7 +39,7 @@ describe SalesforceBulkQuery do
|
|
39
39
|
|
40
40
|
describe "query" do
|
41
41
|
context "when you give it no options" do
|
42
|
-
it "downloads the data to a few
|
42
|
+
it "downloads the data to a few files", :constraint => 'slow' do
|
43
43
|
result = @api.query("Opportunity", "SELECT Id, Name FROM Opportunity")
|
44
44
|
result[:filenames].should have_at_least(2).items
|
45
45
|
result[:results].should_not be_empty
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salesforce_bulk_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Cvengros
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -128,12 +128,12 @@ require_paths:
|
|
128
128
|
- lib
|
129
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - '>='
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '1.9'
|
134
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
@@ -143,4 +143,3 @@ signing_key:
|
|
143
143
|
specification_version: 4
|
144
144
|
summary: Downloading data from Salesforce Bulk API made easy and scalable.
|
145
145
|
test_files: []
|
146
|
-
has_rdoc:
|