jekyll-remote-theme 0.3.0 → 0.4.3

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
  SHA256:
3
- metadata.gz: e39b39cafa24a34892141eb0d7d386988faa47a922a50195eb33458f0ec5cb18
4
- data.tar.gz: 3ebfdb2d308084fabce1d92a5eba50fde22aa1be8cd742a7c44bcd9bc5f75e33
3
+ metadata.gz: 4c9167cea38476d7fc4ef44836e821cb07d5bcabb665e834a8df9f1cae315b70
4
+ data.tar.gz: 28698c0255ba7c3b9b85758e7ed52c899ffbdd49460064513d8a28a19d174b49
5
5
  SHA512:
6
- metadata.gz: dfc7198186058021058cfcd85b34330fb1b8df153cc6ee2ae5ac280afac7e21a26e0c3257c8285890a676c9b14f600bdf1a8bf893997cf1370e95279353f0271
7
- data.tar.gz: 93f287e3f8455eef42f66595d97e11b55aa378e2bda0e94cb644793d2ceb8429d71ab094d097d36aa036f59b4ade98c4f5af6b39cead00064939c684c003e946
6
+ metadata.gz: 5c9f12811ead638abbb9022f63221ef49fd6bd2f743e42d58645431aa0565946b74324131710d76ed9567adc812b316425f47e41c55ba379a4073f7812ec5b0a
7
+ data.tar.gz: 4ae168e2f471af7bfa0cdc39a479f3bb05fe4420d30a3036206f29b50f49f267004fa8ac4deaa4da26f887eae3f3b5e38b521cb189ed479d5262aa289d33dc11
@@ -19,9 +19,9 @@ module Jekyll
19
19
  autoload :Theme, "jekyll-remote-theme/theme"
20
20
  autoload :VERSION, "jekyll-remote-theme/version"
21
21
 
22
- CONFIG_KEY = "remote_theme".freeze
23
- LOG_KEY = "Remote Theme:".freeze
24
- TEMP_PREFIX = "jekyll-remote-theme-".freeze
22
+ CONFIG_KEY = "remote_theme"
23
+ LOG_KEY = "Remote Theme:"
24
+ TEMP_PREFIX = "jekyll-remote-theme-"
25
25
 
26
26
  def self.init(site)
27
27
  Munger.new(site).munge!
@@ -3,18 +3,14 @@
3
3
  module Jekyll
4
4
  module RemoteTheme
5
5
  class Downloader
6
- HOST = "https://codeload.github.com".freeze
7
- PROJECT_URL = "https://github.com/benbalter/jekyll-remote-theme".freeze
8
- USER_AGENT = "Jekyll Remote Theme/#{VERSION} (+#{PROJECT_URL})".freeze
6
+ PROJECT_URL = "https://github.com/benbalter/jekyll-remote-theme"
7
+ USER_AGENT = "Jekyll Remote Theme/#{VERSION} (+#{PROJECT_URL})"
9
8
  MAX_FILE_SIZE = 1 * (1024 * 1024 * 1024) # Size in bytes (1 GB)
10
9
  NET_HTTP_ERRORS = [
11
- Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
10
+ Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::OpenTimeout,
12
11
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
13
12
  ].freeze
14
13
 
15
- attr_reader :theme
16
- private :theme
17
-
18
14
  def initialize(theme)
19
15
  @theme = theme
20
16
  end
@@ -35,6 +31,8 @@ module Jekyll
35
31
 
36
32
  private
37
33
 
34
+ attr_reader :theme
35
+
38
36
  def zip_file
39
37
  @zip_file ||= Tempfile.new([TEMP_PREFIX, ".zip"], :binmode => true)
40
38
  end
@@ -57,6 +55,7 @@ module Jekyll
57
55
 
58
56
  def request
59
57
  return @request if defined? @request
58
+
60
59
  @request = Net::HTTP::Get.new zip_url.request_uri
61
60
  @request["User-Agent"] = USER_AGENT
62
61
  @request
@@ -64,11 +63,13 @@ module Jekyll
64
63
 
65
64
  def raise_unless_sucess(response)
66
65
  return if response.is_a?(Net::HTTPSuccess)
67
- raise DownloadError, "#{response.code} - #{response.message}"
66
+
67
+ raise DownloadError, "#{response.code} - #{response.message} - Loading URL: #{zip_url}"
68
68
  end
69
69
 
70
70
  def enforce_max_file_size(size)
71
71
  return unless size && size > MAX_FILE_SIZE
72
+
72
73
  raise DownloadError, "Maximum file size of #{MAX_FILE_SIZE} bytes exceeded"
73
74
  end
74
75
 
@@ -88,8 +89,10 @@ module Jekyll
88
89
 
89
90
  # Full URL to codeload zip download endpoint for the given theme
90
91
  def zip_url
91
- @zip_url ||= Addressable::URI.join(
92
- HOST, "#{theme.owner}/", "#{theme.name}/", "zip/", theme.git_ref
92
+ @zip_url ||= Addressable::URI.new(
93
+ :scheme => theme.scheme,
94
+ :host => "codeload.#{theme.host}",
95
+ :path => [theme.owner, theme.name, "zip", theme.git_ref].join("/")
93
96
  ).normalize
94
97
  end
95
98
 
@@ -9,8 +9,8 @@ module Jekyll
9
9
  extend Forwardable
10
10
  def_delegator :theme, :root, :full_gem_path
11
11
 
12
- DEPENDENCY_PREFIX = %r!^\s*[a-z]+\.add_(?:runtime_)?dependency!
13
- DEPENDENCY_REGEX = %r!#{DEPENDENCY_PREFIX}\(?\s*["']([a-z_-]+)["']!
12
+ DEPENDENCY_PREFIX = %r!^\s*[a-z]+\.add_(?:runtime_)?dependency!.freeze
13
+ DEPENDENCY_REGEX = %r!#{DEPENDENCY_PREFIX}\(?\s*["']([a-z_-]+)["']!.freeze
14
14
 
15
15
  def initialize(theme)
16
16
  @theme = theme
@@ -20,10 +20,10 @@ module Jekyll
20
20
  end
21
21
 
22
22
  Jekyll.logger.info LOG_KEY, "Using theme #{theme.name_with_owner}"
23
- return theme if munged?
24
-
25
- downloader.run
26
- configure_theme
23
+ unless munged?
24
+ downloader.run
25
+ configure_theme
26
+ end
27
27
  enqueue_theme_cleanup
28
28
 
29
29
  theme
@@ -32,7 +32,7 @@ module Jekyll
32
32
  private
33
33
 
34
34
  def munged?
35
- site.theme && site.theme.is_a?(Jekyll::RemoteTheme::Theme)
35
+ site.theme&.is_a?(Jekyll::RemoteTheme::Theme)
36
36
  end
37
37
 
38
38
  def theme
@@ -49,16 +49,16 @@ module Jekyll
49
49
 
50
50
  def configure_theme
51
51
  return unless theme
52
+
52
53
  site.config["theme"] = theme.name
53
54
  site.theme = theme
54
- site.theme.configure_sass
55
+ site.theme.configure_sass if site.theme.respond_to?(:configure_sass)
55
56
  site.send(:configure_include_paths)
56
57
  site.plugin_manager.require_theme_deps
57
58
  end
58
59
 
59
60
  def enqueue_theme_cleanup
60
61
  at_exit do
61
- return unless munged? && downloader.downloaded?
62
62
  Jekyll.logger.debug LOG_KEY, "Cleaning up #{theme.root}"
63
63
  FileUtils.rm_rf theme.root
64
64
  end
@@ -3,10 +3,10 @@
3
3
  module Jekyll
4
4
  module RemoteTheme
5
5
  class Theme < Jekyll::Theme
6
- OWNER_REGEX = %r!(?<owner>[a-z0-9\-]+)!i
7
- NAME_REGEX = %r!(?<name>[a-z0-9\._\-]+)!i
8
- REF_REGEX = %r!@(?<ref>[a-z0-9\._\-]+)!i # May be a branch, tag, or commit
9
- THEME_REGEX = %r!\A#{OWNER_REGEX}/#{NAME_REGEX}(?:#{REF_REGEX})?\z!i
6
+ OWNER_REGEX = %r!(?<owner>[a-z0-9\-]+)!i.freeze
7
+ NAME_REGEX = %r!(?<name>[a-z0-9\._\-]+)!i.freeze
8
+ REF_REGEX = %r!@(?<ref>[a-z0-9\._\-]+)!i.freeze # May be a branch, tag, or commit
9
+ THEME_REGEX = %r!\A#{OWNER_REGEX}/#{NAME_REGEX}(?:#{REF_REGEX})?\z!i.freeze
10
10
 
11
11
  # Initializes a new Jekyll::RemoteTheme::Theme
12
12
  #
@@ -14,6 +14,10 @@ module Jekyll
14
14
  #
15
15
  # 1. owner/theme-name - a GitHub owner + theme-name string
16
16
  # 2. owner/theme-name@git_ref - a GitHub owner + theme-name + Git ref string
17
+ # 3. http[s]://github.<yourEnterprise>.com/owner/theme-name
18
+ # - An enterprise GitHub instance + a GitHub owner + a theme-name string
19
+ # 4. http[s]://github.<yourEnterprise>.com/owner/theme-name@git_ref
20
+ # - An enterprise GitHub instance + a GitHub owner + a theme-name + Git ref string
17
21
  def initialize(raw_theme)
18
22
  @raw_theme = raw_theme.to_s.downcase.strip
19
23
  super(@raw_theme)
@@ -27,17 +31,27 @@ module Jekyll
27
31
  theme_parts[:owner]
28
32
  end
29
33
 
34
+ def host
35
+ uri&.host
36
+ end
37
+
38
+ def scheme
39
+ uri&.scheme
40
+ end
41
+
30
42
  def name_with_owner
31
43
  [owner, name].join("/")
32
44
  end
33
45
  alias_method :nwo, :name_with_owner
34
46
 
35
47
  def valid?
36
- theme_parts && name && owner
48
+ return false unless uri && theme_parts && name && owner
49
+
50
+ host && valid_hosts.include?(host)
37
51
  end
38
52
 
39
53
  def git_ref
40
- theme_parts[:ref] || "master"
54
+ theme_parts[:ref] || "HEAD"
41
55
  end
42
56
 
43
57
  def root
@@ -45,19 +59,43 @@ module Jekyll
45
59
  end
46
60
 
47
61
  def inspect
48
- "#<Jekyll::RemoteTheme::Theme owner=\"#{owner}\" name=\"#{name}\"" \
62
+ "#<Jekyll::RemoteTheme::Theme host=\"#{host}\" owner=\"#{owner}\" name=\"#{name}\"" \
49
63
  " ref=\"#{git_ref}\" root=\"#{root}\">"
50
64
  end
51
65
 
52
66
  private
53
67
 
68
+ def uri
69
+ return @uri if defined? @uri
70
+
71
+ @uri = if THEME_REGEX.match?(@raw_theme)
72
+ Addressable::URI.new(
73
+ :scheme => "https",
74
+ :host => "github.com",
75
+ :path => @raw_theme
76
+ )
77
+ else
78
+ Addressable::URI.parse @raw_theme
79
+ end
80
+ rescue Addressable::URI::InvalidURIError
81
+ @uri = nil
82
+ end
83
+
54
84
  def theme_parts
55
- @theme_parts ||= @raw_theme.match(THEME_REGEX)
85
+ @theme_parts ||= uri.path[1..-1].match(THEME_REGEX) if uri
56
86
  end
57
87
 
58
88
  def gemspec
59
89
  @gemspec ||= MockGemspec.new(self)
60
90
  end
91
+
92
+ def valid_hosts
93
+ @valid_hosts ||= [
94
+ "github.com",
95
+ ENV["PAGES_GITHUB_HOSTNAME"],
96
+ ENV["GITHUB_HOSTNAME"],
97
+ ].compact.to_set
98
+ end
61
99
  end
62
100
  end
63
101
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module RemoteTheme
5
- VERSION = "0.3.0".freeze
5
+ VERSION = "0.4.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,36 +1,82 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-remote-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Balter
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: jekyll
14
+ name: addressable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.5'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jekyll
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.5'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '5.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
25
42
  - !ruby/object:Gem::Version
26
43
  version: '3.5'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '5.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: jekyll-sass-converter
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ - - "<="
55
+ - !ruby/object:Gem::Version
56
+ version: 3.0.0
57
+ - - "!="
58
+ - !ruby/object:Gem::Version
59
+ version: 2.0.0
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '1.0'
67
+ - - "<="
68
+ - !ruby/object:Gem::Version
69
+ version: 3.0.0
70
+ - - "!="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.0.0
27
73
  - !ruby/object:Gem::Dependency
28
74
  name: rubyzip
29
75
  requirement: !ruby/object:Gem::Requirement
30
76
  requirements:
31
77
  - - ">="
32
78
  - !ruby/object:Gem::Version
33
- version: 1.2.1
79
+ version: 1.3.0
34
80
  - - "<"
35
81
  - !ruby/object:Gem::Version
36
82
  version: '3.0'
@@ -40,7 +86,7 @@ dependencies:
40
86
  requirements:
41
87
  - - ">="
42
88
  - !ruby/object:Gem::Version
43
- version: 1.2.1
89
+ version: 1.3.0
44
90
  - - "<"
45
91
  - !ruby/object:Gem::Version
46
92
  version: '3.0'
@@ -72,6 +118,20 @@ dependencies:
72
118
  - - "~>"
73
119
  - !ruby/object:Gem::Version
74
120
  version: '0.2'
121
+ - !ruby/object:Gem::Dependency
122
+ name: kramdown-parser-gfm
123
+ requirement: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '1.0'
128
+ type: :development
129
+ prerelease: false
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: '1.0'
75
135
  - !ruby/object:Gem::Dependency
76
136
  name: pry
77
137
  requirement: !ruby/object:Gem::Requirement
@@ -106,20 +166,28 @@ dependencies:
106
166
  requirements:
107
167
  - - "~>"
108
168
  - !ruby/object:Gem::Version
109
- version: '0.4'
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: 0.49.0
169
+ version: '0.71'
113
170
  type: :development
114
171
  prerelease: false
115
172
  version_requirements: !ruby/object:Gem::Requirement
116
173
  requirements:
117
174
  - - "~>"
118
175
  - !ruby/object:Gem::Version
119
- version: '0.4'
120
- - - ">="
176
+ version: '0.71'
177
+ - !ruby/object:Gem::Dependency
178
+ name: rubocop-jekyll
179
+ requirement: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
121
182
  - !ruby/object:Gem::Version
122
- version: 0.49.0
183
+ version: '0.10'
184
+ type: :development
185
+ prerelease: false
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - "~>"
189
+ - !ruby/object:Gem::Version
190
+ version: '0.10'
123
191
  - !ruby/object:Gem::Dependency
124
192
  name: webmock
125
193
  requirement: !ruby/object:Gem::Requirement
@@ -134,7 +202,7 @@ dependencies:
134
202
  - - "~>"
135
203
  - !ruby/object:Gem::Version
136
204
  version: '3.0'
137
- description:
205
+ description:
138
206
  email:
139
207
  - ben.balter@github.com
140
208
  executables: []
@@ -151,7 +219,7 @@ homepage: https://github.com/benbalter/jekyll-remote-theme
151
219
  licenses:
152
220
  - MIT
153
221
  metadata: {}
154
- post_install_message:
222
+ post_install_message:
155
223
  rdoc_options: []
156
224
  require_paths:
157
225
  - lib
@@ -159,16 +227,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
227
  requirements:
160
228
  - - ">="
161
229
  - !ruby/object:Gem::Version
162
- version: '0'
230
+ version: 2.3.0
163
231
  required_rubygems_version: !ruby/object:Gem::Requirement
164
232
  requirements:
165
233
  - - ">="
166
234
  - !ruby/object:Gem::Version
167
235
  version: '0'
168
236
  requirements: []
169
- rubyforge_project:
170
- rubygems_version: 2.7.6
171
- signing_key:
237
+ rubygems_version: 3.2.14
238
+ signing_key:
172
239
  specification_version: 4
173
240
  summary: Jekyll plugin for building Jekyll sites with any GitHub-hosted theme
174
241
  test_files: []