kuroneko 0.1.1 → 0.1.2

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: 5dc99051a8c3eafa28a676b63a511c76148fc073
4
- data.tar.gz: 947635a252b19355bb3113b01115751df483786f
3
+ metadata.gz: a26e2b922612c37ef906c4b1f116659695045bee
4
+ data.tar.gz: 48a9346469bef41bd70748893154c6c329e75ec1
5
5
  SHA512:
6
- metadata.gz: 7ea1a7eca84b763bb31d933d48b0a3ac2a15ea421bb927e84e6bd210334c452e898fa6c0a4361f3e59a33b95459133b72e0692b2a933c07811450cd7ff4c84e8
7
- data.tar.gz: 966e01a52bc1a91fd9b099563e954e2aa574d16139986c6a6accf4ef24b977805061615468bfdee725df44e5b30bdd91e8ff56d0b7add4525972451cc7f40c9e
6
+ metadata.gz: 0932268fd5844e8d943c05f87b5d72b89eec9f9d4365712d27431175abbf1dd589483ad71b8466c21999cbfd20dd1eb7f72bb7f42736a4c6783b29f26302579c
7
+ data.tar.gz: f0512e95ee6d4c23337d915712ea182be43ad9a84c83b6f812a102dce586e08eee9f1e3d982ec427c9b2f75e9b31a4e70a7bfa9ff8e8054d8314b2ead7a37db2
data/README.md CHANGED
@@ -20,32 +20,68 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ ### 最新状態を取得する
24
+
23
25
  ``` ruby
24
26
  require "kuroneko"
25
27
 
26
28
  neko = Kuroneko.new
27
29
 
28
- # English Version
29
- require "kuroneko/en"
30
- neko = Kuroneko::En.new
30
+ status = neko.status("1234-5678-9012")
31
+ #=> #<struct Kuroneko::Status>
32
+
33
+ status.number
34
+ #=> "123456789012"
35
+
36
+ status.status
37
+ #=> "配達完了"
38
+
39
+ status.to_h
40
+ => {
41
+ number: "123456789012",
42
+ status: "配達完了",
43
+ date: "12/31",
44
+ time: "12:59",
45
+ branch: "北東京ベース店",
46
+ branch_code: "030990"
47
+ }
48
+ ```
31
49
 
32
- # 1 つの荷物の状態履歴
33
- history = neko.history("1234-5678-9012")
50
+ - 履歴のうち最新の `Kuroneko::Status` は `#latest?` に `true` を返します。
51
+ - `Kuroneko#statuses` で複数を一度に照会でき、結果は `Array` で返されます。
34
52
 
35
- # 複数の荷物の状態履歴
36
- histories = neko.histories("1234-5678-9012", "1234-5678-9013", ... )
53
+ ### 状態履歴を取得する
37
54
 
38
- # 1 つの荷物の最新状態
39
- status = neko.status("1234-5678-9012")
40
- # OR
41
- status = history.latest
42
- status = history.find(&:latest?)
55
+ ``` ruby
56
+ history = neko.history("1234-5678-9012")
57
+ #=> #<Kuroneko::StatusHistory<Kuroneko::Status>>
58
+ ```
59
+
60
+ - `StatusHistory` は `Array` を継承していて、以下を追加で実装しています。
61
+ - 履歴のうち最新の状態を返す `#latest`
62
+ - 伝票番号を返す `#number`
63
+ - `Kuroneko#histories` で複数を一度に照会でき、結果は `Array` で返されます。
43
64
 
44
- # 複数の荷物の最新状態
45
- statuses = neko.statuses("1234-5678-9012", "1234-5678-9013", ... )
65
+ ### 英語版を利用する
46
66
 
67
+ ``` diff
68
+ - require "kuroneko"
69
+ - neko = Kuroneko.new
70
+ + require "kuroneko/en"
71
+ + neko = Kuroneko::En.new
47
72
  ```
48
73
 
74
+ 英語版を使うと担当店 / 担当店コードは取得できません。
75
+
76
+ ### 伝票番号
77
+
78
+ `#status`, `#statuses`, `#history`, `#histories` に渡す伝票番号は
79
+ そのまま問い合わせに使用するため、クロネコヤマト側が受け付ける形式であれば
80
+ どのようなものでも可能です。
81
+
82
+ `Kuroneko::StatusHistory`, `Kuroneko::Status` から読み取る伝票番号は
83
+ 照会結果から取得し、数字のみからなる __文字列__ で返ります。
84
+
49
85
  ## Contributing
50
86
 
51
87
  1. Fork it
data/lib/kuroneko/en.rb CHANGED
@@ -3,19 +3,18 @@
3
3
  require 'kuroneko'
4
4
 
5
5
  class Kuroneko
6
- module En
6
+ # 英語版フォームでの問い合わせ
7
+ class En < Kuroneko
7
8
  # @return [String] 問い合わせフォームの URL
8
9
  URL = 'http://track.kuronekoyamato.co.jp/english/tracking'.freeze
9
10
 
10
- class << self
11
- # 英語版で初期化する
12
- #
13
- # @return [Kuroneko]
14
- def new(option={})
15
- obj = Kuroneko.new
16
- obj.url = option[:url] || URL.dup
17
- obj
18
- end
11
+ # インスタンスを初期化する
12
+ #
13
+ # @param [Hash] options
14
+ # @see Kuroneko#initialize
15
+ def initialize(options={})
16
+ super
17
+ @url = URL.dup unless options[:url]
19
18
  end
20
19
  end
21
20
  end
@@ -1,4 +1,4 @@
1
1
  class Kuroneko
2
2
  # @return [String] バージョン
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kuroneko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - wktk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-14 00:00:00.000000000 Z
11
+ date: 2013-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize