georss4rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/MIT-LICENSE +7 -0
  2. data/README +33 -0
  3. data/lib/georss4rb.rb +268 -0
  4. data/rakefile.rb +51 -0
  5. data/test/test_georss.rb +190 -0
  6. metadata +59 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2006 Guilhem Vellut <guilhem.vellut+ym4r@gmail.com>
2
+
3
+ Permission 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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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.
data/README ADDED
@@ -0,0 +1,33 @@
1
+ =GeoRSS4rb
2
+ GeoRSS4rb is an addon to the FeedTools library that aims at making GeoRSS information in a feed easily accessible for users of that library. It currently supports all the dialects (W3CGeo, Simple, GML) detailed in the GeoRSS specification version 1, including all the geometry types.
3
+
4
+ ==Installing
5
+ Just type under a command line:
6
+ gem install georss4rb
7
+ And the last version will be automatically downloaded and installed, along with the latest version of FeedTools, if you don't already have it.
8
+
9
+ ==Operations
10
+ Now you have a +location+ method on <tt>FeedTools::Feed</tt> and <tt>FeedTools::Item</tt> objects, that will return either +nil+, if no location exists, or an object of a subclass of <tt>GeoRss4rb::Geometry</tt>, if a location exists. The subclass can be one of four types:
11
+ - <tt>GeoRss4rb::Point</tt>: With 2 properties, +lat+ and +lon+
12
+ - <tt>GeoRss4rb::Line</tt>: Behaves like an array of points
13
+ - <tt>GeoRss4rb::Polygon</tt>: Behaves like an array of lines (although the GeoRss spec version 1 allows only the exterior ring to be defined)
14
+ - <tt>GeoRss4rb::Box</tt>: Holds 2 corner points, +lower_corner+ and +upper_corner+
15
+
16
+ Here is an example of usage:
17
+ feed = FeedTools::Feed.open('http://example.org/georss')
18
+ feed.title #=>MegaCool GeoRSS feed
19
+ feed.location #=><GeoRss4rb::Box ...>
20
+ feed.items.first.location #=><GeoRss4rb::Point ...>
21
+ The location of the entire feed could be a bounding of the location of the items. Then each item can have a location item, here a point. Note that the specific GeoRSS dialect used does not make any difference in the object returned.
22
+
23
+ ==Changes since last version
24
+ - First release
25
+
26
+ ==TODO
27
+ - Add support for other RSS parsing libraries
28
+
29
+ ==License
30
+ GeoRSS4rb is released under the MIT license.
31
+
32
+ ==Support
33
+ Any questions, enhancement proposals, bug notifications or corrections can be sent to mailto:guilhem.vellut@gmail.com.
data/lib/georss4rb.rb ADDED
@@ -0,0 +1,268 @@
1
+ require 'feed_tools'
2
+
3
+ module GeoRss4rb
4
+ module Location
5
+ #Returns a GeoRss4rb::Geometry object if info about the location is found.
6
+ #Returns +nil+ if no location info is found.
7
+ def location
8
+ if @location.nil?
9
+ #try all the georss dialects, according to uri
10
+ #first the simple W3C geo
11
+ if w3cgeo = find_node("*[namespace-uri()='http://www.w3.org/2003/01/geo/wgs84_pos#']")
12
+ #get the lat and long
13
+ #either inside a Point element or by themselves
14
+ if w3cgeo.local_name == "Point"
15
+ lat = w3cgeo.elements["*[local-name()='lat']"]
16
+ lon = w3cgeo.elements["*[local-name()='long']"]
17
+ else
18
+ if w3cgeo.local_name == "lat"
19
+ lat = w3cgeo.text.to_f
20
+ lon = find_node("*[namespace-uri()='http://www.w3.org/2003/01/geo/wgs84_pos#' and local-name()='long']").text.to_f
21
+ elsif w3cgeo.local_name == "long"
22
+ lon = w3cgeo.text.to_f
23
+ lat = find_node("*[namespace-uri()='http://www.w3.org/2003/01/geo/wgs84_pos#' and local-name()='lat']").text.to_f
24
+ end
25
+ end
26
+ if lat and lon
27
+ @location = GeoRss4rb::Point.new(lat,lon)
28
+ end
29
+ elsif gml = find_node("*[namespace-uri()='http://www.georss.org/georss' and local-name()='where']")
30
+ #the meat!!
31
+ case gml.elements["*"].local_name
32
+ when "Point"
33
+ @location = GeoRss4rb::Point.from_gml(gml)
34
+ when "LineString"
35
+ @location = GeoRss4rb::Line.from_gml(gml)
36
+ when "Polygon"
37
+ @location = GeoRss4rb::Polygon.from_gml(gml)
38
+ when "Envelope"
39
+ @location = GeoRss4rb::Box.from_gml(gml)
40
+ end
41
+ elsif simple = find_node("*[namespace-uri()='http://www.georss.org/georss']")
42
+ #not a gml: simple
43
+ content = simple.text
44
+ options = {:feature_type_tag => simple.attributes["featuretypetag"], :relationship_tag => simple.attributes["relationshiptag"], :elevation => GeoRss4rb.try_f(simple.attributes["elev"]), :floor => GeoRss4rb.try_i(simple.attributes["floor"]), :radius => GeoRss4rb.try_f(simple.attributes["radius"])}
45
+ case simple.local_name
46
+ when 'point'
47
+ @location = GeoRss4rb::Point.from_text(content,options)
48
+ when 'line'
49
+ @location = GeoRss4rb::Line.from_text(content,options)
50
+ when 'polygon'
51
+ @location = GeoRss4rb::Polygon.from_text(content,options)
52
+ when 'box'
53
+ @location = GeoRss4rb::Box.from_text(content,options)
54
+ end
55
+ end
56
+ end
57
+ return @location
58
+ end
59
+
60
+ #True if the feed or the item has some location info
61
+ def located?
62
+ location != nil #retrieve location info if not already there
63
+ end
64
+ end
65
+
66
+ class Geometry
67
+ attr_accessor :feature_type_tag, :relationship_tag, :elevation, :floor, :radius
68
+ def initialize(options = {})
69
+ @feature_type_tag = options[:feature_type_tag] || "location"
70
+ @relationship_tag = options[:relationship_tag] || "is-located_at"
71
+ @elevation = options[:elevation]
72
+ @floor = options[:floor]
73
+ @radius = options[:radius]
74
+ end
75
+ def to_s
76
+ inspect
77
+ end
78
+ end
79
+
80
+ class Point < GeoRss4rb::Geometry
81
+ attr_accessor :lat,:lon
82
+ def initialize(lat,lon,options = {})
83
+ super(options)
84
+ @lat = lat
85
+ @lon = lon
86
+ end
87
+
88
+ def ==(point)
89
+ if point.class != GeoRss4rb::Point
90
+ false
91
+ else
92
+ @lat = point.lat and @lon = point.lon
93
+ end
94
+ end
95
+
96
+ def self.from_array(array,options = {})
97
+ GeoRss4rb::Point.new(array[0],array[1],options)
98
+ end
99
+
100
+ def self.from_text(text,options = {})
101
+ array = GeoRss4rb::parse_text(text)
102
+ return nil if array.length != 2
103
+ self.from_array(array,options)
104
+ end
105
+
106
+ def self.from_gml(gml)
107
+ pos = gml.elements["//*[local-name()='pos']"]
108
+ if pos.nil?
109
+ nil
110
+ else
111
+ self.from_text(pos.text)
112
+ end
113
+ end
114
+ end
115
+
116
+ class Line < GeoRss4rb::Geometry
117
+ attr_reader :points
118
+ def initialize(points,options = {})
119
+ super(options)
120
+ @points = points
121
+ end
122
+
123
+ #Makes the line behave as an array of points
124
+ def method_missing(method_name,*args,&b)
125
+ @points.send(method_name,*args,&b)
126
+ end
127
+
128
+ def ==(line)
129
+ if line.class != GeoRss4rb::Line or
130
+ line.length != self.length
131
+ false
132
+ else
133
+ index = 0
134
+ while index < length
135
+ return false if self[index] != line[index]
136
+ index+=1
137
+ end
138
+ true
139
+ end
140
+ end
141
+
142
+ def self.from_array(array,options = {})
143
+ points = []
144
+ 0.upto(array.length / 2 - 1) do |pos|
145
+ points << GeoRss4rb::Point.from_array(array[pos * 2,2])
146
+ end
147
+ GeoRss4rb::Line.new(points,options)
148
+ end
149
+
150
+ def self.from_text(text,options = {})
151
+ array = GeoRss4rb::parse_text(text)
152
+ return nil if array.length % 2 != 0 or array.length < 4 # 2 points minimum
153
+ self.from_array(array,options)
154
+ end
155
+
156
+ def self.from_gml(gml)
157
+ pos_list = gml.elements["//*[local-name()='posList']"]
158
+ if pos_list.nil?
159
+ nil
160
+ else
161
+ self.from_text(pos_list.text)
162
+ end
163
+ end
164
+ end
165
+
166
+ class Polygon < GeoRss4rb::Geometry
167
+ attr_reader :rings
168
+ def initialize(rings,options)
169
+ super(options)
170
+ @rings = rings
171
+ end
172
+
173
+ #Makes the Polygon behave as an array of rings/lines
174
+ def method_missing(method_name,*args,&b)
175
+ @rings.send(method_name,*args,&b)
176
+ end
177
+
178
+ def ==(polygon)
179
+ if polygon.class != GeoRss4rb::Polygon or
180
+ polygon.length != self.length
181
+ false
182
+ else
183
+ index = 0
184
+ while index < length
185
+ return false if self[index] != polygon[index]
186
+ index+=1
187
+ end
188
+ true
189
+ end
190
+ end
191
+
192
+ def self.from_text(text,options = {})
193
+ array = GeoRss4rb::parse_text(text)
194
+ return nil if array.length % 2 != 0 or array.length < 8 # 4 points minimum
195
+ rings = [GeoRss4rb::Line.from_array(array)] #exterior only
196
+ GeoRss4rb::Polygon.new(rings,options)
197
+ end
198
+ def self.from_gml(gml)
199
+ pos_list = gml.elements["//*[local-name()='posList']"]
200
+ if pos_list.nil?
201
+ nil
202
+ else
203
+ self.from_text(pos_list.text)
204
+ end
205
+ end
206
+ end
207
+
208
+ class Box < GeoRss4rb::Geometry
209
+ attr_reader :lower_corner,:upper_corner
210
+ def initialize(lower_corner,upper_corner,options = {})
211
+ super(options)
212
+ @lower_corner = lower_corner
213
+ @upper_corner = upper_corner
214
+ end
215
+ def ==(box)
216
+ if box.class != GeoRss4rb::Box
217
+ false
218
+ else
219
+ @lower_corner == box.lower_corner and @upper_corner == box.upper_corner
220
+ end
221
+ end
222
+ def self.from_text(text,options = {})
223
+ array = GeoRss4rb::parse_text(text)
224
+ return nil if array.length != 4
225
+ lower_corner = GeoRss4rb::Point.from_array(array[0,2])
226
+ upper_corner = GeoRss4rb::Point.from_array(array[2,2])
227
+ GeoRss4rb::Box.new(lower_corner,upper_corner,options)
228
+ end
229
+ def self.from_gml(gml)
230
+ lower_corner = gml.elements["//*[local-name()='lowerCorner']"]
231
+ upper_corner = gml.elements["//*[local-name()='upperCorner']"]
232
+ if lower_corner and upper_corner
233
+ self.from_text(lower_corner.text + " " + upper_corner.text) #the lazy solution
234
+ end
235
+ end
236
+ end
237
+
238
+
239
+ def self.parse_text(expr)#:nodoc:
240
+ expr.scan(/-?(?:\.\d+|\d+(?:\.\d*)?)/).map {|str| str.to_f}
241
+ end
242
+
243
+
244
+ def self.try_f(expr)#:nodoc:
245
+ if expr.nil?
246
+ nil
247
+ else
248
+ expr.to_f
249
+ end
250
+ end
251
+
252
+
253
+ def self.try_i(expr) #:nodoc:
254
+ if expr.nil?
255
+ nil
256
+ else
257
+ expr.to_f.to_i #to_f does not throw exceptions...
258
+ end
259
+ end
260
+ end
261
+
262
+ FeedTools::FeedItem.class_eval do
263
+ include GeoRss4rb::Location
264
+ end
265
+
266
+ FeedTools::Feed.class_eval do
267
+ include GeoRss4rb::Location
268
+ end
data/rakefile.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
5
+
6
+ task :default => :test
7
+
8
+ desc "Run the tests"
9
+ Rake::TestTask::new do |t|
10
+ t.test_files = FileList['test/test*.rb']
11
+ t.verbose = true
12
+ end
13
+
14
+ desc "Generate the documentation"
15
+ Rake::RDocTask::new do |rdoc|
16
+ rdoc.rdoc_dir = 'georss4rb-doc/'
17
+ rdoc.title = "GeoRSS4rb Documentation"
18
+ rdoc.options << '--line-numbers' << '--inline-source'
19
+ rdoc.rdoc_files.include('README')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ spec = Gem::Specification::new do |s|
24
+ s.platform = Gem::Platform::RUBY
25
+
26
+ s.add_dependency('feedtools', '>= 0.2.26') #others should be ok though...
27
+
28
+ s.name = 'georss4rb'
29
+ s.version = "0.0.1"
30
+ s.summary = "Adds support for all GeoRSS dialects in FeedTools"
31
+ s.description = "Adds support for all GeoRSS dialects in FeedTools"
32
+
33
+ s.author = 'Guilhem Vellut'
34
+ s.email = 'guilhem.vellut@gmail.com'
35
+ s.homepage = "http://thepochisuperstarmegashow.com"
36
+ s.rubyforge_project = "georss4rb"
37
+ s.requirements << 'none'
38
+ s.require_path = 'lib'
39
+ s.files = FileList["lib/**/*.rb","test/**/*.rb", "README","MIT-LICENSE","rakefile.rb"]
40
+ s.test_files = FileList['test/test*.rb']
41
+
42
+ s.has_rdoc = true
43
+ s.extra_rdoc_files = ["README"]
44
+ s.rdoc_options.concat ['--main', 'README']
45
+ end
46
+
47
+ desc "Package the library as a gem"
48
+ Rake::GemPackageTask.new(spec) do |pkg|
49
+ pkg.need_zip = true
50
+ pkg.need_tar = true
51
+ end
@@ -0,0 +1,190 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ require 'georss4rb'
3
+ require 'test/unit'
4
+
5
+ include GeoRss4rb
6
+
7
+ class TestGeorss < Test::Unit::TestCase
8
+ def test_parse_float_list
9
+ arr = GeoRss4rb::parse_text("456.3")
10
+ assert_equal(1,arr.length)
11
+ assert_equal(456.3,arr[0])
12
+
13
+ arr = GeoRss4rb::parse_text("456")
14
+ assert_equal(1,arr.length)
15
+ assert_equal(456,arr[0])
16
+
17
+ arr = GeoRss4rb::parse_text(".456")
18
+ assert_equal(1,arr.length)
19
+ assert_equal(0.456,arr[0])
20
+
21
+ arr = GeoRss4rb::parse_text("456;123; .444 23.44\t56")
22
+ assert_equal(5,arr.length)
23
+ assert_equal([456,123,0.444,23.44,56],arr)
24
+
25
+ arr = GeoRss4rb::parse_text("456.567 123 .444 23.44 56")
26
+ assert_equal(5,arr.length)
27
+ assert_equal([456.567,123,0.444,23.44,56],arr)
28
+
29
+ arr = GeoRss4rb::parse_text("456.567,123 23.44,56")
30
+ assert_equal(4,arr.length)
31
+ assert_equal([456.567,123,23.44,56],arr)
32
+ end
33
+
34
+ def test_w3cgeo
35
+ #atom
36
+ w3cgeo = FeedTools::Feed.open("file://#{File.dirname(__FILE__)}/atom_w3cgeo.xml")
37
+ assert(w3cgeo.respond_to?(:location))
38
+ assert(!w3cgeo.location.nil?)
39
+ assert(w3cgeo.located?)
40
+ assert(GeoRss4rb::Point,w3cgeo.location.class)
41
+ assert_equal(GeoRss4rb::Point.new(26.58,-97.83),w3cgeo.location)
42
+
43
+ assert(!w3cgeo.items.nil?)
44
+ assert_equal(2,w3cgeo.items.length)
45
+
46
+ assert(!w3cgeo.items.first.location.nil?)
47
+ assert_equal(GeoRss4rb::Point.new(28,0.83666),w3cgeo.items.first.location)
48
+
49
+ assert(!w3cgeo.items[1].location.nil?)
50
+ assert_equal(GeoRss4rb::Point.new(55.701,12.552),w3cgeo.items[1].location)
51
+
52
+ #rss
53
+ w3cgeo = FeedTools::Feed.open("file://#{File.dirname(__FILE__)}/rss_w3cgeo.xml")
54
+ assert(w3cgeo.respond_to?(:location))
55
+ assert(!w3cgeo.location.nil?)
56
+ assert(GeoRss4rb::Point,w3cgeo.location.class)
57
+ assert_equal(GeoRss4rb::Point.new(26.58,-97.83),w3cgeo.location)
58
+
59
+ assert(!w3cgeo.items.nil?)
60
+ assert_equal(1,w3cgeo.items.length)
61
+
62
+ assert(!w3cgeo.items[0].location.nil?)
63
+ assert_equal(GeoRss4rb::Point.new(55.701,12.552),w3cgeo.items[0].location)
64
+ end
65
+
66
+ def test_simple
67
+ #atom
68
+ simple = FeedTools::Feed.open("file://#{File.dirname(__FILE__)}/atom_simple.xml")
69
+ assert(simple.respond_to?(:location))
70
+ assert(!simple.location.nil?)
71
+
72
+ #Test point
73
+ assert(GeoRss4rb::Point,simple.location.class)
74
+ assert_equal(GeoRss4rb::Point.new(4.5,56.4123),simple.location)
75
+ assert_equal("bidon",simple.location.feature_type_tag)
76
+ assert_equal("is-centered-at",simple.location.relationship_tag)
77
+ assert_equal(123.3,simple.location.elevation)
78
+ assert_equal(101,simple.location.floor)
79
+ assert_equal(456.1,simple.location.radius)
80
+ assert(!simple.items.nil?)
81
+ assert_equal(3,simple.items.length)
82
+
83
+ #Test line
84
+ first = simple.items.first
85
+ assert(!first.location.nil?)
86
+ assert(GeoRss4rb::Line,first.location.class)
87
+ assert_equal(GeoRss4rb::Line.from_text("123.4 4123.4 312.3 123.5 -65.1 45.1"),first.location)
88
+
89
+ #Test polygon
90
+ second = simple.items[1]
91
+ assert(!second.location.nil?)
92
+ assert(GeoRss4rb::Polygon,second.location.class)
93
+ assert_equal(GeoRss4rb::Polygon.from_text("45.256 -110.45 46.46 -109.48 43.84 -109.86 45.256 -110.45"),second.location)
94
+
95
+ #Test box
96
+ third = simple.items[2]
97
+ assert(!third.location.nil?)
98
+ assert(GeoRss4rb::Box,third.location.class)
99
+ assert_equal(GeoRss4rb::Box.from_text("45.256 -110.45 46.46 -109.48"),third.location)
100
+
101
+ #rss
102
+ simple = FeedTools::Feed.open("file://#{File.dirname(__FILE__)}/rss_simple.xml")
103
+ assert(simple.respond_to?(:location))
104
+ assert(!simple.location.nil?)
105
+
106
+ #Test box
107
+ assert(GeoRss4rb::Box,simple.location.class)
108
+ assert_equal(GeoRss4rb::Box.from_text("45.36758436884978 -18.2373046875 60.951776809566965 8.1298828125"),simple.location)
109
+ assert(!simple.items.nil?)
110
+ assert_equal(3,simple.items.length)
111
+
112
+ #Test point
113
+ first = simple.items.first
114
+ assert(!first.location.nil?)
115
+ assert(GeoRss4rb::Point,first.location.class)
116
+ assert_equal(GeoRss4rb::Point.new(52.8872,-2.04454),first.location)
117
+
118
+ #Test line
119
+ second = simple.items[1]
120
+ assert(!second.location.nil?)
121
+ assert(GeoRss4rb::Line,second.location.class)
122
+ assert_equal(GeoRss4rb::Line.from_text("52.7533,-0.536977 51.73, -0.3336977"),second.location)
123
+
124
+ #Test polygon
125
+ third = simple.items[2]
126
+ assert(!third.location.nil?)
127
+ assert(GeoRss4rb::Polygon,third.location.class)
128
+ assert_equal(GeoRss4rb::Polygon.from_text("55.9756 -3.9165 52.7533 -0.536977 51.73 -0.3336977 52.7533 -0.536977 51.73 -0.3336977"),third.location) #the polygon does not make any sens geometrically speaking, but it is not checked by the library
129
+ end
130
+
131
+ def test_gml
132
+ #atom
133
+ gml = FeedTools::Feed.open("file://#{File.dirname(__FILE__)}/atom_gml.xml")
134
+ assert(gml.respond_to?(:location))
135
+ assert(!gml.location.nil?)
136
+
137
+ #Test point
138
+ assert(GeoRss4rb::Point,gml.location.class)
139
+ assert_equal(GeoRss4rb::Point.new(45.256,-110.45),gml.location)
140
+ assert(!gml.items.nil?)
141
+ assert_equal(3,gml.items.length)
142
+
143
+ #Test line
144
+ first = gml.items.first
145
+ assert(!first.location.nil?)
146
+ assert(GeoRss4rb::Line,first.location.class)
147
+ assert_equal(GeoRss4rb::Line.from_text("45.256 -110.45 46.46 -109.48 43.84 -109.86 45.8 -109.2"),first.location)
148
+
149
+ #Test polygon
150
+ second = gml.items[1]
151
+ assert(!second.location.nil?)
152
+ assert(GeoRss4rb::Polygon,second.location.class)
153
+ assert_equal(GeoRss4rb::Polygon.from_text("45.256 -110.45 46.46 -109.48 43.84 -109.86 45.256 -110.45"),second.location)
154
+
155
+ #Test box
156
+ third = gml.items[2]
157
+ assert(!third.location.nil?)
158
+ assert(GeoRss4rb::Box,third.location.class)
159
+ assert_equal(GeoRss4rb::Box.from_text("42.943 -71.032 43.039 -69.856"),third.location)
160
+
161
+ #rss
162
+ gml = FeedTools::Feed.open("file://#{File.dirname(__FILE__)}/rss_gml.xml")
163
+ assert(gml.respond_to?(:location))
164
+ assert(!gml.location.nil?)
165
+
166
+ #Test point
167
+ assert(GeoRss4rb::Point,gml.location.class)
168
+ assert_equal(GeoRss4rb::Point.new(45.256,-110.45),gml.location)
169
+ assert(!gml.items.nil?)
170
+ assert_equal(3,gml.items.length)
171
+
172
+ #Test line
173
+ first = gml.items.first
174
+ assert(!first.location.nil?)
175
+ assert(GeoRss4rb::Line,first.location.class)
176
+ assert_equal(GeoRss4rb::Line.from_text("45.256 -110.45 46.46 -109.48 43.84 -109.86 45.8 -109.2"),first.location)
177
+
178
+ #Test polygon
179
+ second = gml.items[1]
180
+ assert(!second.location.nil?)
181
+ assert(GeoRss4rb::Polygon,second.location.class)
182
+ assert_equal(GeoRss4rb::Polygon.from_text("45.256 -110.45 46.46 -109.48 43.84 -109.86 45.256 -110.45"),second.location)
183
+
184
+ #Test box
185
+ third = gml.items[2]
186
+ assert(!third.location.nil?)
187
+ assert(GeoRss4rb::Box,third.location.class)
188
+ assert_equal(GeoRss4rb::Box.from_text("42.943 -71.032 43.039 -69.856"),third.location)
189
+ end
190
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: georss4rb
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2006-11-01 00:00:00 +01:00
8
+ summary: Adds support for all GeoRSS dialects in FeedTools
9
+ require_paths:
10
+ - lib
11
+ email: guilhem.vellut@gmail.com
12
+ homepage: http://thepochisuperstarmegashow.com
13
+ rubyforge_project: georss4rb
14
+ description: Adds support for all GeoRSS dialects in FeedTools
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
+ - Guilhem Vellut
31
+ files:
32
+ - lib/georss4rb.rb
33
+ - test/test_georss.rb
34
+ - README
35
+ - MIT-LICENSE
36
+ - rakefile.rb
37
+ test_files:
38
+ - test/test_georss.rb
39
+ rdoc_options:
40
+ - --main
41
+ - README
42
+ extra_rdoc_files:
43
+ - README
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ requirements:
49
+ - none
50
+ dependencies:
51
+ - !ruby/object:Gem::Dependency
52
+ name: feedtools
53
+ version_requirement:
54
+ version_requirements: !ruby/object:Gem::Version::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 0.2.26
59
+ version: