flickru 0.1.1 → 0.1.2
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.
- data/lib/flickru/location.rb +7 -1
- data/lib/flickru/version.rb +1 -1
- metadata +2 -2
data/lib/flickru/location.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# ruby
|
2
2
|
require 'rbconfig'
|
3
3
|
# gems
|
4
|
+
require 'cache'
|
4
5
|
require 'colorize'
|
5
6
|
require 'escape'
|
6
7
|
require 'open-uri'
|
@@ -48,6 +49,8 @@ class Location
|
|
48
49
|
|
49
50
|
private
|
50
51
|
|
52
|
+
@@cache = Cache.new
|
53
|
+
|
51
54
|
def Location.parse location
|
52
55
|
# TODO special characters MAY be escaped
|
53
56
|
idx_accuracy = location.index('#') ? location.index('#') : location.length
|
@@ -99,12 +102,15 @@ private
|
|
99
102
|
end
|
100
103
|
|
101
104
|
def Location.geowiki place
|
105
|
+
if not @@cache[place].nil? then
|
106
|
+
return @@cache[place]
|
107
|
+
end
|
102
108
|
wiki = open("http://en.wikipedia.org/wiki/#{place}").read
|
103
109
|
tool = open(wiki.tr("\"", "\n").split("\n").grep(/geohack/) \
|
104
110
|
.first.sub(/^\/\//,'http://').sub('&','&')).read
|
105
111
|
geo = tool.split("\n").grep(/<span class="geo"/).first
|
106
112
|
latitude = geo.sub(/^.*"Latitude">/, '').sub(/<\/span>, .*/, '')
|
107
113
|
longitude = geo.sub(/.*"Longitude">/, '').sub(/<\/span>.*$/, '')
|
108
|
-
latitude + ", " + longitude
|
114
|
+
@@cache[place] = latitude + ", " + longitude
|
109
115
|
end
|
110
116
|
end
|
data/lib/flickru/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: flickru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jesus Pardillo
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2013-05-
|
13
|
+
date: 2013-05-14 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|