yieldmanager 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/TODO CHANGED
@@ -2,6 +2,7 @@
2
2
  "unknown element: {http://schemas.xmlsoap.org/wsdl/}definitions"
3
3
  * throwing warning when running in autotest, but not spec?: monkeypatch net/http?
4
4
  "warning: peer certificate won't be verified in this SSL session"
5
+ * DONE (chris) Monkey-patch 1.8.7 to handle targetnamespace bug
5
6
  * DONE Using :env => "test" actually hits test environment
6
7
  * DONE add session start/end
7
8
  * DONE add session block
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.5
1
+ 0.4.0
@@ -0,0 +1,22 @@
1
+ module PatchDetector
2
+ def needs_patching?(opts={})
3
+
4
+ ruby_version, minimum_ruby_version_for_patch = opts.values_at(:ruby_version, :minimum_ruby_version_for_patch)
5
+
6
+ [ruby_version, minimum_ruby_version_for_patch].each do |extracted_option|
7
+ raise(ArgumentError, "requires :ruby_version and :minimum_ruby_version_for_patch") if extracted_option.nil? || extracted_option.empty?
8
+ end
9
+
10
+ return false if ruby_version.nil? || minimum_ruby_version_for_patch.nil?
11
+
12
+ minimum_ruby_version_for_patch =~ /(\d+)\.(\d+)\.(\d+)/
13
+ min_release_milestone, min_release_feature, min_release_bug_fix = [$1, $2, $3].collect{|m| m.to_i}
14
+
15
+ ruby_version =~ /(\d+)\.(\d+)\.(\d+)/
16
+ ruby_version_milestone, ruby_version_feature, ruby_version_bug_fix = [$1, $2, $3].collect{|m| m.to_i}
17
+
18
+ return true if (ruby_version_milestone >= min_release_milestone) && (ruby_version_feature >= min_release_feature) && (ruby_version_bug_fix >= min_release_bug_fix)
19
+ return false
20
+ end
21
+ end
22
+
data/lib/wsdl/patch.rb ADDED
@@ -0,0 +1,38 @@
1
+ # warn "Patching WSDL::Import"
2
+
3
+ module WSDL
4
+ class Import < Info
5
+ def parse_attr(attr, value)
6
+ case attr
7
+ when NamespaceAttrName
8
+ @namespace = value.source
9
+ # if @content
10
+ # @content.targetnamespace = @namespace
11
+ # end
12
+ @namespace
13
+ when LocationAttrName
14
+ @location = URI.parse(value.source)
15
+ if @location.relative? and !parent.location.nil? and
16
+ !parent.location.relative?
17
+ @location = parent.location + @location
18
+ end
19
+ if root.importedschema.key?(@location)
20
+ @content = root.importedschema[@location]
21
+ else
22
+ root.importedschema[@location] = nil # placeholder
23
+ @content = import(@location)
24
+ if @content.is_a?(Definitions)
25
+ @content.root = root
26
+ if @namespace
27
+ @content.targetnamespace = @namespace
28
+ end
29
+ end
30
+ root.importedschema[@location] = @content
31
+ end
32
+ @location
33
+ else
34
+ nil
35
+ end
36
+ end
37
+ end
38
+ end
data/lib/yieldmanager.rb CHANGED
@@ -9,6 +9,14 @@ $LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
9
9
  module Yieldmanager
10
10
  end
11
11
 
12
+ require 'patch_detector'
13
+ include PatchDetector
14
+
12
15
  require 'yieldmanager/client'
16
+
17
+ if needs_patching?(:ruby_version => RUBY_VERSION, :minimum_ruby_version_for_patch => "1.8.7")
18
+ require 'wsdl/patch'
19
+ end
20
+
13
21
  require 'yieldmanager/builder'
14
22
  require 'yieldmanager/report'
@@ -17,6 +17,7 @@ module Yieldmanager
17
17
  BASE_URL = "https://api.yieldmanager.com/api-"
18
18
  BASE_URL_TEST = "https://api-test.yieldmanager.com/api-"
19
19
  WSDL_DIR = File.join(File.dirname(__FILE__), '..', '..', 'wsdls')
20
+
20
21
  def self.build_wsdls_for api_version
21
22
  unless api_version.match(/^\d\.\d{2}/)
22
23
  raise ArgumentError, "Non-standard api version"
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'soap/wsdlDriver'
2
3
  require 'open-uri'
3
4
  require 'hpricot'
@@ -0,0 +1,50 @@
1
+ require File.join(File.dirname(__FILE__), *%w[spec_helper])
2
+
3
+ describe PatchDetector do
4
+ describe "needs_patching?" do
5
+ before do
6
+ class Object
7
+ include PatchDetector
8
+ end
9
+ end
10
+
11
+ describe "when invalid arguments are passed" do
12
+ it "should raise an ArgumentError" do
13
+ ruby_version, minimum_ruby_version_for_patch = "", ""
14
+
15
+ lambda {needs_patching?(:ruby_version => ruby_version, :minimum_ruby_version_for_patch => minimum_ruby_version_for_patch)}.should raise_error
16
+ lambda {needs_patching?()}.should raise_error
17
+ lambda {needs_patching?(:fasdfasdfa => "asdfasdfda", :foo => "bar")}.should raise_error
18
+ end
19
+ end
20
+
21
+ describe "when the current ruby version is equal to the minimum ruby version require for patch" do
22
+ it "should be true" do
23
+ ruby_version, minimum_ruby_version_for_patch = "1.8.7", "1.8.7"
24
+ needs_patching?(:ruby_version => ruby_version, :minimum_ruby_version_for_patch => minimum_ruby_version_for_patch).should == true
25
+ end
26
+ end
27
+
28
+ describe "when the current ruby version is greater than the minimum_ruby_version_for_patch" do
29
+ it "should return true" do
30
+ minimum_ruby_version_for_patch = "1.8.7"
31
+
32
+ ruby_version_array = %w(1.8.8 1.8.9 1.8.10)
33
+ ruby_version_array.each do |rv|
34
+ needs_patching?(:ruby_version => rv, :minimum_ruby_version_for_patch => minimum_ruby_version_for_patch).should == true
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "when the current ruby version is smaller than the minimum_ruby_version_for_patch" do
40
+ it "should return true" do
41
+ minimum_ruby_version_for_patch = "1.8.7"
42
+
43
+ ruby_version_array = %w(1.8.2 1.7.7 0.8.10)
44
+ ruby_version_array.each do |rv|
45
+ needs_patching?(:ruby_version => rv, :minimum_ruby_version_for_patch => minimum_ruby_version_for_patch).should == false
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'yieldmanager'
4
4
  require 'spec'
5
5
  require 'spec/autorun'
6
-
6
+ require 'patch_detector'
7
7
  Spec::Runner.configure do |config|
8
8
 
9
9
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- NEED_ENV_ARGS_MSG = <<EOM
3
+ CLIENT_NEED_ENV_ARGS_MSG = <<EOM
4
4
  Please set these environment variables to match your Yieldmanager account:
5
5
  * YIELDMANAGER_USER
6
6
  * YIELDMANAGER_PASS
@@ -114,7 +114,7 @@ describe "A new Yieldmanager client" do
114
114
  unless ENV["YIELDMANAGER_USER"] &&
115
115
  ENV["YIELDMANAGER_PASS"] &&
116
116
  ENV["YIELDMANAGER_API_VERSION"]
117
- raise(ArgumentError, NEED_ENV_ARGS_MSG)
117
+ raise(ArgumentError, CLIENT_NEED_ENV_ARGS_MSG)
118
118
  end
119
119
  @login_args ||= {
120
120
  :user => ENV["YIELDMANAGER_USER"],
@@ -1,11 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- NEED_ENV_ARGS_MSG = <<EOM
3
+ REPORT_NEED_ENV_ARGS_MSG = <<EOM
4
4
  Please set these environment variables to match your Yieldmanager account:
5
5
  * YIELDMANAGER_USER
6
6
  * YIELDMANAGER_PASS
7
7
  * YIELDMANAGER_API_VERSION
8
- * YIELDMANAGER_CONTACT_ID
8
+ * YIELDMANAGER_CONTACT_ID (get this from the contact_id attribute in any UI-created reportware report)
9
9
  * YIELDMANAGER_IP_ADDRESS (your external IP address)
10
10
  EOM
11
11
 
@@ -77,14 +77,15 @@ describe "A Yieldmanager report request" do
77
77
  @login_args ||= {
78
78
  :user => ENV["YIELDMANAGER_USER"],
79
79
  :pass => ENV["YIELDMANAGER_PASS"],
80
- :api_version => ENV["YIELDMANAGER_API_VERSION"]
80
+ :api_version => ENV["YIELDMANAGER_API_VERSION"],
81
+ :env => "test"
81
82
  }
82
83
  end
83
84
 
84
85
  def request_xml
85
86
  unless ENV["YIELDMANAGER_CONTACT_ID"] &&
86
87
  ENV["YIELDMANAGER_IP_ADDRESS"]
87
- raise(ArgumentError, NEED_ENV_ARGS_MSG)
88
+ raise(ArgumentError, REPORT_NEED_ENV_ARGS_MSG)
88
89
  end
89
90
  <<EOR
90
91
  <?xml version="1.0"?>
data/yieldmanager.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{yieldmanager}
8
- s.version = "0.3.5"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bill Gathen"]
12
- s.date = %q{2009-12-23}
12
+ s.date = %q{2010-01-05}
13
13
  s.description = %q{This gem offers full access to YieldManager's API tools (read/write) as well as ad-hoc reporting through the Reportware tool}
14
14
  s.email = %q{bill@billgathen.com}
15
15
  s.extra_rdoc_files = [
@@ -25,10 +25,13 @@ Gem::Specification.new do |s|
25
25
  "Rakefile",
26
26
  "TODO",
27
27
  "VERSION",
28
+ "lib/patch_detector.rb",
29
+ "lib/wsdl/patch.rb",
28
30
  "lib/yieldmanager.rb",
29
31
  "lib/yieldmanager/builder.rb",
30
32
  "lib/yieldmanager/client.rb",
31
33
  "lib/yieldmanager/report.rb",
34
+ "spec/patch_detector_spec.rb",
32
35
  "spec/reports/sample_report.xml",
33
36
  "spec/spec.opts",
34
37
  "spec/spec_helper.rb",
@@ -81,7 +84,8 @@ Gem::Specification.new do |s|
81
84
  s.rubygems_version = %q{1.3.5}
82
85
  s.summary = %q{Interact with RightMedia's YieldManager API and Reportware products}
83
86
  s.test_files = [
84
- "spec/spec_helper.rb",
87
+ "spec/patch_detector_spec.rb",
88
+ "spec/spec_helper.rb",
85
89
  "spec/yieldmanager/builder_spec.rb",
86
90
  "spec/yieldmanager/client_spec.rb",
87
91
  "spec/yieldmanager/report_spec.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yieldmanager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Gathen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-23 00:00:00 -05:00
12
+ date: 2010-01-05 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,10 +50,13 @@ files:
50
50
  - Rakefile
51
51
  - TODO
52
52
  - VERSION
53
+ - lib/patch_detector.rb
54
+ - lib/wsdl/patch.rb
53
55
  - lib/yieldmanager.rb
54
56
  - lib/yieldmanager/builder.rb
55
57
  - lib/yieldmanager/client.rb
56
58
  - lib/yieldmanager/report.rb
59
+ - spec/patch_detector_spec.rb
57
60
  - spec/reports/sample_report.xml
58
61
  - spec/spec.opts
59
62
  - spec/spec_helper.rb
@@ -128,6 +131,7 @@ signing_key:
128
131
  specification_version: 3
129
132
  summary: Interact with RightMedia's YieldManager API and Reportware products
130
133
  test_files:
134
+ - spec/patch_detector_spec.rb
131
135
  - spec/spec_helper.rb
132
136
  - spec/yieldmanager/builder_spec.rb
133
137
  - spec/yieldmanager/client_spec.rb