jekyll-netlify 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +28 -0
- data/README.md +2 -1
- data/jekyll-netlify.gemspec +2 -3
- data/lib/jekyll/netlify/generator.rb +34 -1
- data/lib/jekyll/netlify/version.rb +2 -1
- data/test/test_netlify.rb +98 -2
- metadata +15 -15
- data/Gemfile.lock +0 -99
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aae431f9d6f5183479bd3d88a753e7805f65802
|
4
|
+
data.tar.gz: c1881d6e1fe8729cdc76c9134c7c4256f0131bfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 639773eb1a7bb2c7458a60ba51f10f2c99b56d23fa748784c02cda6d2ab62c5558e3e0283826c291f66b9dcc4b2f62f75f806929cc1647f3288fbae88b00210b
|
7
|
+
data.tar.gz: 7caca1b0233ba3c338d5f6ce5d3809b2a4e7831b05f473d655612191b81a853f4232e1d2bcd6fd4df92524c9094b0a3c72f12e7af0f48fbfd2c9210dd2aa8f4a
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 2.1
|
4
|
+
Metrics/ClassLength:
|
5
|
+
Exclude:
|
6
|
+
- test/**/*.rb
|
7
|
+
Style/FileName:
|
8
|
+
Exclude:
|
9
|
+
- lib/jekyll-netlify.rb
|
10
|
+
Metrics/MethodLength:
|
11
|
+
Max: 30
|
12
|
+
Metrics/AbcSize:
|
13
|
+
Max: 30
|
14
|
+
Metrics/BlockLength:
|
15
|
+
Exclude:
|
16
|
+
- test/**/*.rb
|
17
|
+
Style/TrailingCommaInLiteral:
|
18
|
+
Enabled: false
|
19
|
+
Style/TrailingCommaInArguments:
|
20
|
+
Enabled: false
|
21
|
+
Style/ClassAndModuleChildren:
|
22
|
+
Enabled: false
|
23
|
+
Style/MultilineTernaryOperator:
|
24
|
+
Enabled: false
|
25
|
+
Style/ConditionalAssignment:
|
26
|
+
Enabled: false
|
27
|
+
Style/GuardClause:
|
28
|
+
Enabled: false
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/jayvdb/jekyll-netlify.svg?branch=master)](https://travis-ci.org/jayvdb/jekyll-netlify)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll-netlify.svg)](https://badge.fury.io/rb/jekyll-netlify)
|
2
3
|
|
3
4
|
# Jekyll::Netlify
|
4
5
|
|
@@ -31,7 +32,7 @@ This plugin adds hash of `site.netlify` containing
|
|
31
32
|
|
32
33
|
- repository_url
|
33
34
|
- branch
|
34
|
-
- pull_request: bool
|
35
|
+
- pull_request: bool (but the next release it will also be the pull_request number when available)
|
35
36
|
- head
|
36
37
|
- commit
|
37
38
|
- context
|
data/jekyll-netlify.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'jekyll/netlify/version'
|
@@ -21,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
21
20
|
spec.add_dependency 'jekyll', '~> 3.0'
|
22
21
|
|
23
22
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
24
|
-
spec.add_development_dependency 'rake'
|
25
|
-
spec.add_development_dependency 'shoulda'
|
26
23
|
spec.add_development_dependency 'mocha'
|
24
|
+
spec.add_development_dependency 'rake'
|
27
25
|
spec.add_development_dependency 'rubocop', '~> 0.41'
|
26
|
+
spec.add_development_dependency 'shoulda'
|
28
27
|
end
|
@@ -32,6 +32,27 @@ module Jekyll
|
|
32
32
|
ENV['PULL_REQUEST'].eql?('true') ? true : false
|
33
33
|
end
|
34
34
|
|
35
|
+
def pull_request_id(env = ENV)
|
36
|
+
branch = env['BRANCH']
|
37
|
+
return false unless branch =~ /^(pull|merge-requests)/
|
38
|
+
|
39
|
+
parts = branch.split(%r{\/})
|
40
|
+
parts[1].to_i
|
41
|
+
end
|
42
|
+
|
43
|
+
def pull_request_url(env = ENV)
|
44
|
+
repository_url = env['REPOSITORY_URL']
|
45
|
+
if repository_url.start_with? 'git@'
|
46
|
+
repository_url = repository_url.tr(':', '/')
|
47
|
+
repository_url = repository_url.gsub('git@', 'https://')
|
48
|
+
end
|
49
|
+
if repository_url.include? 'gitlab'
|
50
|
+
return repository_url + '/merge_requests/' + pull_request_id.to_s
|
51
|
+
elsif repository_url.include? 'github'
|
52
|
+
return repository_url + '/pulls/' + pull_request_id.to_s
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
35
56
|
def webhook?
|
36
57
|
ENV.key?('WEBHOOK_URL')
|
37
58
|
end
|
@@ -40,7 +61,6 @@ module Jekyll
|
|
40
61
|
data = {
|
41
62
|
'repository_url' => env['REPOSITORY_URL'],
|
42
63
|
'branch' => env['BRANCH'],
|
43
|
-
'pull_request' => pull_request?,
|
44
64
|
'head' => env['HEAD'],
|
45
65
|
'commit' => env['COMMIT_REF'],
|
46
66
|
'context' => env['CONTEXT'],
|
@@ -48,6 +68,19 @@ module Jekyll
|
|
48
68
|
'url' => ENV['URL'],
|
49
69
|
'deploy_prime_url' => env['DEPLOY_PRIME_URL'],
|
50
70
|
}
|
71
|
+
if pull_request?
|
72
|
+
id = pull_request_id
|
73
|
+
if id
|
74
|
+
data['pull_request'] = {
|
75
|
+
'id' => id,
|
76
|
+
'url' => pull_request_url,
|
77
|
+
}
|
78
|
+
else
|
79
|
+
data['pull_request'] = true
|
80
|
+
end
|
81
|
+
else
|
82
|
+
data['pull_request'] = false
|
83
|
+
end
|
51
84
|
data['webhook'] = !webhook? ? false : {
|
52
85
|
'title' => env['WEBHOOK_TITLE'],
|
53
86
|
'body' => env['WEBHOOK_BODY'],
|
data/test/test_netlify.rb
CHANGED
@@ -93,7 +93,7 @@ class Jekyll::NetlifyTest < Minitest::Test
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
context 'netlify pull request' do
|
96
|
+
context 'netlify unrecognised pull request' do
|
97
97
|
setup do
|
98
98
|
Jekyll.instance_variable_set(
|
99
99
|
:@logger, Jekyll::LogAdapter.new(Jekyll::Stevenson.new, :error)
|
@@ -102,7 +102,7 @@ class Jekyll::NetlifyTest < Minitest::Test
|
|
102
102
|
ENV.clear
|
103
103
|
|
104
104
|
ENV['URL'] = 'https://example.com'
|
105
|
-
ENV['BRANCH'] = '
|
105
|
+
ENV['BRANCH'] = 'foo/bar'
|
106
106
|
ENV['CONTEXT'] = 'deploy-preview'
|
107
107
|
ENV['PULL_REQUEST'] = 'true'
|
108
108
|
ENV['DEPLOY_URL'] = 'https://578ab634d5d5cf960d620--open-api.netlify.com'
|
@@ -147,6 +147,102 @@ class Jekyll::NetlifyTest < Minitest::Test
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
+
context 'netlify github pull request' do
|
151
|
+
setup do
|
152
|
+
Jekyll.instance_variable_set(
|
153
|
+
:@logger, Jekyll::LogAdapter.new(Jekyll::Stevenson.new, :error)
|
154
|
+
)
|
155
|
+
|
156
|
+
ENV.clear
|
157
|
+
|
158
|
+
ENV['REPOSITORY_URL'] = 'https://github.com/foo/bar'
|
159
|
+
ENV['URL'] = 'https://example.com'
|
160
|
+
ENV['BRANCH'] = 'pull/23/head'
|
161
|
+
ENV['CONTEXT'] = 'deploy-preview'
|
162
|
+
ENV['PULL_REQUEST'] = 'true'
|
163
|
+
ENV['DEPLOY_URL'] = 'https://578ab634d5d5cf960d620--open-api.netlify.com'
|
164
|
+
ENV['DEPLOY_PRIME_URL'] = 'https://beta--open-api.netlify.com'
|
165
|
+
|
166
|
+
config = Jekyll.configuration(
|
167
|
+
source: jekyll_test_site,
|
168
|
+
destination: File.join(jekyll_test_site, '_site'),
|
169
|
+
)
|
170
|
+
@site = Jekyll::Site.new(config)
|
171
|
+
@site.read
|
172
|
+
@site.generate
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'info' do
|
176
|
+
setup do
|
177
|
+
@netlify = @site.config['netlify']
|
178
|
+
end
|
179
|
+
|
180
|
+
should 'be a pull request' do
|
181
|
+
assert_operator @netlify, :has_key?, 'pull_request'
|
182
|
+
assert_instance_of Hash, @netlify['pull_request']
|
183
|
+
end
|
184
|
+
|
185
|
+
should 'have a pull request id' do
|
186
|
+
assert_instance_of Integer, @netlify['pull_request']['id']
|
187
|
+
assert_equal 23, @netlify['pull_request']['id']
|
188
|
+
end
|
189
|
+
|
190
|
+
should 'have a pull request url' do
|
191
|
+
assert_instance_of String, @netlify['pull_request']['url']
|
192
|
+
assert_equal 'https://github.com/foo/bar/pulls/23',
|
193
|
+
@netlify['pull_request']['url']
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context 'netlify gitlab pull request' do
|
199
|
+
setup do
|
200
|
+
Jekyll.instance_variable_set(
|
201
|
+
:@logger, Jekyll::LogAdapter.new(Jekyll::Stevenson.new, :error)
|
202
|
+
)
|
203
|
+
|
204
|
+
ENV.clear
|
205
|
+
|
206
|
+
ENV['REPOSITORY_URL'] = 'git@gitlab.com:foo/bar'
|
207
|
+
ENV['URL'] = 'https://example.com'
|
208
|
+
ENV['BRANCH'] = 'merge-requests/23/head'
|
209
|
+
ENV['CONTEXT'] = 'deploy-preview'
|
210
|
+
ENV['PULL_REQUEST'] = 'true'
|
211
|
+
ENV['DEPLOY_URL'] = 'https://578ab634d5d5cf960d620--open-api.netlify.com'
|
212
|
+
ENV['DEPLOY_PRIME_URL'] = 'https://beta--open-api.netlify.com'
|
213
|
+
|
214
|
+
config = Jekyll.configuration(
|
215
|
+
source: jekyll_test_site,
|
216
|
+
destination: File.join(jekyll_test_site, '_site'),
|
217
|
+
)
|
218
|
+
@site = Jekyll::Site.new(config)
|
219
|
+
@site.read
|
220
|
+
@site.generate
|
221
|
+
end
|
222
|
+
|
223
|
+
context 'info' do
|
224
|
+
setup do
|
225
|
+
@netlify = @site.config['netlify']
|
226
|
+
end
|
227
|
+
|
228
|
+
should 'be a pull request' do
|
229
|
+
assert_operator @netlify, :has_key?, 'pull_request'
|
230
|
+
assert_instance_of Hash, @netlify['pull_request']
|
231
|
+
end
|
232
|
+
|
233
|
+
should 'have a pull request id' do
|
234
|
+
assert_instance_of Integer, @netlify['pull_request']['id']
|
235
|
+
assert_equal 23, @netlify['pull_request']['id']
|
236
|
+
end
|
237
|
+
|
238
|
+
should 'have a pull request url' do
|
239
|
+
assert_instance_of String, @netlify['pull_request']['url']
|
240
|
+
assert_equal 'https://gitlab.com/foo/bar/merge_requests/23',
|
241
|
+
@netlify['pull_request']['url']
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
150
246
|
context 'netlify webhook deploy' do
|
151
247
|
setup do
|
152
248
|
Jekyll.instance_variable_set(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-netlify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Vandenberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: mocha
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,33 +67,33 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '0.41'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '0.41'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: shoulda
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0
|
96
|
+
version: '0'
|
97
97
|
description: Access Netlify environment values in Jekyll templates
|
98
98
|
email:
|
99
99
|
- jayvdb@gmail.com
|
@@ -102,9 +102,9 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
|
+
- ".rubocop.yml"
|
105
106
|
- ".travis.yml"
|
106
107
|
- Gemfile
|
107
|
-
- Gemfile.lock
|
108
108
|
- LICENSE
|
109
109
|
- README.md
|
110
110
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
jekyll-netlify (0.1.0)
|
5
|
-
jekyll (~> 3.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activesupport (5.1.4)
|
11
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (~> 0.7)
|
13
|
-
minitest (~> 5.1)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
addressable (2.5.2)
|
16
|
-
public_suffix (>= 2.0.2, < 4.0)
|
17
|
-
ast (2.3.0)
|
18
|
-
colorator (1.1.0)
|
19
|
-
concurrent-ruby (1.0.5)
|
20
|
-
ffi (1.9.18)
|
21
|
-
forwardable-extended (2.6.0)
|
22
|
-
i18n (0.9.1)
|
23
|
-
concurrent-ruby (~> 1.0)
|
24
|
-
jekyll (3.6.2)
|
25
|
-
addressable (~> 2.4)
|
26
|
-
colorator (~> 1.0)
|
27
|
-
jekyll-sass-converter (~> 1.0)
|
28
|
-
jekyll-watch (~> 1.1)
|
29
|
-
kramdown (~> 1.14)
|
30
|
-
liquid (~> 4.0)
|
31
|
-
mercenary (~> 0.3.3)
|
32
|
-
pathutil (~> 0.9)
|
33
|
-
rouge (>= 1.7, < 3)
|
34
|
-
safe_yaml (~> 1.0)
|
35
|
-
jekyll-sass-converter (1.5.0)
|
36
|
-
sass (~> 3.4)
|
37
|
-
jekyll-watch (1.5.0)
|
38
|
-
listen (~> 3.0)
|
39
|
-
kramdown (1.15.0)
|
40
|
-
liquid (4.0.0)
|
41
|
-
listen (3.1.5)
|
42
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
43
|
-
mercenary (0.3.6)
|
44
|
-
metaclass (0.0.4)
|
45
|
-
minitest (5.10.3)
|
46
|
-
mocha (1.3.0)
|
47
|
-
metaclass (~> 0.0.1)
|
48
|
-
parallel (1.12.0)
|
49
|
-
parser (2.4.0.0)
|
50
|
-
ast (~> 2.2)
|
51
|
-
pathutil (0.16.0)
|
52
|
-
forwardable-extended (~> 2.6)
|
53
|
-
powerpack (0.1.1)
|
54
|
-
public_suffix (3.0.1)
|
55
|
-
rainbow (2.2.2)
|
56
|
-
rake
|
57
|
-
rake (12.2.1)
|
58
|
-
rb-fsevent (0.10.2)
|
59
|
-
rb-inotify (0.9.10)
|
60
|
-
ffi (>= 0.5.0, < 2)
|
61
|
-
rouge (2.2.1)
|
62
|
-
rubocop (0.51.0)
|
63
|
-
parallel (~> 1.10)
|
64
|
-
parser (>= 2.3.3.1, < 3.0)
|
65
|
-
powerpack (~> 0.1)
|
66
|
-
rainbow (>= 2.2.2, < 3.0)
|
67
|
-
ruby-progressbar (~> 1.7)
|
68
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
69
|
-
ruby-progressbar (1.9.0)
|
70
|
-
safe_yaml (1.0.4)
|
71
|
-
sass (3.5.3)
|
72
|
-
sass-listen (~> 4.0.0)
|
73
|
-
sass-listen (4.0.0)
|
74
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
75
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
76
|
-
shoulda (3.5.0)
|
77
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
78
|
-
shoulda-matchers (>= 1.4.1, < 3.0)
|
79
|
-
shoulda-context (1.2.2)
|
80
|
-
shoulda-matchers (2.8.0)
|
81
|
-
activesupport (>= 3.0.0)
|
82
|
-
thread_safe (0.3.6)
|
83
|
-
tzinfo (1.2.4)
|
84
|
-
thread_safe (~> 0.1)
|
85
|
-
unicode-display_width (1.3.0)
|
86
|
-
|
87
|
-
PLATFORMS
|
88
|
-
ruby
|
89
|
-
|
90
|
-
DEPENDENCIES
|
91
|
-
bundler (~> 1.6)
|
92
|
-
jekyll-netlify!
|
93
|
-
mocha
|
94
|
-
rake
|
95
|
-
rubocop (~> 0.41)
|
96
|
-
shoulda
|
97
|
-
|
98
|
-
BUNDLED WITH
|
99
|
-
1.16.0
|