rosemary 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ # Save as .codeclimate.yml (note leading .) in project root directory
2
+ languages:
3
+ Ruby: true
4
+ # exclude_paths:
5
+ # - "foo/bar.rb"
@@ -10,3 +10,7 @@ rvm:
10
10
  notifications:
11
11
  email:
12
12
  - info@christophbuente.de
13
+
14
+ addons:
15
+ code_climate:
16
+ repo_token: 9b4adcf51537fa2b279a8e9ce948227f84c25288c6758c18f12f4f9e2dd3b0b6
@@ -2,6 +2,18 @@ rosemary CHANGELOG
2
2
  ===================================
3
3
  This file is used to list changes made in each version.
4
4
 
5
+ v0.4.4 (2015 May 29)
6
+ ------
7
+
8
+ * FIX: #14 Use htmlentities gem to sanitize input for tag values.
9
+ * Remove coveralls in favor of codeclimate test coverage reporter
10
+ * Exchange PNG badges in favor of SVG badges.
11
+
12
+ v0.4.3 (2015 Feb 19)
13
+ ------
14
+
15
+ * Add "find elements within bounding box" functionality. Thanks to [Leo Roos Version](https://github.com/leoroos)
16
+
5
17
  v0.4.2 (2014 Aug 7)
6
18
  ------
7
19
 
@@ -12,12 +24,12 @@ v0.4.2 (2014 Aug 7)
12
24
  v0.4.1 (2014 May 27)
13
25
  ------
14
26
 
15
- * Fix: Return value of notes API call (thanks github.com/alexandrz)
27
+ * FIX: Return value of notes API call. Thanks to [Aleksandr Zykov](https://github.com/alexandrz)
16
28
 
17
29
  v0.4.0 (2014 April 23)
18
30
  ------
19
31
 
20
- * Add support for the notes API call. (thanks github.com/alexandrz)
32
+ * Add support for the notes API call. Thanks to [Aleksandr Zykov](https://github.com/alexandrz)
21
33
 
22
34
  v0.1.0
23
35
  ------
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Rosemary: OpenStreetMap for Ruby
2
2
 
3
- [![Gem Version](https://fury-badge.herokuapp.com/rb/rosemary.png)](http://badge.fury.io/rb/rosemary)
4
- [![Build Status](https://travis-ci.org/sozialhelden/rosemary.png?branch=master)](https://travis-ci.org/sozialhelden/rosemary)
3
+ [![Gem Version](https://badge.fury.io/rb/rosemary.svg)](http://badge.fury.io/rb/rosemary)
4
+ [![Build Status](https://travis-ci.org/sozialhelden/rosemary.svg?branch=master)](https://travis-ci.org/sozialhelden/rosemary)
5
5
  [![Dependency Status](https://gemnasium.com/sozialhelden/rosemary.png)](https://gemnasium.com/sozialhelden/rosemary)
6
- [![Coverage Status](https://coveralls.io/repos/sozialhelden/rosemary/badge.png)](https://coveralls.io/r/sozialhelden/rosemary)
7
- [![Code Climate](https://codeclimate.com/github/sozialhelden/rosemary.png)](https://codeclimate.com/github/sozialhelden/rosemary)
8
- [![License](http://img.shields.io/license/MIT.png?color=green) ](https://github.com/sozialhelden/rosemary/blob/master/LICENSE)
9
- [![Gittip ](http://img.shields.io/gittip/sozialhelden.png)](https://gittip.com/sozialhelden)
6
+ [![Coverage Status](https://codeclimate.com/github/sozialhelden/rosemary/badges/coverage.svg)](https://codeclimate.com/github/sozialhelden/rosemary/coverage)
7
+ [![Code Climate](https://codeclimate.com/github/sozialhelden/rosemary.svg)](https://codeclimate.com/github/sozialhelden/rosemary)
8
+ [![License](https://img.shields.io/badge/license-MIT-green.svg) ](https://github.com/sozialhelden/rosemary/blob/master/LICENSE)
9
+ [![Gittip ](https://img.shields.io/gittip/sozialhelden.svg)](https://gittip.com/sozialhelden)
10
10
 
11
11
  This ruby gem is an API client for the current OpenStreetMap [API v0.6](http://wiki.openstreetmap.org/wiki/API_v0.6). It provides easy access to OpenStreetMap (OSM) data.
12
12
 
@@ -20,6 +20,7 @@ require 'rosemary/oauth_client'
20
20
  require 'rosemary/parser'
21
21
  require 'rosemary/api'
22
22
  require 'oauth'
23
+ require 'htmlentities'
23
24
 
24
25
  # The Rosemary module just handles class load.
25
26
  module Rosemary
@@ -16,6 +16,10 @@ class Rosemary::Parser < HTTParty::Parser
16
16
  end
17
17
  end
18
18
 
19
+ def coder
20
+ @coder ||= HTMLEntities.new
21
+ end
22
+
19
23
  def xml
20
24
  # instead of using
21
25
  # LibXML::XML::default_substitute_entities = true
@@ -158,7 +162,7 @@ class Rosemary::Parser < HTTParty::Parser
158
162
  if respond_to?(:tag)
159
163
  return unless tag(@context, attr_hash['k'], attr_value['v'])
160
164
  end
161
- @context.tags.merge!(attr_hash['k'] => attr_hash['v'])
165
+ @context.tags.merge!(attr_hash['k'] => coder.decode(attr_hash['v']))
162
166
  end
163
167
 
164
168
  def _member(attr_hash)
@@ -4,6 +4,10 @@ module Rosemary
4
4
  # It is a subclass of Hash.
5
5
  class Tags < Hash
6
6
 
7
+ def coder
8
+ @coder ||= HTMLEntities.new
9
+ end
10
+
7
11
  # Return XML for these tags. This method uses the Builder library.
8
12
  # The only parameter ist the builder object.
9
13
  def to_xml(options = {})
@@ -11,7 +15,7 @@ module Rosemary
11
15
  xml.instruct! unless options[:skip_instruct]
12
16
  each do |key, value|
13
17
  # Remove leading and trailing whitespace from tag values
14
- xml.tag(:k => key, :v => value.strip) unless value.blank?
18
+ xml.tag(:k => key, :v => coder.decode(value.strip)) unless value.blank?
15
19
  end unless empty?
16
20
  end
17
21
 
@@ -1,4 +1,4 @@
1
1
  module Rosemary
2
2
  # The current version of this gem.
3
- VERSION = "0.4.3"
3
+ VERSION = "0.4.4"
4
4
  end
@@ -34,24 +34,26 @@ Gem::Specification.new do |s|
34
34
  s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
35
35
  s.add_runtime_dependency(%q<oauth>, [">= 0.4.7"])
36
36
  s.add_runtime_dependency(%q<activemodel>, [">= 3.0.20"])
37
+ s.add_runtime_dependency(%q<htmlentities>)
37
38
  s.add_development_dependency(%q<rspec>, [">= 2.7"])
38
39
  s.add_development_dependency(%q<webmock>, [">= 1.7"])
39
40
  s.add_development_dependency(%q<rake>, [">= 0.9"])
40
41
  s.add_development_dependency(%q<yard>, [">= 0.8"])
41
42
  s.add_development_dependency(%q<redcarpet>, [">= 2.2.0"])
42
- s.add_development_dependency(%q<coveralls>)
43
+ s.add_development_dependency(%q<codeclimate-test-reporter>)
43
44
  else
44
45
  s.add_dependency(%q<httparty>, ["~> 0.10.0"])
45
46
  s.add_dependency(%q<libxml-ruby>, [">= 2.4.0"])
46
47
  s.add_dependency(%q<builder>, [">= 2.1.2"])
47
48
  s.add_dependency(%q<oauth>, [">= 0.4.7"])
48
49
  s.add_dependency(%q<activemodel>, [">= 3.0.20"])
50
+ s.add_dependency(%q<htmlentities>)
49
51
  s.add_dependency(%q<rspec>, [">= 2.7"])
50
52
  s.add_dependency(%q<webmock>, [">= 1.7"])
51
53
  s.add_dependency(%q<rake>, [">= 0.9"])
52
54
  s.add_dependency(%q<yard>, [">= 0.8"])
53
55
  s.add_dependency(%q<redcarpet>, [">= 2.2.0"])
54
- s.add_dependency(%q<coveralls>)
56
+ s.add_dependency(%q<codeclimate-test-reporter>)
55
57
  end
56
58
  else
57
59
  s.add_dependency(%q<httparty>, ["~> 0.10.0"])
@@ -59,11 +61,12 @@ Gem::Specification.new do |s|
59
61
  s.add_dependency(%q<builder>, [">= 2.1.2"])
60
62
  s.add_dependency(%q<oauth>, [">= 0.4.7"])
61
63
  s.add_dependency(%q<activemodel>, [">= 3.0.20"])
64
+ s.add_dependency(%q<htmlentities>)
62
65
  s.add_dependency(%q<rspec>, [">= 2.7"])
63
66
  s.add_dependency(%q<webmock>, [">= 1.7"])
64
67
  s.add_dependency(%q<rake>, [">= 0.9"])
65
68
  s.add_dependency(%q<yard>, [">= 0.8"])
66
69
  s.add_dependency(%q<redcarpet>, [">= 2.2.0"])
67
- s.add_dependency(%q<coveralls>)
70
+ s.add_dependency(%q<codeclimate-test-reporter>)
68
71
  end
69
72
  end
@@ -104,11 +104,22 @@ describe Node do
104
104
  expect(subject.to_xml).not_to match /k=\"wheelchair\"/
105
105
  end
106
106
 
107
- it "should properly escape ampersands" do
107
+ it "should properly encode ampersands" do
108
108
  subject.name = "foo & bar"
109
109
  expect(subject.to_xml).to match "foo &amp; bar"
110
110
  end
111
111
 
112
+ it "should not double encode ampersands" do
113
+ subject.name = "foo &amp; bar"
114
+ expect(subject.to_xml).to match "foo &amp; bar"
115
+ end
116
+
117
+ it "should fix double encoded ampersands" do
118
+ subject.name = "foo &#38; bar"
119
+ expect(subject.to_xml).to match "foo &amp; bar"
120
+ end
121
+
122
+
112
123
  it "should properly strip leading and trailing whitespace" do
113
124
  subject.name = " Allice and Bob "
114
125
  expect(subject.to_xml).to match "\"Allice and Bob\""
@@ -3,7 +3,21 @@ include Rosemary
3
3
  describe Parser do
4
4
  context "xml" do
5
5
  it "parses ampersands correctly" do
6
+ node_xml =<<-EOF
7
+ <osm>
8
+ <node id="123" lat="51.2" lon="13.4" version="42" changeset="12" user="fred" uid="123" visible="true" timestamp="2005-07-30T14:27:12+01:00">
9
+ <tag k="note" v="Just a node"/>
10
+ <tag k="amenity" v="bar" />
11
+ <tag k="name" v="The rose &amp; the pony" />
12
+ </node>
13
+ </osm>
14
+ EOF
15
+
16
+ n = Parser.call(node_xml, :xml)
17
+ expect(n.name).to eql "The rose & the pony"
18
+ end
6
19
 
20
+ it "parses utf-8 encoded ampersands correctly" do
7
21
  node_xml =<<-EOF
8
22
  <osm>
9
23
  <node id="123" lat="51.2" lon="13.4" version="42" changeset="12" user="fred" uid="123" visible="true" timestamp="2005-07-30T14:27:12+01:00">
@@ -16,9 +30,21 @@ describe Parser do
16
30
 
17
31
  n = Parser.call(node_xml, :xml)
18
32
  expect(n.name).to eql "The rose & the pony"
33
+ end
19
34
 
35
+ it "parses double encoded ampersands correctly" do
36
+ node_xml =<<-EOF
37
+ <osm>
38
+ <node id="123" lat="51.2" lon="13.4" version="42" changeset="12" user="fred" uid="123" visible="true" timestamp="2005-07-30T14:27:12+01:00">
39
+ <tag k="note" v="Just a node"/>
40
+ <tag k="amenity" v="bar" />
41
+ <tag k="name" v="The rose &amp;#38; the pony" />
42
+ </node>
43
+ </osm>
44
+ EOF
20
45
 
21
-
46
+ n = Parser.call(node_xml, :xml)
47
+ expect(n.name).to eql "The rose & the pony"
22
48
  end
23
49
 
24
50
  it "parses empty set of permissions" do
@@ -1,8 +1,8 @@
1
1
  require 'webmock/rspec'
2
2
  require 'rosemary'
3
3
  require 'libxml'
4
- require 'coveralls'
5
- Coveralls.wear!
4
+ require 'codeclimate-test-reporter'
5
+ CodeClimate::TestReporter.start
6
6
 
7
7
  RSpec::Matchers.define :have_xml do |xpath, text|
8
8
  match do |body|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosemary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-19 00:00:00.000000000 Z
12
+ date: 2015-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: 3.0.20
94
+ - !ruby/object:Gem::Dependency
95
+ name: htmlentities
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
94
110
  - !ruby/object:Gem::Dependency
95
111
  name: rspec
96
112
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +188,7 @@ dependencies:
172
188
  - !ruby/object:Gem::Version
173
189
  version: 2.2.0
174
190
  - !ruby/object:Gem::Dependency
175
- name: coveralls
191
+ name: codeclimate-test-reporter
176
192
  requirement: !ruby/object:Gem::Requirement
177
193
  none: false
178
194
  requirements:
@@ -197,6 +213,7 @@ extra_rdoc_files:
197
213
  - LICENSE
198
214
  - README.md
199
215
  files:
216
+ - .codeclimate.yml
200
217
  - .gitignore
201
218
  - .rspec
202
219
  - .ruby-version
@@ -261,7 +278,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
261
278
  version: '0'
262
279
  segments:
263
280
  - 0
264
- hash: 3366646183016379761
281
+ hash: -2160330113018353665
265
282
  required_rubygems_version: !ruby/object:Gem::Requirement
266
283
  none: false
267
284
  requirements: