dhl-get_quote 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![Build Status](https://travis-ci.org/deseretbook/dhl-get_quote.png)](https://travis-ci.org/deseretbook/dhl-get_quote)
2
+ [![Code Climate](https://codeclimate.com/github/deseretbook/dhl-get_quote.png)](https://codeclimate.com/github/deseretbook/dhl-get_quote)
2
3
 
3
4
  # Dhl::GetQuote
4
5
 
@@ -41,10 +42,10 @@ Or install it yourself as:
41
42
  r.from('US', 84010)
42
43
 
43
44
  r.pieces << Dhl::GetQuote::Piece.new(
44
- :height => 20,
45
- :weight => 20,
46
- :width => 20,
47
- :depth => 19
45
+ :height => 20.0,
46
+ :weight => 20.0,
47
+ :width => 20.0,
48
+ :depth => 19.0
48
49
  )
49
50
 
50
51
  response = r.post
@@ -196,15 +197,15 @@ To add items to the shipping quote request, generate a new Dhl::GetQuote::Piece
196
197
 
197
198
  ```ruby
198
199
  # minimal
199
- request.pieces << Dhl::GetQuote::Piece.new( :weight => 20 )
200
+ request.pieces << Dhl::GetQuote::Piece.new( :weight => 20.0 )
200
201
 
201
202
  # more details
202
203
  request.pieces << Dhl::GetQuote::Piece.new(
203
- :weight => 20, :height => 20, :width => 20, :depth => 19
204
+ :weight => 20.0, :height => 20.0, :width => 20.0, :depth => 19.0
204
205
  )
205
206
  ```
206
207
 
207
- Dhl::GetQuote::Piece requires *at least* :weight to be specified, and it must be a nonzero integer. Optionally, you can provide :width, :depth and :height. The measurement options must all be added at once and cannot be added individually. They must be integers.
208
+ Dhl::GetQuote::Piece requires *at least* :weight to be specified, and it must be a nonzero integer or float. Optionally, you can provide :width, :depth and :height. The measurement options must all be added at once and cannot be added individually. They must be integers or floats.
208
209
 
209
210
  #### Posting to DHL
210
211
 
@@ -3,7 +3,7 @@ class Dhl::GetQuote::Piece
3
3
 
4
4
  def initialize(options = {})
5
5
  [ :width, :height, :depth, :weight ].each do |i|
6
- options[i] = options[i].to_i if !!options[i]
6
+ options[i] = options[i].to_f if !!options[i]
7
7
  end
8
8
 
9
9
  if options[:weight] && options[:weight] > 0
@@ -14,8 +14,8 @@ class Dhl::GetQuote::Piece
14
14
 
15
15
  if options[:width] || options[:height] || options[:depth]
16
16
  [ :width, :height, :depth ].each do |req|
17
- if options[req].to_i > 0
18
- instance_variable_set("@#{req}", options[req].to_i)
17
+ if options[req].to_f > 0.0
18
+ instance_variable_set("@#{req}", options[req].to_f)
19
19
  else
20
20
  raise Dhl::GetQuote::OptionsError, required_option_error_message(req)
21
21
  end
@@ -54,6 +54,6 @@ eos
54
54
  private
55
55
 
56
56
  def required_option_error_message(field)
57
- ":#{field} is a required for Dhl::GetQuote::Piece. Must be nonzero integer."
57
+ ":#{field} is a required for Dhl::GetQuote::Piece. Must be nonzero integer or float."
58
58
  end
59
59
  end
@@ -1,6 +1,6 @@
1
1
  class Dhl
2
2
  class GetQuote
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
 
5
5
  PostInstallMessage = <<EOS
6
6
 
@@ -13,6 +13,10 @@ This version introduces the following changes from 0.4.x:
13
13
 
14
14
  * dutiable() replaces dutiable! now requires arguments (dutiable value and currency).
15
15
 
16
+ This version introduces the following changes from 0.5.1:
17
+
18
+ * Product.new() can accept weights and measures as float as well as by integer.
19
+
16
20
  EOS
17
21
  end
18
22
  end
@@ -72,10 +72,10 @@ describe Dhl::GetQuote::Piece do
72
72
  subject.to_xml.must == <<eos
73
73
  <Piece>
74
74
  <PieceID>1</PieceID>
75
- <Height>1</Height>
76
- <Depth>4</Depth>
77
- <Width>3</Width>
78
- <Weight>2</Weight>
75
+ <Height>1.0</Height>
76
+ <Depth>4.0</Depth>
77
+ <Width>3.0</Width>
78
+ <Weight>2.0</Weight>
79
79
  </Piece>
80
80
  eos
81
81
  end
@@ -85,7 +85,7 @@ eos
85
85
  dhl.to_xml.must == <<eos
86
86
  <Piece>
87
87
  <PieceID>1</PieceID>
88
- <Weight>99</Weight>
88
+ <Weight>99.0</Weight>
89
89
  </Piece>
90
90
  eos
91
91
  end
@@ -96,7 +96,7 @@ eos
96
96
  dhl.to_xml.must == <<eos
97
97
  <Piece>
98
98
  <PieceID>88</PieceID>
99
- <Weight>1</Weight>
99
+ <Weight>1.0</Weight>
100
100
  </Piece>
101
101
  eos
102
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhl-get_quote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-03 00:00:00.000000000 Z
13
+ date: 2013-06-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -148,7 +148,7 @@ files:
148
148
  - lib/dhl/get_quote/request.rb
149
149
  - lib/dhl/get_quote/response.rb
150
150
  - lib/dhl/get_quote/version.rb
151
- - spec/lib/dhl/dh-get_quote_spec.rb
151
+ - spec/lib/dhl/dhl-get_quote_spec.rb
152
152
  - spec/lib/dhl/get_quote/market_service_spec.rb
153
153
  - spec/lib/dhl/get_quote/piece_spec.rb
154
154
  - spec/lib/dhl/get_quote/request_spec.rb
@@ -160,7 +160,9 @@ licenses: []
160
160
  post_install_message: ! "\n*** NOTE Dhl-GetQuote ***\n\nThis version introduces the
161
161
  following changes from 0.4.x:\n\n* #inches!, #pounds!, #kilograms! and #centimeters
162
162
  have been depricated.\n Please use #us_measurements! or #metric_measurements!.\n\n*
163
- dutiable() replaces dutiable! now requires arguments (dutiable value and currency).\n\n"
163
+ dutiable() replaces dutiable! now requires arguments (dutiable value and currency).\n\nThis
164
+ version introduces the following changes from 0.5.1:\n\n* Product.new() can accept
165
+ weights and measures as float as well as by integer.\n\n"
164
166
  rdoc_options: []
165
167
  require_paths:
166
168
  - lib
@@ -183,7 +185,7 @@ signing_key:
183
185
  specification_version: 3
184
186
  summary: Gem to interface with DHL's XML-PI shipping quote service.
185
187
  test_files:
186
- - spec/lib/dhl/dh-get_quote_spec.rb
188
+ - spec/lib/dhl/dhl-get_quote_spec.rb
187
189
  - spec/lib/dhl/get_quote/market_service_spec.rb
188
190
  - spec/lib/dhl/get_quote/piece_spec.rb
189
191
  - spec/lib/dhl/get_quote/request_spec.rb