rforce 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,19 +1,24 @@
1
- == 0.1.0 2005-09-02
1
+ == 0.4 2010-01-21
2
2
 
3
- * 1 major enhancement:
4
- * Initial release
3
+ * 1 minor enhancement:
4
+ * Moved RubyGems dependencies into the gemspec where they belong
5
5
 
6
- == 0.2.0 2008-07-03
6
+ == 0.3 2009-04-16
7
7
 
8
- * 1 major enhancement:
9
- * Incorporated fixes from ActiveSalesforce project
8
+ * 1 minor enhancement:
9
+ * Updated for Ruby 1.9
10
10
 
11
11
  == 0.2.1 2008-07-04
12
12
 
13
13
  * 1 minor enhancement:
14
14
  * Updated examples for SalesForce API v10
15
15
 
16
- == 0.3 2009-04-16
17
-
18
- * 1 minor enhancement:
19
- * Updated for Ruby 1.9
16
+ == 0.2.0 2008-07-03
17
+
18
+ * 1 major enhancement:
19
+ * Incorporated fixes from ActiveSalesforce project
20
+
21
+ == 0.1.0 2005-09-02
22
+
23
+ * 1 major enhancement:
24
+ * Initial release
data/Manifest.txt CHANGED
@@ -5,6 +5,7 @@ Rakefile
5
5
  lib/rforce.rb
6
6
  lib/rforce/binding.rb
7
7
  lib/rforce/soap_pullable.rb
8
+ lib/rforce/soap_response.rb
8
9
  lib/rforce/soap_response_expat.rb
9
10
  lib/rforce/soap_response_hpricot.rb
10
11
  lib/rforce/soap_response_rexml.rb
@@ -13,5 +14,4 @@ spec/rforce_spec.rb
13
14
  spec/soap-response.xml
14
15
  spec/spec.opts
15
16
  spec/spec_helper.rb
16
- tasks/rspec.rake
17
17
  tasks/timing.rake
data/README.txt CHANGED
@@ -53,7 +53,7 @@ Rather than enforcing adherence to the sforce.com schema, RForce assumes you are
53
53
 
54
54
  == LICENSE:
55
55
 
56
- Copyright (c) 2005-2009 Ian Dees and contributors
56
+ Copyright (c) 2005-2010 Ian Dees and contributors
57
57
 
58
58
  Permission is hereby granted, free of charge, to any person obtaining
59
59
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,15 +1,17 @@
1
1
  # -*- ruby -*-
2
2
 
3
3
  $:.unshift './lib'
4
+
4
5
  require 'rubygems'
5
6
  require 'hoe'
6
7
  require 'rforce/version'
7
8
 
8
9
  Hoe.new('rforce', RForce::VERSION) do |p|
9
- p.developer('Ian Dees', 'undees@gmail.com')
10
- p.extra_deps = [['builder', '>= 2.0.0'], ['facets', '>= 2.4']]
11
- p.extra_dev_deps = [['hoe', '>= 1.7.0']]
10
+ p.developer 'Ian Dees', 'undees@gmail.com'
11
+ p.extra_deps = [['builder', '>= 2.0.0'], ['facets', '>= 2.4']]
12
+ p.extra_dev_deps = [['rspec', '>= 1.3']]
12
13
  p.remote_rdoc_dir = ''
14
+ p.rspec_options = ['-rubygems', '--options', 'spec/spec.opts']
13
15
  end
14
16
 
15
17
  Dir['tasks/**/*.rake'].each { |rake| load rake }
data/lib/rforce.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2005-2009 Ian Dees and contributors
2
+ Copyright (c) 2005-2010 Ian Dees and contributors
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -46,37 +46,10 @@ SOFTWARE.
46
46
  # binding.create 'sObject {"xsi:type" => "Opportunity"}' => opportunity
47
47
  #
48
48
 
49
-
50
- require 'net/https'
51
- require 'uri'
52
- require 'zlib'
53
- require 'stringio'
54
-
55
- require 'rubygems'
56
-
57
- gem 'builder', '>= 2.0.0'
58
- require 'builder'
59
-
60
- gem 'facets', '>= 2.4'
61
- require 'facets/openhash'
62
-
63
49
  require 'rforce/binding'
64
- require 'rforce/soap_response_rexml'
65
- begin; require 'rforce/soap_response_hpricot'; rescue LoadError; end
66
- begin; require 'rforce/soap_response_expat'; rescue LoadError; end
67
-
50
+ require 'rforce/soap_response'
68
51
 
69
52
  module RForce
70
- # Use the fastest XML parser available.
71
- def self.parser(name)
72
- RForce.const_get(name) rescue nil
73
- end
74
-
75
- SoapResponse =
76
- parser(:SoapResponseExpat) ||
77
- parser(:SoapResponseHpricot) ||
78
- SoapResponseRexml
79
-
80
53
  # Expand Ruby data structures into XML.
81
54
  def expand(builder, args, xmlns = nil)
82
55
  # Nest arrays: [:a, 1, :b, 2] => [[:a, 1], [:b, 2]]
@@ -111,5 +84,4 @@ module RForce
111
84
  end
112
85
  end
113
86
  end
114
-
115
87
  end
@@ -1,3 +1,10 @@
1
+ require 'net/https'
2
+ require 'uri'
3
+ require 'zlib'
4
+ require 'stringio'
5
+ require 'builder'
6
+
7
+
1
8
  module RForce
2
9
  # Implements the connection to the SalesForce server.
3
10
  class Binding
@@ -84,10 +91,13 @@ module RForce
84
91
  # a hash or (if order is important) an array of alternating
85
92
  # keys and values.
86
93
  def call_remote(method, args)
94
+
95
+ urn, soap_url = block_given? ? yield : ["urn:partner.soap.sforce.com", @url.path]
96
+
87
97
  # Create XML text from the arguments.
88
98
  expanded = ''
89
99
  @builder = Builder::XmlMarkup.new(:target => expanded)
90
- expand(@builder, {method => args}, 'urn:partner.soap.sforce.com')
100
+ expand(@builder, {method => args}, urn)
91
101
 
92
102
  extra_headers = ""
93
103
  extra_headers << (AssignmentRuleHeaderUsingRuleId % assignment_rule_id) if assignment_rule_id
@@ -128,7 +138,7 @@ module RForce
128
138
  end
129
139
 
130
140
  # Send the request to the server and read the response.
131
- response = @server.post2(@url.path, request.lstrip, headers)
141
+ response = @server.post2(soap_url, request.lstrip, headers)
132
142
 
133
143
  # decode if we have encoding
134
144
  content = decode(response)
@@ -142,7 +152,7 @@ module RForce
142
152
  request = encode(request)
143
153
 
144
154
  # Send the request to the server and read the response.
145
- response = @server.post2(@url.path, request.lstrip, headers)
155
+ response = @server.post2(soap_url, request.lstrip, headers)
146
156
 
147
157
  content = decode(response)
148
158
  end
@@ -1,3 +1,5 @@
1
+ require 'facets/openhash'
2
+
1
3
  module RForce
2
4
  module SoapPullable
3
5
  SOAP_ENVELOPE = 'soapenv:Envelope'
@@ -21,7 +23,11 @@ module RForce
21
23
  end
22
24
 
23
25
  def text(data)
24
- @current_value = data.strip.empty? ? nil : data
26
+ adding = data.strip.empty? ? nil : data
27
+
28
+ if adding
29
+ @current_value = (@current_value || '') + adding
30
+ end
25
31
  end
26
32
 
27
33
  def tag_end(name)
@@ -0,0 +1,12 @@
1
+ begin; require 'rforce/soap_response_hpricot'; rescue LoadError; end
2
+ begin; require 'rforce/soap_response_expat'; rescue LoadError; end
3
+ require 'rforce/soap_response_rexml'
4
+
5
+
6
+ module RForce
7
+ # Use the fastest XML parser available.
8
+ SoapResponse =
9
+ RForce::const_get(:SoapResponseExpat) ||
10
+ RForce::const_get(:SoapResponseHpricot) ||
11
+ SoapResponseRexml
12
+ end
@@ -8,8 +8,8 @@ module RForce
8
8
  def initialize(content)
9
9
  @content = content
10
10
  end
11
-
12
- def parse
11
+
12
+ def parse
13
13
  @current_value = nil
14
14
  @stack = []
15
15
  @parsed = OpenHash.new({})
@@ -25,7 +25,7 @@ module RForce
25
25
  when XML::Parser::END_ELEM then
26
26
  tag_end name
27
27
  end
28
-
28
+
29
29
  break if @done
30
30
  end
31
31
 
@@ -1,4 +1,5 @@
1
1
  require 'hpricot'
2
+ require 'cgi'
2
3
 
3
4
 
4
5
  module RForce
@@ -14,9 +15,13 @@ module RForce
14
15
  node = document % 'soapenv:Body'
15
16
  self.class.node_to_ruby node
16
17
  end
17
-
18
+
18
19
  private
19
-
20
+
21
+ def self.unescapeXML(string)
22
+ CGI.unescapeHTML(string).gsub("&apos;", "'")
23
+ end
24
+
20
25
  def self.node_to_ruby(node)
21
26
  # Convert text nodes into simple strings.
22
27
  children = (node.children || []).reject do |c|
@@ -24,11 +29,11 @@ module RForce
24
29
  end
25
30
 
26
31
  if node.is_a?(Hpricot::Text)
27
- return node.inner_text.to_s
32
+ return SoapResponseHpricot.unescapeXML(node.inspect[1..-2])
28
33
  end
29
-
34
+
30
35
  if children.first.is_a?(Hpricot::Text)
31
- return children.first.to_s
36
+ return SoapResponseHpricot.unescapeXML(children.first.inspect[1..-2])
32
37
  end
33
38
 
34
39
  # Convert nodes with children into MethodHashes.
@@ -38,11 +43,11 @@ module RForce
38
43
  children.each do |e|
39
44
  next if e.is_a?(Hpricot::Text) && e.to_s.strip.empty?
40
45
  name = e.name
41
-
46
+
42
47
  if name.include? ':'
43
48
  name = name.split(':').last
44
49
  end
45
-
50
+
46
51
  name = name.to_sym
47
52
 
48
53
  case elements[name]
@@ -1,3 +1,3 @@
1
1
  module RForce
2
- VERSION = '0.3'
2
+ VERSION = '0.4'
3
3
  end
data/spec/rforce_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
1
+ require 'spec_helper'
2
2
 
3
3
  describe 'expand' do
4
4
  it 'turns Ruby into XML' do
@@ -68,6 +68,25 @@ describe 'a SoapResponse implementation' do
68
68
  pending 'hpricot not installed' unless @hpricot_recs
69
69
  @hpricot_recs.should resemble(@rexml_recs)
70
70
  end
71
+
72
+ it 'understands XML entities' do
73
+ expected = "Bee's knees"
74
+ @rexml_recs.first.Description.should == expected
75
+
76
+ pending 'expat not installed' unless @expat_recs
77
+ @expat_recs.first.Description.should == expected
78
+
79
+ pending 'hpricot not installed' unless @hpricot
80
+ @hpricot_recs.first.Description.should == expected
81
+ end
82
+ end
83
+
84
+ describe 'SoapResponseHpricot' do
85
+ it 'parses basic XML entities' do
86
+ text = '&lt;tag attr=&quot;Bee&apos;s knees &amp; toes&quot;&gt;'
87
+ SoapResponseHpricot.unescapeXML(text).should ==
88
+ %q(<tag attr="Bee's knees & toes">)
89
+ end
71
90
  end
72
91
 
73
92
  CreateXml = <<HERE.gsub(/\n\s*/, '')
@@ -84,4 +103,3 @@ CreateXml = <<HERE.gsub(/\n\s*/, '')
84
103
  </partner:sObjects>
85
104
  </partner:create>
86
105
  HERE
87
-
@@ -39,7 +39,7 @@
39
39
  <sf:AssistantName xsi:nil="true"/>
40
40
  <sf:LeadSource xsi:nil="true"/>
41
41
  <sf:Birthdate xsi:nil="true"/>
42
- <sf:Description xsi:nil="true"/>
42
+ <sf:Description>Bee&apos;s knees</sf:Description>
43
43
  <sf:OwnerId>0000000000ABcDEFGH</sf:OwnerId>
44
44
  <sf:CreatedDate>2008-03-01T01:52:35.000Z</sf:CreatedDate>
45
45
  <sf:CreatedById>0000000000ABcDEFGH</sf:CreatedById>
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,4 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems'
5
- gem 'rspec'
6
- require 'spec'
7
- end
8
-
9
- $:.unshift(File.dirname(__FILE__) + '/../lib')
1
+ gem 'builder'
10
2
  require 'rforce'
11
3
 
12
4
  include RForce
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.3"
4
+ version: "0.4"
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: 2009-04-16 00:00:00 -07:00
12
+ date: 2010-01-21 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -33,14 +33,14 @@ dependencies:
33
33
  version: "2.4"
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
- name: hoe
36
+ name: rspec
37
37
  type: :development
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 1.7.0
43
+ version: "1.3"
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: hoe
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 1.12.1
53
+ version: 2.5.0
54
54
  version:
55
55
  description: RForce is a simple, usable binding to the SalesForce API.
56
56
  email:
@@ -71,6 +71,7 @@ files:
71
71
  - lib/rforce.rb
72
72
  - lib/rforce/binding.rb
73
73
  - lib/rforce/soap_pullable.rb
74
+ - lib/rforce/soap_response.rb
74
75
  - lib/rforce/soap_response_expat.rb
75
76
  - lib/rforce/soap_response_hpricot.rb
76
77
  - lib/rforce/soap_response_rexml.rb
@@ -79,10 +80,11 @@ files:
79
80
  - spec/soap-response.xml
80
81
  - spec/spec.opts
81
82
  - spec/spec_helper.rb
82
- - tasks/rspec.rake
83
83
  - tasks/timing.rake
84
84
  has_rdoc: true
85
85
  homepage: http://rforce.rubyforge.org
86
+ licenses: []
87
+
86
88
  post_install_message:
87
89
  rdoc_options:
88
90
  - --main
@@ -104,9 +106,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
106
  requirements: []
105
107
 
106
108
  rubyforge_project: rforce
107
- rubygems_version: 1.3.1
109
+ rubygems_version: 1.3.5
108
110
  signing_key:
109
- specification_version: 2
111
+ specification_version: 3
110
112
  summary: RForce is a simple, usable binding to the SalesForce API.
111
113
  test_files: []
112
114
 
data/tasks/rspec.rake DELETED
@@ -1,21 +0,0 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems'
5
- require 'spec'
6
- end
7
- begin
8
- require 'spec/rake/spectask'
9
- rescue LoadError
10
- puts <<-EOS
11
- To use rspec for testing you must install rspec gem:
12
- gem install rspec
13
- EOS
14
- exit(0)
15
- end
16
-
17
- desc "Run the specs"
18
- Spec::Rake::SpecTask.new do |t|
19
- t.spec_opts = ['--options', "spec/spec.opts"]
20
- t.spec_files = FileList['spec/**/*_spec.rb']
21
- end