document_builder 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/document_builder.gemspec +2 -0
- data/lib/document_builder/coercion.rb +9 -0
- data/lib/document_builder/version.rb +1 -1
- data/lib/document_builder.rb +1 -1
- data/spec/fixtures/document.rb +3 -2
- data/spec/integration_spec.rb +14 -3
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWNiNzZjNjY4MzVhMmNiNTZmOGRhMWEyODE4ZWZkZjM1MGVkYWZjZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yjk4MTRiZjdjOTk1ZDQ5YjJjMTA3NzUyM2UyZmNjYmQyYTRkMWRkYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDg0NjMwZjU4ZWYzMThhOTRmMzQ1MmMyODc4MTQ5YTQwMTJkMGI5MmQyNjQy
|
10
|
+
MmNlNTk1ZTI5N2EzOWEzZWZjOTc0Yjk2YWRkYTg0YjlkODQ4NzM4NjMzMDRi
|
11
|
+
NTU4MTU1YzRjN2Q3ZjcxYjBmYTUxMTU5MDU2ZDFkN2E4ZTkwOGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWJlMjNhYjEwZTdmMTUyYmU4Y2I2N2U1NzAyZTRmNGQ2ZjBlYzVmYjA1MGZm
|
14
|
+
ZmRmNjkwYWYzYTllYTgxYWFiOTI5ZTljYzBkZjMwNTY5NTJjYmFkNWIwOTg1
|
15
|
+
OTdkMGZmMGQ2Zjc1MGI4MWE0YjlhN2E1ZGMzN2E0MTk0MTIwNWE=
|
data/document_builder.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency 'activesupport'
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
25
|
spec.add_development_dependency "nokogiri", "~> 1.6.6"
|
@@ -45,6 +45,15 @@ module DocumentBuilder
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
class UtcTimeAttribute
|
49
|
+
include Coercion
|
50
|
+
def self.coerce(document)
|
51
|
+
Time.use_zone("UTC") do
|
52
|
+
Time.zone.parse(document.text)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
48
57
|
class ElementAttribute
|
49
58
|
include Coercion
|
50
59
|
def self.call(document, params = {})
|
data/lib/document_builder.rb
CHANGED
data/spec/fixtures/document.rb
CHANGED
@@ -25,12 +25,13 @@ module Document
|
|
25
25
|
xpath "item"
|
26
26
|
attribute :title
|
27
27
|
attribute :link
|
28
|
-
attribute :pub_date, "pubDate", DocumentBuilder::
|
28
|
+
attribute :pub_date, "pubDate", DocumentBuilder::UtcTimeAttribute
|
29
29
|
attribute :creator, "dc:creator"
|
30
30
|
attribute :content, "content:encoded"
|
31
31
|
attribute :excerpt, "excerpt:encoded"
|
32
32
|
attribute :id, "wp:post_id", DocumentBuilder::IntegerAttribute
|
33
|
-
attribute :
|
33
|
+
attribute :post_date, 'wp:post_date', DocumentBuilder::TimeAttribute
|
34
|
+
attribute :post_date_gmt, 'wp:post_date_gmt', DocumentBuilder::UtcTimeAttribute
|
34
35
|
attribute :comment_status, "wp:comment_status"
|
35
36
|
attribute :ping_status, "wp:ping_status"
|
36
37
|
attribute :name, 'wp:post_name'
|
data/spec/integration_spec.rb
CHANGED
@@ -28,8 +28,19 @@ describe Document::Post do
|
|
28
28
|
expect(subject.name).to eq "welcome-to-wrxer-news"
|
29
29
|
end
|
30
30
|
|
31
|
-
it 'has a
|
32
|
-
expect(subject.
|
31
|
+
it 'has a post_date' do
|
32
|
+
expect(subject.post_date).to eq Time.parse("2007-11-17 15:30:51")
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'has a utc post_date_gmt' do
|
36
|
+
expect(subject.post_date_gmt).to eq Time.parse("2007-11-17 21:30:51 UTC")
|
37
|
+
expect(subject.post_date_gmt.utc?).to eq true
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'has a utc pub_date' do
|
41
|
+
expect(subject.pub_date).to eq(
|
42
|
+
Time.parse("Sat, 17 Nov 2007 21:30:51 +0000"))
|
43
|
+
expect(subject.pub_date.utc?).to eq true
|
33
44
|
end
|
34
45
|
|
35
46
|
it 'has a category' do
|
@@ -64,7 +75,7 @@ describe Document::Post do
|
|
64
75
|
end
|
65
76
|
|
66
77
|
it 'returns nil for time' do
|
67
|
-
expect(subject.
|
78
|
+
expect(subject.post_date_gmt).to eq nil
|
68
79
|
end
|
69
80
|
end
|
70
81
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: document_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Schmitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|