russianpost 0.4.3 → 0.4.4

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: c5c7faa5c898406ea60051e097b08e86c3903511
4
- data.tar.gz: fbecdcde1434ea1ae21708292bd3555c9132490a
3
+ metadata.gz: 595a6fbe6c70c7bf03e14593ead155e90ff97a43
4
+ data.tar.gz: decf63446a5161e4af60fdea6b45e133eb8d2eda
5
5
  SHA512:
6
- metadata.gz: 868eff4aa1929d16c5ebf7a7f23c5b5675d9640e2acf51a4c62186ca1c443519bc3aae7d067458261519d1d717356958acec792f7a731c6da2d89e19ba0494ed
7
- data.tar.gz: 11eb9bae98a6860910dd9a78c6d4083ca2873723b17c1971017691a72bf0c3b55b2725564eda2ec0746c4ca91feb7b91b0bc1cfb82d5432275b33647c3e52638
6
+ metadata.gz: 0805d8eb588ffb9fdd532a3108fb460450ba34a7d930f0a605935400a5c4d1b36d941748def570b6ac188b8b984bf0bef84327adffa8dbc63ad13bb8a2973136
7
+ data.tar.gz: 10b56196608dcac4ba2718bdbc28bfbbe97e992f3591ea68afb228a68e52fda0ff9479ec3af4fa3e3dfdf48ad922926fc784a74598f686b96394544f17954eed
data/README.md CHANGED
@@ -2,7 +2,9 @@
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
- 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.
5
+ Ruby client for Russian Post package tracking SOAP API. Works on a per-package basis (contrary to the bulk ticket-based API). The client tries to be smart and fills gaps in the information provided by Russian Post using external knowledge.
6
+
7
+ Use it at your own risk, since the API may appear unstable and require authorization in future.
6
8
 
7
9
  ## Installation
8
10
 
@@ -12,7 +14,7 @@ To install gem stand-alone:
12
14
 
13
15
  To use gem in a Rails app, add the following to your `Gemfile`:
14
16
 
15
- gem "russianpost", "~> 0.4.3"
17
+ gem "russianpost", "~> 0.4.4"
16
18
 
17
19
  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
20
 
@@ -0,0 +1,18 @@
1
+ require "iso3166_ru"
2
+ require "russianpost/operation"
3
+
4
+ module RussianPost
5
+ module CountryFactory
6
+ def self.build(country_config, opts = {})
7
+ country_list = opts[:country_list] || Iso3166Ru::CountryList.new
8
+ proxy = country_list.find_by(iso: country_config[:id])
9
+
10
+ RussianPost::Country.new(
11
+ proxy.iso.to_i,
12
+ proxy.alpha2,
13
+ proxy.alpha3,
14
+ proxy.name,
15
+ proxy.english)
16
+ end
17
+ end
18
+ end
@@ -1,9 +1,12 @@
1
+ require "iso3166_ru"
1
2
  require "russianpost/operation"
3
+ require "russianpost/country_factory"
2
4
 
3
5
  module RussianPost
4
6
  module OperationsFactory
5
7
  class << self
6
8
  def build(operations_hash)
9
+ @country_list = Iso3166Ru::CountryList.new
7
10
  operations_hash.map { |o| build_operation(o) }
8
11
  end
9
12
 
@@ -50,12 +53,7 @@ module RussianPost
50
53
 
51
54
  def process_country(key, value)
52
55
  if [:mail_direct, :country_from, :country_oper].include? key
53
- RussianPost::Country.new(
54
- value[:id] ? value[:id].to_i : nil,
55
- value[:code_2a],
56
- value[:code_3a],
57
- value[:name_ru],
58
- value[:name_en])
56
+ RussianPost::CountryFactory.build(value, country_list: @country_list)
59
57
  end
60
58
  end
61
59
 
@@ -1,3 +1,3 @@
1
1
  module Russianpost
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
data/russianpost.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "webmock"
24
24
  spec.add_development_dependency "vcr", "~> 2.4.0"
25
25
  spec.add_dependency "savon", "~> 2.1.0"
26
+ spec.add_dependency "iso3166_ru", "~>0.1.1"
26
27
  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.3
4
+ version: 0.4.4
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-05-02 00:00:00.000000000 Z
11
+ date: 2013-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: iso3166_ru
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 0.1.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 0.1.1
83
97
  description: Thin wrapper around Russian Post package tracking SOAP API. Works on
84
98
  a per-package basis (contrary to the bulk ticket-based API). Use it at your own
85
99
  risk, since the API may appear unstable and require authorization in future.
@@ -99,6 +113,7 @@ files:
99
113
  - lib/russianpost/barcode.rb
100
114
  - lib/russianpost/barcode_validator.rb
101
115
  - lib/russianpost/client.rb
116
+ - lib/russianpost/country_factory.rb
102
117
  - lib/russianpost/operation.rb
103
118
  - lib/russianpost/operations_factory.rb
104
119
  - lib/russianpost/parcel.rb