ship 0.0.1 → 0.0.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.
Files changed (3) hide show
  1. data/lib/ship.rb +3 -5
  2. metadata +2 -3
  3. data/lib/test.rb +0 -26
data/lib/ship.rb CHANGED
@@ -5,15 +5,13 @@ module Ship
5
5
  class Ship
6
6
  CORREIOS = 0
7
7
 
8
- def self.providers
8
+ def self.providers(country=nil)
9
9
  @providers = [Correios.new]
10
- end
11
-
12
- def self.providers_by_country(country)
10
+ return @providers if country.nil?
13
11
  self.providers.select do |provider|
14
12
  provider.countries.select {|c| c.code==country}.size>0
15
13
  end
16
- end
14
+ end
17
15
 
18
16
  def self.cost(provider,shipping)
19
17
  provider.cost(shipping)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Eustaquio Rangel
@@ -28,7 +28,6 @@ extra_rdoc_files:
28
28
  - LICENSE
29
29
  files:
30
30
  - lib/country.rb
31
- - lib/test.rb
32
31
  - lib/service.rb
33
32
  - lib/correios.rb
34
33
  - lib/shipping.rb
data/lib/test.rb DELETED
@@ -1,26 +0,0 @@
1
- require "ship.rb"
2
-
3
- correios = Ship::Ship.providers[Ship::Ship::CORREIOS]
4
- services = [correios.services[Ship::Correios::SEDEX_SEM_CONTRATO],
5
- correios.services[Ship::Correios::PAC_SEM_CONTRATO]]
6
-
7
- puts "Calculating using #{correios} and #{services.map {|s| s.name}.join(',')}"
8
-
9
- shipping = Ship::Shipping.new
10
- shipping.from = "15085520"
11
- shipping.to = "15130000"
12
- shipping.weight = 1
13
- shipping.width = 25
14
- shipping.height = 5
15
- shipping.length = 25
16
- shipping.format = Ship::Correios.formats[Ship::Correios::CAIXA_PACOTE]
17
- shipping.service = services
18
-
19
- begin
20
- costs = Ship::Ship.cost(correios,shipping)
21
- for service in services
22
- puts "#{service.name}\t= R$ #{costs[service.code.to_s]["Valor"]}"
23
- end
24
- rescue Exception => e
25
- puts "ERROR: #{e}"
26
- end