russianpost 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/russianpost/barcode.rb +1 -0
- data/lib/russianpost/version.rb +1 -1
- data/test/russianpost/barcode_test.rb +15 -13
- data/test/russianpost/parcel_test.rb +44 -42
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82573cc61a9559f67a85f8d49564460d6c99d593
|
4
|
+
data.tar.gz: 0f0463f91a86d28b1666d405305c46841db593ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 782fffaa94b8bbe08c2ee98ffb5ee5d2291e81b349ab567d0f248f4e852b3aa88bef7bd07c68cdca9ceb4b1544cc2ee34ef9a7acbfd67f29747e43b38d9bdc66
|
7
|
+
data.tar.gz: e091b25a0faae0038f7d6bad7bfd8d3f1d41957fc0260023627f74d2c930e9229ab274ed35b4fc766071b1dbcd884eb00ed305b7c90bee2ad8aba9d37b368788
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/artemshitov/russianpost.png?branch=master)](https://travis-ci.org/artemshitov/russianpost) [![Code Climate](https://codeclimate.com/github/artemshitov/russianpost.png)](https://codeclimate.com/github/artemshitov/russianpost)
|
4
4
|
|
5
|
-
|
5
|
+
Ruby wrapper around Russian Post package tracking SOAP API. Works on a per-package basis (contrary to the bulk ticket-based API). Use it at your own risk, since the API may appear unstable and require authorization in future.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -12,7 +12,7 @@ To install gem stand-alone:
|
|
12
12
|
|
13
13
|
To use gem in a Rails app, add the following to your `Gemfile`:
|
14
14
|
|
15
|
-
gem "russianpost", "~> 0.4.
|
15
|
+
gem "russianpost", "~> 0.4.1"
|
16
16
|
|
17
17
|
This gem uses [Savon](http://savonrb.com/), which in turn uses [HTTPI](https://github.com/savonrb/httpi) internally. HTTPI chooses the best HTTP library of those you have installed. For the fastest results, make sure you add [Curb](https://github.com/taf2/curb) to your `Gemfile`:
|
18
18
|
|
data/lib/russianpost/barcode.rb
CHANGED
data/lib/russianpost/version.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
require "russianpost/barcode"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module RussianPost
|
5
|
+
class BarcodeTest < MiniTest::Unit::TestCase
|
6
|
+
def test_implicitly_converts_to_string
|
7
|
+
barcode = Barcode.new("RD025500807SE")
|
8
|
+
assert_equal "bar RD025500807SE", "bar #{barcode}"
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
def test_raises_on_invalid_barcode
|
12
|
+
["123", "RR123456789EE"].each do |barcode|
|
13
|
+
assert_raises InvalidBarcode do
|
14
|
+
Barcode.new(barcode)
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
|
-
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def test_doesnt_raise_on_valid_barcode
|
20
|
+
["RD025500807SE", "12345678901234"].each do |barcode|
|
21
|
+
Barcode.new(barcode)
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
@@ -3,60 +3,62 @@
|
|
3
3
|
require "test_helper"
|
4
4
|
require "russianpost/parcel"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
module RussianPost
|
7
|
+
class ParcelTest < MiniTest::Unit::TestCase
|
8
|
+
def test_returns_array_of_operations
|
9
|
+
VCR.use_cassette :valid_barcode do
|
10
|
+
parcel = Parcel.new("RD025500807SE")
|
11
|
+
assert_kind_of Array, parcel.operations
|
12
|
+
assert_kind_of Operation, parcel.operations[0]
|
13
|
+
end
|
12
14
|
end
|
13
|
-
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def test_returns_empty_array_on_nonexistent_parcel
|
17
|
+
VCR.use_cassette("nonexistent_parcel") do
|
18
|
+
parcel = Parcel.new("RR123456785EE")
|
19
|
+
assert_kind_of Array, parcel.operations
|
20
|
+
assert parcel.operations.empty?
|
21
|
+
end
|
20
22
|
end
|
21
|
-
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
def test_raises_error_on_invalid_barcode
|
25
|
+
assert_raises InvalidBarcode do
|
26
|
+
Parcel.new("123")
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
28
|
-
end
|
29
30
|
|
30
|
-
class ParcelMetaTest < MiniTest::Unit::TestCase
|
31
|
-
|
31
|
+
class ParcelMetaTest < MiniTest::Unit::TestCase
|
32
|
+
attr_reader :parcel
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
def setup
|
35
|
+
VCR.use_cassette :valid_barcode do
|
36
|
+
@parcel = Parcel.new("RD025500807SE")
|
37
|
+
parcel.operations
|
38
|
+
end
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
def test_knows_current_location
|
42
|
+
location = Address.new("127576", "Москва 576")
|
43
|
+
assert_equal location, parcel.location
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
def test_knows_parcel_mass
|
47
|
+
assert_equal 281, parcel.mass
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
def test_knows_type
|
51
|
+
type = GenericOperationParameter.new(5, "Мелкий пакет")
|
52
|
+
assert_equal type, parcel.type
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
def test_knows_rank
|
56
|
+
rank = GenericOperationParameter.new(0, "Без разряда")
|
57
|
+
assert_equal rank, parcel.rank
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
def test_knows_recipient
|
61
|
+
assert_equal "ЕЛЕНА", parcel.recipient
|
62
|
+
end
|
61
63
|
end
|
62
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: russianpost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Shitov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|