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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTc3MWYxYWFhYWQwOWI4MjUzOGRhMGE3MGRlNWI0MWExNzk0MDk4NA==
4
+ ZWNiNzZjNjY4MzVhMmNiNTZmOGRhMWEyODE4ZWZkZjM1MGVkYWZjZQ==
5
5
  data.tar.gz: !binary |-
6
- NDM3MGRkYzNiMWEzMmEyNDYxYjg5MmE5Y2ViZjMzN2Y0NGFiZmYyZQ==
6
+ Yjk4MTRiZjdjOTk1ZDQ5YjJjMTA3NzUyM2UyZmNjYmQyYTRkMWRkYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjJhZjQwYjk3ZWQ1NzQ3ZjY2ZTI5ZWUzOWQxYmE1YmVmNTQ4ODc1MDljOGJh
10
- YzhmMTAwZTQ4MGUzMjI0MWRiZGUwZmU4ZjgyZDhiODkyNjM1NmVlODZjYWRl
11
- MTZmZDU1NTNjY2NhMWZmNmM1MjFkMzBmNjliZTg2M2MzZDljNDM=
9
+ ZDg0NjMwZjU4ZWYzMThhOTRmMzQ1MmMyODc4MTQ5YTQwMTJkMGI5MmQyNjQy
10
+ MmNlNTk1ZTI5N2EzOWEzZWZjOTc0Yjk2YWRkYTg0YjlkODQ4NzM4NjMzMDRi
11
+ NTU4MTU1YzRjN2Q3ZjcxYjBmYTUxMTU5MDU2ZDFkN2E4ZTkwOGU=
12
12
  data.tar.gz: !binary |-
13
- MzIyMTJlN2E1NjBhNDUyYjQ0MjdhY2YxYjljNzhmNTNkMWE5OWZmZjViMzcz
14
- ODA5NDQ5N2FhNWE5Y2M1ZTA2YWU0ZTA4YzY2MmE5ZDM4Mjg0MjI4YjY5MGZh
15
- YmM3ODNlZTZjYTk0YjI1YjJjNTY4M2IwNDhjYTRhZGU5MGY5Yjg=
13
+ NWJlMjNhYjEwZTdmMTUyYmU4Y2I2N2U1NzAyZTRmNGQ2ZjBlYzVmYjA1MGZm
14
+ ZmRmNjkwYWYzYTllYTgxYWFiOTI5ZTljYzBkZjMwNTY5NTJjYmFkNWIwOTg1
15
+ OTdkMGZmMGQ2Zjc1MGI4MWE0YjlhN2E1ZGMzN2E0MTk0MTIwNWE=
@@ -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 = {})
@@ -1,3 +1,3 @@
1
1
  module DocumentBuilder
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require "document_builder/version"
2
2
 
3
- require 'time'
3
+ require 'active_support/time'
4
4
  require 'json'
5
5
 
6
6
  require 'document_builder/coercion'
@@ -25,12 +25,13 @@ module Document
25
25
  xpath "item"
26
26
  attribute :title
27
27
  attribute :link
28
- attribute :pub_date, "pubDate", DocumentBuilder::TimeAttribute
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 :published_at, 'wp:post_date_gmt', DocumentBuilder::TimeAttribute
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'
@@ -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 post date' do
32
- expect(subject.published_at).to eq Time.parse("2007-11-17 21:30:51")
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.published_at).to eq nil
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.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-08 00:00:00.000000000 Z
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