opensrs 0.2.0 → 0.2.1

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/Rakefile CHANGED
@@ -11,8 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/voxxit/opensrs"
12
12
  gem.authors = ["Josh Delsman"]
13
13
  gem.add_dependency "libxml-ruby"
14
- gem.add_development_dependency "thoughtbot-shoulda"
15
- gem.add_development_dependency "rspec"
14
+ gem.add_development_dependency "rspec", "~> 2.0"
16
15
  end
17
16
  rescue LoadError
18
17
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/lib/opensrs/xml.rb CHANGED
@@ -15,7 +15,7 @@ module OpenSRS
15
15
  header << Node.new("version", "0.9")
16
16
  body << data_block = Node.new("data_block")
17
17
 
18
- encode_data(data, data_block)
18
+ data_block << encode_data(data, data_block)
19
19
 
20
20
  return xml.to_s
21
21
  end
@@ -88,12 +88,8 @@ module OpenSRS
88
88
 
89
89
  dt_array << item_node
90
90
  end
91
-
92
- if container
93
- container << dt_array
94
- else
95
- return dt_array
96
- end
91
+
92
+ return dt_array
97
93
  end
98
94
 
99
95
  def self.encode_dt_assoc(data, container)
@@ -106,12 +102,8 @@ module OpenSRS
106
102
 
107
103
  dt_assoc << item_node
108
104
  end
109
-
110
- if container
111
- container << dt_assoc
112
- else
113
- return dt_assoc
114
- end
105
+
106
+ return dt_assoc
115
107
  end
116
108
  end
117
109
  end
data/opensrs.gemspec ADDED
@@ -0,0 +1,61 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{opensrs}
8
+ s.version = "0.2.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Josh Delsman"]
12
+ s.date = %q{2011-01-31}
13
+ s.description = %q{Provides support to utilise the OpenSRS API with Ruby/Rails.}
14
+ s.email = %q{josh@voxx.it}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "lib/opensrs.rb",
26
+ "lib/opensrs/response.rb",
27
+ "lib/opensrs/server.rb",
28
+ "lib/opensrs/xml.rb",
29
+ "opensrs.gemspec",
30
+ "spec/opensrs/xml_spec.rb",
31
+ "spec/spec_helper.rb",
32
+ "test/opensrs_test.rb",
33
+ "test/test_helper.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/voxxit/opensrs}
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.4.2}
38
+ s.summary = %q{Provides support to utilise the OpenSRS API with Ruby/Rails.}
39
+ s.test_files = [
40
+ "spec/opensrs/xml_spec.rb",
41
+ "spec/spec_helper.rb",
42
+ "test/opensrs_test.rb",
43
+ "test/test_helper.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<libxml-ruby>, [">= 0"])
51
+ s.add_development_dependency(%q<rspec>, ["~> 2.0"])
52
+ else
53
+ s.add_dependency(%q<libxml-ruby>, [">= 0"])
54
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<libxml-ruby>, [">= 0"])
58
+ s.add_dependency(%q<rspec>, ["~> 2.0"])
59
+ end
60
+ end
61
+
@@ -2,7 +2,15 @@ require 'spec_helper'
2
2
  require 'date'
3
3
 
4
4
  describe OpenSRS::XML do
5
- describe '#encode_data' do
5
+ describe ".build" do
6
+ it "should create XML for a nested hash" do
7
+ attributes = {:foo => {:bar => 'baz'}}
8
+ xml = OpenSRS::XML.build(attributes)
9
+ xml.should eq %{<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<OPS_envelope>\n <header>\n <version>0.9</version>\n </header>\n <body>\n <data_block>\n <dt_assoc>\n <item key=\"foo\">\n <dt_assoc>\n <item key=\"bar\">baz</item>\n </dt_assoc>\n </item>\n </dt_assoc>\n </data_block>\n </body>\n</OPS_envelope>\n}
10
+ end
11
+ end
12
+
13
+ describe '.encode_data' do
6
14
  context "on a 3 element array" do
7
15
  before(:each) do
8
16
  @e = OpenSRS::XML.encode_data([1,2,3])
@@ -49,6 +57,36 @@ describe OpenSRS::XML do
49
57
  @e.children[0].attributes["key"].should == 'name'
50
58
  end
51
59
  end
60
+
61
+ context "on a nested hash" do
62
+ before(:each) do
63
+ @e = OpenSRS::XML.encode_data({:suggestion => {:maximum => "10"}})
64
+ end
65
+
66
+ it "is a REXML::Element" do
67
+ @e.should be_an_instance_of(LibXML::XML::Node)
68
+ end
69
+
70
+ it "is a dt_assoc" do
71
+ @e.name.should == 'dt_assoc'
72
+ end
73
+
74
+ it "has an <item> child with the correct children" do
75
+ @e.should have(1).children
76
+ suggestion = @e.children[0]
77
+ suggestion.name.should == 'item'
78
+ suggestion.attributes["key"].should == 'suggestion'
79
+
80
+ suggestion.should have(1).children
81
+ dt_assoc = suggestion.children[0]
82
+ dt_assoc.name.should == 'dt_assoc'
83
+
84
+ dt_assoc.should have(1).children
85
+ maximum = dt_assoc.children[0]
86
+ maximum.name.should == 'item'
87
+ maximum.attributes["key"].should == 'maximum'
88
+ end
89
+ end
52
90
 
53
91
  context "produces a scalar" do
54
92
  it "from a string" do
@@ -79,7 +117,7 @@ describe OpenSRS::XML do
79
117
  end
80
118
  end
81
119
 
82
- describe '#parse' do
120
+ describe '.parse' do
83
121
  it "should handle scalar values" do
84
122
  xml = %{<?xml version='1.0' encoding='UTF-8' standalone='no' ?>
85
123
  <!DOCTYPE OPS_envelope SYSTEM 'ops.dtd'>
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opensrs
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 21
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 0
9
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Josh Delsman
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-26 00:00:00 -05:00
18
+ date: 2011-01-31 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,37 +26,27 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 3
28
30
  segments:
29
31
  - 0
30
32
  version: "0"
31
33
  type: :runtime
32
34
  version_requirements: *id001
33
35
  - !ruby/object:Gem::Dependency
34
- name: thoughtbot-shoulda
36
+ name: rspec
35
37
  prerelease: false
36
38
  requirement: &id002 !ruby/object:Gem::Requirement
37
39
  none: false
38
40
  requirements:
39
- - - ">="
41
+ - - ~>
40
42
  - !ruby/object:Gem::Version
43
+ hash: 3
41
44
  segments:
45
+ - 2
42
46
  - 0
43
- version: "0"
47
+ version: "2.0"
44
48
  type: :development
45
49
  version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- name: rspec
48
- prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
- version: "0"
57
- type: :development
58
- version_requirements: *id003
59
50
  description: Provides support to utilise the OpenSRS API with Ruby/Rails.
60
51
  email: josh@voxx.it
61
52
  executables: []
@@ -67,7 +58,6 @@ extra_rdoc_files:
67
58
  - README.rdoc
68
59
  files:
69
60
  - .document
70
- - .gitignore
71
61
  - LICENSE
72
62
  - README.rdoc
73
63
  - Rakefile
@@ -76,6 +66,7 @@ files:
76
66
  - lib/opensrs/response.rb
77
67
  - lib/opensrs/server.rb
78
68
  - lib/opensrs/xml.rb
69
+ - opensrs.gemspec
79
70
  - spec/opensrs/xml_spec.rb
80
71
  - spec/spec_helper.rb
81
72
  - test/opensrs_test.rb
@@ -85,8 +76,8 @@ homepage: http://github.com/voxxit/opensrs
85
76
  licenses: []
86
77
 
87
78
  post_install_message:
88
- rdoc_options:
89
- - --charset=UTF-8
79
+ rdoc_options: []
80
+
90
81
  require_paths:
91
82
  - lib
92
83
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -94,6 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
85
  requirements:
95
86
  - - ">="
96
87
  - !ruby/object:Gem::Version
88
+ hash: 3
97
89
  segments:
98
90
  - 0
99
91
  version: "0"
@@ -102,13 +94,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
94
  requirements:
103
95
  - - ">="
104
96
  - !ruby/object:Gem::Version
97
+ hash: 3
105
98
  segments:
106
99
  - 0
107
100
  version: "0"
108
101
  requirements: []
109
102
 
110
103
  rubyforge_project:
111
- rubygems_version: 1.3.7
104
+ rubygems_version: 1.4.2
112
105
  signing_key:
113
106
  specification_version: 3
114
107
  summary: Provides support to utilise the OpenSRS API with Ruby/Rails.
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- pkg