jp_shipping_rate 0.1.6

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bc0cc4a998d5174db490a914e14daf0ad080b221
4
+ data.tar.gz: 3a289661a37e848294903d1722ff125258260e77
5
+ SHA512:
6
+ metadata.gz: f42c62e32e787332fb9972ded3fa9c26fc7c0e569d7bede2250c9a32f583a820189cb2df0b310366dca2fc34c3dc3af66980c7007afa699738a8178e50a79f9d
7
+ data.tar.gz: 2236e9f9fefc97ded5b7070c9c7a207363f0ca6ae4b6e9ffaa04d5231cc20b3dcdd6dd074b25451a6a6dc61535017e4c5a22666969e19caae977e8591c15be07
@@ -0,0 +1,64 @@
1
+ ---
2
+
3
+ version: "2"
4
+
5
+ plugins:
6
+ duplication:
7
+ enabled: true
8
+
9
+ config:
10
+ languages:
11
+ javascript:
12
+
13
+ ruby:
14
+ mass_threshold: 100
15
+
16
+ fixme:
17
+ enabled: true
18
+
19
+ config:
20
+ strings:
21
+ - FIXME
22
+ - BUG
23
+
24
+ grep:
25
+ enabled: true
26
+
27
+ config:
28
+ patterns:
29
+ no-trailing-whitespace:
30
+ pattern: \s*$
31
+ annotation: "Don't leave trailing whitespace"
32
+ severity: minor
33
+ categories: Style
34
+ path_patterns:
35
+ - "**.arb"
36
+ - "**.coffee"
37
+ - "**.css"
38
+ - "**.erb"
39
+ - "**.es6"
40
+ - "**.feature"
41
+ - "**.gemfile"
42
+ - "**.gemspec"
43
+ - "**.html"
44
+ - "**.js"
45
+ - "**.md"
46
+ - "**.rake"
47
+ - "**.rb"
48
+ - "**.scss"
49
+ - "**.yml"
50
+ - ".*.yml"
51
+
52
+ markdownlint:
53
+ enabled: true
54
+
55
+ rubocop:
56
+ enabled: true
57
+ channel: rubocop-0-51
58
+
59
+ exclude_patterns:
60
+ - "gemfiles/vendor/"
61
+ - ".test-rails-apps/"
62
+ - "spec/rails/"
63
+ - "coverage/"
64
+ - "vendor/"
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at tranduchanh.ms@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in JPShippingCost.gemspec
6
+ gemspec
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jp_shipping_rate (0.1.5)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (10.5.0)
11
+ rspec (3.7.0)
12
+ rspec-core (~> 3.7.0)
13
+ rspec-expectations (~> 3.7.0)
14
+ rspec-mocks (~> 3.7.0)
15
+ rspec-core (3.7.1)
16
+ rspec-support (~> 3.7.0)
17
+ rspec-expectations (3.7.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.7.0)
20
+ rspec-mocks (3.7.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.7.0)
23
+ rspec-support (3.7.1)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.16)
30
+ jp_shipping_rate!
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 1.16.0
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ Copyright (c) 2017 Aromajoin
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
12
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15
+ SOFTWARE.
@@ -0,0 +1,83 @@
1
+ # JPShippingRate
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/jp_shipping_rate.svg)](https://badge.fury.io/rb/jp_shipping_rate)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/24f6e2854063f8364613/maintainability)](https://codeclimate.com/github/aromajoin/jp-shipping-rate/maintainability)
5
+
6
+ A Ruby gem provides look-up and calculations tool for Japan Shipping Rate.
7
+
8
+ At present, it supports international and domestic shipping methods:
9
+
10
+ * With international shipping method is EMS fee = rate + extra charges.
11
+ * With domestic (inside Japan) is Yu-Pack fee = domestic rate + extra charges. Only support calculating fee for Kyoto deposite now.
12
+
13
+ ## Installation
14
+
15
+ If you are in Rails, add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'jp_shipping_rate'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $gem install jp_shipping_rate
28
+
29
+ ## Usage
30
+
31
+ ### Instance
32
+
33
+ ```Ruby
34
+ shipping_rate = JPShippingRate.instance
35
+ ```
36
+
37
+ ### Calculate EMS fee with extra charges (base charges + insurrance cost)
38
+
39
+ ```Ruby
40
+ shipping_rate.international(1500, "US")
41
+ => 8500 # equivalent to 8500 yen
42
+ ```
43
+
44
+ ### Or calculate domestic Yu-pack fee with with extra charges (base charges + insurrance cost)
45
+
46
+ *Note: Just support domestic from Kyoto for now.*
47
+
48
+ ```Ruby
49
+ shipping_rate.domestic(140, "okinawa")
50
+ # => 3200 (yen)
51
+ ```
52
+
53
+ ### Only look-up shipping rate
54
+
55
+ for EMS rate
56
+
57
+ ```Ruby
58
+ # weight = 3500 (g)
59
+ # region = "asia"
60
+ shipping_rate.international_rate(weight, region)
61
+ ```
62
+
63
+ for JP domestic rate (Yu-pack)
64
+
65
+ ```Ruby
66
+ # size = 120 is total of length, width, height of parcel
67
+ # destination_area = "okinawa" area is based on Japan post service definition.
68
+ shipping_rate.domestic_rate(size, destination_area)
69
+ ```
70
+
71
+ We also provides utility methods, please look at source codes.
72
+
73
+ ## Contributing
74
+
75
+ Bug reports and pull requests are welcome on GitHub at https://github.com/aromajoin/jp-shipping-rate. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
76
+
77
+ ## Code of Conduct
78
+
79
+ Everyone interacting in the JPShippingRate project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/aromajoin/jp-shipping-rate/blob/master/CODE_OF_CONDUCT.md).
80
+
81
+ ## LICENSE
82
+
83
+ JPShippingRate is released under the [Apache License](/LICENSE).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "JPShippingCost"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,131 @@
1
+ asia:
2
+ - IN: "India"
3
+ - ID: "Indonesia"
4
+ - KR: "Korea"
5
+ - KH: "Cambodia"
6
+ - GU: "Guam"
7
+ - MP: "Saipan"
8
+ - SG: "Singapore"
9
+ - LK: "Sri Lanka"
10
+ - TH: "Thailand"
11
+ - TW: "Taiwan"
12
+ - CN: "China"
13
+ - NP: "Nepal"
14
+ - PK: "Pakistan"
15
+ - BD: "Bangladesh"
16
+ - PH: "Philippines"
17
+ - BT: "Bhutan"
18
+ - BN: "Brunei"
19
+ - VN: "Vietnam"
20
+ - HK: "Hong Kong"
21
+ - MO: "Macao"
22
+ - MY: "Malaysia"
23
+ - MM: "Myanmar"
24
+ - MV: "Maldives"
25
+ - MN: "Mongolia"
26
+ - LA: "Laos"
27
+ oceania:
28
+ - AU: "Australia"
29
+ - SB: "Solomon"
30
+ - NC: "New Caledonia"
31
+ - NZ: "New Zealand"
32
+ - PG: "Papua New Guinea"
33
+ - FJ: "Fiji"
34
+ nc_america:
35
+ - US: "United States"
36
+ - SV: "El Salvador"
37
+ - CA: "Canada"
38
+ - CU: "Cuba"
39
+ - CR: "Costa Rica"
40
+ - JM: "Jamaica"
41
+ - TT: "Trinidad and Tobago"
42
+ - PA: "Panama"
43
+ - BB: "Barbados"
44
+ - HN: "Honduras"
45
+ - MX: "Mexico"
46
+ middle_east:
47
+ - AE: "United Arab Emirates"
48
+ - IL: "Israel"
49
+ - IQ: "Iraq"
50
+ - IR: "Iran"
51
+ - OM: "Oman"
52
+ - QA: "Qatar"
53
+ - CY: "Cyprus"
54
+ - KW: "Kuwait"
55
+ - SA: "Saudi Arabia"
56
+ - SY: "Syria"
57
+ - TR: "Turkey"
58
+ - BH: "Bahrain"
59
+ - JO: "Jordan"
60
+ europe:
61
+ - IS: "Iceland"
62
+ - IE: "Ireland"
63
+ - AZ: "Azerbaijan"
64
+ - IT: "Italy"
65
+ - UA: "Ukraine"
66
+ - GB: "United Kingdom"
67
+ - EE: "Estonia"
68
+ - AT: "Austria"
69
+ - NL: "Netherlands"
70
+ - GR: "Greece"
71
+ - HR: "Croatia"
72
+ - CH: "Switzerland"
73
+ - SE: "Sweden"
74
+ - ES: "Spain"
75
+ - SK: "Slovakia"
76
+ - SI: "Slovenia"
77
+ - CZ: "Czech Republic"
78
+ - DK: "Denmark"
79
+ - DE: "Germany"
80
+ - NO: "Norway"
81
+ - HU: "Hungary"
82
+ - FI: "Finland"
83
+ - FR: "France"
84
+ - BG: "Bulgaria"
85
+ - BY: "Belarus"
86
+ - BE: "Belgium"
87
+ - PL: "Poland"
88
+ - PT: "Portugal"
89
+ - MK: "Macedonia"
90
+ - MT: "Malta"
91
+ - MC: "Monaco"
92
+ - LV: "Latvia"
93
+ - LT: "Lithuania"
94
+ - LI: "Liechtenstein"
95
+ - LU: "Luxembourg"
96
+ - RO: "Romania"
97
+ - RU: "Russian Federation"
98
+ south_america:
99
+ - AR: "Argentina"
100
+ - UY: "Uruguay"
101
+ - EC: "Ecuador"
102
+ - CO: "Colombia"
103
+ - CL: "Chile"
104
+ - PY: "Paraguay"
105
+ - BR: "Brazil"
106
+ - VE: "Venezuela"
107
+ - PE: "Peru"
108
+ africa:
109
+ - DZ: "Algeria"
110
+ - UG: "Uganda"
111
+ - EG: "Egypt"
112
+ - ET: "Ethiopia"
113
+ - GH: "Ghana"
114
+ - GA: "Gabon"
115
+ - KE: "Kenya"
116
+ - CI: "Cote d'Ivoire"
117
+ - SL: "Sierra Leone"
118
+ - DJ: "Djibouti"
119
+ - ZW: "Zimbabwe"
120
+ - SD: "Sudan"
121
+ - SN: "Senegal"
122
+ - TZ: "Tanzania"
123
+ - TN: "Tunisia"
124
+ - TG: "Togo"
125
+ - NG: "Nigeria"
126
+ - BW: "Botswana"
127
+ - MG: "Madagascar"
128
+ - ZA: "Republic of South Africa"
129
+ - MU: "Mauritius"
130
+ - MA: "Morocco"
131
+ - RW: "Rwanda"
@@ -0,0 +1,64 @@
1
+ kyoto:
2
+ - Kyōto: "Kyōto"
3
+ - kyoto: "Kyoto"
4
+ hokkaido:
5
+ - hokkaido: "Hokkaido"
6
+ tohoku:
7
+ - aomori: "Aomori"
8
+ - iwate: "Iwate"
9
+ - miyagi: "Miyagi"
10
+ - akita: "Akita"
11
+ - yamagata: "Yamagata"
12
+ - fukushima_ken: "Fukushima-ken"
13
+ kanto:
14
+ - ibaraki: "Ibaraki"
15
+ - tochigi: "Tochigi"
16
+ - gunma: "Gunma"
17
+ - saitama: "Saitama"
18
+ - chiba: "Chiba"
19
+ - kanagawa: "Kanagawa"
20
+ - yamanashi: "Yamanashi"
21
+ - tokyo: "Tokyo"
22
+ - Tōkyō: "Tōkyō"
23
+ shin_etsu:
24
+ - niigata: "Niigata"
25
+ - nagano: "Nagano"
26
+ hokuriku:
27
+ - toyama: "Toyama"
28
+ - ishikawa: "Ishikawa"
29
+ - fukui: "Fukui"
30
+ tokai:
31
+ - shizuoka: "Shizuoka"
32
+ - aichi: "Aichi"
33
+ - gifu: "Gifu"
34
+ - mie: "Mie"
35
+ kinki:
36
+ - nara: "Nara"
37
+ - shiga: "Shiga"
38
+ - Ōsaka: "Ōsaka"
39
+ - osaka: "Osaka"
40
+ - Hyōgo: "Hyōgo"
41
+ - hyogo: "Hyogo"
42
+ - wakayama: "Wakayama"
43
+ chugoku:
44
+ - okayama: "Okayama"
45
+ - hiroshima: "Hiroshima"
46
+ - tottori: "Tottori"
47
+ - shimane: "Shimane"
48
+ - yamaguchi: "Yamaguchi"
49
+ shikoku:
50
+ - tokushima: "Tokushima"
51
+ - kagawa: "Kagawa"
52
+ - ehime: "Ehime"
53
+ - Kōchi: "Kōchi"
54
+ kyushu:
55
+ - fukuoka: "Fukuoka"
56
+ - oita: "Oita"
57
+ - Ōita: "Ōita"
58
+ - miyazaki: "Miyazaki"
59
+ - kagoshima: "Kagoshima"
60
+ - kumamoto: "Kumamoto"
61
+ - saga: "Saga"
62
+ - nagasaki: "Nagasaki"
63
+ okinawa:
64
+ - okinawa: "Okinawa"
@@ -0,0 +1,284 @@
1
+ domestic_parcel:
2
+ 100:
3
+ - kyoto: 1130
4
+ - hokkaido: 1730
5
+ - tohoku: 1400
6
+ - kanto: 1280
7
+ - shin_etsu: 1280
8
+ - hokuriku: 1180
9
+ - tokai: 1180
10
+ - kinki: 1180
11
+ - chugoku: 1180
12
+ - shikoku: 1180
13
+ - kyushu: 1280
14
+ - okinawa: 1730
15
+ 120:
16
+ - kyoto: 1340
17
+ - hokkaido: 1940
18
+ - tohoku: 1610
19
+ - kanto: 1500
20
+ - shin_etsu: 1500
21
+ - hokuriku: 1400
22
+ - tokai: 1400
23
+ - kinki: 1400
24
+ - chugoku: 1400
25
+ - shikoku: 1400
26
+ - kyushu: 1500
27
+ - okinawa: 1900
28
+ 140:
29
+ - kyoto: 1560
30
+ - hokkaido: 2160
31
+ - tohoku: 1830
32
+ - kanto: 1720
33
+ - shin_etsu: 1720
34
+ - hokuriku: 1610
35
+ - tokai: 1610
36
+ - kinki: 1610
37
+ - chugoku: 1610
38
+ - shikoku: 1610
39
+ - kyushu: 1720
40
+ - okinawa: 2160
41
+ 160:
42
+ - kyoto: 1780
43
+ - hokkaido: 2370
44
+ - tohoku: 2040
45
+ - kanto: 1930
46
+ - shin_etsu: 1930
47
+ - hokuriku: 1830
48
+ - tokai: 1830
49
+ - kinki: 1830
50
+ - chugoku: 1830
51
+ - shikoku: 1830
52
+ - kyushu: 1930
53
+ - okinawa: 2370
54
+ 170:
55
+ - kyoto: 2070
56
+ - hokkaido: 2710
57
+ - tohoku: 2360
58
+ - kanto: 2250
59
+ - shin_etsu: 2250
60
+ - hokuriku: 2140
61
+ - tokai: 2140
62
+ - kinki: 2140
63
+ - chugoku: 2140
64
+ - shikoku: 2140
65
+ - kyushu: 2250
66
+ - okinawa: 2710
67
+
68
+ international_ems:
69
+ 500:
70
+ - asia: 1400
71
+ - oceania: 2000
72
+ - nc_america: 2000
73
+ - middle_east: 2000
74
+ - europe: 2200
75
+ - south_america: 2400
76
+ - africa: 2400
77
+ 600:
78
+ - asia: 1540
79
+ - oceania: 2180
80
+ - nc_america: 2180
81
+ - middle_east: 2180
82
+ - europe: 2400
83
+ - south_america: 2740
84
+ - africa: 2740
85
+ 700:
86
+ - asia: 1680
87
+ - oceania: 2360
88
+ - nc_america: 2360
89
+ - middle_east: 2360
90
+ - europe: 2600
91
+ - south_america: 3080
92
+ - africa: 3080
93
+ 800:
94
+ - asia: 1820
95
+ - oceania: 2540
96
+ - nc_america: 2540
97
+ - middle_east: 2540
98
+ - europe: 2800
99
+ - south_america: 3420
100
+ - africa: 3420
101
+ 900:
102
+ - asia: 1960
103
+ - oceania: 2720
104
+ - nc_america: 2720
105
+ - middle_east: 2720
106
+ - europe: 3000
107
+ - south_america: 3760
108
+ - africa: 3760
109
+ 1000:
110
+ - asia: 2100
111
+ - oceania: 2900
112
+ - nc_america: 2900
113
+ - middle_east: 2900
114
+ - europe: 3200
115
+ - south_america: 4100
116
+ - africa: 4100
117
+ 1250:
118
+ - asia: 2400
119
+ - oceania: 3300
120
+ - nc_america: 3300
121
+ - middle_east: 3300
122
+ - europe: 3650
123
+ - south_america: 4900
124
+ - africa: 4900
125
+ 1500:
126
+ - asia: 2700
127
+ - oceania: 3700
128
+ - nc_america: 3700
129
+ - middle_east: 3700
130
+ - europe: 4100
131
+ - south_america: 5700
132
+ - africa: 5700
133
+ 1750:
134
+ - asia: 3000
135
+ - oceania: 4100
136
+ - nc_america: 4100
137
+ - middle_east: 4100
138
+ - europe: 4550
139
+ - south_america: 6500
140
+ - africa: 6500
141
+ 2000:
142
+ - asia: 3300
143
+ - oceania: 4500
144
+ - nc_america: 4500
145
+ - middle_east: 4500
146
+ - europe: 5000
147
+ - south_america: 7300
148
+ - africa: 7300
149
+ 2500:
150
+ - asia: 3800
151
+ - oceania: 5200
152
+ - nc_america: 5200
153
+ - middle_east: 5200
154
+ - europe: 5800
155
+ - south_america: 8800
156
+ - africa: 8800
157
+ 3000:
158
+ - asia: 4300
159
+ - oceania: 5900
160
+ - nc_america: 5900
161
+ - middle_east: 5900
162
+ - europe: 6600
163
+ - south_america: 10300
164
+ - africa: 10300
165
+ 3500:
166
+ - asia: 4800
167
+ - oceania: 6600
168
+ - nc_america: 6600
169
+ - middle_east: 6600
170
+ - europe: 7400
171
+ - south_america: 11800
172
+ - africa: 11800
173
+ 4000:
174
+ - asia: 5300
175
+ - oceania: 7300
176
+ - nc_america: 7300
177
+ - middle_east: 7300
178
+ - europe: 8200
179
+ - south_america: 13300
180
+ - africa: 13300
181
+ 4500:
182
+ - asia: 5800
183
+ - oceania: 8000
184
+ - nc_america: 8000
185
+ - middle_east: 8000
186
+ - europe: 9000
187
+ - south_america: 14800
188
+ - africa: 14800
189
+ 5000:
190
+ - asia: 6300
191
+ - oceania: 8700
192
+ - nc_america: 8700
193
+ - middle_east: 8700
194
+ - europe: 9800
195
+ - south_america: 16300
196
+ - africa: 16300
197
+ 5500:
198
+ - asia: 6800
199
+ - oceania: 9400
200
+ - nc_america: 9400
201
+ - middle_east: 9400
202
+ - europe: 10600
203
+ - south_america: 17800
204
+ - africa: 17800
205
+ 6000:
206
+ - asia: 7300
207
+ - oceania: 10100
208
+ - nc_america: 10100
209
+ - middle_east: 10100
210
+ - europe: 11400
211
+ - south_america: 19300
212
+ - africa: 19300
213
+ 7000:
214
+ - asia: 8100
215
+ - oceania: 11200
216
+ - nc_america: 11200
217
+ - middle_east: 11200
218
+ - europe: 12700
219
+ - south_america: 21400
220
+ - africa: 21400
221
+ 8000:
222
+ - asia: 8900
223
+ - oceania: 12300
224
+ - nc_america: 12300
225
+ - middle_east: 12300
226
+ - europe: 14000
227
+ - south_america: 23500
228
+ - africa: 23500
229
+ 9000:
230
+ - asia: 9700
231
+ - oceania: 13400
232
+ - nc_america: 13400
233
+ - middle_east: 13400
234
+ - europe: 15300
235
+ - south_america: 25600
236
+ - africa: 25600
237
+ 10000:
238
+ - asia: 10500
239
+ - oceania: 14500
240
+ - nc_america: 14500
241
+ - middle_east: 14500
242
+ - europe: 16600
243
+ - south_america: 27700
244
+ - africa: 27700
245
+ 11000:
246
+ - asia: 11300
247
+ - oceania: 15600
248
+ - nc_america: 15600
249
+ - middle_east: 15600
250
+ - europe: 17900
251
+ - south_america: 29800
252
+ - africa: 29800
253
+ 12000:
254
+ - asia: 12100
255
+ - oceania: 16700
256
+ - nc_america: 16700
257
+ - middle_east: 16700
258
+ - europe: 19200
259
+ - south_america: 31900
260
+ - africa: 31900
261
+ 13000:
262
+ - asia: 12900
263
+ - oceania: 17800
264
+ - nc_america: 17800
265
+ - middle_east: 17800
266
+ - europe: 20500
267
+ - south_america: 34000
268
+ - africa: 34000
269
+ 14000:
270
+ - asia: 12900
271
+ - oceania: 17800
272
+ - nc_america: 17800
273
+ - middle_east: 17800
274
+ - europe: 20500
275
+ - south_america: 34000
276
+ - africa: 34000
277
+ 15000:
278
+ - asia: 13700
279
+ - oceania: 18900
280
+ - nc_america: 18900
281
+ - middle_east: 18900
282
+ - europe: 21800
283
+ - south_america: 36100
284
+ - africa: 36100
@@ -0,0 +1,27 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jp_shipping_rate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'jp_shipping_rate'
8
+ spec.version = JPShippingRate::VERSION
9
+ spec.authors = ['Hanh D. TRAN']
10
+ spec.email = ['tranduchanh@aromajoin.com']
11
+
12
+ spec.summary = %q{A Ruby gem for Japan shipping rate calculation.}
13
+ spec.description = %q{it provides EMS shipping rate calculation for Japan}
14
+ spec.homepage = 'https://github.com/aromajoin/jp-shipping-rate'
15
+ spec.license = 'MIT'
16
+ spec.required_ruby_version = '>= 1.9.0'
17
+
18
+ spec.files = `git ls-files`.split("\n")
19
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = %w[lib config]
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.16'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
+ end
@@ -0,0 +1,149 @@
1
+ # frozen_string_literal: true
2
+
3
+ # external modules
4
+ require 'singleton'
5
+ require 'yaml'
6
+
7
+ require_relative 'jp_shipping_rate/version'
8
+
9
+ #
10
+ # This is a singleton class provides interface API calculate EMS shipping rate
11
+ # from Japan.
12
+ # There are several basic functions such as look-up international shipping rate,
13
+ # domestic shipping rate, look-up region of a country,
14
+ # Japan's area of a prefecture.
15
+ #
16
+ # Usage:
17
+ # shipping_rate = JPShippingRate.instance
18
+ # shipping_rate.international(1500, "US")
19
+ # => 8500
20
+ # or
21
+ #
22
+ # Note: Just support domestic from Kyoto for now.
23
+ # shipping_rate.domestic(140, "okinawa")
24
+ # => 3200
25
+ #
26
+ class JPShippingRate
27
+ include Singleton
28
+
29
+ def initialize
30
+ @rates = load_shipping_rates
31
+ @regions = load_regions
32
+ @jp_areas = load_domestic_areas
33
+ end
34
+
35
+ # For internaltion shipping (EMS):
36
+ # 1. How much weight of the parcel?
37
+ # 2. Identify country region from country code of destination
38
+ # 3. Look up the shipping rate for weight and region
39
+ # 4. plus base extra charges for internaltional shipping and insurrance charge?
40
+ def international(weight, to_country_code)
41
+ region = region_of_country(to_country_code)
42
+ rate = 0
43
+ rate += international_rate(weight, region) if weight > 0
44
+ rate + international_extra_charges
45
+ end
46
+
47
+ # For domestic shipping:
48
+ # 1. default size = 120 for now, parcel size is total of length, width and height
49
+ # 2. state of destination is in lowercase format, e.g. kyoto, tokyo, osaka
50
+ # 3. calculate cost with given size and state
51
+ # 4. plus extra charges for domestic shipping and insurrance charge?
52
+ def domestic(size = 120, to_state)
53
+ area = area_of_prefecture(to_state)
54
+ rate = 0
55
+ rate += domestic_rate(size, area) if size > 0
56
+ rate + domestic_extra_charges
57
+ end
58
+
59
+ # Find region of the country
60
+ # with given country code from the order info.
61
+ def region_of_country(country_code = 'JP')
62
+ result = @regions['asia'].to_s
63
+ @regions.each do |region, countries|
64
+ countries.each do |country|
65
+ return result = region.to_s unless country[country_code].nil?
66
+ end
67
+ end
68
+ rescue NoMethodError
69
+ return 'asia'
70
+ end
71
+
72
+ # Find domestic area of Japan's states
73
+ # Such as: Hokkaido, Kanto, Okinawa, ...
74
+ def area_of_prefecture(state_name = 'kyoto')
75
+ result = 'okinawa'
76
+ @jp_areas.each do |area, states|
77
+ states.each do |state|
78
+ return result = area.to_s unless state[state_name].nil?
79
+ end
80
+ end
81
+ rescue NoMethodError
82
+ return 'hokkaido'
83
+ end
84
+
85
+ # Calculate an extra charge for internation EMS
86
+ # with a base extra charge and insurrance condition?
87
+ def international_extra_charges(base = 3_500, insurrance = false)
88
+ extra = base
89
+ extra += 3_000 if insurrance
90
+ extra
91
+ end
92
+
93
+ # Calculate an extra charge for domestic shipping
94
+ # with a base extra charge and insurrance condition?
95
+ def domestic_extra_charges(base = 850, insurrance = false)
96
+ extra = base
97
+ extra += 1_000 if insurrance
98
+ extra
99
+ end
100
+
101
+ # Calculate EMS rate with given params
102
+ # @param: weight::Integer - Weight of the parcel.
103
+ # @param: region::String - Regions that is defined by Japan Post service
104
+ def international_rate(weight, region)
105
+ rate = 0
106
+ @rates['international_ems'].each do |w, r|
107
+ next if w.to_i < weight
108
+ r.each do |r_rate|
109
+ return rate = r_rate[region] unless r_rate[region].nil?
110
+ end
111
+ end
112
+ rate
113
+ end
114
+
115
+ # Calculate domestic shipping rate with given params
116
+ # @param size::Integer - size of total of length, width and height
117
+ # @param area::String - Areas of Japan (Okinawa, Hokkaido, Kanto,...)
118
+ def domestic_rate(size = 100, area = 'okinawa')
119
+ rate = 0
120
+ @rates['domestic_parcel'].each do |w, r|
121
+ next if w.to_i < size
122
+ r.each do |r_rate|
123
+ return rate = r_rate[area] unless r_rate[area].nil?
124
+ end
125
+ end
126
+ rate
127
+ end
128
+
129
+ private
130
+
131
+ def root_path
132
+ File.expand_path '../..', __FILE__
133
+ end
134
+
135
+ # Load data of EMS shipping rates
136
+ def load_shipping_rates
137
+ YAML.load_file("#{root_path}/config/rates.yml")
138
+ end
139
+
140
+ # Load data of region of countries
141
+ def load_regions
142
+ YAML.load_file("#{root_path}/config/countries.yml")
143
+ end
144
+
145
+ # Load Japan areas
146
+ def load_domestic_areas
147
+ YAML.load_file("#{root_path}/config/japan_areas.yml")
148
+ end
149
+ end
@@ -0,0 +1,3 @@
1
+ class JPShippingRate
2
+ VERSION = '0.1.6'.freeze
3
+ end
@@ -0,0 +1,23 @@
1
+ RSpec.describe JPShippingRate do
2
+ subject { JPShippingRate.instance }
3
+
4
+ it 'has a version number' do
5
+ expect(JPShippingRate::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'Should have 8000(yen) EMS fee of 2000(g) parcel weight to US' do
9
+ expect(subject.international(2000, 'US')).to eq(8_000)
10
+ end
11
+
12
+ it 'Should have 2570(yen) Yu-pack fee of 140(size) parcel to Tokyo' do
13
+ expect(subject.domestic(140, 'tokyo')).to eq(2_570)
14
+ end
15
+
16
+ it 'Should have 4500(yen) EMS basic-fee of 2000(g) parcel weight to US' do
17
+ expect(subject.international_rate(2000, 'nc_america')).to eq(4_500)
18
+ end
19
+
20
+ it 'Should have 1720(yen) Yu-pack basic fee of 140(size) parcel to Tokyo' do
21
+ expect(subject.domestic_rate(140, 'kanto')).to eq(1_720)
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ require 'bundler/setup'
2
+ require 'jp_shipping_rate'
3
+
4
+ RSpec.configure do |config|
5
+ # Enable flags like --only-failures and --next-failure
6
+ config.example_status_persistence_file_path = '.rspec_status'
7
+
8
+ # Disable RSpec exposing methods globally on `Module` and `main`
9
+ config.disable_monkey_patching!
10
+
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jp_shipping_rate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ platform: ruby
6
+ authors:
7
+ - Hanh D. TRAN
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: it provides EMS shipping rate calculation for Japan
56
+ email:
57
+ - tranduchanh@aromajoin.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".codeclimate.yml"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - Gemfile.lock
69
+ - LICENSE
70
+ - README.md
71
+ - Rakefile
72
+ - bin/console
73
+ - bin/setup
74
+ - config/countries.yml
75
+ - config/japan_areas.yml
76
+ - config/rates.yml
77
+ - jp_shipping_rate.gemspec
78
+ - lib/jp_shipping_rate.rb
79
+ - lib/jp_shipping_rate/version.rb
80
+ - spec/jp_shipping_rate_spec.rb
81
+ - spec/spec_helper.rb
82
+ homepage: https://github.com/aromajoin/jp-shipping-rate
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ - config
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 1.9.0
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.6.11
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: A Ruby gem for Japan shipping rate calculation.
107
+ test_files: []