cargowise 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ v0.8.3 - 10th January 2011
2
+ * transparently convert all measurements to metric
3
+
4
+ v0.8.2 - 15th September 2010
5
+ * new Shipment attribute - packings
6
+
1
7
  v0.8.1 - 15th September 2010
2
8
  * add explicit dependency on curb
3
9
 
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Peter Yandell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -15,7 +15,7 @@ module Cargowise
15
15
 
16
16
  def self.endpoint(name)
17
17
  @endpoints ||= {}
18
- @endpoints[name]
18
+ @endpoints[name]
19
19
  end
20
20
 
21
21
  def self.via(name)
@@ -54,6 +54,11 @@ module Cargowise
54
54
  node.xpath("#{path}/text()", "tns" => Cargowise::DEFAULT_NS).to_s
55
55
  end
56
56
 
57
+ def attribute_value(path)
58
+ path = path.gsub(/\/([^@])/u,'/tns:\1')
59
+ node.xpath(path, "tns" => Cargowise::DEFAULT_NS).to_s
60
+ end
61
+
57
62
  def time_value(path)
58
63
  val = text_value(path)
59
64
  val.nil? ? nil : DateTime.parse(val)
@@ -63,5 +68,37 @@ module Cargowise
63
68
  val = text_value(path)
64
69
  val.nil? ? nil : BigDecimal.new(val)
65
70
  end
71
+
72
+ # return a weight value in KG. Transparently handles the
73
+ # conversion from other units.
74
+ #
75
+ def kg_value(path)
76
+ val = text_value(path)
77
+ type = attribute_value("#{path}/@DimensionType")
78
+
79
+ if type.to_s.downcase == "kg"
80
+ BigDecimal.new(val)
81
+ elsif type.to_s.downcase == "lbs"
82
+ BigDecimal.new(val) * BigDecimal.new("0.45359237")
83
+ else
84
+ nil
85
+ end
86
+ end
87
+
88
+ # return a cubic value in meters cubed. Transparently handles the
89
+ # conversion from other units.
90
+ #
91
+ def cubic_value(path)
92
+ val = text_value(path)
93
+ type = attribute_value("#{path}/@DimensionType")
94
+
95
+ if type.to_s.downcase == "m3" # cubic metres
96
+ BigDecimal.new(val)
97
+ elsif type.to_s.downcase == "f3" # cubic feet
98
+ BigDecimal.new(val) * BigDecimal.new("0.0283168466")
99
+ else
100
+ nil
101
+ end
102
+ end
66
103
  end
67
104
  end
@@ -15,8 +15,8 @@ module Cargowise
15
15
 
16
16
  @pack_type = text_value("./PackType")
17
17
  @line_price = decimal_value("./LinePrice")
18
- @weight = decimal_value("./Weight")
19
- @volume = decimal_value("./Volume")
18
+ @weight = kg_value("./Weight")
19
+ @volume = cubic_value("./Volume")
20
20
  @description = text_value("./Description")
21
21
  end
22
22
  end
@@ -24,6 +24,7 @@ module Cargowise
24
24
  attr_reader :number, :housebill, :goods_description, :service_level
25
25
  attr_reader :client_reference
26
26
  attr_reader :origin, :destination, :etd, :eta, :delivered_date
27
+ attr_reader :kg, :cubic_meters
27
28
 
28
29
  attr_reader :shipper_name
29
30
 
@@ -44,6 +45,8 @@ module Cargowise
44
45
  @etd = time_value("./ETD")
45
46
  @eta = time_value("./ETA")
46
47
  @delivered_date = time_value("./DeliveredDate")
48
+ @kg = kg_value("./Weight")
49
+ @cubic_meters = cubic_value("./Size")
47
50
 
48
51
  @shipper_name = text_value("./Shipper/OrganisationDetails/Name")
49
52
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cargowise
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 2
10
- version: 0.8.2
9
+ - 3
10
+ version: 0.8.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Healy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-15 00:00:00 +10:00
18
+ date: 2011-01-10 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -80,7 +80,8 @@ dependencies:
80
80
  type: :runtime
81
81
  version_requirements: *id004
82
82
  description: Retrieve tracking and status information on your shipments from entpriseEDI
83
- email: james@yob.id.au
83
+ email:
84
+ - james@yob.id.au
84
85
  executables: []
85
86
 
86
87
  extensions: []
@@ -107,11 +108,11 @@ files:
107
108
  - CHANGELOG
108
109
  - TODO
109
110
  - COPYING
110
- - LICENSE
111
+ - MIT-LICENSE
111
112
  has_rdoc: true
112
113
  homepage: http://github.com/yob/cargowise
113
- licenses: []
114
-
114
+ licenses:
115
+ - mit
115
116
  post_install_message:
116
117
  rdoc_options:
117
118
  - --title
data/LICENSE DELETED
@@ -1,56 +0,0 @@
1
- Cargowise is copyrighted free software produced by James Healy along with
2
- community contributions. See git log for authorship information.
3
-
4
- Licensing terms follow (License of Ruby 1.8):
5
-
6
- You can redistribute Cargowise and/or modify it under either the terms of the GPL
7
- (see COPYING file), or the conditions below:
8
-
9
- 1. You may make and give away verbatim copies of the source form of the
10
- software without restriction, provided that you duplicate all of the
11
- original copyright notices and associated disclaimers.
12
-
13
- 2. You may modify your copy of the software in any way, provided that
14
- you do at least ONE of the following:
15
-
16
- a) place your modifications in the Public Domain or otherwise
17
- make them Freely Available, such as by posting said
18
- modifications to Usenet or an equivalent medium, or by allowing
19
- the author to include your modifications in the software.
20
-
21
- b) use the modified software only within your corporation or
22
- organization.
23
-
24
- c) rename any non-standard executables so the names do not conflict
25
- with standard executables, which must also be provided.
26
-
27
- d) make other distribution arrangements with the author.
28
-
29
- 3. You may distribute the software in object code or executable
30
- form, provided that you do at least ONE of the following:
31
-
32
- a) distribute the executables and library files of the software,
33
- together with instructions (in the manual page or equivalent)
34
- on where to get the original distribution.
35
-
36
- b) accompany the distribution with the machine-readable source of
37
- the software.
38
-
39
- c) give non-standard executables non-standard names, with
40
- instructions on where to get the original software distribution.
41
-
42
- d) make other distribution arrangements with the author.
43
-
44
- 4. You may modify and include the part of the software into any other
45
- software (possibly commercial).
46
-
47
- 5. The scripts and library files supplied as input to or produced as
48
- output from the software do not automatically fall under the
49
- copyright of the software, but belong to whomever generated them,
50
- and may be sold commercially, and may be aggregated with this
51
- software.
52
-
53
- 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
- PURPOSE.