rforce 0.2.1 → 0.3

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.
@@ -10,3 +10,65 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
10
  require 'rforce'
11
11
 
12
12
  include RForce
13
+
14
+ module RForceXmlMatchers
15
+ class Resemble
16
+ def initialize(expected)
17
+ @expected = expected
18
+ end
19
+
20
+ def matches?(actual)
21
+ @actual = actual
22
+
23
+ return false if different 'size',
24
+ @actual.size,
25
+ @expected.size
26
+
27
+ @expected.each_with_index do |exp_rec, index|
28
+ act_rec = @actual[index]
29
+
30
+ # Only bother to look at the first <Id>
31
+ # tag in a (presumably) duplicated set.
32
+ act_id = first_id(act_rec[:Id])
33
+ exp_id = first_id(exp_rec[:Id])
34
+
35
+ return false if different '<Id>', act_id, exp_id
36
+ return false if different 'keys', act_rec.keys, exp_rec.keys
37
+
38
+ exp_rec.each do |key, _|
39
+ unless key == :Id
40
+ return false if different key, act_rec[key], exp_rec[key]
41
+ end
42
+ end
43
+ end
44
+
45
+ return true
46
+ end
47
+
48
+ def failure_message_for_should
49
+ %Q{expected "#{@actual.to_s[0..9]}..." } +
50
+ %Q{to resemble "#{@expected.to_s[0..9]}...":\n} +
51
+ @difference
52
+ end
53
+
54
+ private
55
+
56
+ def first_id(id)
57
+ id.is_a?(Array) ? id.first : id
58
+ end
59
+
60
+ def different(name, act, exp)
61
+ return nil if act == exp
62
+ @difference = %Q{ for #{name}, got:\n } +
63
+ %Q{#{act.inspect}\n expected:\n #{exp.inspect}}
64
+ end
65
+ end
66
+
67
+ def resemble(expected)
68
+ Resemble.new(expected)
69
+ end
70
+ end
71
+
72
+ Spec::Runner.configure do |config|
73
+ config.include(RForceXmlMatchers)
74
+ end
@@ -14,7 +14,7 @@ EOS
14
14
  exit(0)
15
15
  end
16
16
 
17
- desc "Run the specs under spec/models"
17
+ desc "Run the specs"
18
18
  Spec::Rake::SpecTask.new do |t|
19
19
  t.spec_opts = ['--options', "spec/spec.opts"]
20
20
  t.spec_files = FileList['spec/**/*_spec.rb']
@@ -0,0 +1,21 @@
1
+ require 'rforce'
2
+
3
+ desc 'Perform a crude comparison of the various response parsers'
4
+ task :timing do
5
+ fname = File.join(File.dirname(__FILE__), '../spec/soap-response.xml')
6
+ contents = File.open(fname) {|f| f.read}
7
+
8
+ [:SoapResponseRexml,
9
+ :SoapResponseExpat,
10
+ :SoapResponseHpricot].each do |name|
11
+ begin
12
+ klass = RForce.const_get name
13
+ started_at = Time.now
14
+ klass.new(contents).parse
15
+ elapsed = Time.now - started_at
16
+ puts "#{klass}: #{elapsed}"
17
+ rescue NameError
18
+ # no-op
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: "0.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Dees
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-04 00:00:00 -07:00
12
+ date: 2009-04-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 2.0.0
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: facets
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "2.4"
34
+ version:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: hoe
27
37
  type: :development
@@ -40,7 +50,7 @@ dependencies:
40
50
  requirements:
41
51
  - - ">="
42
52
  - !ruby/object:Gem::Version
43
- version: 1.7.0
53
+ version: 1.12.1
44
54
  version:
45
55
  description: RForce is a simple, usable binding to the SalesForce API.
46
56
  email:
@@ -59,10 +69,18 @@ files:
59
69
  - README.txt
60
70
  - Rakefile
61
71
  - lib/rforce.rb
72
+ - lib/rforce/binding.rb
73
+ - lib/rforce/soap_pullable.rb
74
+ - lib/rforce/soap_response_expat.rb
75
+ - lib/rforce/soap_response_hpricot.rb
76
+ - lib/rforce/soap_response_rexml.rb
77
+ - lib/rforce/version.rb
62
78
  - spec/rforce_spec.rb
79
+ - spec/soap-response.xml
63
80
  - spec/spec.opts
64
81
  - spec/spec_helper.rb
65
82
  - tasks/rspec.rake
83
+ - tasks/timing.rake
66
84
  has_rdoc: true
67
85
  homepage: http://rforce.rubyforge.org
68
86
  post_install_message:
@@ -86,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
104
  requirements: []
87
105
 
88
106
  rubyforge_project: rforce
89
- rubygems_version: 1.2.0
107
+ rubygems_version: 1.3.1
90
108
  signing_key:
91
109
  specification_version: 2
92
110
  summary: RForce is a simple, usable binding to the SalesForce API.