postmon_cli 0.0.2 → 0.0.3

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: ee7422a4ae88f2349ff955f8bd92a3d6ed005902
4
- data.tar.gz: 5358885130b773dbf9dfd4e26ceb93121ecb9f28
3
+ metadata.gz: ffa19e98dfdd1ce99f813028b6d50f7d6b3969bb
4
+ data.tar.gz: 429e3d8e18fd12a0e72069ab75b24e8330e9654f
5
5
  SHA512:
6
- metadata.gz: e660206a65d6ae586d509b682bcba42da011b373fe9d324e67c611144fb879d0eb06f958872ea2f9815c78e6a8c656f69a8436cfd7dc13d9e56a17f021623434
7
- data.tar.gz: 1741b2d3b0c75ffb6fcc063fd2de02c1be29f1c1e76e56d043ab5ac20a57e7d3b24804c20e098df9fb965452d2fdcbd382ed418f856ed63c64a9bc2e89e47960
6
+ metadata.gz: ce8ca860fa2d279eecc5c93a2bd4a7ebafcbde9ea289cd54f7161674ae18132d7c16c2b7bbed96a7b65cc55b49dedea52142d6e44870dd4986d52a07665057f1
7
+ data.tar.gz: d76909e0805e51cb724c8efd6de5ed3103d73a251634adca0e5b507ee6e1e30d8fead9ce8acf20f6071a53b2951950fa513e8e8375312fd344878553293a4e93
data/README.md CHANGED
@@ -67,4 +67,4 @@ pelos correios, tudo pelo bash :)
67
67
  ## Contribua
68
68
 
69
69
  O PostmonCli utiliza o PostmonAPI para Ruby, a gem PostmonRuby(https://github.com/PostmonAPI/postmon-ruby).
70
- Todo tipo de contribuição é sempre bem-vinda(a). :wink:
70
+ Todo tipo de contribuição é sempre bem-vinda. :wink:
data/bin/postmon CHANGED
@@ -23,13 +23,13 @@ HELP
23
23
  unless ARGV.empty?
24
24
  case ARGV.first
25
25
  when "cep"
26
- PostmonCli::Wrapper.get_cep(ARGV.last)
26
+ PostmonCli::Wrapper.cep(ARGV.last)
27
27
  when "cidade"
28
- PostmonCli::Wrapper.get_cidade(ARGV[1], ARGV[2])
28
+ PostmonCli::Wrapper.cidade(ARGV[1], ARGV[2])
29
29
  when "estado"
30
- PostmonCli::Wrapper.get_estado(ARGV.last)
30
+ PostmonCli::Wrapper.estado(ARGV.last)
31
31
  when "rastreio"
32
- PostmonCli::Wrapper.get_rastreio(ARGV.last)
32
+ PostmonCli::Wrapper.rastreio(ARGV.last)
33
33
  else
34
34
  puts "Opção inválida"
35
35
  end
data/lib/postmon_cli.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "postmon_cli/version"
2
2
  require "postmon_cli/wrapper"
3
+ require "postmon_cli/output"
3
4
 
4
5
  module PostmonCli
5
6
  end
@@ -0,0 +1,29 @@
1
+ module PostmonCli
2
+ class Output
3
+ private
4
+ def self.resultado(resultado)
5
+ if resultado.not_found
6
+ puts "Nenhum resultado encontrado."
7
+ else
8
+ info = {}
9
+
10
+ resultado.instance_variables.each do |var|
11
+ info[var.to_s.delete("@").capitalize] = resultado.instance_variable_get(var)
12
+ end
13
+
14
+ print_array_output(info)
15
+ end
16
+ end
17
+
18
+ def self.print_array_output(array, level = 0)
19
+ array.each do |k, v|
20
+ print "\t" if level > 0
21
+ if( (!v.kind_of?(String) && v.kind_of?(Enumerable) ) || ( !k.kind_of?(String) && k.kind_of?(Enumerable) ))
22
+ print_array_output(v||k, 1)
23
+ else
24
+ puts "#{k}: #{v}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module PostmonCli
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,20 +2,24 @@ require 'postmon_ruby'
2
2
 
3
3
  module PostmonCli
4
4
  class Wrapper
5
- def self.get_cep(cep)
6
- PostmonRuby::GemOutput.cep(cep)
5
+ def self.cep(cep)
6
+ resultado = PostmonRuby::Client.search :cep, cep
7
+ Output.resultado(resultado)
7
8
  end
8
9
 
9
- def self.get_cidade(uf, cidade)
10
- PostmonRuby::GemOutput.cidade(uf, cidade)
10
+ def self.cidade(uf, cidade)
11
+ resultado = PostmonRuby::Client.search :cidade, uf, cidade
12
+ Output.resultado(resultado)
11
13
  end
12
14
 
13
- def self.get_estado(uf)
14
- PostmonRuby::GemOutput.estado(uf)
15
+ def self.estado(uf)
16
+ resultado = PostmonRuby::Client.search :estado, uf
17
+ Output.resultado(resultado)
15
18
  end
16
19
 
17
- def self.get_rastreio(codigo)
18
- PostmonRuby::GemOutput.rastreio(codigo)
20
+ def self.rastreio(rastreio)
21
+ resultado = PostmonRuby::Client.search :rastreio, :ect, rastreio
22
+ Output.resultado(resultado)
19
23
  end
20
24
  end
21
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmon_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Breno Moura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-09 00:00:00.000000000 Z
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: postmon_ruby
@@ -63,6 +63,7 @@ files:
63
63
  - README.md
64
64
  - bin/postmon
65
65
  - lib/postmon_cli.rb
66
+ - lib/postmon_cli/output.rb
66
67
  - lib/postmon_cli/version.rb
67
68
  - lib/postmon_cli/wrapper.rb
68
69
  - test/lib/wrapper_test.rb