active_shipping 0.0.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.
Files changed (81) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGELOG +23 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.markdown +173 -0
  5. data/Rakefile +55 -0
  6. data/VERSION +1 -0
  7. data/init.rb +1 -0
  8. data/lib/active_shipping.rb +50 -0
  9. data/lib/active_shipping/lib/connection.rb +170 -0
  10. data/lib/active_shipping/lib/country.rb +319 -0
  11. data/lib/active_shipping/lib/error.rb +4 -0
  12. data/lib/active_shipping/lib/post_data.rb +22 -0
  13. data/lib/active_shipping/lib/posts_data.rb +47 -0
  14. data/lib/active_shipping/lib/requires_parameters.rb +16 -0
  15. data/lib/active_shipping/lib/utils.rb +18 -0
  16. data/lib/active_shipping/lib/validateable.rb +76 -0
  17. data/lib/active_shipping/shipping/base.rb +15 -0
  18. data/lib/active_shipping/shipping/carrier.rb +75 -0
  19. data/lib/active_shipping/shipping/carriers.rb +17 -0
  20. data/lib/active_shipping/shipping/carriers/bogus_carrier.rb +16 -0
  21. data/lib/active_shipping/shipping/carriers/fedex.rb +315 -0
  22. data/lib/active_shipping/shipping/carriers/shipwire.rb +167 -0
  23. data/lib/active_shipping/shipping/carriers/ups.rb +368 -0
  24. data/lib/active_shipping/shipping/carriers/usps.rb +496 -0
  25. data/lib/active_shipping/shipping/location.rb +100 -0
  26. data/lib/active_shipping/shipping/package.rb +144 -0
  27. data/lib/active_shipping/shipping/rate_estimate.rb +54 -0
  28. data/lib/active_shipping/shipping/rate_response.rb +19 -0
  29. data/lib/active_shipping/shipping/response.rb +49 -0
  30. data/lib/active_shipping/shipping/shipment_event.rb +14 -0
  31. data/lib/active_shipping/shipping/tracking_response.rb +22 -0
  32. data/lib/certs/cacert.pem +7815 -0
  33. data/lib/vendor/quantified/MIT-LICENSE +22 -0
  34. data/lib/vendor/quantified/README.markdown +49 -0
  35. data/lib/vendor/quantified/Rakefile +21 -0
  36. data/lib/vendor/quantified/init.rb +0 -0
  37. data/lib/vendor/quantified/lib/quantified.rb +6 -0
  38. data/lib/vendor/quantified/lib/quantified/attribute.rb +208 -0
  39. data/lib/vendor/quantified/lib/quantified/length.rb +20 -0
  40. data/lib/vendor/quantified/lib/quantified/mass.rb +19 -0
  41. data/lib/vendor/quantified/test/length_test.rb +92 -0
  42. data/lib/vendor/quantified/test/mass_test.rb +88 -0
  43. data/lib/vendor/quantified/test/test_helper.rb +2 -0
  44. data/lib/vendor/test_helper.rb +13 -0
  45. data/lib/vendor/xml_node/README +36 -0
  46. data/lib/vendor/xml_node/Rakefile +21 -0
  47. data/lib/vendor/xml_node/benchmark/bench_generation.rb +32 -0
  48. data/lib/vendor/xml_node/init.rb +1 -0
  49. data/lib/vendor/xml_node/lib/xml_node.rb +222 -0
  50. data/lib/vendor/xml_node/test/test_generating.rb +94 -0
  51. data/lib/vendor/xml_node/test/test_parsing.rb +43 -0
  52. data/test/fixtures.yml +13 -0
  53. data/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_request.xml +67 -0
  54. data/test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_response.xml +213 -0
  55. data/test/fixtures/xml/fedex/tracking_request.xml +27 -0
  56. data/test/fixtures/xml/fedex/tracking_response.xml +153 -0
  57. data/test/fixtures/xml/shipwire/international_rates_response.xml +17 -0
  58. data/test/fixtures/xml/shipwire/invalid_credentials_response.xml +4 -0
  59. data/test/fixtures/xml/shipwire/new_carrier_rate_response.xml +18 -0
  60. data/test/fixtures/xml/shipwire/no_rates_response.xml +7 -0
  61. data/test/fixtures/xml/shipwire/rates_response.xml +36 -0
  62. data/test/fixtures/xml/ups/example_tracking_response.xml +53 -0
  63. data/test/fixtures/xml/ups/shipment_from_tiger_direct.xml +222 -0
  64. data/test/fixtures/xml/ups/test_real_home_as_residential_destination_response.xml +1 -0
  65. data/test/fixtures/xml/usps/beverly_hills_to_ottawa_book_rate_response.xml +85 -0
  66. data/test/fixtures/xml/usps/beverly_hills_to_ottawa_book_wii_rate_response.xml +168 -0
  67. data/test/fixtures/xml/usps/beverly_hills_to_ottawa_wii_rate_response.xml +85 -0
  68. data/test/remote/fedex_test.rb +140 -0
  69. data/test/remote/shipwire_test.rb +88 -0
  70. data/test/remote/ups_test.rb +187 -0
  71. data/test/remote/usps_test.rb +184 -0
  72. data/test/test_helper.rb +167 -0
  73. data/test/unit/base_test.rb +18 -0
  74. data/test/unit/carriers/fedex_test.rb +78 -0
  75. data/test/unit/carriers/shipwire_test.rb +130 -0
  76. data/test/unit/carriers/ups_test.rb +81 -0
  77. data/test/unit/carriers/usps_test.rb +206 -0
  78. data/test/unit/location_test.rb +46 -0
  79. data/test/unit/package_test.rb +65 -0
  80. data/test/unit/response_test.rb +10 -0
  81. metadata +158 -0
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class LocationTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Shipping
5
+
6
+ def setup
7
+ @locations = TestFixtures.locations.dup
8
+ end
9
+
10
+ def test_countries
11
+ assert_instance_of ActiveMerchant::Country, @locations[:ottawa].country
12
+ assert_equal 'CA', @locations[:ottawa].country_code(:alpha2)
13
+ end
14
+
15
+ def test_location_from_strange_hash
16
+ hash = { :country => 'CA',
17
+ :zip => '90210',
18
+ :territory_code => 'QC',
19
+ :town => 'Perth',
20
+ :address => '66 Gregory Ave.',
21
+ :phone => '515-555-1212',
22
+ :fax_number => 'none to speak of',
23
+ :address_type => :commercial
24
+ }
25
+ location = Location.from(hash)
26
+
27
+ assert_equal hash[:country], location.country_code(:alpha2)
28
+ assert_equal hash[:zip], location.zip
29
+ assert_equal hash[:territory_code], location.province
30
+ assert_equal hash[:town], location.city
31
+ assert_equal hash[:address], location.address1
32
+ assert_equal hash[:phone], location.phone
33
+ assert_equal hash[:fax_number], location.fax
34
+ assert_equal hash[:address_type].to_s, location.address_type
35
+ end
36
+
37
+ def to_s
38
+ expected = "110 Laurier Avenue West\nOttawa, ON, K1P 1J1\nCanada"
39
+ assert_equal expected, @locations[:ottawa].to_s
40
+ end
41
+
42
+ def test_inspect
43
+ expected = "110 Laurier Avenue West\nOttawa, ON, K1P 1J1\nCanada\nPhone: 1-613-580-2400\nFax: 1-613-580-2495"
44
+ assert_equal expected, @locations[:ottawa].inspect
45
+ end
46
+ end
@@ -0,0 +1,65 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class PackageTest < Test::Unit::TestCase
4
+
5
+ GRAMS_IN_AN_OUNCE = 28.349523125
6
+ OUNCES_IN_A_GRAM = 0.0352739619495804
7
+ INCHES_IN_A_CM = 0.393700787401575
8
+ CM_IN_AN_INCH = 2.54
9
+
10
+ def setup
11
+ @imperial_package = Package.new(65, [3,6,8.5],
12
+ :units => :imperial,
13
+ :value => 10.65,
14
+ :currency => 'USD'
15
+ )
16
+
17
+ @metric_package = Package.new(100, [5,18.5,40],
18
+ :value => 860,
19
+ :currency => 'CAD'
20
+ )
21
+
22
+ @packages = TestFixtures.packages
23
+ end
24
+
25
+ def test_accessors
26
+ # :wii => Package.new((7.5 * 16), [15, 10, 4.5], :units => :imperial, :value => 269.99, :currency => 'GBP')
27
+ wii = @packages[:wii]
28
+ [:x, :max, :long, :length].each do |sym|
29
+ assert_equal 15, wii.inches(sym)
30
+ assert_equal 15, wii.in(sym)
31
+ assert_equal 15 * CM_IN_AN_INCH, wii.centimetres(sym)
32
+ assert_equal 15 * CM_IN_AN_INCH, wii.cm(sym)
33
+ end
34
+ [:y, :mid, :width, :wide].each do |sym|
35
+ assert_equal 10, wii.inches(sym)
36
+ assert_equal 10, wii.in(sym)
37
+ assert_equal 10 * CM_IN_AN_INCH, wii.centimetres(sym)
38
+ assert_equal 10 * CM_IN_AN_INCH, wii.cm(sym)
39
+ end
40
+ [:z, :min, :height, :high, :depth, :deep].each do |sym|
41
+ assert_equal 4.5, wii.inches(sym)
42
+ assert_equal 4.5, wii.in(sym)
43
+ assert_equal 4.5 * CM_IN_AN_INCH, wii.centimetres(sym)
44
+ assert_equal 4.5 * CM_IN_AN_INCH, wii.cm(sym)
45
+ end
46
+ [:pounds, :lbs, :lb].each do |sym|
47
+ assert_equal 7.5, wii.send(sym)
48
+ end
49
+ [:ounces, :oz].each do |sym|
50
+ assert_equal 120, wii.send(sym)
51
+ end
52
+ [:grams, :g].each do |sym|
53
+ assert_equal 120 * GRAMS_IN_AN_OUNCE, wii.send(sym)
54
+ end
55
+ [:kilograms, :kgs, :kg].each do |sym|
56
+ assert_equal 120 * GRAMS_IN_AN_OUNCE / 1000, wii.send(sym)
57
+ end
58
+ assert_equal 675.0, wii.inches(:volume)
59
+ assert_equal 675.0, wii.inches(:box_volume)
60
+
61
+
62
+ assert_equal 'GBP', wii.currency
63
+ assert_equal 26999, wii.value
64
+ end
65
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ResponseTest < Test::Unit::TestCase
4
+ def test_initialize
5
+ assert_nothing_raised do
6
+ RateResponse.new(true, "success!", {:rate => 'Free!'}, :rates => [stub(:service_name => 'Free!', :total_price => 0)], :xml => "<rate>Free!</rate>")
7
+ end
8
+
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_shipping
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - James MacAulay
8
+ - Tobias Luetke
9
+ - Cody Fauser
10
+ - Jimmy Baker
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2009-10-26 00:00:00 -04:00
16
+ default_executable:
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: activesupport
20
+ type: :runtime
21
+ version_requirement:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: "0"
27
+ version:
28
+ description: Shipping API extension for Active Merchant.
29
+ email: jmacaulay@gmail.com
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - README.markdown
36
+ files:
37
+ - .gitignore
38
+ - CHANGELOG
39
+ - MIT-LICENSE
40
+ - README.markdown
41
+ - Rakefile
42
+ - VERSION
43
+ - init.rb
44
+ - lib/active_shipping.rb
45
+ - lib/active_shipping/lib/connection.rb
46
+ - lib/active_shipping/lib/country.rb
47
+ - lib/active_shipping/lib/error.rb
48
+ - lib/active_shipping/lib/post_data.rb
49
+ - lib/active_shipping/lib/posts_data.rb
50
+ - lib/active_shipping/lib/requires_parameters.rb
51
+ - lib/active_shipping/lib/utils.rb
52
+ - lib/active_shipping/lib/validateable.rb
53
+ - lib/active_shipping/shipping/base.rb
54
+ - lib/active_shipping/shipping/carrier.rb
55
+ - lib/active_shipping/shipping/carriers.rb
56
+ - lib/active_shipping/shipping/carriers/bogus_carrier.rb
57
+ - lib/active_shipping/shipping/carriers/fedex.rb
58
+ - lib/active_shipping/shipping/carriers/shipwire.rb
59
+ - lib/active_shipping/shipping/carriers/ups.rb
60
+ - lib/active_shipping/shipping/carriers/usps.rb
61
+ - lib/active_shipping/shipping/location.rb
62
+ - lib/active_shipping/shipping/package.rb
63
+ - lib/active_shipping/shipping/rate_estimate.rb
64
+ - lib/active_shipping/shipping/rate_response.rb
65
+ - lib/active_shipping/shipping/response.rb
66
+ - lib/active_shipping/shipping/shipment_event.rb
67
+ - lib/active_shipping/shipping/tracking_response.rb
68
+ - lib/certs/cacert.pem
69
+ - lib/vendor/quantified/MIT-LICENSE
70
+ - lib/vendor/quantified/README.markdown
71
+ - lib/vendor/quantified/Rakefile
72
+ - lib/vendor/quantified/init.rb
73
+ - lib/vendor/quantified/lib/quantified.rb
74
+ - lib/vendor/quantified/lib/quantified/attribute.rb
75
+ - lib/vendor/quantified/lib/quantified/length.rb
76
+ - lib/vendor/quantified/lib/quantified/mass.rb
77
+ - lib/vendor/quantified/test/length_test.rb
78
+ - lib/vendor/quantified/test/mass_test.rb
79
+ - lib/vendor/quantified/test/test_helper.rb
80
+ - lib/vendor/test_helper.rb
81
+ - lib/vendor/xml_node/README
82
+ - lib/vendor/xml_node/Rakefile
83
+ - lib/vendor/xml_node/benchmark/bench_generation.rb
84
+ - lib/vendor/xml_node/init.rb
85
+ - lib/vendor/xml_node/lib/xml_node.rb
86
+ - lib/vendor/xml_node/test/test_generating.rb
87
+ - lib/vendor/xml_node/test/test_parsing.rb
88
+ - test/fixtures.yml
89
+ - test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_request.xml
90
+ - test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_response.xml
91
+ - test/fixtures/xml/fedex/tracking_request.xml
92
+ - test/fixtures/xml/fedex/tracking_response.xml
93
+ - test/fixtures/xml/shipwire/international_rates_response.xml
94
+ - test/fixtures/xml/shipwire/invalid_credentials_response.xml
95
+ - test/fixtures/xml/shipwire/new_carrier_rate_response.xml
96
+ - test/fixtures/xml/shipwire/no_rates_response.xml
97
+ - test/fixtures/xml/shipwire/rates_response.xml
98
+ - test/fixtures/xml/ups/example_tracking_response.xml
99
+ - test/fixtures/xml/ups/shipment_from_tiger_direct.xml
100
+ - test/fixtures/xml/ups/test_real_home_as_residential_destination_response.xml
101
+ - test/fixtures/xml/usps/beverly_hills_to_ottawa_book_rate_response.xml
102
+ - test/fixtures/xml/usps/beverly_hills_to_ottawa_book_wii_rate_response.xml
103
+ - test/fixtures/xml/usps/beverly_hills_to_ottawa_wii_rate_response.xml
104
+ - test/remote/fedex_test.rb
105
+ - test/remote/shipwire_test.rb
106
+ - test/remote/ups_test.rb
107
+ - test/remote/usps_test.rb
108
+ - test/test_helper.rb
109
+ - test/unit/base_test.rb
110
+ - test/unit/carriers/fedex_test.rb
111
+ - test/unit/carriers/shipwire_test.rb
112
+ - test/unit/carriers/ups_test.rb
113
+ - test/unit/carriers/usps_test.rb
114
+ - test/unit/location_test.rb
115
+ - test/unit/package_test.rb
116
+ - test/unit/response_test.rb
117
+ has_rdoc: true
118
+ homepage: http://github.com/Shopify/active_shipping
119
+ licenses: []
120
+
121
+ post_install_message:
122
+ rdoc_options:
123
+ - --charset=UTF-8
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: "0"
131
+ version:
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: "0"
137
+ version:
138
+ requirements: []
139
+
140
+ rubyforge_project:
141
+ rubygems_version: 1.3.5
142
+ signing_key:
143
+ specification_version: 3
144
+ summary: Shipping API extension for Active Merchant.
145
+ test_files:
146
+ - test/remote/fedex_test.rb
147
+ - test/remote/shipwire_test.rb
148
+ - test/remote/ups_test.rb
149
+ - test/remote/usps_test.rb
150
+ - test/test_helper.rb
151
+ - test/unit/base_test.rb
152
+ - test/unit/carriers/fedex_test.rb
153
+ - test/unit/carriers/shipwire_test.rb
154
+ - test/unit/carriers/ups_test.rb
155
+ - test/unit/carriers/usps_test.rb
156
+ - test/unit/location_test.rb
157
+ - test/unit/package_test.rb
158
+ - test/unit/response_test.rb