google_query 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +11 -0
- data/README.txt +78 -0
- data/Rakefile +19 -0
- data/bin/gmoney +8 -0
- data/bin/gpop +8 -0
- data/bin/gtime +8 -0
- data/lib/google_query.rb +32 -0
- data/lib/google_query/currency.rb +8 -0
- data/lib/google_query/population.rb +10 -0
- data/lib/google_query/worldtime.rb +10 -0
- metadata +78 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
GoogleQuery
|
2
|
+
http://germanforblack.com/
|
3
|
+
== DESCRIPTION:
|
4
|
+
|
5
|
+
Uses Google to get currency conversion, world time and human population
|
6
|
+
|
7
|
+
== FEATURES/PROBLEMS:
|
8
|
+
|
9
|
+
* Query Google for:
|
10
|
+
* Time in uganda
|
11
|
+
* Population in frankfurt
|
12
|
+
* How little your money is vs sterling
|
13
|
+
* There are no tests. You want tests? Write your own.
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
|
17
|
+
require 'rubygems'
|
18
|
+
require 'google_query'
|
19
|
+
|
20
|
+
# See how you get spanked by the pound
|
21
|
+
GoogleQuery::Currency.get 'AUD to GBP'
|
22
|
+
=> 1 U.S. dollar = 0.490484599 British pounds
|
23
|
+
|
24
|
+
# Get population in Melbourne
|
25
|
+
GoogleQuery::Population.get 'melbourne'
|
26
|
+
=> Population: 3,850,000 (Est.) (2nd)
|
27
|
+
|
28
|
+
# Get the current time in London
|
29
|
+
GoogleQuery::Time.get 'london'
|
30
|
+
=> 2:26 PM on Monday, July 30
|
31
|
+
|
32
|
+
# On the command line:
|
33
|
+
bens-pb:~ ben$ gpop melbourne
|
34
|
+
|
35
|
+
Population: 3,850,000 (Est.) (2nd)
|
36
|
+
|
37
|
+
bens-pb:~ ben$ gtime london
|
38
|
+
2:26 PM on Monday, July 30
|
39
|
+
|
40
|
+
# Couldn't resist naming it gmoney
|
41
|
+
bens-pb:~ ben$ gmoney AUD GBP
|
42
|
+
1 Australian dollar = 0.424269178 British pounds
|
43
|
+
|
44
|
+
== REQUIREMENTS:
|
45
|
+
|
46
|
+
* Ruby
|
47
|
+
* Open-uri
|
48
|
+
* Hpricot
|
49
|
+
* ERB
|
50
|
+
|
51
|
+
== INSTALL:
|
52
|
+
|
53
|
+
sudo gem install google_query --include-dependencies
|
54
|
+
|
55
|
+
== LICENSE:
|
56
|
+
|
57
|
+
(The MIT License)
|
58
|
+
|
59
|
+
Copyright (c) 2007 Ben Schwarz
|
60
|
+
|
61
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
62
|
+
a copy of this software and associated documentation files (the
|
63
|
+
'Software'), to deal in the Software without restriction, including
|
64
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
65
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
66
|
+
permit persons to whom the Software is furnished to do so, subject to
|
67
|
+
the following conditions:
|
68
|
+
|
69
|
+
The above copyright notice and this permission notice shall be
|
70
|
+
included in all copies or substantial portions of the Software.
|
71
|
+
|
72
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
73
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
74
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
75
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
76
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
77
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
78
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/google_query.rb'
|
6
|
+
|
7
|
+
Hoe.new('google_query', GoogleQuery::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'googlequery'
|
9
|
+
p.author = 'Ben Schwarz'
|
10
|
+
p.email = 'ben.schwarz@gmail.com'
|
11
|
+
p.summary = 'Uses Google to get currency conversion, world time and human population'
|
12
|
+
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
13
|
+
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
14
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
15
|
+
p.extra_deps << ['hpricot', '0.6']
|
16
|
+
p.remote_rdoc_dir = ''
|
17
|
+
end
|
18
|
+
|
19
|
+
# vim: syntax=Ruby
|
data/bin/gmoney
ADDED
data/bin/gpop
ADDED
data/bin/gtime
ADDED
data/lib/google_query.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
%w(rubygems open-uri hpricot erb).each{|r|require r}
|
2
|
+
module GoogleQuery
|
3
|
+
VERSION = "0.0.1"
|
4
|
+
class Query
|
5
|
+
def self.get(string)
|
6
|
+
@query_string = ERB::Util.u string
|
7
|
+
hp = Hpricot resource
|
8
|
+
(hp/@response_path).first.nil? ? nil : (hp/@response_path).inner_text
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
# Get the resource
|
13
|
+
def self.resource
|
14
|
+
r = ''
|
15
|
+
open(self.url) {|response| r = response.read}
|
16
|
+
return r
|
17
|
+
end
|
18
|
+
|
19
|
+
# Make the prepender nice
|
20
|
+
def self.prepender
|
21
|
+
ERB::Util.u @prepender
|
22
|
+
end
|
23
|
+
|
24
|
+
# The base url for all queries
|
25
|
+
def self.url
|
26
|
+
"http://www.google.com/search?q=#{self.prepender}+#{@query_string}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
path = File.dirname(__FILE__) + "/google_query/"
|
32
|
+
%w(currency population worldtime).each{|r| require path + r}
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.3
|
3
|
+
specification_version: 1
|
4
|
+
name: google_query
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2007-07-31 00:00:00 +10:00
|
8
|
+
summary: Uses Google to get currency conversion, world time and human population
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: ben.schwarz@gmail.com
|
12
|
+
homepage: http://germanforblack.com/
|
13
|
+
rubyforge_project: googlequery
|
14
|
+
description: "== SYNOPSIS: require 'rubygems' require 'google_query' # See how you get spanked by the pound GoogleQuery::Currency.get 'AUD to GBP' => 1 U.S. dollar = 0.490484599 British pounds # Get population in Melbourne GoogleQuery::Population.get 'melbourne' => Population: 3,850,000 (Est.) (2nd) # Get the current time in London GoogleQuery::Time.get 'london' => 2:26 PM on Monday, July 30 # On the command line: bens-pb:~ ben$ gpop melbourne"
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Ben Schwarz
|
31
|
+
files:
|
32
|
+
- History.txt
|
33
|
+
- Manifest.txt
|
34
|
+
- README.txt
|
35
|
+
- Rakefile
|
36
|
+
- bin/gmoney
|
37
|
+
- bin/gpop
|
38
|
+
- bin/gtime
|
39
|
+
- lib/google_query.rb
|
40
|
+
- lib/google_query/currency.rb
|
41
|
+
- lib/google_query/population.rb
|
42
|
+
- lib/google_query/worldtime.rb
|
43
|
+
test_files: []
|
44
|
+
|
45
|
+
rdoc_options:
|
46
|
+
- --main
|
47
|
+
- README.txt
|
48
|
+
extra_rdoc_files:
|
49
|
+
- History.txt
|
50
|
+
- Manifest.txt
|
51
|
+
- README.txt
|
52
|
+
executables:
|
53
|
+
- gmoney
|
54
|
+
- gpop
|
55
|
+
- gtime
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
dependencies:
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: hpricot
|
63
|
+
version_requirement:
|
64
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0.6"
|
69
|
+
version:
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: hoe
|
72
|
+
version_requirement:
|
73
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.2.2
|
78
|
+
version:
|