contentful-scheduler 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6c1e89296a0e023ab7a1965e8d4e61227f50a7e
4
- data.tar.gz: 1b88d27deb5cff6083fd1806ab6ee20cf73e3678
3
+ metadata.gz: 14dd6e0b1a4ab640ac6dc86da32aaf78dd662b24
4
+ data.tar.gz: b29d84702d42a542f8e19dcb2702e47fc87cf6d1
5
5
  SHA512:
6
- metadata.gz: 6ff9efe84ab5612b5d4aeabfe8193968cd15cb4745a6f5e55bd4761ce2cd3e27f7ae7473641ca848fffa564c4036ab17689373ba6dec12142feff88390cc27b5
7
- data.tar.gz: 5f1e89b67d58bbf5f8772c749846cb98908425e2a5387990670c96f65e69cd1d04745c26eeee3d7fd3c57db00d40d84852760e71eb8beac053f9626aeb9c3e2b
6
+ metadata.gz: '087d6c529736e060a0a9b5994a0399459907030276ae1bc5d6654f5fb44b178ebbc086f1e472bf3b629c0d51fa247dfeab587b6dfc609201acfd8acb021c61f6'
7
+ data.tar.gz: 62eb5b0c1828c8e6d323d0b595dc684a20ea80b4f2cde62d716671373d5d1c9dd8375919c80762bff5ccada05dd8a88c67972964ef51ed3954a067254808d541
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.3
4
+ - 2.3.1
5
+ - 2.4.0
4
6
  before_install: gem install bundler -v 1.10.6
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.2.1
6
+
7
+ ### Fixed
8
+ * Fix time parsing.
9
+
5
10
  ## 0.2.0
6
11
 
7
12
  ### Added
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency "resque", "~> 1.0"
25
25
  spec.add_runtime_dependency "resque-scheduler", "~> 4.0"
26
26
  spec.add_runtime_dependency "redis", "~> 3.0"
27
+ spec.add_runtime_dependency "chronic", "~> 0.10"
27
28
 
28
29
  spec.add_development_dependency "bundler", "~> 1.10"
29
30
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,4 +1,5 @@
1
1
  require_relative "tasks"
2
+ require 'chronic'
2
3
  require 'contentful/webhook/listener'
3
4
 
4
5
  module Contentful
@@ -18,7 +19,7 @@ module Contentful
18
19
  return if already_published?(webhook)
19
20
 
20
21
  success = Resque.enqueue_at(
21
- publish_date(webhook).to_time.utc,
22
+ publish_date(webhook),
22
23
  ::Contentful::Scheduler::Tasks::Publish,
23
24
  webhook.space_id,
24
25
  webhook.id,
@@ -61,11 +62,11 @@ module Contentful
61
62
  end
62
63
 
63
64
  def already_published?(webhook)
64
- return true if publish_date(webhook) < DateTime.now
65
+ return true if publish_date(webhook) < Time.now.utc
65
66
  return false unless webhook.sys.key?('publishedAt')
66
67
 
67
68
  if !webhook.sys['publishedAt'].nil?
68
- return DateTime.strptime(webhook.sys['publishedAt']).to_time.utc < DateTime.now.to_time.utc
69
+ return Chronic.parse(webhook.sys['publishedAt']).utc < Time.now.utc
69
70
  end
70
71
 
71
72
  false
@@ -80,7 +81,7 @@ module Contentful
80
81
  def publish_date(webhook)
81
82
  date_field = webhook_publish_field(webhook)
82
83
  date_field = date_field[date_field.keys[0]] if date_field.is_a? Hash
83
- DateTime.strptime(date_field)
84
+ Chronic.parse(date_field).utc
84
85
  end
85
86
 
86
87
  def spaces
@@ -1,5 +1,5 @@
1
1
  module Contentful
2
2
  module Scheduler
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -82,10 +82,22 @@ describe Contentful::Scheduler::Queue do
82
82
  )).to eq 'something'
83
83
  end
84
84
 
85
- it '#publish_date' do
86
- expect(subject.publish_date(
87
- WebhookDouble.new('bar', 'foo', {}, {'my_field' => '2011-04-04T22:00:00+00:00'})
88
- )).to eq DateTime.new(2011, 4, 4, 22, 0, 0)
85
+ describe '#publish_date' do
86
+ it 'works if date field not localized' do
87
+ expect(subject.publish_date(
88
+ WebhookDouble.new('bar', 'foo', {}, {'my_field' => '2011-04-04T22:00:00+00:00'})
89
+ )).to eq DateTime.new(2011, 4, 4, 22, 0, 0).to_time.utc
90
+ end
91
+
92
+ it 'works if date field localized by grabbing first available locale' do
93
+ expect(subject.publish_date(
94
+ WebhookDouble.new('bar', 'foo', {}, {'my_field' => {'en-US': '2011-04-04T22:00:00+00:00'}})
95
+ )).to eq DateTime.new(2011, 4, 4, 22, 0, 0).to_time.utc
96
+
97
+ expect(subject.publish_date(
98
+ WebhookDouble.new('bar', 'foo', {}, {'my_field' => {'en-CA': '2011-04-04T23:00:00Z'}})
99
+ )).to eq DateTime.new(2011, 4, 4, 23, 0, 0).to_time.utc
100
+ end
89
101
  end
90
102
 
91
103
  describe '#already_published?' do
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'simplecov'
2
2
  SimpleCov.start
3
3
 
4
+ require 'rspec'
5
+
4
6
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
7
  require 'contentful/scheduler'
6
8
  require 'contentful/webhook/listener'
@@ -51,3 +53,8 @@ class Contentful::Webhook::Listener::Controllers::Wait
51
53
  value
52
54
  end
53
55
  end
56
+
57
+ RSpec.configure do |config|
58
+ config.filter_run :focus => true
59
+ config.run_all_when_everything_filtered = true
60
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentful-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentful GmbH (David Litvak Bruno0
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-19 00:00:00.000000000 Z
11
+ date: 2017-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contentful-webhook-listener
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: chronic
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
231
  version: '0'
218
232
  requirements: []
219
233
  rubyforge_project:
220
- rubygems_version: 2.5.1
234
+ rubygems_version: 2.6.14
221
235
  signing_key:
222
236
  specification_version: 4
223
237
  summary: Customizable Scheduler for Contentful Entries.