muamba 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 653a4b49af61de3c2a58f01e42139c63f2601f99
4
+ data.tar.gz: 922dae55e1679639fc1092807679b56ca9e9aee2
5
+ SHA512:
6
+ metadata.gz: 804c7a23baaa18e2695169599c23e456e200092c2c14be4ebb5a144a222f8e45bd3fad5b1753e96da1839305a060a73a3a980f5128e988240892804537cb5d2f
7
+ data.tar.gz: 3fae39c1385511ac17ac89afea475aa8b70484d4d96c4d69455e761f74d552ff418f95b32643075af37473e6b4f03a9d898ef80e07899b118efcd56f8ab99161
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in muamba.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Bruno Buccolo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Muamba
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'muamba'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install muamba
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/muamba/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/muamba ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/ruby
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ Bundler.require(:default)
5
+
6
+ Muamba::CLI.start(ARGV)
data/lib/muamba/cli.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'thor'
2
+
3
+ module Muamba
4
+ class CLI < ::Thor
5
+ desc "track tag TRACKING", "tracks stuff"
6
+ option :d
7
+ def track(tag, tracking)
8
+ if options[:d]
9
+ puts "Removendo #{tag}"
10
+ Persistence.new.untrack(tag)
11
+ else
12
+ puts "Rastreando #{tag} #{tracking}"
13
+ Persistence.new.track(tag, tracking)
14
+ end
15
+ end
16
+
17
+ desc "listar", "mostra as muambas cadastradas"
18
+ def listar
19
+ Persistence.new.list
20
+ end
21
+
22
+ desc "cade", "mostra aonde estão suas muambas"
23
+ def cade
24
+ Persistence.new.wtf
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,54 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'terminal-table'
4
+
5
+ module Muamba
6
+ class Persistence
7
+ URL = "http://websro.correios.com.br/sro_bin/txect01$.QueryList?P_LINGUA=001&P_TIPO=001&P_COD_UNI="
8
+
9
+ def track(tag, tracking)
10
+ muambas { |m| m.merge! tag => tracking }
11
+ end
12
+
13
+ def untrack(tag)
14
+ muambas { |m| m.reject! {|k,v| k == tag } }
15
+ end
16
+
17
+ def list
18
+ muambas { |m| puts m }
19
+ end
20
+
21
+ def wtf
22
+ muambas do |muamba|
23
+ muamba.each do |tag, tracking|
24
+ puts "\n\n::::::::::::::::::::::: #{tag} (#{tracking}) :::::::::::::::::::::::"
25
+ html = Nokogiri::HTML open(URL + tracking)
26
+ rows = []
27
+ html.css("tr").each do |tr|
28
+ rows << tr.css("td").map(&:text)
29
+ end
30
+ header = rows.shift
31
+ rows.unshift :separator
32
+ rows.unshift header
33
+ puts Terminal::Table.new :rows => rows
34
+ end
35
+ end
36
+ end
37
+
38
+ def muambas
39
+ begin
40
+ File.open(File.expand_path("~/.muambas"), "r+") do |file|
41
+ @muambas = Marshal.load(file.read) rescue {}
42
+ yield @muambas
43
+ file.truncate(0)
44
+ file.rewind
45
+ file.write Marshal.dump(@muambas)
46
+ end
47
+
48
+ rescue Errno::ENOENT
49
+ File.open(File.expand_path("~/.muambas"), "w+") { |f| f.write "" }
50
+ retry
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,3 @@
1
+ module Muamba
2
+ VERSION = "0.0.2"
3
+ end
data/lib/muamba.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "muamba/version"
2
+ require "muamba/persistence"
3
+ require "muamba/cli"
4
+
5
+ module Muamba
6
+ end
data/muamba.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'muamba/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "muamba"
8
+ spec.version = Muamba::VERSION
9
+ spec.authors = ["Bruno Buccolo"]
10
+ spec.email = ["bruno.buccolo@gmail.com"]
11
+ spec.summary = %q{ Tracks the whereabouts of your Muambas. }
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'thor', '~> 0.19'
22
+ spec.add_dependency 'nokogiri', '~> 1.6'
23
+ spec.add_dependency 'terminal-table', '~> 1.4'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.5"
26
+ spec.add_development_dependency "rake"
27
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: muamba
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Bruno Buccolo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: terminal-table
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: ''
84
+ email:
85
+ - bruno.buccolo@gmail.com
86
+ executables:
87
+ - muamba
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/muamba
97
+ - lib/muamba.rb
98
+ - lib/muamba/cli.rb
99
+ - lib/muamba/persistence.rb
100
+ - lib/muamba/version.rb
101
+ - muamba.gemspec
102
+ homepage: ''
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.0.3
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Tracks the whereabouts of your Muambas.
126
+ test_files: []