juliocesar-goingtorain-cli 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +23 -0
- data/Rakefile +10 -0
- data/bin/goingtorain +19 -0
- data/goingtorain-cli.gemspec +36 -0
- metadata +71 -0
data/README.markdown
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#goingtorain.com CLI interface
|
2
|
+
|
3
|
+
A simple CLI interface for (goingtorain.com)[http://goingtorain.com].
|
4
|
+
|
5
|
+
##Usage
|
6
|
+
|
7
|
+
I'll build a gem soon. In the meantime, clone this repo, then run
|
8
|
+
|
9
|
+
./goingtorain
|
10
|
+
|
11
|
+
That will give you the prospects of raining today where you are, as precise as goingtorain.com can determine. You
|
12
|
+
can also specify a location, like for instance
|
13
|
+
|
14
|
+
./goingtorain london
|
15
|
+
|
16
|
+
Or alternatively, you can find out tomorrow's weather by just passing on "tomorrow" as an argument
|
17
|
+
|
18
|
+
./goingtorain tomorrow tokyo
|
19
|
+
|
20
|
+
##Notes
|
21
|
+
|
22
|
+
goingtorain.com apparently only takes input from a cookie. Attempting to just submit the form on the page
|
23
|
+
with a location's name would always yield a forecast for my current detected location. Had to resort to WWW::Mechanize.
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('goingtorain-cli', '0.1') do |g|
|
6
|
+
g.description = 'A command line interface for goingtorain.com'
|
7
|
+
g.url = 'http://github.com/juliocesar/goingtorain-cli'
|
8
|
+
g.author = 'Julio Cesar Ody'
|
9
|
+
g.email = 'julioody@gmail.com'
|
10
|
+
end
|
data/bin/goingtorain
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
%w(rubygems mechanize hpricot).each { |lib| require lib }
|
5
|
+
rescue LoadError
|
6
|
+
STDERR.puts 'Seems you\'re missing either WWW::Mechanize or Hpricot. Run "sudo gem install mechanize" and/or "sudo gem install hpricot"'
|
7
|
+
exit(-1)
|
8
|
+
end
|
9
|
+
|
10
|
+
tomorrow = ARGV.member?('tomorrow') ? ARGV.delete('tomorrow') : ''
|
11
|
+
|
12
|
+
agent = WWW::Mechanize.new
|
13
|
+
page = agent.get "http://goingtorain.com/#{tomorrow}"
|
14
|
+
unless ARGV.empty?
|
15
|
+
cookie = agent.cookies.first
|
16
|
+
cookie.value = [cookie.value.split('%3A').first, '%3A', ARGV.join(' ')].join
|
17
|
+
page = agent.get "http://goingtorain.com/#{tomorrow}"
|
18
|
+
end
|
19
|
+
puts page.search('#forecast').text.gsub(/[\n\t]+/, ' ').sub(/^ /, '').capitalize
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{goingtorain-cli}
|
5
|
+
s.version = "0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Julio Cesar Ody"]
|
9
|
+
s.date = %q{2008-12-01}
|
10
|
+
s.default_executable = %q{goingtorain}
|
11
|
+
s.description = %q{A command line interface for goingtorain.com}
|
12
|
+
s.email = %q{julioody@gmail.com}
|
13
|
+
s.executables = ["goingtorain"]
|
14
|
+
s.extra_rdoc_files = ["bin/goingtorain", "README.markdown"]
|
15
|
+
s.files = ["bin/goingtorain", "Rakefile", "README.markdown", "Manifest", "goingtorain-cli.gemspec"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://github.com/juliocesar/goingtorain-cli}
|
18
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Goingtorain-cli", "--main", "README.markdown"]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubyforge_project = %q{goingtorain-cli}
|
21
|
+
s.rubygems_version = %q{1.3.1}
|
22
|
+
s.summary = %q{A command line interface for goingtorain.com}
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
+
s.specification_version = 2
|
27
|
+
|
28
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
+
s.add_development_dependency(%q<echoe>, [">= 0"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
32
|
+
end
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: juliocesar-goingtorain-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Julio Cesar Ody
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-01 00:00:00 -08:00
|
13
|
+
default_executable: goingtorain
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: echoe
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description: A command line interface for goingtorain.com
|
25
|
+
email: julioody@gmail.com
|
26
|
+
executables:
|
27
|
+
- goingtorain
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- bin/goingtorain
|
32
|
+
- README.markdown
|
33
|
+
files:
|
34
|
+
- bin/goingtorain
|
35
|
+
- Rakefile
|
36
|
+
- README.markdown
|
37
|
+
- Manifest
|
38
|
+
- goingtorain-cli.gemspec
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/juliocesar/goingtorain-cli
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --line-numbers
|
44
|
+
- --inline-source
|
45
|
+
- --title
|
46
|
+
- Goingtorain-cli
|
47
|
+
- --main
|
48
|
+
- README.markdown
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "1.2"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: goingtorain-cli
|
66
|
+
rubygems_version: 1.2.0
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: A command line interface for goingtorain.com
|
70
|
+
test_files: []
|
71
|
+
|