nightcrawler_swift 0.10.0 → 0.11.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
  SHA1:
3
- metadata.gz: e04d9c076ba20ec7b69abfbdd9e12dfe1fb9bdbb
4
- data.tar.gz: f0316bd255df069ec3d28bab88ec5c669ef0d14e
3
+ metadata.gz: fa3a7c817fbab29ce6d0775b57d43fd81bce658b
4
+ data.tar.gz: 2a4450d5398adcb8d3f6a87987d944af05181baf
5
5
  SHA512:
6
- metadata.gz: 736a0dcc2f1262453ddc33fdc3094525743e2d38e0f57fff3797e6748590cc963950d7445ead3999a62de12502c3ef1b3096ab43e77df8b60e629d120bff6932
7
- data.tar.gz: a21e6d537c5baf9373a276cb2e6cfa81941ef4d22e3aa2671ccd1ba7aa34b14efa03258f3022dafda821b2dae63a614472b80802f08f56b00ec9424ca5d382b5
6
+ metadata.gz: 30beffddd727dd1f344a01a301503c2dfd285ad609b9bc0b58d178ff93b89dc94636b921ee60cfae464df85626b882ea15f17f0de0b80c23cfd3b087deed9672
7
+ data.tar.gz: adade8009b82cb95234cc689ef55d319256b2f38d06038c12c03e69278d0f2a74ca37e4f84e5c7cec26c38aab54757ab9d89c3790bc9d76992cfb277d0f6cdb5
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0
4
+
5
+ - Exclude ```Expires``` header when max-age used
6
+ - Add ```Expires``` header as an independent option
7
+
3
8
  ## 0.10.0
4
9
 
5
10
  - Added support for custom headers
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nightcrawler_swift (0.10.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
@@ -94,6 +94,10 @@ config.nightcrawler_swift.logger = Logger.new(STDOUT)
94
94
 
95
95
  Defines the *Cache-Control:max-age=<value>* header.
96
96
 
97
+ > expires
98
+
99
+ Defines the *Expires* header.
100
+
97
101
  > content_encoding
98
102
 
99
103
  Defines the *Content-Encoding:<vaule>* header
@@ -1,4 +1,3 @@
1
- require "cgi"
2
1
  require "date"
3
2
  require "json"
4
3
  require "logger"
@@ -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}", expires: expires(max_age)) if 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
@@ -1,3 +1,3 @@
1
1
  module NightcrawlerSwift
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -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}
@@ -2,6 +2,7 @@ require "codeclimate-test-reporter"
2
2
  CodeClimate::TestReporter.start
3
3
 
4
4
  require "rake"
5
+ require "timecop"
5
6
  RUBY_VERSION =~ /1\.9/ ? require("debugger") : require("byebug")
6
7
  require "nightcrawler_swift"
7
8
 
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.10.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-11-27 00:00:00.000000000 Z
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