embulk-input-marketo 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +14 -0
- data/CHANGELOG.md +5 -0
- data/Rakefile +5 -51
- data/embulk-input-marketo.gemspec +2 -1
- data/gemfiles/embulk-0.6.16 +4 -0
- data/gemfiles/embulk-0.6.17 +4 -0
- data/gemfiles/embulk-0.6.18 +4 -0
- data/gemfiles/embulk-0.6.19 +4 -0
- data/gemfiles/embulk-0.6.20 +4 -0
- data/gemfiles/embulk-0.6.21 +4 -0
- data/gemfiles/embulk-0.6.22 +4 -0
- data/gemfiles/embulk-0.6.23 +4 -0
- data/gemfiles/embulk-0.6.24 +4 -0
- data/gemfiles/embulk-0.6.25 +4 -0
- data/gemfiles/embulk-latest +4 -0
- data/gemfiles/template.erb +4 -0
- data/lib/embulk/input/marketo/activity_log.rb +5 -1
- data/lib/embulk/input/marketo/base.rb +3 -1
- data/lib/embulk/input/marketo_api/soap/activity_log.rb +20 -10
- data/test/activity_log_fixtures.rb +16 -0
- data/test/embulk/input/marketo/test_activity_log.rb +14 -0
- data/test/embulk/input/marketo/test_base.rb +11 -0
- data/test/embulk/input/marketo_api/soap/test_activity_log.rb +22 -3
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d395df72b2b9fafe6be7824001fb866c00f1f08
|
4
|
+
data.tar.gz: b344e828ecd3eb921ba38f9bc3c6bf26a3271ebe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1893639b47f6268c154c4636fc432152b3a9061e2a8292edba2b03c0b32a51b85152f0d2c5f861ccb5404e4d5ca091670b92e411a9a25c3316470735483d2b07
|
7
|
+
data.tar.gz: c75fdc17d13700f6aef74022e9d5849777f5b1d861bd2a62ed2d24008c87245ee8cf7ed53c17acb432b8788222a9174a725ac11368571a88d482f355c9c55a5f
|
data/.travis.yml
CHANGED
@@ -10,3 +10,17 @@ notifications:
|
|
10
10
|
secure: NP6hpwbwLnX9jFgENk3FN3B4jO4b2bIeK7gU9tRw87QmlUFDCcypSVYJrd7j1oQP4plZy+ohZMCs7RQJmtP1k2RQ99tu2ncWhslpz6f5zZo1Hjx4hleFpAv6N9tycfxEILcq/USxcTdM/8/YPtDr5WXM+w3hTuE21VlxqT6ED9LUYaiiUZeZApBXYAe36BIOGe+TtmwWrMfXvaqaoAt0A7pIzaXPD4i7WxR+qAMM4gjJGzH4JKs2zoQ2MgI81xD5Pe0yz/5ciiHATJj0WFkrOeZaoqFvW5MQ20eArvfW9dC7/fXnrPx8RPd6iaD29hQfnPI2mnWRvXxch0DsBcYOfFzYpdgx43XVTXVJ3zyudbgqnL8RrTbwIMsxIrEW3hAZ1MvxiKDBACWFdbzz8GAjywaq0zRZ/zKam1zcDRMQAWnZP54wUFHfSXvZWhRDzImSYTM75EqaspTabRQp89SpRuaGl+ab7wEDdJBXqLiUf7jHYc2K3F9o4B99luSvbxGv97M9D7P+Aee7tpFe4mjTuxjDnIVDbQzdza8qrZWXNfymSPb2pZOKP535alF92XalExBQnxKPzmUYDpTksrsgYPZeUHcnwO6J5lCPfPerWJ/U+s4PEm0HE5TpghhsZ901gYxCeDw/KnVQGsIy3f8YAI/+YVwjl4Ld4BOd1MV2PB8=
|
11
11
|
jdk:
|
12
12
|
- oraclejdk8
|
13
|
+
gemfile:
|
14
|
+
- gemfiles/embulk-0.6.16
|
15
|
+
- gemfiles/embulk-0.6.17
|
16
|
+
- gemfiles/embulk-0.6.18
|
17
|
+
- gemfiles/embulk-0.6.19
|
18
|
+
- gemfiles/embulk-0.6.20
|
19
|
+
- gemfiles/embulk-0.6.21
|
20
|
+
- gemfiles/embulk-0.6.22
|
21
|
+
- gemfiles/embulk-0.6.23
|
22
|
+
- gemfiles/embulk-latest
|
23
|
+
matrix:
|
24
|
+
allow_failures:
|
25
|
+
- gemfile: gemfiles/embulk-0.6.22
|
26
|
+
- gemfile: gemfiles/embulk-latest
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.1.1 - 2015-08-19
|
2
|
+
|
3
|
+
* [enhanement] Support scheduled execution [#20](https://github.com/treasure-data/embulk-input-marketo/pull/20) [[Reported by @muga](https://github.com/treasure-data/embulk-input-marketo/issues/18). Thanks!]
|
4
|
+
* [maintenance] Use everyleaf-embulk_helper [#19](https://github.com/treasure-data/embulk-input-marketo/pull/19)
|
5
|
+
|
1
6
|
## 0.1.0 - 2015-07-15
|
2
7
|
|
3
8
|
We implemented activity_log plugin for marketo, so config generated from 0.0.1 should be modified. Please check README.md to do it.
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "
|
2
|
+
require "everyleaf/embulk_helper/tasks"
|
3
3
|
|
4
4
|
task default: :test
|
5
5
|
|
@@ -8,53 +8,7 @@ task :test do
|
|
8
8
|
ruby("test/run-test.rb", "--use-color=yes", "--collector=dir")
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
changelog_file = root_dir.join("CHANGELOG.md")
|
16
|
-
gemspec_file = root_dir.join("embulk-input-marketo.gemspec")
|
17
|
-
|
18
|
-
system("git fetch origin")
|
19
|
-
|
20
|
-
# detect merged PR
|
21
|
-
old_version = gemspec_file.read[/spec\.version += *"([0-9]+\.[0-9]+\.[0-9]+)"/, 1]
|
22
|
-
pr_numbers = `git log v#{old_version}..origin/master --oneline`.scan(/#[0-9]+/)
|
23
|
-
|
24
|
-
if !$?.success? || pr_numbers.empty?
|
25
|
-
puts "Detecting PR failed. Please confirm if any PR were merged after the latest release."
|
26
|
-
exit(false)
|
27
|
-
end
|
28
|
-
|
29
|
-
# Generate new version
|
30
|
-
major, minor, patch = old_version.split(".").map(&:to_i)
|
31
|
-
new_version = "#{major}.#{minor}.#{patch + 1}"
|
32
|
-
|
33
|
-
# Update ChangeLog
|
34
|
-
pr_descriptions = pr_numbers.map do |number|
|
35
|
-
body = open("https://api.github.com/repos/treasure-data/embulk-input-marketo/issues/#{number.gsub("#", "")}").read
|
36
|
-
payload = JSON.parse(body)
|
37
|
-
"* [] #{payload["title"]} [#{number}](https://github.com/treasure-data/embulk-input-marketo/pull/#{number.gsub('#', '')})"
|
38
|
-
end.join("\n")
|
39
|
-
|
40
|
-
new_changelog = <<-HEADER
|
41
|
-
## #{new_version} - #{Time.now.strftime("%Y-%m-%d")}
|
42
|
-
#{pr_descriptions}
|
43
|
-
|
44
|
-
#{changelog_file.read.chomp}
|
45
|
-
HEADER
|
46
|
-
|
47
|
-
File.open(changelog_file, "w") {|f| f.write(new_changelog) }
|
48
|
-
|
49
|
-
# Update version.rb
|
50
|
-
old_content = gemspec_file.read
|
51
|
-
File.open(gemspec_file, "w") do |f|
|
52
|
-
f.write old_content.gsub(/(spec\.version += *)".*?"/, %Q!\\1"#{new_version}"!)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Update Gemfile.lock
|
56
|
-
system("bundle install")
|
57
|
-
|
58
|
-
puts "ChangeLog, version and Gemfile.lock were updated. New version is #{new_version}."
|
59
|
-
end
|
60
|
-
end
|
11
|
+
Everyleaf::EmbulkHelper::Tasks.install(
|
12
|
+
gemspec: "./embulk-input-marketo.gemspec",
|
13
|
+
github_name: "treasure-data/embulk-input-marketo",
|
14
|
+
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "embulk-input-marketo"
|
3
|
-
spec.version = "0.1.
|
3
|
+
spec.version = "0.1.1"
|
4
4
|
spec.authors = ["uu59", "yoshihara"]
|
5
5
|
spec.summary = "Marketo input plugin for Embulk"
|
6
6
|
spec.description = "Loads records from Marketo."
|
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_development_dependency 'test-unit'
|
21
21
|
spec.add_development_dependency 'test-unit-rr'
|
22
22
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
23
|
+
spec.add_development_dependency 'everyleaf-embulk_helper'
|
23
24
|
end
|
@@ -33,7 +33,7 @@ module Embulk
|
|
33
33
|
|
34
34
|
count = 0
|
35
35
|
|
36
|
-
@soap.each(@last_updated_at, batch_size: batch_size) do |activity_log|
|
36
|
+
last_updated_at = @soap.each(@last_updated_at, batch_size: batch_size) do |activity_log|
|
37
37
|
values = @columns.map do |column|
|
38
38
|
name = column["name"].to_s
|
39
39
|
activity_log[name]
|
@@ -47,6 +47,10 @@ module Embulk
|
|
47
47
|
page_builder.finish
|
48
48
|
|
49
49
|
commit_report = {}
|
50
|
+
if !preview? && last_updated_at
|
51
|
+
commit_report = {last_updated_at: last_updated_at}
|
52
|
+
end
|
53
|
+
|
50
54
|
return commit_report
|
51
55
|
end
|
52
56
|
end
|
@@ -37,7 +37,9 @@ module Embulk
|
|
37
37
|
def self.resume(task, columns, count, &control)
|
38
38
|
commit_reports = yield(task, columns, count)
|
39
39
|
|
40
|
-
|
40
|
+
# NOTE: If this plugin supports to run by multi threads, this
|
41
|
+
# implementation is terrible.
|
42
|
+
next_config_diff = commit_reports.first
|
41
43
|
return next_config_diff
|
42
44
|
end
|
43
45
|
|
@@ -16,11 +16,13 @@ module Embulk
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def each(last_updated_at, options={}, &block)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
response = fetch_by_last_updated_at(last_updated_at, options, &block)
|
20
|
+
while response[:remaining_count] > 0 do
|
21
|
+
offset = response[:offset]
|
22
|
+
response = fetch_by_offset(offset, options, &block)
|
23
23
|
end
|
24
|
+
|
25
|
+
response[:last_updated_at]
|
24
26
|
end
|
25
27
|
|
26
28
|
private
|
@@ -55,7 +57,15 @@ module Embulk
|
|
55
57
|
remaining = response.body[:success_get_lead_changes][:result][:remaining_count].to_i
|
56
58
|
Embulk.logger.info "Remaining records: #{remaining}"
|
57
59
|
|
58
|
-
|
60
|
+
activities_list = response.body[:success_get_lead_changes][:result][:lead_change_record_list]
|
61
|
+
|
62
|
+
if activities_list.nil?
|
63
|
+
Embulk.logger.info "No record is fetched."
|
64
|
+
return {remaining_count: 0, offset: nil, last_updated_at: nil}
|
65
|
+
end
|
66
|
+
|
67
|
+
activities = activities_list[:lead_change_record].sort { |activity| activity[:activity_date_time] }
|
68
|
+
|
59
69
|
activities.each do |activity|
|
60
70
|
record = {
|
61
71
|
"id" => activity[:id],
|
@@ -76,11 +86,11 @@ module Embulk
|
|
76
86
|
block.call(record)
|
77
87
|
end
|
78
88
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
89
|
+
{
|
90
|
+
remaining_count: remaining,
|
91
|
+
offset: response.body[:success_get_lead_changes][:result][:new_start_position][:offset],
|
92
|
+
last_updated_at: activities.last[:activity_date_time]
|
93
|
+
}
|
84
94
|
end
|
85
95
|
end
|
86
96
|
end
|
@@ -13,6 +13,10 @@ module ActivityLogFixtures
|
|
13
13
|
activity_logs(preview_response)
|
14
14
|
end
|
15
15
|
|
16
|
+
def none_activity_log_response
|
17
|
+
activity_logs(none_response)
|
18
|
+
end
|
19
|
+
|
16
20
|
def activity_logs(body)
|
17
21
|
Struct.new(:body).new({
|
18
22
|
success_get_lead_changes: {
|
@@ -152,4 +156,16 @@ module ActivityLogFixtures
|
|
152
156
|
}
|
153
157
|
}
|
154
158
|
end
|
159
|
+
|
160
|
+
def none_response
|
161
|
+
{
|
162
|
+
result: {
|
163
|
+
return_count: 0,
|
164
|
+
remaining_count: 0,
|
165
|
+
new_start_position: {
|
166
|
+
},
|
167
|
+
lead_change_record_list: nil
|
168
|
+
}
|
169
|
+
}
|
170
|
+
end
|
155
171
|
end
|
@@ -110,6 +110,20 @@ module Embulk
|
|
110
110
|
@plugin.run
|
111
111
|
end
|
112
112
|
|
113
|
+
def test_run_with_no_response
|
114
|
+
stub(@plugin).preview? { false }
|
115
|
+
|
116
|
+
any_instance_of(Savon::Client) do |klass|
|
117
|
+
mock(klass).call(:get_lead_changes, message: request) do
|
118
|
+
none_activity_log_response
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
mock(@page_builder).finish
|
123
|
+
|
124
|
+
@plugin.run
|
125
|
+
end
|
126
|
+
|
113
127
|
def test_preview_through
|
114
128
|
stub(@plugin).preview? { true }
|
115
129
|
|
@@ -21,6 +21,17 @@ module Embulk
|
|
21
21
|
Base.transaction(config, &control)
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_resume
|
25
|
+
next_config_diff = {last_updated_at: last_updated_at}
|
26
|
+
control = proc { [next_config_diff] } # In actual, embulk prepares control block returning Array.
|
27
|
+
columns = task[:columns].map do |col|
|
28
|
+
Column.new(nil, col["name"], col["type"].to_sym)
|
29
|
+
end
|
30
|
+
|
31
|
+
actual = Base.resume(task, columns, 1, &control)
|
32
|
+
assert_equal(next_config_diff, actual)
|
33
|
+
end
|
34
|
+
|
24
35
|
private
|
25
36
|
|
26
37
|
def config
|
@@ -27,11 +27,30 @@ module Embulk
|
|
27
27
|
end
|
28
28
|
|
29
29
|
proc = proc{ "" }
|
30
|
-
|
30
|
+
activity_logs = next_stream_activity_logs_response[:body][:success_get_lead_changes][:result][:lead_change_record_list][:lead_change_record]
|
31
|
+
last_activity_log = activity_logs.last
|
31
32
|
|
32
|
-
mock(proc).call(anything).times(
|
33
|
+
mock(proc).call(anything).times(activity_logs.size)
|
34
|
+
assert_equal(last_activity_log[:activity_date_time], soap.each(last_updated_at, &proc))
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_each_with_no_response
|
38
|
+
request = {
|
39
|
+
start_position: {
|
40
|
+
oldest_created_at: Time.parse(last_updated_at).iso8601,
|
41
|
+
},
|
42
|
+
batch_size: 100
|
43
|
+
}
|
44
|
+
|
45
|
+
any_instance_of(Savon::Client) do |klass|
|
46
|
+
mock(klass).call(:get_lead_changes, message: request) do
|
47
|
+
none_activity_log_response
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
proc = proc{ "" }
|
33
52
|
|
34
|
-
soap.each(last_updated_at, &proc)
|
53
|
+
assert_nil(soap.each(last_updated_at, &proc))
|
35
54
|
end
|
36
55
|
|
37
56
|
class TestMetadata < self
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-marketo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uu59
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +129,20 @@ dependencies:
|
|
129
129
|
- - '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
|
+
- !ruby/object:Gem::Dependency
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
name: everyleaf-embulk_helper
|
139
|
+
prerelease: false
|
140
|
+
type: :development
|
141
|
+
version_requirements: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
132
146
|
description: Loads records from Marketo.
|
133
147
|
email:
|
134
148
|
- k@uu59.org
|
@@ -146,6 +160,18 @@ files:
|
|
146
160
|
- README.md
|
147
161
|
- Rakefile
|
148
162
|
- embulk-input-marketo.gemspec
|
163
|
+
- gemfiles/embulk-0.6.16
|
164
|
+
- gemfiles/embulk-0.6.17
|
165
|
+
- gemfiles/embulk-0.6.18
|
166
|
+
- gemfiles/embulk-0.6.19
|
167
|
+
- gemfiles/embulk-0.6.20
|
168
|
+
- gemfiles/embulk-0.6.21
|
169
|
+
- gemfiles/embulk-0.6.22
|
170
|
+
- gemfiles/embulk-0.6.23
|
171
|
+
- gemfiles/embulk-0.6.24
|
172
|
+
- gemfiles/embulk-0.6.25
|
173
|
+
- gemfiles/embulk-latest
|
174
|
+
- gemfiles/template.erb
|
149
175
|
- lib/embulk/input/marketo/activity_log.rb
|
150
176
|
- lib/embulk/input/marketo/base.rb
|
151
177
|
- lib/embulk/input/marketo/lead.rb
|