contentful-scheduler-custom-build-john 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/Rakefile +2 -0
- data/lib/contentful/scheduler/queue.rb +10 -0
- data/lib/contentful/scheduler/version.rb +1 -1
- data/spec/contentful/scheduler/queue_spec.rb +25 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9effd984ba12b46d9163fb79c6cbc56e3939e5b
|
4
|
+
data.tar.gz: 8990dceef48eaf43bfc1f34db9154a8091c63aef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f9ae6df3be63888b743b8c778e67b06330ff3e93e5de3d5542e6782c7b4ce3f3f81ad6f93928c7818cc15f45f71bbe7723fd61e6102d36e0a4f932db649ebf5
|
7
|
+
data.tar.gz: 6d1694ff1e4d69617ec89a0ca8404027bdc28c9cff78994235aea39fdc010b467607afbfc6af0c59ba4fd20aed471ff21b51e8a1f3958fe6c4df66ade5609158
|
data/example/Rakefile
CHANGED
@@ -15,6 +15,8 @@ config = {
|
|
15
15
|
spaces: {
|
16
16
|
'YOUR_SPACE_ID' => {
|
17
17
|
publish_field: 'publishDate', # It specifies the field ID for your Publish Date in your Content Type
|
18
|
+
is_publish_in_future: false, # If true then for any future publish_field datetime it can schedule already published
|
19
|
+
# content otherwise it will only publish only new content that is never published for future datetime.
|
18
20
|
management_token: 'YOUR_TOKEN'
|
19
21
|
}
|
20
22
|
}
|
@@ -63,6 +63,12 @@ module Contentful
|
|
63
63
|
|
64
64
|
def already_published?(webhook)
|
65
65
|
return true if publish_date(webhook) < Time.now.utc
|
66
|
+
if !webhook_is_publish_in_future(webhook).nil?
|
67
|
+
return false unless webhook.sys.key?('publishedAt')
|
68
|
+
if !webhook.sys['publishedAt'].nil?
|
69
|
+
return Chronic.parse(webhook.sys['publishedAt']).utc < Time.now.utc
|
70
|
+
end
|
71
|
+
end
|
66
72
|
|
67
73
|
false
|
68
74
|
end
|
@@ -91,6 +97,10 @@ module Contentful
|
|
91
97
|
webhook.fields[spaces[webhook.space_id][:publish_field]]
|
92
98
|
end
|
93
99
|
|
100
|
+
def webhook_is_publish_in_future(webhook)
|
101
|
+
webhook.fields[spaces[webhook.space_id][:is_publish_in_future]]
|
102
|
+
end
|
103
|
+
|
94
104
|
private
|
95
105
|
|
96
106
|
def initialize(logger)
|
@@ -24,6 +24,7 @@ describe Contentful::Scheduler::Queue do
|
|
24
24
|
spaces: {
|
25
25
|
'foo' => {
|
26
26
|
publish_field: 'my_field',
|
27
|
+
is_publish_in_future: 'is_publish_in_future',
|
27
28
|
management_token: 'foo'
|
28
29
|
}
|
29
30
|
}
|
@@ -124,6 +125,30 @@ describe Contentful::Scheduler::Queue do
|
|
124
125
|
WebhookDouble.new('bar', 'foo', {'publishedAt' => nil}, {'my_field' => '2099-04-04T22:00:00+00:00'})
|
125
126
|
)).to be_falsey
|
126
127
|
end
|
128
|
+
|
129
|
+
it 'false if sys.publishedAt is present but nil and is_publish_in_future is true' do
|
130
|
+
expect(subject.already_published?(
|
131
|
+
WebhookDouble.new('bar', 'foo', {'publishedAt' => nil}, {'my_field' => '2099-04-04T22:00:00+00:00', 'is_publish_in_future' => true})
|
132
|
+
)).to be_falsey
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'true if sys.publishedAt is in past and is_publish_in_future is true' do
|
136
|
+
expect(subject.already_published?(
|
137
|
+
WebhookDouble.new('bar', 'foo', {'publishedAt' => '2011-04-04T22:00:00+00:00'}, {'my_field' => '2099-04-04T22:00:00+00:00', 'is_publish_in_future' => true})
|
138
|
+
)).to be_truthy
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'false if sys.publishedAt is not present and is_publish_in_future is false' do
|
142
|
+
expect(subject.already_published?(
|
143
|
+
WebhookDouble.new('bar', 'foo', {}, {'my_field' => '2099-04-04T22:00:00+00:00', 'is_publish_in_future' => false})
|
144
|
+
)).to be_falsey
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'true if webhook publish_date is in past and is_publish_in_future is true' do
|
148
|
+
expect(subject.already_published?(
|
149
|
+
WebhookDouble.new('bar', 'foo', {}, {'my_field' => '2011-04-04T22:00:00+00:00', 'is_publish_in_future' => true})
|
150
|
+
)).to be_truthy
|
151
|
+
end
|
127
152
|
end
|
128
153
|
|
129
154
|
describe '#publishable?' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-scheduler-custom-build-john
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.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:
|
11
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contentful-webhook-listener
|