nightcrawler_swift 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +5 -0
- data/Gemfile.lock +3 -1
- data/README.md +4 -0
- data/lib/nightcrawler_swift.rb +0 -1
- data/lib/nightcrawler_swift/cli/opt_parser.rb +10 -0
- data/lib/nightcrawler_swift/commands/upload.rb +4 -5
- data/lib/nightcrawler_swift/version.rb +1 -1
- data/nightcrawler_swift.gemspec +1 -0
- data/spec/lib/nightcrawler_swift/commands/upload_spec.rb +22 -15
- data/spec/spec_helper.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa3a7c817fbab29ce6d0775b57d43fd81bce658b
|
4
|
+
data.tar.gz: 2a4450d5398adcb8d3f6a87987d944af05181baf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30beffddd727dd1f344a01a301503c2dfd285ad609b9bc0b58d178ff93b89dc94636b921ee60cfae464df85626b882ea15f17f0de0b80c23cfd3b087deed9672
|
7
|
+
data.tar.gz: adade8009b82cb95234cc689ef55d319256b2f38d06038c12c03e69278d0f2a74ca37e4f84e5c7cec26c38aab54757ab9d89c3790bc9d76992cfb277d0f6cdb5
|
data/Changelog.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nightcrawler_swift (0.
|
4
|
+
nightcrawler_swift (0.11.0)
|
5
5
|
concurrent-ruby (~> 0.8.0)
|
6
6
|
multi_mime (>= 1.0.1)
|
7
7
|
rest-client
|
@@ -48,6 +48,7 @@ GEM
|
|
48
48
|
simplecov-html (~> 0.8.0)
|
49
49
|
simplecov-html (0.8.0)
|
50
50
|
slop (3.6.0)
|
51
|
+
timecop (0.8.0)
|
51
52
|
|
52
53
|
PLATFORMS
|
53
54
|
ruby
|
@@ -59,3 +60,4 @@ DEPENDENCIES
|
|
59
60
|
nightcrawler_swift!
|
60
61
|
rake
|
61
62
|
rspec
|
63
|
+
timecop
|
data/README.md
CHANGED
data/lib/nightcrawler_swift.rb
CHANGED
@@ -36,6 +36,7 @@ module NightcrawlerSwift::CLI
|
|
36
36
|
configure_option_bucket
|
37
37
|
configure_option_max_age
|
38
38
|
configure_option_content_encoding
|
39
|
+
configure_option_expires
|
39
40
|
configure_option_config
|
40
41
|
configure_option_no_cache
|
41
42
|
configure_option_help
|
@@ -69,6 +70,15 @@ module NightcrawlerSwift::CLI
|
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
73
|
+
def configure_option_expires
|
74
|
+
desc = "Custom expires header value"
|
75
|
+
@parser.on("--expires=VALUE", String, desc) do |value|
|
76
|
+
expires = Time.parse(value)
|
77
|
+
@runner.options.config_hash[:expires] = expires
|
78
|
+
@runner.log "Using expires: #{expires}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
72
82
|
def configure_option_config
|
73
83
|
@parser.on("-c", "--config=PATH", String, "Alternative '#{NightcrawlerSwift::CLI::CONFIG_FILE}' file") do |path|
|
74
84
|
path = File.expand_path(path.strip)
|
@@ -6,7 +6,10 @@ module NightcrawlerSwift
|
|
6
6
|
headers = {etag: etag(body), content_type: content_type(file)}
|
7
7
|
|
8
8
|
max_age = opts[:max_age] || options.max_age
|
9
|
-
headers.merge!(cache_control: "public, max-age=#{max_age}"
|
9
|
+
headers.merge!(cache_control: "public, max-age=#{max_age}") if max_age
|
10
|
+
|
11
|
+
expires = opts[:expires]
|
12
|
+
headers.merge!(expires: CGI.rfc1123_date(expires)) if expires
|
10
13
|
|
11
14
|
content_encoding = opts[:content_encoding] || options.content_encoding
|
12
15
|
headers.merge!(content_encoding: content_encoding.to_s) if content_encoding
|
@@ -28,9 +31,5 @@ module NightcrawlerSwift
|
|
28
31
|
Digest::MD5.hexdigest(content)
|
29
32
|
end
|
30
33
|
|
31
|
-
def expires max_age
|
32
|
-
CGI.rfc1123_date(Time.now + max_age)
|
33
|
-
end
|
34
|
-
|
35
34
|
end
|
36
35
|
end
|
data/nightcrawler_swift.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "rspec"
|
28
28
|
spec.add_development_dependency "codeclimate-test-reporter"
|
29
|
+
spec.add_development_dependency "timecop"
|
29
30
|
|
30
31
|
if RUBY_VERSION =~ /1\.9/
|
31
32
|
spec.add_development_dependency "debugger"
|
@@ -94,21 +94,6 @@ describe NightcrawlerSwift::Upload do
|
|
94
94
|
)
|
95
95
|
)
|
96
96
|
end
|
97
|
-
|
98
|
-
it "also sends the expires header based on max_age" do
|
99
|
-
now = Time.now
|
100
|
-
allow(Time).to receive(:now).and_return(now)
|
101
|
-
expires = CGI.rfc1123_date(Time.now + max_age)
|
102
|
-
|
103
|
-
NightcrawlerSwift.configure max_age: max_age
|
104
|
-
execute
|
105
|
-
expect(subject).to have_received(:put).with(
|
106
|
-
anything,
|
107
|
-
hash_including(
|
108
|
-
headers: default_headers.merge(cache_control: "public, max-age=#{max_age}", expires: expires)
|
109
|
-
)
|
110
|
-
)
|
111
|
-
end
|
112
97
|
end
|
113
98
|
|
114
99
|
context "custom_headers" do
|
@@ -128,6 +113,28 @@ describe NightcrawlerSwift::Upload do
|
|
128
113
|
end
|
129
114
|
end
|
130
115
|
|
116
|
+
context "expires" do
|
117
|
+
let :default_headers do
|
118
|
+
{content_type: "text/css", etag: etag}
|
119
|
+
end
|
120
|
+
let(:timestamp) { "Tue, 08 Dec 2015 17:03:31 GMT" }
|
121
|
+
|
122
|
+
it "allows custom content_encoding" do
|
123
|
+
time = Time.parse(timestamp)
|
124
|
+
|
125
|
+
Timecop.freeze(time) do
|
126
|
+
NightcrawlerSwift.configure
|
127
|
+
subject.execute path, file, expires: time
|
128
|
+
expect(subject).to have_received(:put).with(
|
129
|
+
anything,
|
130
|
+
hash_including(
|
131
|
+
headers: hash_including(expires: timestamp)
|
132
|
+
)
|
133
|
+
)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
131
138
|
context "content_encoding" do
|
132
139
|
let :default_headers do
|
133
140
|
{content_type: "text/css", etag: etag}
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nightcrawler_swift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tulios
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -109,6 +109,20 @@ dependencies:
|
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: timecop
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: byebug
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|