rosemary 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rosemary::Way do
4
+
5
+ before do
6
+ WebMock.disable_net_connect!
7
+ end
8
+
9
+ let :osm do
10
+ Rosemary::Api.new
11
+ end
12
+
13
+ def valid_fake_way
14
+ way=<<-EOF
15
+ <osm>
16
+ <way id="1234" version="142" changeset="12" user="fred" uid="123" visible="true" timestamp="2005-07-30T14:27:12+01:00">
17
+ <tag k="note" v="Just a way"/>
18
+ <nd ref="15735248"/>
19
+ <nd ref="169269997"/>
20
+ <nd ref="169270001"/>
21
+ <nd ref="15735251"/>
22
+ <nd ref="15735252"/>
23
+ <nd ref="15735253"/>
24
+ <nd ref="15735250"/>
25
+ <nd ref="15735247"/>
26
+ <nd ref="15735246"/>
27
+ <nd ref="15735249"/>
28
+ <nd ref="15735248"/>
29
+ </way>
30
+ </osm>
31
+ EOF
32
+ end
33
+
34
+ describe '#find:' do
35
+
36
+ it "should build a Way from API response via get_way" do
37
+ stub_request(:get, "http://www.openstreetmap.org/api/0.6/way/1234").to_return(:status => 200, :body => valid_fake_way, :headers => {'Content-Type' => 'application/xml'})
38
+ way = osm.find_way(1234)
39
+ way.class.should eql Rosemary::Way
40
+ way.nodes.should include(15735246)
41
+ end
42
+ end
43
+
44
+ describe '#create:' do
45
+ end
46
+
47
+ describe '#update:' do
48
+ end
49
+
50
+ describe '#delete:' do
51
+ end
52
+ end
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Rosemary::Changeset' do
4
+
5
+ let :changeset do
6
+ Rosemary::Changeset.new( :id => "123",
7
+ :user => "fred",
8
+ :uid => "123",
9
+ :created_at => "2008-11-08T19:07:39+01:00",
10
+ :open => "true",
11
+ :min_lat => "52.2",
12
+ :max_lat => "52.3",
13
+ :min_lon => "13.4",
14
+ :max_lon => "13.5")
15
+ end
16
+
17
+ it "should have an id attribute set from attributes" do
18
+ changeset.id.should eql(123)
19
+ end
20
+
21
+ it "should have an id attribute within xml representation" do
22
+ changeset.to_xml.should match /id=\"123\"/
23
+ end
24
+
25
+ it "should have a user attributes set from attributes" do
26
+ changeset.user.should eql("fred")
27
+ end
28
+
29
+ it "should have a user attribute within xml representation" do
30
+ changeset.to_xml.should match /user=\"fred\"/
31
+ end
32
+
33
+ it "should have an uid attribute set from attributes" do
34
+ changeset.uid.should eql(123)
35
+ end
36
+
37
+ it "should have an uid attribute within xml representation" do
38
+ changeset.to_xml.should match /uid=\"123\"/
39
+ end
40
+
41
+ it "should have a changeset attributes set from attributes" do
42
+ changeset.should be_open
43
+ end
44
+
45
+ it "should have an open attribute within xml representation" do
46
+ changeset.to_xml.should match /open=\"true\"/
47
+ end
48
+
49
+ it "should have a min_lat attribute set from attributes" do
50
+ changeset.min_lat.should eql(52.2)
51
+ end
52
+
53
+ it "should have a min_lat attribute within xml representation" do
54
+ changeset.to_xml.should match /min_lat=\"52.2\"/
55
+ end
56
+
57
+ it "should have a min_lon attribute set from attributes" do
58
+ changeset.min_lon.should eql(13.4)
59
+ end
60
+
61
+ it "should have a min_lon attribute within xml representation" do
62
+ changeset.to_xml.should match /min_lon=\"13.4\"/
63
+ end
64
+
65
+ it "should have a max_lat attribute set from attributes" do
66
+ changeset.max_lat.should eql(52.3)
67
+ end
68
+
69
+ it "should have a max_lat attribute within xml representation" do
70
+ changeset.to_xml.should match /max_lat=\"52.3\"/
71
+ end
72
+
73
+ it "should have a max_lon attribute set from attributes" do
74
+ changeset.max_lon.should eql(13.5)
75
+ end
76
+
77
+ it "should have a max_lon attribute within xml representation" do
78
+ changeset.to_xml.should match /max_lon=\"13.5\"/
79
+ end
80
+
81
+ it "should have a created_at attribute set from attributes" do
82
+ changeset.created_at.should eql Time.parse('2008-11-08T19:07:39+01:00')
83
+ end
84
+
85
+ it "should have a created_at attribute within xml representation" do
86
+ changeset.to_xml.should match /created_at=\"/
87
+ end
88
+
89
+
90
+ end
@@ -0,0 +1,87 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Rosemary::Node' do
4
+
5
+ subject do
6
+ Rosemary::Node.new(:id => "123",
7
+ :lat => "52.2",
8
+ :lon => "13.4",
9
+ :changeset => "12",
10
+ :user => "fred",
11
+ :uid => "123",
12
+ :visible => true,
13
+ :timestamp => "2005-07-30T14:27:12+01:00")
14
+ end
15
+
16
+ it { should be_valid }
17
+
18
+ it "should be invalid without lat, lon" do
19
+ subject.lat = nil
20
+ subject.lon = nil
21
+ subject.should_not be_valid
22
+ end
23
+
24
+ it "should not be valid when using to large lat value" do
25
+ subject.lat = 181
26
+ subject.should_not be_valid
27
+ end
28
+
29
+ it "should not be valid when using to large lat value" do
30
+ subject.lon = 91
31
+ subject.should_not be_valid
32
+ end
33
+
34
+ it "should have an id attribute set from attributes" do
35
+ subject.id.should eql(123)
36
+ end
37
+
38
+ it "should have an id attribute within xml representation" do
39
+ subject.to_xml.should match /id=\"123\"/
40
+ end
41
+
42
+ it "should have a lat attribute set from attributes" do
43
+ subject.lat.should eql(52.2)
44
+ end
45
+
46
+ it "should have a lat attribute within xml representation" do
47
+ subject.to_xml.should match /lat=\"52.2\"/
48
+ end
49
+
50
+ it "should have a lon attribute set from attributes" do
51
+ subject.lon.should eql(13.4)
52
+ end
53
+
54
+ it "should have a lon attribute within xml representation" do
55
+ subject.to_xml.should match /lon=\"13.4\"/
56
+ end
57
+
58
+ it "should have a user attributes set from attributes" do
59
+ subject.user.should eql("fred")
60
+ end
61
+
62
+ it "should have a user attribute within xml representation" do
63
+ subject.to_xml.should match /user=\"fred\"/
64
+ end
65
+
66
+ it "should have a changeset attributes set from attributes" do
67
+ subject.changeset.should eql(12)
68
+ end
69
+
70
+ it "should have a changeset attribute within xml representation" do
71
+ subject.to_xml.should match /changeset=\"12\"/
72
+ end
73
+
74
+ it "should have a uid attribute set from attributes" do
75
+ subject.uid.should eql(123)
76
+ end
77
+
78
+ it "should have a uid attribute within xml representation" do
79
+ subject.to_xml.should match /uid=\"123\"/
80
+ end
81
+
82
+ it "should produce xml" do
83
+ subject.add_tags(:wheelchair => 'yes')
84
+ subject.to_xml.should match /k=\"wheelchair\"/
85
+ subject.to_xml.should match /v=\"yes\"/
86
+ end
87
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Rosemary::Relation' do
4
+
5
+ subject do
6
+ Rosemary::Relation.new(:id => "123",
7
+ :lat => "52.2",
8
+ :lon => "13.4",
9
+ :changeset => "12",
10
+ :user => "fred",
11
+ :uid => "123",
12
+ :visible => true,
13
+ :timestamp => "2005-07-30T14:27:12+01:00",
14
+ :member => [
15
+ {"type"=>"relation", "ref"=>"1628007", "role"=>"outer"},
16
+ {"type"=>"way", "ref"=>"50197015", "role"=>""}
17
+ ])
18
+ end
19
+
20
+ it { should be_valid }
21
+
22
+ it "should have members" do
23
+ subject.members.size.should eql 2
24
+ end
25
+
26
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Rosemary::Way' do
4
+
5
+ def valid_fake_way
6
+ way=<<-EOF
7
+ <osm>
8
+ <way id="1234" version="142" changeset="12" user="fred" uid="123" visible="true" timestamp="2005-07-30T14:27:12+01:00">
9
+ <tag k="note" v="Just a way"/>
10
+ <nd ref="15735248"/>
11
+ <nd ref="169269997"/>
12
+ <nd ref="169270001"/>
13
+ <nd ref="15735251"/>
14
+ <nd ref="15735252"/>
15
+ <nd ref="15735253"/>
16
+ <nd ref="15735250"/>
17
+ <nd ref="15735247"/>
18
+ <nd ref="15735246"/>
19
+ <nd ref="15735249"/>
20
+ <nd ref="15735248"/>
21
+ </way>
22
+ </osm>
23
+ EOF
24
+ end
25
+
26
+ subject do
27
+ @way ||= Rosemary::Way.from_xml(valid_fake_way)
28
+ end
29
+
30
+ it "should have 4 nodes" do
31
+ subject.nodes.size.should eql 11
32
+ subject.nodes.first.should eql 15735248
33
+ end
34
+
35
+ it "should have node referenzes in xml representation" do
36
+ subject.to_xml.should match /ref=\"15735248\"/
37
+ end
38
+
39
+
40
+ it "should have an id attribute set from attributes" do
41
+ subject.id.should eql(1234)
42
+ end
43
+
44
+ it "should have an id attribute within xml representation" do
45
+ subject.to_xml.should match /id=\"1234\"/
46
+ end
47
+
48
+ it "should have a user attributes set from attributes" do
49
+ subject.user.should eql("fred")
50
+ end
51
+
52
+ it "should have a user attribute within xml representation" do
53
+ subject.to_xml.should match /user=\"fred\"/
54
+ end
55
+
56
+ it "should have a changeset attributes set from attributes" do
57
+ subject.changeset.should eql(12)
58
+ end
59
+
60
+ it "should have a changeset attribute within xml representation" do
61
+ subject.to_xml.should match /changeset=\"12\"/
62
+ end
63
+
64
+ it "should have a uid attribute set from attributes" do
65
+ subject.uid.should eql(123)
66
+ end
67
+
68
+ it "should have a uid attribute within xml representation" do
69
+ subject.to_xml.should match /uid=\"123\"/
70
+ end
71
+
72
+ it "should produce xml" do
73
+ subject.add_tags(:wheelchair => 'yes')
74
+ subject.to_xml.should match /k=\"wheelchair\"/
75
+ subject.to_xml.should match /v=\"yes\"/
76
+ end
77
+ end
@@ -0,0 +1,3 @@
1
+ require 'webmock/rspec'
2
+ require 'rosemary'
3
+
metadata ADDED
@@ -0,0 +1,244 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rosemary
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 2
10
+ version: 0.2.2
11
+ platform: ruby
12
+ authors:
13
+ - Christoph Bu{fc}nte, Enno Brehm
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-03-22 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ prerelease: false
31
+ requirement: *id001
32
+ name: httparty
33
+ type: :runtime
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ hash: 3
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ prerelease: false
45
+ requirement: *id002
46
+ name: libxml-ruby
47
+ type: :runtime
48
+ - !ruby/object:Gem::Dependency
49
+ version_requirements: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ prerelease: false
59
+ requirement: *id003
60
+ name: builder
61
+ type: :runtime
62
+ - !ruby/object:Gem::Dependency
63
+ version_requirements: &id004 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ prerelease: false
73
+ requirement: *id004
74
+ name: oauth
75
+ type: :runtime
76
+ - !ruby/object:Gem::Dependency
77
+ version_requirements: &id005 !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ prerelease: false
87
+ requirement: *id005
88
+ name: activemodel
89
+ type: :runtime
90
+ - !ruby/object:Gem::Dependency
91
+ version_requirements: &id006 !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ prerelease: false
101
+ requirement: *id006
102
+ name: rspec
103
+ type: :development
104
+ - !ruby/object:Gem::Dependency
105
+ version_requirements: &id007 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ hash: 3
111
+ segments:
112
+ - 0
113
+ version: "0"
114
+ prerelease: false
115
+ requirement: *id007
116
+ name: webmock
117
+ type: :development
118
+ - !ruby/object:Gem::Dependency
119
+ version_requirements: &id008 !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ hash: 3
125
+ segments:
126
+ - 0
127
+ version: "0"
128
+ prerelease: false
129
+ requirement: *id008
130
+ name: rake
131
+ type: :development
132
+ description: OpenStreetMap API client for ruby
133
+ email:
134
+ - info@christophbuente.de
135
+ executables: []
136
+
137
+ extensions: []
138
+
139
+ extra_rdoc_files:
140
+ - CHANGELOG
141
+ - LICENSE
142
+ - README.md
143
+ - lib/changeset_callbacks.rb
144
+ - lib/hash.rb
145
+ - lib/rosemary/api.rb
146
+ - lib/rosemary/basic_auth_client.rb
147
+ - lib/rosemary/changeset.rb
148
+ - lib/rosemary/element.rb
149
+ - lib/rosemary/errors.rb
150
+ - lib/rosemary/member.rb
151
+ - lib/rosemary/node.rb
152
+ - lib/rosemary/oauth_client.rb
153
+ - lib/rosemary/parser.rb
154
+ - lib/rosemary/relation.rb
155
+ - lib/rosemary/tags.rb
156
+ - lib/rosemary/user.rb
157
+ - lib/rosemary/way.rb
158
+ - lib/rosemary.rb
159
+ files:
160
+ - .gitignore
161
+ - .rbenv-version
162
+ - .rspec
163
+ - .rvmrc
164
+ - .travis.yml
165
+ - CHANGELOG
166
+ - Gemfile
167
+ - LICENSE
168
+ - Manifest
169
+ - README.md
170
+ - Rakefile
171
+ - lib/changeset_callbacks.rb
172
+ - lib/hash.rb
173
+ - lib/rosemary.rb
174
+ - lib/rosemary/api.rb
175
+ - lib/rosemary/basic_auth_client.rb
176
+ - lib/rosemary/changeset.rb
177
+ - lib/rosemary/element.rb
178
+ - lib/rosemary/errors.rb
179
+ - lib/rosemary/member.rb
180
+ - lib/rosemary/node.rb
181
+ - lib/rosemary/oauth_client.rb
182
+ - lib/rosemary/parser.rb
183
+ - lib/rosemary/relation.rb
184
+ - lib/rosemary/tags.rb
185
+ - lib/rosemary/user.rb
186
+ - lib/rosemary/version.rb
187
+ - lib/rosemary/way.rb
188
+ - rosemary.gemspec
189
+ - spec/integration/changeset_spec.rb
190
+ - spec/integration/node_spec.rb
191
+ - spec/integration/way_spec.rb
192
+ - spec/models/changeset_spec.rb
193
+ - spec/models/node_spec.rb
194
+ - spec/models/relation_spec.rb
195
+ - spec/models/way_spec.rb
196
+ - spec/spec_helper.rb
197
+ homepage: https://github.com/sozialhelden/openstreetmap
198
+ licenses: []
199
+
200
+ post_install_message:
201
+ rdoc_options:
202
+ - --line-numbers
203
+ - --inline-source
204
+ - --title
205
+ - OpenStreetMap
206
+ - --main
207
+ - README.md
208
+ require_paths:
209
+ - lib
210
+ required_ruby_version: !ruby/object:Gem::Requirement
211
+ none: false
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ hash: 3
216
+ segments:
217
+ - 0
218
+ version: "0"
219
+ required_rubygems_version: !ruby/object:Gem::Requirement
220
+ none: false
221
+ requirements:
222
+ - - ">="
223
+ - !ruby/object:Gem::Version
224
+ hash: 11
225
+ segments:
226
+ - 1
227
+ - 2
228
+ version: "1.2"
229
+ requirements: []
230
+
231
+ rubyforge_project: rosemary
232
+ rubygems_version: 1.8.15
233
+ signing_key:
234
+ specification_version: 3
235
+ summary: OpenStreetMap API client for ruby
236
+ test_files:
237
+ - spec/integration/changeset_spec.rb
238
+ - spec/integration/node_spec.rb
239
+ - spec/integration/way_spec.rb
240
+ - spec/models/changeset_spec.rb
241
+ - spec/models/node_spec.rb
242
+ - spec/models/relation_spec.rb
243
+ - spec/models/way_spec.rb
244
+ - spec/spec_helper.rb