sem4r 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gemtest +0 -0
  2. data/Gemfile +2 -22
  3. data/Gemfile.lock +43 -20
  4. data/Rakefile +4 -2
  5. data/bin/sem +2 -6
  6. data/lib/sem4r/adwords.rb +8 -142
  7. data/lib/sem4r/campaign/campaign_account_extension.rb +4 -5
  8. data/lib/sem4r/profile.rb +173 -0
  9. data/lib/sem4r/sem4r_utilities.rb +113 -0
  10. data/lib/sem4r/v13_report/report.rb +5 -0
  11. data/lib/sem4r/version.rb +27 -0
  12. data/lib/sem4r.rb +5 -26
  13. data/lib/sem4r_cli/cli_sem.rb +116 -170
  14. data/lib/sem4r_cli/commands/{cli_ads.rb → cmd_ads.rb} +4 -4
  15. data/lib/sem4r_cli/commands/{cli_campaign.rb → cmd_campaign.rb} +7 -7
  16. data/lib/sem4r_cli/commands/{cli_clients.rb → cmd_clients.rb} +4 -5
  17. data/lib/sem4r_cli/commands/{cli_ideas.rb → cmd_ideas.rb} +7 -5
  18. data/lib/sem4r_cli/commands/{cli_info.rb → cmd_info.rb} +6 -6
  19. data/lib/sem4r_cli/commands/{cli_job.rb → cmd_job.rb} +4 -2
  20. data/lib/sem4r_cli/commands/{cli_keywords.rb → cmd_keywords.rb} +4 -4
  21. data/lib/sem4r_cli/commands/{cli_profile.rb → cmd_profile.rb} +23 -19
  22. data/lib/sem4r_cli/commands/{cli_repdef.rb → cmd_repdef.rb} +6 -4
  23. data/lib/sem4r_cli/commands/{cli_report.rb → cmd_report.rb} +8 -6
  24. data/lib/sem4r_cli.rb +6 -4
  25. data/lib/sem4r_debug_client/client.rb +200 -0
  26. data/lib/sem4r_debug_client.rb +31 -0
  27. data/lib/sem4r_sinatra/cli_server.rb +45 -0
  28. data/lib/sem4r_sinatra/helpers.rb +60 -0
  29. data/lib/sem4r_sinatra/web_server.rb +46 -0
  30. data/lib/sem4r_sinatra.rb +13 -0
  31. data/lib/sem4r_soap/http_connector.rb +5 -6
  32. data/lib/sem4r_soap/soap_dumper.rb +3 -14
  33. data/lib/sem4r_soap/soap_service.rb +5 -5
  34. data/lib/sem4r_soap/soap_service_v2010.rb +2 -2
  35. data/lib/sem4r_soap.rb +24 -0
  36. data/sem4r.gemspec +75 -313
  37. data/spec/fixtures/password.example.yml +5 -3
  38. data/spec/helpers/rspec_matchers.rb +2 -19
  39. data/spec/helpers/rspec_sem4r_helper.rb +25 -9
  40. data/spec/rspec_helper.rb +7 -0
  41. data/spec/sem4r/ad_group/ad_group_spec.rb +2 -3
  42. data/spec/sem4r/ad_group_ad/fixtures/mutate_add_mobile_ad-req.xml +8 -11
  43. data/spec/sem4r/ad_group_criterion/fixtures/mutate_add_negative_keyword-req.xml +1 -3
  44. data/spec/sem4r/adwords_spec.rb +0 -5
  45. data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-req.xml +18 -33
  46. data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-res.xml +232 -416
  47. data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-req.xml +55 -104
  48. data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-res.xml +25 -47
  49. data/spec/sem4r/geo_location/fixtures/get-req.xml +23 -40
  50. data/spec/sem4r/geo_location/fixtures/get-res.xml +31 -59
  51. data/spec/sem4r/info/fixtures/get-req.xml +19 -32
  52. data/spec/sem4r/info/fixtures/get-res.xml +16 -26
  53. data/spec/sem4r/profiles_spec.rb +52 -0
  54. data/spec/sem4r/report_definition/fixtures/get-list-repdef-req.xml +13 -20
  55. data/spec/sem4r/report_definition/fixtures/get-list-repdef-res.xml +34 -72
  56. data/spec/sem4r/report_definition/fixtures/getReportFields-req.xml +13 -22
  57. data/spec/sem4r/report_definition/fixtures/getReportFields-res.xml +476 -1198
  58. data/spec/sem4r/report_definition/fixtures/mutate-add-report-req.xml +30 -61
  59. data/spec/sem4r/report_definition/fixtures/mutate-add-report-res.xml +31 -67
  60. data/spec/sem4r/report_definition/report_definition_spec.rb +1 -1
  61. data/spec/sem4r/v13_report/fixtures/schedule_report_job-req.xml +11 -33
  62. data/spec/sem4r_cli/cli_spec.rb +4 -22
  63. data/tasks/sem4r.rake +0 -3
  64. data/tasks/yard.rake +2 -2
  65. metadata +188 -177
  66. data/VERSION.yml +0 -5
  67. data/lib/sem4r_cli/cli_helpers.rb +0 -59
  68. data/lib/sem4r_cli/cli_mini_framework.rb +0 -147
  69. data/tasks/jeweler.rake +0 -66
data/VERSION.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- :major: 0
3
- :minor: 1
4
- :patch: 3
5
- :build:
@@ -1,59 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- module Sem4rCli
3
-
4
- # From http://gist.github.com/72234
5
- #
6
- # mysql-style output for an array of ActiveRecord objects
7
- #
8
- # Usage:
9
- # report(records) # displays report with all fields
10
- # report(records, :field1, :field2, ...) # displays report with given fields
11
- #
12
- # Example:
13
- # >> report(records, :id, :amount, :created_at)
14
- # +------+-----------+--------------------------------+
15
- # | id | amount | created_at |
16
- # +------+-----------+--------------------------------+
17
- # | 8301 | $12.40 | Sat Feb 28 09:20:47 -0800 2009 |
18
- # | 6060 | $39.62 | Sun Feb 15 14:45:38 -0800 2009 |
19
- # | 6061 | $167.52 | Sun Feb 15 14:45:38 -0800 2009 |
20
- # | 6067 | $12.00 | Sun Feb 15 14:45:40 -0800 2009 |
21
- # | 6059 | $1,000.00 | Sun Feb 15 14:45:38 -0800 2009 |
22
- # +------+-----------+--------------------------------+
23
- # 5 rows in set
24
- #
25
- def self.report(items, *fields) #:nodoc: all
26
- # find max length for each field; start with the field names themselves
27
- max_len = Hash[*fields.map {|f| [f, f.to_s.length]}.flatten]
28
-
29
- items.each do |item|
30
- fields.each do |field|
31
- len = item.send(field).to_s.length
32
- max_len[field] = len if len > max_len[field]
33
- end
34
- end
35
-
36
- border = '+-' + fields.map {|f| '-' * max_len[f] }.join('-+-') + '-+'
37
- title_row = '| ' + fields.map {|f| sprintf("%-#{max_len[f]}s", f.to_s) }.join(' | ') + ' |'
38
-
39
- puts border
40
- puts title_row
41
- puts border
42
-
43
- items.each do |item|
44
- row = '| ' + fields.map {|f| sprintf("%-#{max_len[f]}s", item.send(f)) }.join(' | ') + ' |'
45
- puts row
46
- end
47
-
48
- puts border
49
- puts "#{items.length} rows in set\n"
50
- end
51
- end
52
-
53
- if __FILE__ == $0
54
- require 'ostruct'
55
- o = OpenStruct.new
56
- o.a = 1
57
- o.b = 2
58
- Sem4r::report( [o], :a, :b )
59
- end
@@ -1,147 +0,0 @@
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
-
25
- module Sem4rCli
26
-
27
- class Cli
28
- def self.run
29
- cli = self.new
30
- cli.parse_and_run(ARGV)
31
- end
32
- end
33
-
34
- #
35
- # Base class for generic command
36
- # @example
37
- # class MyCommand < CliCommand
38
- # def self.command; "mycommand"; end
39
- # def self.description; "mycomand description"; end
40
- #
41
- # def initialize(common_args)
42
- # ...
43
- # end
44
- #
45
- # def parse_and_run(args)
46
- # ...
47
- # if run_successful then true else false end
48
- # end
49
- # end
50
- #
51
- class CliCommand
52
-
53
- class << self
54
-
55
- #
56
- # @private
57
- # Add class to the list of command.
58
- #
59
- def inherited(base)
60
- @command_list ||= []
61
- @command_list << base
62
- end
63
-
64
- #
65
- # All definited commands
66
- #
67
- def commands
68
- return @commands if @commands
69
- @commands = {}
70
- @command_list.each { |cmd| @commands[cmd.command] = cmd }
71
- @commands
72
- end
73
-
74
- #
75
- # Finds the name of command into args.
76
- # If ARGV is <opt1> <opt2> command_name <rest of cli>
77
- # @return[ ar1, name, ar2 ] where
78
- # ar1 is = <opt1> <opt2>
79
- # name is command_name
80
- # ar2 is = <rest of cli>
81
- #
82
- # def split_args(argv)
83
- # idx = argv.find_index { |e| commands.key?(e) }
84
- # if idx
85
- # common_args = argv[0, idx]
86
- # command = argv[idx]
87
- # command_args = argv[idx+1..-1]
88
- # [common_args, command, command_args]
89
- # else
90
- # [argv, nil, nil]
91
- # end
92
- # end
93
-
94
- #
95
- # Helper method to define new command
96
- #
97
- # @example
98
- # CliMyCommand = CliCommand.define_command("mycommand", "my command description") do |cli|
99
- # ...
100
- # <might access to cli methods as common options>
101
- # ...
102
- # if run_successful then true else false end
103
- # end
104
- #
105
- def define_command(command_name, description, &block)
106
-
107
- unless block_given?
108
- raise "define_command: missing block"
109
- end
110
-
111
- cls = Class.new(CliCommand) do
112
- def initialize(common_args)
113
- @common_args = common_args
114
- end
115
-
116
- def opt_parser(options)
117
- opt_parser = OptionParser.new
118
- opt_parser.banner= "#{self.class.description}"
119
- opt_parser.on("-h", "--help", "show this message") do
120
- puts opt_parser
121
- options.exit = true
122
- end
123
- end
124
-
125
- define_method("parse_and_run") do |argv|
126
- options = OpenStruct.new
127
- opt_parser(options).parse(argv)
128
- return false if options.exit
129
- block.call(@common_args)
130
- end
131
- end
132
-
133
- s = class << cls;
134
- self;
135
- end
136
- s.class_eval do
137
- define_method("command") { command_name }
138
- define_method("description") { description }
139
- end
140
- cls
141
- end
142
-
143
- end # class << self
144
-
145
- end # class CliCommand
146
-
147
- end
data/tasks/jeweler.rake DELETED
@@ -1,66 +0,0 @@
1
- #
2
- # jeweler
3
- #
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
-
8
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
9
- gem.name = "sem4r"
10
- gem.summary = %Q{Library to access google adwords api. Works with ruby 1.9 and ruby 1.8}
11
- gem.description = %Q{
12
- Sem4r is a library to access google adwords api.
13
- It will works with ruby 1.9 and ruby 1.8 without soap4r.
14
- It uses a high level model instead of a low level api.
15
- You think about clients, campaigns, keywords and not about operations, operands, selectors, service calls.
16
-
17
- This is a ALPHA version don't use in production.
18
- If you are interested in this project let me now: install it and update periodically, so the gemcutter
19
- download counter go up. Or subscribe to my feed at sem4r.com. Or watch the project on github.
20
- Or simply drop me a line in email. However I will know there is someone out of here.
21
- }
22
-
23
- gem.authors = ["Sem4r"]
24
- gem.email = "sem4ruby@gmail.com"
25
- gem.homepage = "http://www.sem4r.com"
26
-
27
- #
28
- # dependecies
29
- #
30
- # gem.add_dependency 'patron'
31
- gem.add_dependency 'builder'
32
- gem.add_dependency 'nokogiri'
33
- gem.add_development_dependency 'rspec'
34
- gem.add_development_dependency 'differ'
35
-
36
- #
37
- # files
38
- #
39
- gem.files = %w{LICENSE README.rdoc Rakefile VERSION.yml sem4r.gemspec Gemfile Gemfile.lock}
40
- gem.files << 'config/sem4r.example.yml'
41
- gem.files.concat Dir['examples_sem4r/*.rb']
42
- gem.files.concat Dir['examples_blog/*.rb']
43
- gem.files.concat Dir['tasks/**/*.rake']
44
- gem.files.concat Dir['lib/**/*.rb']
45
-
46
- #
47
- # test files
48
- #
49
- gem.test_files = Dir['spec/**/*.rb']
50
- gem.test_files.concat Dir['spec/**/*.xml']
51
- gem.test_files.concat Dir['spec/fixtures/**/*']
52
-
53
- #
54
- # rubyforge
55
- #
56
- # gem.rubyforge_project = 'sem'
57
- end
58
-
59
- # Jeweler::RubyforgeTasks.new do |rubyforge|
60
- # rubyforge.doc_task = "rdoc"
61
- # end
62
-
63
- Jeweler::GemcutterTasks.new
64
- rescue LoadError
65
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
66
- end