sem4r 0.1.3 → 0.1.5
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.
- data/.gemtest +0 -0
- data/Gemfile +2 -22
- data/Gemfile.lock +43 -20
- data/Rakefile +4 -2
- data/bin/sem +2 -6
- data/lib/sem4r/adwords.rb +8 -142
- data/lib/sem4r/campaign/campaign_account_extension.rb +4 -5
- data/lib/sem4r/profile.rb +173 -0
- data/lib/sem4r/sem4r_utilities.rb +113 -0
- data/lib/sem4r/v13_report/report.rb +5 -0
- data/lib/sem4r/version.rb +27 -0
- data/lib/sem4r.rb +5 -26
- data/lib/sem4r_cli/cli_sem.rb +116 -170
- data/lib/sem4r_cli/commands/{cli_ads.rb → cmd_ads.rb} +4 -4
- data/lib/sem4r_cli/commands/{cli_campaign.rb → cmd_campaign.rb} +7 -7
- data/lib/sem4r_cli/commands/{cli_clients.rb → cmd_clients.rb} +4 -5
- data/lib/sem4r_cli/commands/{cli_ideas.rb → cmd_ideas.rb} +7 -5
- data/lib/sem4r_cli/commands/{cli_info.rb → cmd_info.rb} +6 -6
- data/lib/sem4r_cli/commands/{cli_job.rb → cmd_job.rb} +4 -2
- data/lib/sem4r_cli/commands/{cli_keywords.rb → cmd_keywords.rb} +4 -4
- data/lib/sem4r_cli/commands/{cli_profile.rb → cmd_profile.rb} +23 -19
- data/lib/sem4r_cli/commands/{cli_repdef.rb → cmd_repdef.rb} +6 -4
- data/lib/sem4r_cli/commands/{cli_report.rb → cmd_report.rb} +8 -6
- data/lib/sem4r_cli.rb +6 -4
- data/lib/sem4r_debug_client/client.rb +200 -0
- data/lib/sem4r_debug_client.rb +31 -0
- data/lib/sem4r_sinatra/cli_server.rb +45 -0
- data/lib/sem4r_sinatra/helpers.rb +60 -0
- data/lib/sem4r_sinatra/web_server.rb +46 -0
- data/lib/sem4r_sinatra.rb +13 -0
- data/lib/sem4r_soap/http_connector.rb +5 -6
- data/lib/sem4r_soap/soap_dumper.rb +3 -14
- data/lib/sem4r_soap/soap_service.rb +5 -5
- data/lib/sem4r_soap/soap_service_v2010.rb +2 -2
- data/lib/sem4r_soap.rb +24 -0
- data/sem4r.gemspec +75 -313
- data/spec/fixtures/password.example.yml +5 -3
- data/spec/helpers/rspec_matchers.rb +2 -19
- data/spec/helpers/rspec_sem4r_helper.rb +25 -9
- data/spec/rspec_helper.rb +7 -0
- data/spec/sem4r/ad_group/ad_group_spec.rb +2 -3
- data/spec/sem4r/ad_group_ad/fixtures/mutate_add_mobile_ad-req.xml +8 -11
- data/spec/sem4r/ad_group_criterion/fixtures/mutate_add_negative_keyword-req.xml +1 -3
- data/spec/sem4r/adwords_spec.rb +0 -5
- data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-req.xml +18 -33
- data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-res.xml +232 -416
- data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-req.xml +55 -104
- data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-res.xml +25 -47
- data/spec/sem4r/geo_location/fixtures/get-req.xml +23 -40
- data/spec/sem4r/geo_location/fixtures/get-res.xml +31 -59
- data/spec/sem4r/info/fixtures/get-req.xml +19 -32
- data/spec/sem4r/info/fixtures/get-res.xml +16 -26
- data/spec/sem4r/profiles_spec.rb +52 -0
- data/spec/sem4r/report_definition/fixtures/get-list-repdef-req.xml +13 -20
- data/spec/sem4r/report_definition/fixtures/get-list-repdef-res.xml +34 -72
- data/spec/sem4r/report_definition/fixtures/getReportFields-req.xml +13 -22
- data/spec/sem4r/report_definition/fixtures/getReportFields-res.xml +476 -1198
- data/spec/sem4r/report_definition/fixtures/mutate-add-report-req.xml +30 -61
- data/spec/sem4r/report_definition/fixtures/mutate-add-report-res.xml +31 -67
- data/spec/sem4r/report_definition/report_definition_spec.rb +1 -1
- data/spec/sem4r/v13_report/fixtures/schedule_report_job-req.xml +11 -33
- data/spec/sem4r_cli/cli_spec.rb +4 -22
- data/tasks/sem4r.rake +0 -3
- data/tasks/yard.rake +2 -2
- metadata +188 -177
- data/VERSION.yml +0 -5
- data/lib/sem4r_cli/cli_helpers.rb +0 -59
- data/lib/sem4r_cli/cli_mini_framework.rb +0 -147
- data/tasks/jeweler.rake +0 -66
@@ -76,7 +76,7 @@ module Sem4rSoap
|
|
76
76
|
end
|
77
77
|
when "v2010"
|
78
78
|
else
|
79
|
-
raise "
|
79
|
+
raise "unknown api version #{api_version}"
|
80
80
|
end
|
81
81
|
|
82
82
|
soap_xml = build_soap_message(build_soap_header(credentials), soap_body)
|
@@ -105,7 +105,7 @@ module Sem4rSoap
|
|
105
105
|
else
|
106
106
|
smutate = "true"
|
107
107
|
end
|
108
|
-
|
108
|
+
ruby_str =<<-EOFS
|
109
109
|
define_method :#{method.to_sym} do |*args|
|
110
110
|
credentials = args.shift
|
111
111
|
if #{smutate}
|
@@ -116,9 +116,9 @@ module Sem4rSoap
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
EOFS
|
119
|
-
eval
|
119
|
+
eval ruby_str
|
120
120
|
|
121
|
-
|
121
|
+
ruby_str =<<-EOFS
|
122
122
|
define_method :#{(method.to_s + "_raw").to_sym} do |*args|
|
123
123
|
credentials = args.shift
|
124
124
|
soap_message = args.shift
|
@@ -129,7 +129,7 @@ module Sem4rSoap
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
EOFS
|
132
|
-
eval
|
132
|
+
eval ruby_str
|
133
133
|
end
|
134
134
|
|
135
135
|
end
|
data/lib/sem4r_soap.rb
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# -------------------------------------------------------------------
|
3
|
+
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
# -------------------------------------------------------------------
|
24
|
+
|
1
25
|
#
|
2
26
|
# soap connection layer
|
3
27
|
#
|
data/sem4r.gemspec
CHANGED
@@ -1,321 +1,83 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sem4r/version.rb"
|
5
4
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "sem4r"
|
7
|
+
gem.version = Sem4r::VERSION
|
8
|
+
gem.platform = Gem::Platform::RUBY
|
9
|
+
gem.summary = %Q{Library to access google adwords api. Works with ruby 1.9 and ruby 1.8}
|
10
|
+
gem.description = %Q{
|
11
|
+
Sem4r is a library to access google adwords api.
|
12
|
+
It will works with ruby 1.9 and ruby 1.8 without soap4r.
|
13
|
+
It uses a high level model instead of a low level api.
|
14
|
+
You think about clients, campaigns, keywords and not about operations, operands, selectors, service calls.
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Sem4r is a library to access google adwords api.
|
16
|
-
It will works with ruby 1.9 and ruby 1.8 without soap4r.
|
17
|
-
It uses a high level model instead of a low level api.
|
18
|
-
You think about clients, campaigns, keywords and not about operations, operands, selectors, service calls.
|
16
|
+
This is a ALPHA version.rb don't use in production.
|
17
|
+
If you are interested in this project let me now: install it and update periodically, so the gemcutter
|
18
|
+
download counter go up. Or subscribe to my feed at sem4r.com. Or watch the project on github.
|
19
|
+
Or simply drop me a line in email. However I will know there is someone out of here.
|
20
|
+
}
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
"examples_sem4r/31_empty_accounts.rb",
|
59
|
-
"examples_sem4r/example_helper.rb",
|
60
|
-
"lib/sem4r.rb",
|
61
|
-
"lib/sem4r/account.rb",
|
62
|
-
"lib/sem4r/ad_group/ad_group.rb",
|
63
|
-
"lib/sem4r/ad_group/ad_group_bids.rb",
|
64
|
-
"lib/sem4r/ad_group/ad_group_service.rb",
|
65
|
-
"lib/sem4r/ad_group/mobile_ad_image.rb",
|
66
|
-
"lib/sem4r/ad_group_ad/ad_group_ad.rb",
|
67
|
-
"lib/sem4r/ad_group_ad/ad_group_ad_operations.rb",
|
68
|
-
"lib/sem4r/ad_group_ad/ad_group_ad_service.rb",
|
69
|
-
"lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb",
|
70
|
-
"lib/sem4r/ad_group_ad/ad_group_text_ad.rb",
|
71
|
-
"lib/sem4r/ad_group_criterion/ad_group_criterion.rb",
|
72
|
-
"lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb",
|
73
|
-
"lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb",
|
74
|
-
"lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb",
|
75
|
-
"lib/sem4r/ad_group_criterion/criterion.rb",
|
76
|
-
"lib/sem4r/ad_group_criterion/criterion_keyword.rb",
|
77
|
-
"lib/sem4r/ad_group_criterion/criterion_placement.rb",
|
78
|
-
"lib/sem4r/ad_param/ad_param.rb",
|
79
|
-
"lib/sem4r/ad_param/ad_param_operation.rb",
|
80
|
-
"lib/sem4r/ad_param/ad_param_service.rb",
|
81
|
-
"lib/sem4r/adwords.rb",
|
82
|
-
"lib/sem4r/base.rb",
|
83
|
-
"lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb",
|
84
|
-
"lib/sem4r/bulk_mutate_job/bulk_mutate_job_account_extension.rb",
|
85
|
-
"lib/sem4r/bulk_mutate_job/bulk_mutate_job_selector.rb",
|
86
|
-
"lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb",
|
87
|
-
"lib/sem4r/bulk_mutate_job/job_operations.rb",
|
88
|
-
"lib/sem4r/campaign/campaign.rb",
|
89
|
-
"lib/sem4r/campaign/campaign_account_extension.rb",
|
90
|
-
"lib/sem4r/campaign/campaign_service.rb",
|
91
|
-
"lib/sem4r/credentials.rb",
|
92
|
-
"lib/sem4r/extensions.rb",
|
93
|
-
"lib/sem4r/geo_location/address.rb",
|
94
|
-
"lib/sem4r/geo_location/geo_location_account_extension.rb",
|
95
|
-
"lib/sem4r/geo_location/geo_location_selector.rb",
|
96
|
-
"lib/sem4r/geo_location/geo_location_service.rb",
|
97
|
-
"lib/sem4r/info/info_account_extension.rb",
|
98
|
-
"lib/sem4r/info/info_selector.rb",
|
99
|
-
"lib/sem4r/info/info_service.rb",
|
100
|
-
"lib/sem4r/operation.rb",
|
101
|
-
"lib/sem4r/report_definition/report_definition.rb",
|
102
|
-
"lib/sem4r/report_definition/report_definition_account_extension.rb",
|
103
|
-
"lib/sem4r/report_definition/report_definition_operation.rb",
|
104
|
-
"lib/sem4r/report_definition/report_definition_selector.rb",
|
105
|
-
"lib/sem4r/report_definition/report_definition_service.rb",
|
106
|
-
"lib/sem4r/report_definition/report_field.rb",
|
107
|
-
"lib/sem4r/sem4r_error.rb",
|
108
|
-
"lib/sem4r/sem4r_templates.rb",
|
109
|
-
"lib/sem4r/service.rb",
|
110
|
-
"lib/sem4r/targeting_idea/targeting_idea.rb",
|
111
|
-
"lib/sem4r/targeting_idea/targeting_idea_account_extension.rb",
|
112
|
-
"lib/sem4r/targeting_idea/targeting_idea_selector.rb",
|
113
|
-
"lib/sem4r/targeting_idea/targeting_idea_service.rb",
|
114
|
-
"lib/sem4r/v13_account/account_account_extension.rb",
|
115
|
-
"lib/sem4r/v13_account/account_service.rb",
|
116
|
-
"lib/sem4r/v13_account/billing_address.rb",
|
117
|
-
"lib/sem4r/v13_report/report.rb",
|
118
|
-
"lib/sem4r/v13_report/report_account_extension.rb",
|
119
|
-
"lib/sem4r/v13_report/report_job.rb",
|
120
|
-
"lib/sem4r/v13_report/report_service.rb",
|
121
|
-
"lib/sem4r_cli.rb",
|
122
|
-
"lib/sem4r_cli/cli_helpers.rb",
|
123
|
-
"lib/sem4r_cli/cli_mini_framework.rb",
|
124
|
-
"lib/sem4r_cli/cli_sem.rb",
|
125
|
-
"lib/sem4r_cli/commands/cli_ads.rb",
|
126
|
-
"lib/sem4r_cli/commands/cli_campaign.rb",
|
127
|
-
"lib/sem4r_cli/commands/cli_clients.rb",
|
128
|
-
"lib/sem4r_cli/commands/cli_ideas.rb",
|
129
|
-
"lib/sem4r_cli/commands/cli_info.rb",
|
130
|
-
"lib/sem4r_cli/commands/cli_job.rb",
|
131
|
-
"lib/sem4r_cli/commands/cli_keywords.rb",
|
132
|
-
"lib/sem4r_cli/commands/cli_profile.rb",
|
133
|
-
"lib/sem4r_cli/commands/cli_repdef.rb",
|
134
|
-
"lib/sem4r_cli/commands/cli_report.rb",
|
135
|
-
"lib/sem4r_soap.rb",
|
136
|
-
"lib/sem4r_soap/http_connector.rb",
|
137
|
-
"lib/sem4r_soap/soap_attributes.rb",
|
138
|
-
"lib/sem4r_soap/soap_dumper.rb",
|
139
|
-
"lib/sem4r_soap/soap_error.rb",
|
140
|
-
"lib/sem4r_soap/soap_response.rb",
|
141
|
-
"lib/sem4r_soap/soap_service.rb",
|
142
|
-
"lib/sem4r_soap/soap_service_v13.rb",
|
143
|
-
"lib/sem4r_soap/soap_service_v2010.rb",
|
144
|
-
"sem4r.gemspec",
|
145
|
-
"tasks/jeweler.rake",
|
146
|
-
"tasks/rspec.rake",
|
147
|
-
"tasks/sem4r.rake",
|
148
|
-
"tasks/yard.rake"
|
149
|
-
]
|
150
|
-
s.homepage = %q{http://www.sem4r.com}
|
151
|
-
s.require_paths = ["lib"]
|
152
|
-
s.rubygems_version = %q{1.3.7}
|
153
|
-
s.summary = %q{Library to access google adwords api. Works with ruby 1.9 and ruby 1.8}
|
154
|
-
s.test_files = [
|
155
|
-
"spec/build_fixtures.rb",
|
156
|
-
"spec/fixtures/password.example.yml",
|
157
|
-
"spec/fixtures/sem4r.example.yml",
|
158
|
-
"spec/fixtures/soap_error.xml",
|
159
|
-
"spec/fixtures/soap_error2.xml",
|
160
|
-
"spec/helpers/dump_interceptor.rb",
|
161
|
-
"spec/helpers/fixtures_bulk_mutate_job.rb",
|
162
|
-
"spec/helpers/fixtures_geo_location.rb",
|
163
|
-
"spec/helpers/fixtures_info.rb",
|
164
|
-
"spec/helpers/fixtures_report_definition.rb",
|
165
|
-
"spec/helpers/rspec_hash.rb",
|
166
|
-
"spec/helpers/rspec_matchers.rb",
|
167
|
-
"spec/helpers/rspec_sem4r_helper.rb",
|
168
|
-
"spec/helpers/sem4r_stubs.rb",
|
169
|
-
"spec/rspec_helper.rb",
|
170
|
-
"spec/sem4r/account_spec.rb",
|
171
|
-
"spec/sem4r/ad_group/ad_group_bids_spec.rb",
|
172
|
-
"spec/sem4r/ad_group/ad_group_service_spec.rb",
|
173
|
-
"spec/sem4r/ad_group/ad_group_spec.rb",
|
174
|
-
"spec/sem4r/ad_group/fixtures/get-first-req.xml",
|
175
|
-
"spec/sem4r/ad_group/fixtures/get-first-res.xml",
|
176
|
-
"spec/sem4r/ad_group/fixtures/get-manual-cpm-bids-req.xml",
|
177
|
-
"spec/sem4r/ad_group/fixtures/get-manual-cpm-bids-res.xml",
|
178
|
-
"spec/sem4r/ad_group/fixtures/mutate_add-req.xml",
|
179
|
-
"spec/sem4r/ad_group/fixtures/mutate_add-res.xml",
|
180
|
-
"spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb",
|
181
|
-
"spec/sem4r/ad_group_ad/ad_group_ad_service_spec.rb",
|
182
|
-
"spec/sem4r/ad_group_ad/ad_group_ad_spec.rb",
|
183
|
-
"spec/sem4r/ad_group_ad/fixtures/get_mobile_ad-req.xml",
|
184
|
-
"spec/sem4r/ad_group_ad/fixtures/get_mobile_ad-res.xml",
|
185
|
-
"spec/sem4r/ad_group_ad/fixtures/get_text_ad-req.xml",
|
186
|
-
"spec/sem4r/ad_group_ad/fixtures/get_text_ad-res.xml",
|
187
|
-
"spec/sem4r/ad_group_ad/fixtures/mutate_add_mobile_ad-req.xml",
|
188
|
-
"spec/sem4r/ad_group_ad/fixtures/mutate_add_mobile_ad-res.xml",
|
189
|
-
"spec/sem4r/ad_group_ad/fixtures/mutate_add_text_ad-req.xml",
|
190
|
-
"spec/sem4r/ad_group_ad/fixtures/mutate_add_text_ad-res.xml",
|
191
|
-
"spec/sem4r/ad_group_ad/fixtures/mutate_add_two_criterions-req.xml",
|
192
|
-
"spec/sem4r/ad_group_ad/fixtures/mutate_add_two_criterions-res.xml",
|
193
|
-
"spec/sem4r/ad_group_criterion/ad_group_criterion_bids_spec.rb",
|
194
|
-
"spec/sem4r/ad_group_criterion/ad_group_criterion_service_spec.rb",
|
195
|
-
"spec/sem4r/ad_group_criterion/ad_group_criterion_spec.rb",
|
196
|
-
"spec/sem4r/ad_group_criterion/criterion_spec.rb",
|
197
|
-
"spec/sem4r/ad_group_criterion/fixtures/get-req.xml",
|
198
|
-
"spec/sem4r/ad_group_criterion/fixtures/get-res.xml",
|
199
|
-
"spec/sem4r/ad_group_criterion/fixtures/mutate_add_criterion_keyword-req.xml",
|
200
|
-
"spec/sem4r/ad_group_criterion/fixtures/mutate_add_criterion_keyword-res.xml",
|
201
|
-
"spec/sem4r/ad_group_criterion/fixtures/mutate_add_criterion_placement-req.xml",
|
202
|
-
"spec/sem4r/ad_group_criterion/fixtures/mutate_add_criterion_placement-res.xml",
|
203
|
-
"spec/sem4r/ad_group_criterion/fixtures/mutate_add_negative_keyword-req.xml",
|
204
|
-
"spec/sem4r/ad_group_criterion/fixtures/mutate_add_negative_keyword-res.xml",
|
205
|
-
"spec/sem4r/ad_param/ad_param_service_spec.rb",
|
206
|
-
"spec/sem4r/ad_param/ad_param_spec.rb",
|
207
|
-
"spec/sem4r/ad_param/fixtures/mutate_set-req.xml",
|
208
|
-
"spec/sem4r/ad_param/fixtures/mutate_set-res.xml",
|
209
|
-
"spec/sem4r/adwords_spec.rb",
|
210
|
-
"spec/sem4r/bulk_mutate_job/bulk_mutate_job_selector_spec.rb",
|
211
|
-
"spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb",
|
212
|
-
"spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb",
|
213
|
-
"spec/sem4r/bulk_mutate_job/fixtures/get-list_job-req.xml",
|
214
|
-
"spec/sem4r/bulk_mutate_job/fixtures/get-list_job-res.xml",
|
215
|
-
"spec/sem4r/bulk_mutate_job/fixtures/get-req.xml",
|
216
|
-
"spec/sem4r/bulk_mutate_job/fixtures/get-res.xml",
|
217
|
-
"spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-req.xml",
|
218
|
-
"spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-res.xml",
|
219
|
-
"spec/sem4r/bulk_mutate_job/fixtures/mutate-req.xml",
|
220
|
-
"spec/sem4r/bulk_mutate_job/fixtures/mutate-res.xml",
|
221
|
-
"spec/sem4r/bulk_mutate_job/job_operation_spec.rb",
|
222
|
-
"spec/sem4r/campaign/campaign_service_spec.rb",
|
223
|
-
"spec/sem4r/campaign/campaign_spec.rb",
|
224
|
-
"spec/sem4r/campaign/fixtures/get-req.xml",
|
225
|
-
"spec/sem4r/campaign/fixtures/get-res.xml",
|
226
|
-
"spec/sem4r/campaign/fixtures/mutate_add-req.xml",
|
227
|
-
"spec/sem4r/campaign/fixtures/mutate_add-res.xml",
|
228
|
-
"spec/sem4r/credentials_spec.rb",
|
229
|
-
"spec/sem4r/geo_location/address_spec.rb",
|
230
|
-
"spec/sem4r/geo_location/fixtures/get-req.xml",
|
231
|
-
"spec/sem4r/geo_location/fixtures/get-res.xml",
|
232
|
-
"spec/sem4r/info/account_info_extension_spec.rb",
|
233
|
-
"spec/sem4r/info/fixtures/get-req.xml",
|
234
|
-
"spec/sem4r/info/fixtures/get-res.xml",
|
235
|
-
"spec/sem4r/info/fixtures/get_unit_count-req.xml",
|
236
|
-
"spec/sem4r/info/fixtures/get_unit_count-res.xml",
|
237
|
-
"spec/sem4r/nokogiri_parsing_spec.rb",
|
238
|
-
"spec/sem4r/operation_spec.rb",
|
239
|
-
"spec/sem4r/report_definition/fixtures/get-list-repdef-req.xml",
|
240
|
-
"spec/sem4r/report_definition/fixtures/get-list-repdef-res.xml",
|
241
|
-
"spec/sem4r/report_definition/fixtures/getReportFields-req.xml",
|
242
|
-
"spec/sem4r/report_definition/fixtures/getReportFields-res.xml",
|
243
|
-
"spec/sem4r/report_definition/fixtures/mutate-add-report-req.xml",
|
244
|
-
"spec/sem4r/report_definition/fixtures/mutate-add-report-res.xml",
|
245
|
-
"spec/sem4r/report_definition/report_definition_service_spec.rb",
|
246
|
-
"spec/sem4r/report_definition/report_definition_spec.rb",
|
247
|
-
"spec/sem4r/report_definition/report_field_spec.rb",
|
248
|
-
"spec/sem4r/rexml_parsing_spec.rb",
|
249
|
-
"spec/sem4r/service_spec.rb",
|
250
|
-
"spec/sem4r/targeting_idea/fixtures/get-req-all-options.xml",
|
251
|
-
"spec/sem4r/targeting_idea/fixtures/get-req.xml",
|
252
|
-
"spec/sem4r/targeting_idea/fixtures/get-res.xml",
|
253
|
-
"spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb",
|
254
|
-
"spec/sem4r/targeting_idea/targeting_idea_service_spec.rb",
|
255
|
-
"spec/sem4r/targeting_idea/targeting_idea_spec.rb",
|
256
|
-
"spec/sem4r/v13_account/account_account_extension_spec.rb",
|
257
|
-
"spec/sem4r/v13_account/account_service_spec.rb",
|
258
|
-
"spec/sem4r/v13_account/billing_address_spec.rb",
|
259
|
-
"spec/sem4r/v13_account/fixtures/get_account_info-req.xml",
|
260
|
-
"spec/sem4r/v13_account/fixtures/get_account_info-res.xml",
|
261
|
-
"spec/sem4r/v13_account/fixtures/get_client_accounts-req.xml",
|
262
|
-
"spec/sem4r/v13_account/fixtures/get_client_accounts-res.xml",
|
263
|
-
"spec/sem4r/v13_report/fixtures/get_all_jobs-req.xml",
|
264
|
-
"spec/sem4r/v13_report/fixtures/get_all_jobs-res.xml",
|
265
|
-
"spec/sem4r/v13_report/fixtures/schedule_report_job-req.xml",
|
266
|
-
"spec/sem4r/v13_report/fixtures/schedule_report_job-res.xml",
|
267
|
-
"spec/sem4r/v13_report/report_service_spec.rb",
|
268
|
-
"spec/sem4r/v13_report/report_spec.rb",
|
269
|
-
"spec/sem4r_cli/cli_spec.rb",
|
270
|
-
"spec/sem4r_soap/soap_attributes_spec.rb",
|
271
|
-
"spec/sem4r_soap/soap_response_spec.rb",
|
272
|
-
"spec/sem4r_soap/soap_service_spec.rb"
|
22
|
+
gem.authors = ["Sem4r"]
|
23
|
+
gem.email = "sem4ruby@gmail.com"
|
24
|
+
gem.homepage = "http://www.sem4r.com"
|
25
|
+
|
26
|
+
#
|
27
|
+
# dependencies
|
28
|
+
#
|
29
|
+
gem.add_runtime_dependency(%q<builder>, [">= 0"])
|
30
|
+
gem.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
31
|
+
gem.add_runtime_dependency(%q<httpclient>, [">= 0"])
|
32
|
+
gem.add_runtime_dependency(%q<highline>, [">= 0"])
|
33
|
+
gem.add_runtime_dependency(%q<builder>, [">= 0"])
|
34
|
+
gem.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
35
|
+
gem.add_runtime_dependency(%q<signet>, [">= 0"])
|
36
|
+
gem.add_runtime_dependency(%q<optparse-command>, ["0.1.6"])
|
37
|
+
gem.add_runtime_dependency(%q<sinatra>, [">=0"])
|
38
|
+
gem.add_runtime_dependency(%q<haml>, [">=0"])
|
39
|
+
|
40
|
+
gem.add_development_dependency(%q<rake>, [">= 0"])
|
41
|
+
gem.add_development_dependency(%q<yard>, [">= 0"])
|
42
|
+
gem.add_development_dependency(%q<bundler>, [">= 0"])
|
43
|
+
gem.add_development_dependency(%q<rspec>, [">= 0"])
|
44
|
+
gem.add_development_dependency(%q<differ>, [">= 0"])
|
45
|
+
|
46
|
+
#platforms :jruby do
|
47
|
+
# gem 'jruby-openssl'
|
48
|
+
#end
|
49
|
+
#
|
50
|
+
|
51
|
+
#
|
52
|
+
# bin
|
53
|
+
#
|
54
|
+
gem.executables = %w{ sem }
|
55
|
+
# s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
56
|
+
|
57
|
+
gem.extra_rdoc_files = [
|
58
|
+
"LICENSE",
|
59
|
+
"README.rdoc"
|
273
60
|
]
|
274
61
|
|
275
|
-
|
276
|
-
|
277
|
-
|
62
|
+
#
|
63
|
+
# files
|
64
|
+
#
|
65
|
+
# s.files = `git ls-files`.split("\n")
|
66
|
+
gem.files = %w{LICENSE README.rdoc Rakefile sem4r.gemspec .gemtest Gemfile Gemfile.lock}
|
67
|
+
gem.files << 'config/sem4r.example.yml'
|
68
|
+
gem.files.concat Dir['examples_sem4r/*.rb']
|
69
|
+
gem.files.concat Dir['examples_blog/*.rb']
|
70
|
+
gem.files.concat Dir['tasks/**/*.rake']
|
71
|
+
gem.files.concat Dir['lib/**/*.rb']
|
278
72
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
287
|
-
s.add_development_dependency(%q<bundler>, [">= 0"])
|
288
|
-
s.add_runtime_dependency(%q<builder>, [">= 0"])
|
289
|
-
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
290
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
291
|
-
s.add_development_dependency(%q<differ>, [">= 0"])
|
292
|
-
else
|
293
|
-
s.add_dependency(%q<builder>, [">= 0"])
|
294
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
295
|
-
s.add_dependency(%q<httpclient>, [">= 0"])
|
296
|
-
s.add_dependency(%q<highline>, [">= 0"])
|
297
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
298
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
299
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
300
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
301
|
-
s.add_dependency(%q<builder>, [">= 0"])
|
302
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
303
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
304
|
-
s.add_dependency(%q<differ>, [">= 0"])
|
305
|
-
end
|
306
|
-
else
|
307
|
-
s.add_dependency(%q<builder>, [">= 0"])
|
308
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
309
|
-
s.add_dependency(%q<httpclient>, [">= 0"])
|
310
|
-
s.add_dependency(%q<highline>, [">= 0"])
|
311
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
312
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
313
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
314
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
315
|
-
s.add_dependency(%q<builder>, [">= 0"])
|
316
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
317
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
318
|
-
s.add_dependency(%q<differ>, [">= 0"])
|
319
|
-
end
|
320
|
-
end
|
73
|
+
#
|
74
|
+
# test files
|
75
|
+
#
|
76
|
+
# s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
77
|
+
gem.test_files = Dir['spec/**/*.rb']
|
78
|
+
gem.test_files.concat Dir['spec/**/*.xml']
|
79
|
+
gem.test_files.concat Dir['spec/fixtures/**/*']
|
321
80
|
|
81
|
+
|
82
|
+
# gem.require_paths = ["lib"]
|
83
|
+
end
|
@@ -32,34 +32,17 @@ require 'differ/string'
|
|
32
32
|
#
|
33
33
|
# http://drawohara.com/post/89110816/ruby-comparing-xml
|
34
34
|
|
35
|
-
def pretty_xml(xml)
|
36
|
-
normalized = Class.new(REXML::Formatters::Pretty) do
|
37
|
-
def write_text(node, output)
|
38
|
-
super(node.to_s.strip, output)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
normalized.new(0, false).write(xml, xml_pretty='')
|
42
|
-
xml_pretty
|
43
|
-
end
|
44
|
-
|
45
35
|
def normalize_xml(expected_xml)
|
46
36
|
if expected_xml.class != String
|
47
37
|
expected_xml = expected_xml.to_s
|
48
38
|
end
|
49
39
|
|
50
40
|
if expected_xml.class == String
|
41
|
+
expected_xml = expected_xml.gsub(/^\n/, "") # erase empty lines
|
51
42
|
# erase namespaces i.e. <ns1:tag> -> <tag>
|
52
43
|
expected_xml = expected_xml.gsub(/\b(ns\d:|xsi:|s:|soapenv:|env:|soap:|^\n)/, "").strip
|
53
|
-
begin
|
54
|
-
expected_xml = REXML::Document.new(expected_xml)
|
55
|
-
rescue RuntimeError
|
56
|
-
puts "----------------------------------"
|
57
|
-
puts xml
|
58
|
-
puts "----------------------------------"
|
59
|
-
raise
|
60
|
-
end
|
61
44
|
end
|
62
|
-
expected_normalized =
|
45
|
+
expected_normalized = Sem4r::pretty_print_xml_with_nokogiri(expected_xml)
|
63
46
|
# erase namespaces i.e. <ns1:tag> -> <tag>
|
64
47
|
expected_normalized.gsub(/(ns\d:|xsi:|s:|soapenv:|env:|soap:|^\n| {2,})/, "").strip
|
65
48
|
end
|
@@ -25,22 +25,38 @@
|
|
25
25
|
module Sem4rSpecHelper
|
26
26
|
|
27
27
|
require "stringio"
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
|
29
|
+
# def with_stdout_captured
|
30
|
+
# old_stdout = $stdout
|
31
|
+
# out = StringIO.new
|
32
|
+
# $stdout = out
|
33
|
+
# begin
|
34
|
+
# yield
|
35
|
+
# ensure
|
36
|
+
# $stdout = old_stdout
|
37
|
+
# end
|
38
|
+
# out.string
|
39
|
+
# end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Capture $stdout and $stderr of a block
|
43
|
+
#
|
44
|
+
def capture_out
|
45
|
+
old_stdout, old_stderr = $stdout, $stderr
|
46
|
+
out, err = StringIO.new, StringIO.new
|
47
|
+
$stdout, $stderr = out, err
|
32
48
|
begin
|
33
49
|
yield
|
34
50
|
ensure
|
35
|
-
$stdout = old_stdout
|
51
|
+
$stdout, $stderr = old_stdout, old_stderr
|
36
52
|
end
|
37
|
-
out.string
|
53
|
+
OpenStruct.new(:out => out.string, :err => err.string)
|
38
54
|
end
|
39
55
|
|
40
56
|
#############################################################################
|
41
57
|
|
42
58
|
def read_xml(service, file_name)
|
43
|
-
xml_filepath
|
59
|
+
xml_filepath = File.expand_path File.join(File.dirname(__FILE__), "..", "sem4r", service, "fixtures", file_name)
|
44
60
|
unless File.exist?(xml_filepath)
|
45
61
|
raise "file #{xml_filepath} not exists"
|
46
62
|
end
|
@@ -51,7 +67,7 @@ module Sem4rSpecHelper
|
|
51
67
|
end
|
52
68
|
|
53
69
|
def write_xml(service, file_name, xml)
|
54
|
-
fixture_dir
|
70
|
+
fixture_dir = File.expand_path File.join(File.dirname(__FILE__), "..", "sem4r", service, "fixtures")
|
55
71
|
FileUtils.mkdir_p(fixture_dir) unless File.directory?(fixture_dir)
|
56
72
|
pathname = File.join(fixture_dir, file_name)
|
57
73
|
puts "writing to #{pathname}"
|
@@ -61,7 +77,7 @@ module Sem4rSpecHelper
|
|
61
77
|
end
|
62
78
|
|
63
79
|
def read_model(xpath, service, xml_file, &blk)
|
64
|
-
contents
|
80
|
+
contents = read_xml(service, xml_file)
|
65
81
|
xml_document = Nokogiri::XML::Document.parse(contents)
|
66
82
|
if xpath && blk
|
67
83
|
el = xml_document.xpath(xpath).each do |node|
|
data/spec/rspec_helper.rb
CHANGED
@@ -20,7 +20,6 @@
|
|
20
20
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
#
|
24
23
|
# -------------------------------------------------------------------------
|
25
24
|
|
26
25
|
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
@@ -86,8 +85,8 @@ describe AdGroup do
|
|
86
85
|
site_max_cpc 30000000
|
87
86
|
end
|
88
87
|
end
|
89
|
-
|
90
|
-
adgroup.to_xml("operand").should xml_equivalent(
|
88
|
+
expected_xml = read_model("//operand", "ad_group", "mutate_add-req.xml")
|
89
|
+
adgroup.to_xml("operand").should xml_equivalent(expected_xml)
|
91
90
|
end
|
92
91
|
|
93
92
|
it "should parse xml (produced by google)" do
|
@@ -1,5 +1,8 @@
|
|
1
|
-
<?xml version='1.0' encoding='UTF-8'?>
|
2
|
-
<env:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
|
1
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
2
|
+
<env:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
|
3
|
+
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'
|
4
|
+
xmlns='https://adwords.google.com/api/adwords/cm/v200909'
|
5
|
+
xmlns:s='https://adwords.google.com/api/adwords/cm/v200909'>
|
3
6
|
|
4
7
|
<env:Header>
|
5
8
|
<s:RequestHeader env:mustUnderstand='0'>
|
@@ -30,16 +33,10 @@
|
|
30
33
|
<ad xsi:type='MobileAd'>
|
31
34
|
<headline>sem4r</headline>
|
32
35
|
<description>simply adwords</description>
|
33
|
-
<mobileCarriers>
|
34
|
-
Vodafone@IT
|
35
|
-
</mobileCarriers>
|
36
|
+
<mobileCarriers>Vodafone@IT</mobileCarriers>
|
36
37
|
<businessName>sem4r</businessName>
|
37
|
-
<countryCode>
|
38
|
-
|
39
|
-
</countryCode>
|
40
|
-
<phoneNumber>
|
41
|
-
0612345
|
42
|
-
</phoneNumber>
|
38
|
+
<countryCode>IT</countryCode>
|
39
|
+
<phoneNumber>0612345</phoneNumber>
|
43
40
|
</ad>
|
44
41
|
<status>ENABLED</status>
|
45
42
|
</operand>
|