jekyll-remote-theme 0.2.4 → 0.3.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e39b39cafa24a34892141eb0d7d386988faa47a922a50195eb33458f0ec5cb18
|
4
|
+
data.tar.gz: 3ebfdb2d308084fabce1d92a5eba50fde22aa1be8cd742a7c44bcd9bc5f75e33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfc7198186058021058cfcd85b34330fb1b8df153cc6ee2ae5ac280afac7e21a26e0c3257c8285890a676c9b14f600bdf1a8bf893997cf1370e95279353f0271
|
7
|
+
data.tar.gz: 93f287e3f8455eef42f66595d97e11b55aa378e2bda0e94cb644793d2ceb8429d71ab094d097d36aa036f59b4ade98c4f5af6b39cead00064939c684c003e946
|
data/lib/jekyll-remote-theme.rb
CHANGED
@@ -4,7 +4,7 @@ require "jekyll"
|
|
4
4
|
require "fileutils"
|
5
5
|
require "tempfile"
|
6
6
|
require "addressable"
|
7
|
-
require "
|
7
|
+
require "net/http"
|
8
8
|
require "zip"
|
9
9
|
|
10
10
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
@@ -32,5 +32,3 @@ end
|
|
32
32
|
Jekyll::Hooks.register :site, :after_reset do |site|
|
33
33
|
Jekyll::RemoteTheme.init(site)
|
34
34
|
end
|
35
|
-
|
36
|
-
Ethon.logger = Jekyll.logger.writer
|
@@ -5,12 +5,12 @@ module Jekyll
|
|
5
5
|
class Downloader
|
6
6
|
HOST = "https://codeload.github.com".freeze
|
7
7
|
PROJECT_URL = "https://github.com/benbalter/jekyll-remote-theme".freeze
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
USER_AGENT = "Jekyll Remote Theme/#{VERSION} (+#{PROJECT_URL})".freeze
|
9
|
+
MAX_FILE_SIZE = 1 * (1024 * 1024 * 1024) # Size in bytes (1 GB)
|
10
|
+
NET_HTTP_ERRORS = [
|
11
|
+
Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
12
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
|
13
|
+
].freeze
|
14
14
|
|
15
15
|
attr_reader :theme
|
16
16
|
private :theme
|
@@ -27,8 +27,6 @@ module Jekyll
|
|
27
27
|
|
28
28
|
download
|
29
29
|
unzip
|
30
|
-
|
31
|
-
@downloaded = true
|
32
30
|
end
|
33
31
|
|
34
32
|
def downloaded?
|
@@ -38,16 +36,40 @@ module Jekyll
|
|
38
36
|
private
|
39
37
|
|
40
38
|
def zip_file
|
41
|
-
@zip_file ||= Tempfile.new([TEMP_PREFIX, ".zip"])
|
39
|
+
@zip_file ||= Tempfile.new([TEMP_PREFIX, ".zip"], :binmode => true)
|
42
40
|
end
|
43
41
|
|
44
42
|
def download
|
45
43
|
Jekyll.logger.debug LOG_KEY, "Downloading #{zip_url} to #{zip_file.path}"
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
Net::HTTP.start(zip_url.host, zip_url.port, :use_ssl => true) do |http|
|
45
|
+
http.request(request) do |response|
|
46
|
+
raise_unless_sucess(response)
|
47
|
+
enforce_max_file_size(response.content_length)
|
48
|
+
response.read_body do |chunk|
|
49
|
+
zip_file.write chunk
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
@downloaded = true
|
54
|
+
rescue *NET_HTTP_ERRORS => e
|
55
|
+
raise DownloadError, e.message
|
56
|
+
end
|
57
|
+
|
58
|
+
def request
|
59
|
+
return @request if defined? @request
|
60
|
+
@request = Net::HTTP::Get.new zip_url.request_uri
|
61
|
+
@request["User-Agent"] = USER_AGENT
|
62
|
+
@request
|
63
|
+
end
|
64
|
+
|
65
|
+
def raise_unless_sucess(response)
|
66
|
+
return if response.is_a?(Net::HTTPSuccess)
|
67
|
+
raise DownloadError, "#{response.code} - #{response.message}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def enforce_max_file_size(size)
|
71
|
+
return unless size && size > MAX_FILE_SIZE
|
72
|
+
raise DownloadError, "Maximum file size of #{MAX_FILE_SIZE} bytes exceeded"
|
51
73
|
end
|
52
74
|
|
53
75
|
def unzip
|
@@ -59,13 +81,14 @@ module Jekyll
|
|
59
81
|
Zip::File.open(zip_file) do |archive|
|
60
82
|
archive.each { |file| file.extract path_without_name_and_ref(file.name) }
|
61
83
|
end
|
62
|
-
|
84
|
+
ensure
|
85
|
+
zip_file.close
|
63
86
|
zip_file.unlink
|
64
87
|
end
|
65
88
|
|
66
89
|
# Full URL to codeload zip download endpoint for the given theme
|
67
90
|
def zip_url
|
68
|
-
Addressable::URI.join(
|
91
|
+
@zip_url ||= Addressable::URI.join(
|
69
92
|
HOST, "#{theme.owner}/", "#{theme.name}/", "zip/", theme.git_ref
|
70
93
|
).normalize
|
71
94
|
end
|
@@ -78,17 +101,6 @@ module Jekyll
|
|
78
101
|
Dir["#{theme.root}/*"].empty?
|
79
102
|
end
|
80
103
|
|
81
|
-
def raise_if_unsuccessful(response)
|
82
|
-
if response.timed_out?
|
83
|
-
raise DownloadError, "Request timed out"
|
84
|
-
elsif response.code.zero?
|
85
|
-
raise DownloadError, response.return_message
|
86
|
-
elsif response.code != 200
|
87
|
-
msg = "Request failed with #{response.code} - #{response.status_message}"
|
88
|
-
raise DownloadError, msg
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
104
|
# Codeload generated zip files contain a top level folder in the form of
|
93
105
|
# THEME_NAME-GIT_REF/. While requests for Git repos are case insensitive,
|
94
106
|
# the zip subfolder will respect the case in the repository's name, thus
|
@@ -9,16 +9,43 @@ 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_-]+)["']!
|
14
|
+
|
12
15
|
def initialize(theme)
|
13
16
|
@theme = theme
|
14
17
|
end
|
15
18
|
|
16
19
|
def runtime_dependencies
|
17
|
-
|
20
|
+
@runtime_dependencies ||= dependency_names.map do |name|
|
21
|
+
Gem::Dependency.new(name)
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
private
|
21
26
|
|
27
|
+
def contents
|
28
|
+
@contents ||= File.read(path, :encoding => "utf-8") if path
|
29
|
+
end
|
30
|
+
|
31
|
+
def path
|
32
|
+
@path ||= potential_paths.find { |path| File.exist? path }
|
33
|
+
end
|
34
|
+
|
35
|
+
def potential_paths
|
36
|
+
[theme.name, "jekyll-theme-#{theme.name}"].map do |filename|
|
37
|
+
File.expand_path "#{filename}.gemspec", theme.root
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def dependency_names
|
42
|
+
@dependency_names ||= if contents
|
43
|
+
contents.scan(DEPENDENCY_REGEX).flatten
|
44
|
+
else
|
45
|
+
[]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
22
49
|
attr_reader :theme
|
23
50
|
end
|
24
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-remote-theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -45,39 +45,33 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '3.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: jekyll-theme-primer
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.7'
|
54
|
-
- - "<"
|
51
|
+
- - "~>"
|
55
52
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
57
|
-
type: :
|
53
|
+
version: '0.5'
|
54
|
+
type: :development
|
58
55
|
prerelease: false
|
59
56
|
version_requirements: !ruby/object:Gem::Requirement
|
60
57
|
requirements:
|
61
|
-
- - "
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0.7'
|
64
|
-
- - "<"
|
58
|
+
- - "~>"
|
65
59
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
60
|
+
version: '0.5'
|
67
61
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
62
|
+
name: jekyll_test_plugin_malicious
|
69
63
|
requirement: !ruby/object:Gem::Requirement
|
70
64
|
requirements:
|
71
65
|
- - "~>"
|
72
66
|
- !ruby/object:Gem::Version
|
73
|
-
version: '0.
|
67
|
+
version: '0.2'
|
74
68
|
type: :development
|
75
69
|
prerelease: false
|
76
70
|
version_requirements: !ruby/object:Gem::Requirement
|
77
71
|
requirements:
|
78
72
|
- - "~>"
|
79
73
|
- !ruby/object:Gem::Version
|
80
|
-
version: '0.
|
74
|
+
version: '0.2'
|
81
75
|
- !ruby/object:Gem::Dependency
|
82
76
|
name: pry
|
83
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,6 +107,9 @@ dependencies:
|
|
113
107
|
- - "~>"
|
114
108
|
- !ruby/object:Gem::Version
|
115
109
|
version: '0.4'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 0.49.0
|
116
113
|
type: :development
|
117
114
|
prerelease: false
|
118
115
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -120,6 +117,23 @@ dependencies:
|
|
120
117
|
- - "~>"
|
121
118
|
- !ruby/object:Gem::Version
|
122
119
|
version: '0.4'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 0.49.0
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: webmock
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '3.0'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '3.0'
|
123
137
|
description:
|
124
138
|
email:
|
125
139
|
- ben.balter@github.com
|