yuso 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f512205343f8feb86f546224aca11b312255c89
4
- data.tar.gz: 04a990826998e1e5d9bd7d3a818d55a04f1666bc
3
+ metadata.gz: 36bd07e2c2221df620b14c7d2fbfd9efbb505b0f
4
+ data.tar.gz: 1c7fc343ad1c227fa6336a96233dc369fb470e03
5
5
  SHA512:
6
- metadata.gz: 57c1f398ef1fcb82aee6810e20a74413814cbc6e5207323df91a327f9bce861743d2c63f58683e3cc9b4e8f13e0a5b2fd00b205be59d1777d08bb4b8ca0a6a8c
7
- data.tar.gz: c2afbc3314e24eb65543dc7a39cac1a7ab69d36ee4cb593ea780c81a24da79c7c0d49dd364b6177ba4039cfa89b3419846d5c52870a9289d53ede1dcc2eea041
6
+ metadata.gz: b16ea0c402d8c23399f7d1f31df27a17c7178e0e408d554ad2939f998af437911adb443154b845a7a04d578442aa7d33cb0712331b310f95d25ea865850eacbd
7
+ data.tar.gz: bee47766b221d1a2296d03b4a13d6a759a5db266beb75edd34d18ef381d94b4d09058766546e79150c792e95b63229e7a706ad3b97b9bf6e8af513faab8ae4b8
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
- # Yuso
1
+ [![Build Status](https://travis-ci.org/okuramasafumi/yuso.svg?branch=master)](https://travis-ci.org/okuramasafumi/yuso)
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/yuso`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ # Yuso
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Yuso is a gem to get some data from famous Japanese shipping companies such as Yamato.
6
+ Currently it provides prefecture-area mapping and shipping fee data.
6
7
 
7
8
  ## Installation
8
9
 
@@ -22,7 +23,12 @@ Or install it yourself as:
22
23
 
23
24
  ## Usage
24
25
 
25
- TODO: Write usage instructions here
26
+ Yuso supports 3 shipping companies and each have different namespace. There is only one interface: `load` class method. For example:
27
+
28
+ ```ruby
29
+ Yuso::Yamato::Mapping.load # => prefecture-area mapping for Yamato
30
+ Yuso::Sagawa::ShippingFee.load('tokyo') # => shipping fee table for Sagawa and from Tokyo
31
+ ```
26
32
 
27
33
  ## Development
28
34
 
@@ -32,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
38
 
33
39
  ## Contributing
34
40
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/yuso.
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/okuramasafumi/yuso.
36
42
 
37
43
  ## License
38
44
 
@@ -0,0 +1,16 @@
1
+ require "json"
2
+
3
+ module Yuso
4
+ class Sagawa
5
+ class Mapping
6
+ def self.load
7
+ mapping_path = Yuso::DATA_PATH + "/sagawa/mapping.json"
8
+ JSON.load(File.read(mapping_path))
9
+ end
10
+
11
+ def self.areas
12
+ load.values.uniq
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,15 +1,20 @@
1
1
  require "json"
2
+ require_relative "./mapping"
2
3
 
3
4
  module Yuso
4
5
  class Sagawa
5
6
  class ShippingFee
6
7
  def self.load(prefecture_name)
7
- mapping_path = Yuso::DATA_PATH + "/sagawa/mapping.json"
8
- mapping = JSON.load(File.read(mapping_path))
9
8
  area = mapping.fetch(prefecture_name) { raise ArgumentError, 'Prefecture name is not correct.' }
10
9
  json_path = Yuso::DATA_PATH + "/sagawa/#{area}.json"
11
10
  JSON.load(File.read(json_path))
12
11
  end
12
+
13
+ private
14
+
15
+ def self.mapping
16
+ Mapping.load
17
+ end
13
18
  end
14
19
  end
15
20
  end
@@ -1,3 +1,3 @@
1
1
  module Yuso
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,16 @@
1
+ require "json"
2
+
3
+ module Yuso
4
+ class Yamato
5
+ class Mapping
6
+ def self.load
7
+ mapping_path = Yuso::DATA_PATH + "/yamato/mapping.json"
8
+ JSON.load(File.read(mapping_path))
9
+ end
10
+
11
+ def self.areas
12
+ load.values.uniq
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,15 +1,20 @@
1
1
  require "json"
2
+ require_relative "./mapping"
2
3
 
3
4
  module Yuso
4
5
  class Yamato
5
6
  class ShippingFee
6
7
  def self.load(prefecture_name)
7
- mapping_path = Yuso::DATA_PATH + "/yamato/mapping.json"
8
- mapping = JSON.load(File.read(mapping_path))
9
8
  area = mapping.fetch(prefecture_name) { raise ArgumentError, 'Prefecture name is not correct.' }
10
9
  json_path = Yuso::DATA_PATH + "/yamato/#{area}.json"
11
10
  JSON.load(File.read(json_path))
12
11
  end
12
+
13
+ private
14
+
15
+ def self.mapping
16
+ Mapping.load
17
+ end
13
18
  end
14
19
  end
15
20
  end
@@ -0,0 +1,16 @@
1
+ require "json"
2
+
3
+ module Yuso
4
+ class Yubin
5
+ class Mapping
6
+ def self.load
7
+ mapping_path = Yuso::DATA_PATH + "/yubin/mapping.json"
8
+ JSON.load(File.read(mapping_path))
9
+ end
10
+
11
+ def self.areas
12
+ load.values.uniq
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,15 +1,20 @@
1
1
  require "json"
2
+ require_relative "./mapping"
2
3
 
3
4
  module Yuso
4
5
  class Yubin
5
6
  class ShippingFee
6
7
  def self.load(prefecture_name)
7
- mapping_path = Yuso::DATA_PATH + "/yubin/mapping.json"
8
- mapping = JSON.load(File.read(mapping_path))
9
8
  area = mapping.fetch(prefecture_name) { raise ArgumentError, 'Prefecture name is not correct.' }
10
9
  json_path = Yuso::DATA_PATH + "/yubin/#{area}.json"
11
10
  JSON.load(File.read(json_path))
12
11
  end
12
+
13
+ private
14
+
15
+ def self.mapping
16
+ Mapping.load
17
+ end
13
18
  end
14
19
  end
15
20
  end
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.15"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "rspec-collection_matchers", "~> 1.1"
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yuso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Okura Masafumi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-07 00:00:00.000000000 Z
11
+ date: 2017-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-collection_matchers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
55
69
  description: A library containing shipping fee data of three major shipping companies
56
70
  in Japan.
57
71
  email:
@@ -109,9 +123,12 @@ files:
109
123
  - data/yubin/tohoku.json
110
124
  - data/yubin/tokai.json
111
125
  - lib/yuso.rb
126
+ - lib/yuso/sagawa/mapping.rb
112
127
  - lib/yuso/sagawa/shipping_fee.rb
113
128
  - lib/yuso/version.rb
129
+ - lib/yuso/yamato/mapping.rb
114
130
  - lib/yuso/yamato/shipping_fee.rb
131
+ - lib/yuso/yubin/mapping.rb
115
132
  - lib/yuso/yubin/shipping_fee.rb
116
133
  - yuso.gemspec
117
134
  homepage: https://github.com/okuramasafumi/yuso