seiun 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +101 -6
- data/lib/seiun/client.rb +1 -1
- data/lib/seiun/connection.rb +3 -1
- data/lib/seiun/error.rb +7 -0
- data/lib/seiun/job.rb +3 -1
- data/lib/seiun/version.rb +1 -1
- data/lib/seiun/xml_generators/batch_xml.rb +3 -1
- data/lib/seiun/xml_parsers/batch_xml.rb +1 -1
- data/lib/seiun/xml_parsers/stream_listener.rb +1 -1
- data/lib/seiun.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91891c974d9bc379c22e7898c44eea9bcd842a83
|
4
|
+
data.tar.gz: 9adeee1ecea3a7d4be408742db193b8ad4308492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fae81b3efd78c7994b9ab669021572597ec4864da079af25e11470abf6dc729286a32caac1c46ccc84bd6849b922ed7816b37a33b6ac7d061001e6be5c9fd96f
|
7
|
+
data.tar.gz: 303c872863a668447e83fd07d98f1da1a0b9b89162132c9beb1e52433f06c54507460ce8aa5bd8f73ee70db58ad0e9fff71cddfd98b420391fdafd1f09f71232
|
data/README.md
CHANGED
@@ -1,8 +1,90 @@
|
|
1
|
-
|
1
|
+
![Seiun](https://s3-ap-northeast-1.amazonaws.com/naoki-watanabe/GitHub/seiun_20160101.jpg)
|
2
2
|
|
3
|
-
|
3
|
+
## What's this?
|
4
4
|
|
5
|
-
|
5
|
+
* This is the Salesforce client for ruby environment.
|
6
|
+
* You can read/write Salesforce database via Salesforce Bulk API with this gem.
|
7
|
+
* "Winter '16" version correspondence.
|
8
|
+
|
9
|
+
## Faster than popular gem
|
10
|
+
|
11
|
+
This gem "seiun" is **33 times** as fast as "salesforce_bulk_api" gem that is popular to use Salesforce Bulk API.
|
12
|
+
|
13
|
+
About system time, this gem more than 1,000 times as fast as "salesforce_bulk_api" gem.
|
14
|
+
|
15
|
+
```
|
16
|
+
user system total real
|
17
|
+
seiun#0
|
18
|
+
seiun#0 33.020000 0.290000 33.310000 ( 33.310086)
|
19
|
+
salesforce_bulk_api#0
|
20
|
+
salesforce_bulk_api#0 1457.280000 316.500000 1773.780000 (1773.840572)
|
21
|
+
|
22
|
+
```
|
23
|
+
|
24
|
+
The above measure time from receiving arguments to sending xml (10,000 records) on Amazon EC2 t2.medium instance.
|
25
|
+
|
26
|
+
## Callbacks
|
27
|
+
|
28
|
+
You can use original callback class.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
# example
|
32
|
+
class SomeModel < ActiveRecord::Base
|
33
|
+
include Seiun::Callback::Extends
|
34
|
+
seiun_before_request :before_request # call from gem
|
35
|
+
seiun_hashalize :hashalize # call from gem
|
36
|
+
|
37
|
+
def hashalize
|
38
|
+
# return hash object to write salesforce database
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# You can pass ActiveRecord Object without converting
|
43
|
+
@seiun.insert("TableName", SomeModel.where(category: "something"), callback_class: SomeModel)
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
## Queues
|
48
|
+
|
49
|
+
You can use insert/update/upsert/delete queues.
|
50
|
+
You are not a cause for concern about the record size limit. Queue process each 10,000 records.
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
# example
|
54
|
+
queue = @seiun.insert_queue("TableName")
|
55
|
+
SomeMode.find_each{|model| queue << model if model.available? }
|
56
|
+
queue.close
|
57
|
+
|
58
|
+
```
|
59
|
+
|
60
|
+
## Mocks
|
61
|
+
|
62
|
+
With mocks, you can test your application without connecting Salesforce API.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
class Mocks
|
66
|
+
include Seiun::Callback::Extends
|
67
|
+
seiun_mock_response_create_job :create_job
|
68
|
+
|
69
|
+
# This gem process as receive response below
|
70
|
+
def self.create_job
|
71
|
+
<<EOS
|
72
|
+
<?xml version="1.0" encoding="UTF-8"?><jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
|
73
|
+
<id>75028000000oEcVAAU</id>
|
74
|
+
<operation>upsert</operation>
|
75
|
+
<object>Campaign</object>
|
76
|
+
<createdById>00528000001lckgAAA</createdById>
|
77
|
+
<createdDate>2015-12-30T14:51:51.000Z</createdDate>
|
78
|
+
<systemModstamp>2015-12-30T14:51:51.000Z</systemModstamp>
|
79
|
+
<state>Open</state>
|
80
|
+
</jobInfo>
|
81
|
+
EOS
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
@seiun.insert("TableName", records, callback_class: Mocks)
|
86
|
+
|
87
|
+
```
|
6
88
|
|
7
89
|
## Installation
|
8
90
|
|
@@ -22,7 +104,21 @@ Or install it yourself as:
|
|
22
104
|
|
23
105
|
## Usage
|
24
106
|
|
25
|
-
|
107
|
+
This gem dependent on [databasedotcom](https://github.com/heroku/databasedotcom).
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
databasedotcom = Databasedotcom::Client.new(client_id: "customer_key", client_secret: "consumer_secret")
|
111
|
+
databasedotcom.authenticate(:username => "username", :password => "password_woth_security_token")
|
112
|
+
@seiun = Seiun::Client.new(databasedotcom: databasedotcom)
|
113
|
+
|
114
|
+
# example: insert
|
115
|
+
@seiun.insert("TableName", records)
|
116
|
+
|
117
|
+
# example: query
|
118
|
+
@seiun.query("TableName", "SELECT Id, Name FROM Account ORDER BY Id LIMIT 10000")
|
119
|
+
#=> [{ "Id" => "00528000001lckgAAA", "Name" => "Salesforce.com, Inc." }, { "Id" => "75028000000oEcVAAU", "Name" => "GitHub, Inc." }]
|
120
|
+
|
121
|
+
```
|
26
122
|
|
27
123
|
## Development
|
28
124
|
|
@@ -32,10 +128,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
128
|
|
33
129
|
## Contributing
|
34
130
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
131
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/naoki-watanabe/seiun. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
132
|
|
37
133
|
|
38
134
|
## License
|
39
135
|
|
40
136
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
data/lib/seiun/client.rb
CHANGED
data/lib/seiun/connection.rb
CHANGED
data/lib/seiun/error.rb
ADDED
data/lib/seiun/job.rb
CHANGED
@@ -87,14 +87,16 @@ module Seiun
|
|
87
87
|
end
|
88
88
|
batch.job_id = response.job_id || batch.job_id
|
89
89
|
batch.sf_state = response.state || batch.sf_state
|
90
|
+
batch.sf_state_message = response.state_message || batch.sf_state_message
|
90
91
|
batch.sf_created_at = response.created_date || batch.sf_created_at
|
91
92
|
batch.sf_updated_at = response.system_modstamp || batch.sf_updated_at
|
93
|
+
raise Seiun::BatchFailError, response.state_message if response.state == "Failed"
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
95
97
|
class Batch
|
96
98
|
attr_reader :id
|
97
|
-
attr_accessor :job_id, :sf_state, :sf_created_at, :sf_updated_at, :number_records_processed
|
99
|
+
attr_accessor :job_id, :sf_state, :sf_state_message, :sf_created_at, :sf_updated_at, :number_records_processed
|
98
100
|
|
99
101
|
def initialize(id)
|
100
102
|
@id = id
|
data/lib/seiun/version.rb
CHANGED
@@ -7,7 +7,7 @@ module Seiun
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
[ :id, :job_id, :state, :created_date, :system_modstamp ].each do |name|
|
10
|
+
[ :id, :job_id, :state, :created_date, :system_modstamp, :state_message ].each do |name|
|
11
11
|
define_method name do
|
12
12
|
to_hash(true)[Seiun::Utils.camelize(name)]
|
13
13
|
end
|
data/lib/seiun.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seiun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naoki Watanabe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: databasedotcom
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/seiun/callback/wrapper.rb
|
92
92
|
- lib/seiun/client.rb
|
93
93
|
- lib/seiun/connection.rb
|
94
|
+
- lib/seiun/error.rb
|
94
95
|
- lib/seiun/job.rb
|
95
96
|
- lib/seiun/queue.rb
|
96
97
|
- lib/seiun/utils.rb
|