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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7de3f0f124846b84a0df2b1d4fd7824c1453b3ff
4
- data.tar.gz: 7796e77550eb46c7f4208f373dc9c84b5b8b7e0d
3
+ metadata.gz: 9d395df72b2b9fafe6be7824001fb866c00f1f08
4
+ data.tar.gz: b344e828ecd3eb921ba38f9bc3c6bf26a3271ebe
5
5
  SHA512:
6
- metadata.gz: e765f8a460352604ee6b77f49e03f39d25db1a1b4a77d288c55f7e946bd9e88e8bcccd9c680fb2f281eb08e148024af47c86cc8cf3e14f6c1e26ce2e1e7c6c4b
7
- data.tar.gz: 56c092c2965c8c36f2866953e2a74e123d22573cb48ab23ffd7dcbc793b6ab167f22f29c0cfc83d81a6b36a9d1256b2d182b950a0f8cee93d076a1591528bb44
6
+ metadata.gz: 1893639b47f6268c154c4636fc432152b3a9061e2a8292edba2b03c0b32a51b85152f0d2c5f861ccb5404e4d5ca091670b92e411a9a25c3316470735483d2b07
7
+ data.tar.gz: c75fdc17d13700f6aef74022e9d5849777f5b1d861bd2a62ed2d24008c87245ee8cf7ed53c17acb432b8788222a9174a725ac11368571a88d482f355c9c55a5f
@@ -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
@@ -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 "json"
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
- namespace :release do
12
- desc "Add header of now version release to ChangeLog and bump up version"
13
- task :prepare do
14
- root_dir = Pathname.new(File.expand_path("../", __FILE__))
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.0"
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
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.16"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.17"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.18"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.19"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.20"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.21"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.22"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.23"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.24"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "0.6.25"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "> 0.6.16"
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec :path => '../'
3
+
4
+ gem "embulk", "<%= version %>"
@@ -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
- next_config_diff = {}
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
- offset = fetch_by_last_updated_at(last_updated_at, options, &block)
20
-
21
- while offset
22
- offset = fetch_by_offset(offset, options, &block)
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
- activities = response.body[:success_get_lead_changes][:result][:lead_change_record_list][:lead_change_record]
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
- if remaining > 0
80
- response.body[:success_get_lead_changes][:result][:new_start_position][:offset]
81
- else
82
- nil
83
- end
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
- activity_log_count = next_stream_activity_logs_response[:body][:success_get_lead_changes][:result][:lead_change_record_list][:lead_change_record].size
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(activity_log_count)
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.0
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-07-15 00:00:00.000000000 Z
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