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 +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/contentful-scheduler.gemspec +1 -0
- data/lib/contentful/scheduler/queue.rb +5 -4
- data/lib/contentful/scheduler/version.rb +1 -1
- data/spec/contentful/scheduler/queue_spec.rb +16 -4
- data/spec/spec_helper.rb +7 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14dd6e0b1a4ab640ac6dc86da32aaf78dd662b24
|
4
|
+
data.tar.gz: b29d84702d42a542f8e19dcb2702e47fc87cf6d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '087d6c529736e060a0a9b5994a0399459907030276ae1bc5d6654f5fb44b178ebbc086f1e472bf3b629c0d51fa247dfeab587b6dfc609201acfd8acb021c61f6'
|
7
|
+
data.tar.gz: 62eb5b0c1828c8e6d323d0b595dc684a20ea80b4f2cde62d716671373d5d1c9dd8375919c80762bff5ccada05dd8a88c67972964ef51ed3954a067254808d541
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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)
|
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) <
|
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
|
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
|
-
|
84
|
+
Chronic.parse(date_field).utc
|
84
85
|
end
|
85
86
|
|
86
87
|
def spaces
|
@@ -82,10 +82,22 @@ describe Contentful::Scheduler::Queue do
|
|
82
82
|
)).to eq 'something'
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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.
|
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-
|
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.
|
234
|
+
rubygems_version: 2.6.14
|
221
235
|
signing_key:
|
222
236
|
specification_version: 4
|
223
237
|
summary: Customizable Scheduler for Contentful Entries.
|