commuter 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+ gem 'mechanize'
3
+ gem 'commander'
data/MIT-LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ Permissiossion is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2
+
3
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.m is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Commuter
2
+
3
+ This is a silly little command line app written and ruby that tells you the time between two addresses. It screen scrapes this information from Google Maps.
4
+
5
+ I built this for a few reasons:
6
+
7
+ 1. My commute fucking sucks
8
+ 2. I often check on the time the commute will take because I like to know when my commute is going to fucking suck.
9
+ 3. I wanted to play with the mechanize and commander gems. Both are fun, by the way.
10
+
11
+ ## Installation
12
+
13
+ gem install commuter
14
+
15
+ ## Usage
16
+
17
+ commuter --start 'street, city, state, zip' --dest 'street, city, state, zip'
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/commuter ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'rubygems'
6
+ require 'commuter/console'
7
+
8
+ Commuter::Console.run()
data/commuter.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift File.join(File.dirname(__FILE__), 'lib')
3
+
4
+ require "commuter/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "commuter"
8
+ s.version = Commuter::VERSION
9
+ s.authors = ["David Laribee"]
10
+ s.email = ["laribee@gmail.com"]
11
+ s.homepage = "https://github.com/laribee/commuter"
12
+ s.summary = %q{Gives you google maps travel times between two addresses.}
13
+ s.description = %q{Gives you google maps travel times between two addresses.}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib", "bin"]
19
+
20
+ s.default_executable = 'bin/commuter'
21
+ s.add_runtime_dependency "commander"
22
+ s.add_runtime_dependency "mechanize"
23
+ end
@@ -0,0 +1,33 @@
1
+ require 'rubygems'
2
+ require 'commander/import'
3
+ require 'commuter/mapper'
4
+
5
+ module Commuter
6
+ module Console
7
+
8
+ def self.run
9
+ program :name, "commuter"
10
+ program :version, "0.1.0"
11
+ program :description, "Commuter tells you how long your commute will be."
12
+
13
+ default_command :map
14
+
15
+ command :map do |c|
16
+
17
+ c.option '--start ADDRESS', String, 'Specify your starting address.'
18
+ c.option '--dest ADDRESS', String, 'Specify your destination address.'
19
+
20
+ c.action do |args, options|
21
+ say "From: " + options.start
22
+ say "To: " + options.dest
23
+ say "Possible commute times are:"
24
+ times = ::Commuter::Mapper.map(options.start, options.dest)
25
+ say "#{times.join('/n')}"
26
+ end
27
+
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,20 @@
1
+ require 'mechanize'
2
+
3
+ module Commuter
4
+
5
+ module Mapper
6
+
7
+ def self::map(start, dest)
8
+ map_url = "http://maps.google.com/maps?saddr=#{start}&daddr=#{dest}"
9
+ agent = Mechanize.new
10
+ page = agent.get(map_url)
11
+ times = []
12
+ page.search("div.altroute-info span:last-child").each do |span|
13
+ times << span.inner_html
14
+ end
15
+ times
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,3 @@
1
+ module Commuter
2
+ VERSION = "0.0.3"
3
+ end
Binary file
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commuter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Laribee
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: commander
16
+ requirement: &70159843169120 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70159843169120
25
+ - !ruby/object:Gem::Dependency
26
+ name: mechanize
27
+ requirement: &70159843167060 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70159843167060
36
+ description: Gives you google maps travel times between two addresses.
37
+ email:
38
+ - laribee@gmail.com
39
+ executables:
40
+ - commuter
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - Gemfile
45
+ - MIT-LICENSE
46
+ - README.md
47
+ - Rakefile
48
+ - bin/commuter
49
+ - commuter.gemspec
50
+ - lib/commuter/console.rb
51
+ - lib/commuter/mapper.rb
52
+ - lib/commuter/version.rb
53
+ - pkg/commuter-0.0.1.gem
54
+ homepage: https://github.com/laribee/commuter
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ - bin
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 1.8.11
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Gives you google maps travel times between two addresses.
79
+ test_files: []
80
+ has_rdoc: