endicia_label_server-ruby 0.2.3 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 89fce71aa7885d100f728db9d23ce6b7ba5bdbd8
4
- data.tar.gz: 9335e0b92f9481048e8b7f3fce95270b0b05c8da
2
+ SHA256:
3
+ metadata.gz: 48e2f6131b8ada7852acd991a285e290ddf7cdb79e8a215273dd74941f10b2c8
4
+ data.tar.gz: 16401c439b061104b4212f884c7111249cfc9fae422db327d2941da6a0ce2742
5
5
  SHA512:
6
- metadata.gz: 62e9dcdc87ec8dccf502d7f096de83067bf0411ec2f4a99b90afa9583f21563f141afb08e40a44de17cd99d62dbf0a91d502ba0cf518da4e5bdd52abd7f76b90
7
- data.tar.gz: cb1b5dda5436b1a8c8463aeb68dee2dd00e333fc4422cdd4738dcbd23994c26f1de62981ee67588aa0114e8573a5a7dfd4017c8055e24301ae4c5706227eb8a7
6
+ metadata.gz: d1ae8dbba0f5d92978edfa829ff6b737cf04a346a4d1e86c10c8384e58f9f55fed2d17946ee12f4e2c5b47c53c3e9010c4d1a2bf40ef10550a1d8cc1cd465d35
7
+ data.tar.gz: 834bbd3799791bd510cb8d0c833b4e68025e6223ceef9a60a93e78bfb0bebaff5dbffb67a54089c3ec90d8d171fbabac1cd10c8dbad777055d776b22523d6f4d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- endicia_label_server-ruby (0.2.3)
4
+ endicia_label_server-ruby (0.3.3)
5
5
  excon (~> 0.45, >= 0.45.3)
6
6
  insensitive_hash (~> 0.3.3, >= 0.3.3)
7
7
  ox (~> 2.2, >= 2.2.0)
@@ -13,7 +13,7 @@ GEM
13
13
  simplecov
14
14
  diff-lcs (1.3)
15
15
  docile (1.1.5)
16
- excon (0.54.0)
16
+ excon (0.62.0)
17
17
  faker (1.7.2)
18
18
  i18n (~> 0.5)
19
19
  i18n (0.7.0)
@@ -22,7 +22,7 @@ GEM
22
22
  mini_portile2 (2.1.0)
23
23
  nokogiri (1.7.0.1)
24
24
  mini_portile2 (~> 2.1.0)
25
- ox (2.4.9)
25
+ ox (2.9.4)
26
26
  rake (12.0.0)
27
27
  rspec (3.5.0)
28
28
  rspec-core (~> 3.5.0)
@@ -59,4 +59,4 @@ DEPENDENCIES
59
59
  simplecov
60
60
 
61
61
  BUNDLED WITH
62
- 1.15.4
62
+ 1.16.1
@@ -20,8 +20,9 @@ module EndiciaLabelServer
20
20
  #
21
21
  # @param [String] root_name The Name of the XML Root
22
22
  # @return [void]
23
- def initialize(root_name, opts = {})
24
- initialize_xml_roots root_name
23
+ def initialize(root_name, opts = {}, root_attributes = nil)
24
+ initialize_xml_roots(root_name)
25
+ assign_root_attributes(root_attributes) if root_attributes
25
26
 
26
27
  document << root
27
28
 
@@ -65,8 +66,8 @@ module EndiciaLabelServer
65
66
  # Returns a String representation of the XML document being built
66
67
  #
67
68
  # @return [String]
68
- def to_xml
69
- Ox.to_xml document
69
+ def to_xml(opts = {})
70
+ Ox.to_xml(document, opts)
70
71
  end
71
72
 
72
73
  def to_http_post
@@ -75,6 +76,13 @@ module EndiciaLabelServer
75
76
 
76
77
  private
77
78
 
79
+ def assign_root_attributes(root_attributes)
80
+ root_attributes.each do |attr_key, attr_value|
81
+ root_attribute_key = Util.camelize(attr_key)
82
+ root[root_attribute_key] = attr_value
83
+ end
84
+ end
85
+
78
86
  def initialize_xml_roots(root_name)
79
87
  self.document = Document.new
80
88
  self.root = Element.new(root_name)
@@ -1,7 +1,7 @@
1
1
  module EndiciaLabelServer
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 2
4
+ MINOR = 3
5
5
  PATCH = 3
6
6
  BUILD = nil
7
7
 
@@ -1,10 +1,35 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe EndiciaLabelServer::Builders::BuilderBase do
4
+ def dump_xml(builder)
5
+ builder.to_xml(indent: -1).strip
6
+ end
7
+
8
+ describe '.initialize' do
9
+ let(:options) { { foo: 'bar' } }
10
+ let(:root_attributes) { nil }
11
+ let(:builder) { EndiciaLabelServer::Builders::BuilderBase.new('ABuilder', options, root_attributes) }
12
+
13
+ subject { dump_xml(builder) }
14
+
15
+ context 'when passed with root attributes' do
16
+ let(:root_attributes) do
17
+ {
18
+ label_type: 'international',
19
+ label_subtype: 'another'
20
+ }
21
+ end
22
+
23
+ it 'adds the options as root attributes on the root object and returns valid XML' do
24
+ should eql '<ABuilder LabelType="international" LabelSubtype="another"><Foo>bar</Foo></ABuilder>'
25
+ end
26
+ end
27
+ end
28
+
4
29
  describe '.add_array' do
5
30
  let(:builder) { EndiciaLabelServer::Builders::BuilderBase.new 'MyBuilder' }
6
31
 
7
- subject { builder.to_xml.gsub(/\s+/, "") }
32
+ subject { dump_xml(builder) }
8
33
 
9
34
  before do
10
35
  builder.add_array :test, ['1', '2']
@@ -19,7 +44,7 @@ describe EndiciaLabelServer::Builders::BuilderBase do
19
44
  context "When passed symbolized keys" do
20
45
  let(:builder) { EndiciaLabelServer::Builders::BuilderBase.new 'MyBuilder' }
21
46
 
22
- subject { builder.to_xml.gsub(/\s+/, "") }
47
+ subject { dump_xml(builder) }
23
48
 
24
49
  before do
25
50
  builder.add_hash :test, { id: '1', source: 'test' }
@@ -33,7 +58,7 @@ describe EndiciaLabelServer::Builders::BuilderBase do
33
58
  context "When passed string keys" do
34
59
  let(:builder) { EndiciaLabelServer::Builders::BuilderBase.new 'MyBuilder' }
35
60
 
36
- subject { builder.to_xml.gsub(/\s+/, "") }
61
+ subject { dump_xml(builder) }
37
62
 
38
63
  before do
39
64
  builder.add_hash 'TestTest', { 'ID' => '1', 'SourceSource' => 'test' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: endicia_label_server-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Veeqo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-23 00:00:00.000000000 Z
11
+ date: 2018-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ox
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: 1.3.6
144
144
  requirements: []
145
145
  rubyforge_project:
146
- rubygems_version: 2.6.13
146
+ rubygems_version: 2.7.6
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Endicia Label Server