microformats2 2.0.0 → 2.0.1
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.
- checksums.yaml +8 -8
- data/README.md +2 -1
- data/lib/microformats2.rb +1 -0
- data/lib/microformats2/absolute_uri.rb +26 -0
- data/lib/microformats2/collection.rb +2 -13
- data/lib/microformats2/implied_property/url.rb +1 -13
- data/lib/microformats2/property/url.rb +1 -13
- data/lib/microformats2/version.rb +1 -1
- data/microformats2.gemspec +2 -2
- data/spec/lib/microformats2/absolute_uri_spec.rb +48 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDc5YzFkOTExNDgwZTEwM2U2YjVlMTM1YmVlYjExZTA1ZTRkYmQ3Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGU4ZmI0YWI3YjBiNGM4M2Q1M2U3MGFhMTRhYjMxMTc4ZDE3NGEzNg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yzg5MjdhODY1Yjc0OWY1YjJlNmY0MzY0YTY3OTliMTY4MGZiYjQyMmJlMjNj
|
10
|
+
NTk4MjEzYjYwZTBlYWYxNTA5OTNlNzcyNDA2OWZhYTY4MDZiNmZlNzdlZGY0
|
11
|
+
ZGMwNThlYmU0OTk5NGJlN2Y1MzQzMjFmOWE4Y2E2MTc5MWE5Yjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Yjk5Zjk2YzFlNmI0OWRlYzdjMzFkYzFhZThmYzAwMzcxMTA4YzQ1ZTgxYTgx
|
14
|
+
OWIwMWU0NWZmODExMzI3ZWIxODE3YmU0MTJmMWQ4MzQ1ZTk1ZmNmYmQyMmQ2
|
15
|
+
N2Y2NzRkZDU1NTUwNTZmZmY4ZGM1MjQ4ZjZmYWIyNjkwY2ExNmM=
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ Not Implemented:
|
|
33
33
|
|
34
34
|
## Current Version
|
35
35
|
|
36
|
-
2.0.
|
36
|
+
2.0.1
|
37
37
|
|
38
38
|
|
39
39
|
## Requirements
|
@@ -88,6 +88,7 @@ collection.entry.author.format.name.to_s #=> "Jessica Lynn Suttles"
|
|
88
88
|
* Shane Becker / [@veganstraightedge](https://github.com/veganstraightedge)
|
89
89
|
* Chris Stringer / [@jcstringer](https://github.com/jcstringer)
|
90
90
|
* Michael Mitchell / [@variousred](https://github.com/variousred)
|
91
|
+
* Jessica Dillon / [@jessicard](https://github.com/jessicard)
|
91
92
|
|
92
93
|
## Contributions
|
93
94
|
|
data/lib/microformats2.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Microformats2
|
2
|
+
class AbsoluteUri
|
3
|
+
attr_accessor :base, :relative
|
4
|
+
|
5
|
+
def initialize(base, relative)
|
6
|
+
@base = base
|
7
|
+
@relative = relative
|
8
|
+
end
|
9
|
+
|
10
|
+
def absolutize
|
11
|
+
return nil if relative.nil? or relative == ""
|
12
|
+
|
13
|
+
uri = URI.parse(relative)
|
14
|
+
|
15
|
+
if base && !uri.absolute?
|
16
|
+
uri = URI.join(base.to_s, relative.to_s)
|
17
|
+
end
|
18
|
+
|
19
|
+
uri.normalize!
|
20
|
+
uri.to_s
|
21
|
+
|
22
|
+
rescue URI::BadURIError, URI::InvalidURIError => e
|
23
|
+
relative.to_s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -88,7 +88,7 @@ module Microformats2
|
|
88
88
|
|
89
89
|
if rel_values.member?("alternate")
|
90
90
|
alternate_inst = {}
|
91
|
-
alternate_inst["url"] =
|
91
|
+
alternate_inst["url"] = Microformats2::AbsoluteUri.new(@base, rel.attribute("href").text).absolutize
|
92
92
|
alternate_inst["rel"] = (rel_values - ["alternate"]).join(" ")
|
93
93
|
unless rel.attribute("media").nil?
|
94
94
|
alternate_inst["media"] = rel.attribute("media").text
|
@@ -103,21 +103,10 @@ module Microformats2
|
|
103
103
|
else
|
104
104
|
rel_values.each do |rel_value|
|
105
105
|
@rels[rel_value] = [] unless @rels.has_key?(rel_value)
|
106
|
-
@rels[rel_value] <<
|
106
|
+
@rels[rel_value] << Microformats2::AbsoluteUri.new(@base, rel.attribute("href").text).absolutize
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
111
|
-
|
112
|
-
def absolutize(href)
|
113
|
-
uri = URI.parse(href)
|
114
|
-
|
115
|
-
if @base && !uri.absolute?
|
116
|
-
uri = URI.join(@base, href)
|
117
|
-
end
|
118
|
-
|
119
|
-
uri.normalize!
|
120
|
-
uri.to_s
|
121
|
-
end
|
122
111
|
end
|
123
112
|
end
|
@@ -7,19 +7,7 @@ module Microformats2
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def to_s
|
10
|
-
@to_s =
|
11
|
-
end
|
12
|
-
|
13
|
-
# TODO: make dry, repeated in Collection
|
14
|
-
def absolutize(href)
|
15
|
-
uri = URI.parse(href)
|
16
|
-
|
17
|
-
if @base && !uri.absolute?
|
18
|
-
uri = URI.join(@base, href)
|
19
|
-
end
|
20
|
-
|
21
|
-
uri.normalize!
|
22
|
-
uri.to_s
|
10
|
+
@to_s = Microformats2::AbsoluteUri.new(@base, super.to_s).absolutize
|
23
11
|
end
|
24
12
|
|
25
13
|
protected
|
@@ -3,19 +3,7 @@ module Microformats2
|
|
3
3
|
class Url < Foundation
|
4
4
|
|
5
5
|
def to_s
|
6
|
-
@to_s =
|
7
|
-
end
|
8
|
-
|
9
|
-
# TODO: make dry, repeated in Collection
|
10
|
-
def absolutize(href)
|
11
|
-
uri = URI.parse(href)
|
12
|
-
|
13
|
-
if @base && !uri.absolute?
|
14
|
-
uri = URI.join(@base, href)
|
15
|
-
end
|
16
|
-
|
17
|
-
uri.normalize!
|
18
|
-
uri.to_s
|
6
|
+
@to_s = Microformats2::AbsoluteUri.new(@base, super.to_s).absolutize
|
19
7
|
end
|
20
8
|
|
21
9
|
protected
|
data/microformats2.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'microformats2/version'
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "microformats2"
|
8
8
|
gem.version = Microformats2::VERSION
|
9
|
-
gem.authors = ["Jessica Lynn Suttles"]
|
10
|
-
gem.email = ["jlsuttles@gmail.com"]
|
9
|
+
gem.authors = ["Jessica Lynn Suttles", "Jessica Dillon"]
|
10
|
+
gem.email = ["jlsuttles@gmail.com", "jessicard@mac.com"]
|
11
11
|
gem.description = %q{parses HTML for microformats and return a collection of dynamically defined Ruby objects}
|
12
12
|
gem.summary = %q{microformats2 parser}
|
13
13
|
gem.homepage = "https://github.com/G5/microformats2"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "microformats2/absolute_uri"
|
3
|
+
|
4
|
+
describe Microformats2::AbsoluteUri do
|
5
|
+
describe "#absolutize" do
|
6
|
+
subject { Microformats2::AbsoluteUri.new(base, relative).absolutize }
|
7
|
+
let(:base) { nil }
|
8
|
+
|
9
|
+
context "when relative is nil" do
|
10
|
+
let(:relative) { nil }
|
11
|
+
it { should be_nil }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when relative is an empty string" do
|
15
|
+
let(:relative) { "" }
|
16
|
+
it { should be_nil }
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when relative is a valid absolute URI" do
|
20
|
+
let(:relative) { "http://google.com" }
|
21
|
+
it { should eq("http://google.com/") }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when relative is a valid non-absolute URI" do
|
25
|
+
let(:relative) { "bar/qux" }
|
26
|
+
|
27
|
+
context "and base is present but not absolute" do
|
28
|
+
let(:base) { "foo" }
|
29
|
+
it { should eq("bar/qux") }
|
30
|
+
end
|
31
|
+
|
32
|
+
context "and base is present and absolute" do
|
33
|
+
let(:base) { "http://google.com" }
|
34
|
+
it { should eq("http://google.com/bar/qux") }
|
35
|
+
end
|
36
|
+
|
37
|
+
context "and base is not present" do
|
38
|
+
let(:base) { nil }
|
39
|
+
it { should eq("bar/qux") }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "when relative is an invalid URI" do
|
44
|
+
let(:relative) { "git@github.com:G5/microformats2.git" }
|
45
|
+
it { should eq("git@github.com:G5/microformats2.git") }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: microformats2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jessica Lynn Suttles
|
8
|
+
- Jessica Dillon
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: nokogiri
|
@@ -140,6 +141,7 @@ description: parses HTML for microformats and return a collection of dynamically
|
|
140
141
|
Ruby objects
|
141
142
|
email:
|
142
143
|
- jlsuttles@gmail.com
|
144
|
+
- jessicard@mac.com
|
143
145
|
executables: []
|
144
146
|
extensions: []
|
145
147
|
extra_rdoc_files: []
|
@@ -153,6 +155,7 @@ files:
|
|
153
155
|
- README.md
|
154
156
|
- Rakefile
|
155
157
|
- lib/microformats2.rb
|
158
|
+
- lib/microformats2/absolute_uri.rb
|
156
159
|
- lib/microformats2/collection.rb
|
157
160
|
- lib/microformats2/format.rb
|
158
161
|
- lib/microformats2/format_parser.rb
|
@@ -170,6 +173,7 @@ files:
|
|
170
173
|
- lib/microformats2/property_parser.rb
|
171
174
|
- lib/microformats2/version.rb
|
172
175
|
- microformats2.gemspec
|
176
|
+
- spec/lib/microformats2/absolute_uri_spec.rb
|
173
177
|
- spec/lib/microformats2/collection_spec.rb
|
174
178
|
- spec/lib/microformats2/implied_property/name_spec.rb
|
175
179
|
- spec/lib/microformats2/implied_property/photo_spec.rb
|
@@ -372,6 +376,7 @@ signing_key:
|
|
372
376
|
specification_version: 4
|
373
377
|
summary: microformats2 parser
|
374
378
|
test_files:
|
379
|
+
- spec/lib/microformats2/absolute_uri_spec.rb
|
375
380
|
- spec/lib/microformats2/collection_spec.rb
|
376
381
|
- spec/lib/microformats2/implied_property/name_spec.rb
|
377
382
|
- spec/lib/microformats2/implied_property/photo_spec.rb
|