lanyon 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +24 -0
- data/lanyon.gemspec +3 -2
- data/lib/lanyon/application.rb +0 -5
- data/lib/lanyon/version.rb +2 -2
- data/lib/lanyon.rb +11 -0
- data/test/helper.rb +0 -1
- data/test/test_build.rb +10 -0
- data/test/test_integration.rb +15 -13
- metadata +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e17ba8083556f9aa05105223303a5016d35c989
|
4
|
+
data.tar.gz: abaf22a5ae32d30e79c29d7f981688823f454d50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be7b108eb234cdd7670133bbe83f0bf70f16f18f96bb6204983c79cb767b53f46043f887777c25bb7e78338168cf5b8048280e2085286bd1030a4c29a33a17d9
|
7
|
+
data.tar.gz: 7384cc975966d401182b500bdf2cb173d9d5792d4fe1fdc81702b8bc3341f51f83ee7f9cb4d2dbbb69a4075280e5a8236605037e394b7f2dbc01136789a7cbb6
|
data/History.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Release History
|
2
|
+
===============
|
3
|
+
|
4
|
+
## 0.3.0
|
5
|
+
|
6
|
+
* Use ETag instead of Last-Modified for caching
|
7
|
+
* Allow Jekyll 3
|
8
|
+
* Provide a Lanyon.build method
|
9
|
+
|
10
|
+
## 0.2.3
|
11
|
+
|
12
|
+
* Handle URLs with percent-encoded characters
|
13
|
+
|
14
|
+
## 0.2.2
|
15
|
+
|
16
|
+
* Prevent CRLF conversion for served files by using File.binread
|
17
|
+
|
18
|
+
## 0.2.1
|
19
|
+
|
20
|
+
* Sanitize path info to properly handle directory traversal
|
21
|
+
|
22
|
+
## 0.2.0
|
23
|
+
|
24
|
+
First gem release.
|
data/lanyon.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.required_ruby_version = ">= 2.0.0"
|
23
23
|
|
24
|
-
s.add_dependency "jekyll", "
|
24
|
+
s.add_dependency "jekyll", ">= 2.0", "< 4.0"
|
25
25
|
s.add_dependency "rack", "~> 1.6"
|
26
26
|
|
27
27
|
s.add_development_dependency "rake", "~> 10.4"
|
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.files = %w[
|
33
33
|
README.md
|
34
34
|
LICENSE
|
35
|
+
History.md
|
35
36
|
lanyon.gemspec
|
36
37
|
Gemfile
|
37
38
|
Rakefile
|
@@ -41,6 +42,6 @@ Gem::Specification.new do |s|
|
|
41
42
|
Dir.glob("test/**/*") +
|
42
43
|
Dir.glob("demo/**/*").reject {|f| f =~ %r(\Ademo/_site/) }
|
43
44
|
|
44
|
-
s.extra_rdoc_files = %w[README.md LICENSE]
|
45
|
+
s.extra_rdoc_files = %w[README.md LICENSE History.md]
|
45
46
|
s.rdoc_options = ["--charset=UTF-8", "--main=README.md"]
|
46
47
|
end
|
data/lib/lanyon/application.rb
CHANGED
@@ -43,7 +43,6 @@ module Lanyon
|
|
43
43
|
def response(filename) # :nodoc:
|
44
44
|
response = Rack::Response.new(File.binread(filename))
|
45
45
|
response["Content-Type"] = media_type(filename)
|
46
|
-
response["Last-Modified"] = modification_time(filename)
|
47
46
|
|
48
47
|
response.finish
|
49
48
|
end
|
@@ -61,10 +60,6 @@ module Lanyon
|
|
61
60
|
Rack::Mime.mime_type(extension)
|
62
61
|
end
|
63
62
|
|
64
|
-
def modification_time(filename) # :nodoc:
|
65
|
-
File.mtime(filename).httpdate
|
66
|
-
end
|
67
|
-
|
68
63
|
def html_wrap(title, content) # :nodoc:
|
69
64
|
<<-document.gsub(/^ {6}/, "")
|
70
65
|
<!DOCTYPE html>
|
data/lib/lanyon/version.rb
CHANGED
data/lib/lanyon.rb
CHANGED
@@ -49,11 +49,22 @@ module Lanyon
|
|
49
49
|
Rack::Builder.new do
|
50
50
|
use Rack::Head
|
51
51
|
use Rack::ConditionalGet
|
52
|
+
use Rack::ETag
|
52
53
|
|
53
54
|
run Application.new(router)
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
58
|
+
# Builds the Jekyll site.
|
59
|
+
#
|
60
|
+
# Accepts the same options as ::application,
|
61
|
+
# except for the +:skip_build+ option which is ignored.
|
62
|
+
def self.build(options = {})
|
63
|
+
config = jekyll_config(options)
|
64
|
+
|
65
|
+
process(config)
|
66
|
+
end
|
67
|
+
|
57
68
|
# @private
|
58
69
|
def self.default_options # :nodoc:
|
59
70
|
{ :skip_build => false }
|
data/test/helper.rb
CHANGED
data/test/test_build.rb
CHANGED
@@ -41,4 +41,14 @@ describe "when creating a Lanyon application" do
|
|
41
41
|
file_must_exist(@no_page)
|
42
42
|
file_wont_exist(@page)
|
43
43
|
end
|
44
|
+
|
45
|
+
it "does always build the site with ::build" do
|
46
|
+
options = {:skip_build => true}.merge(@dir_options)
|
47
|
+
silence_output do
|
48
|
+
Lanyon.build(options)
|
49
|
+
end
|
50
|
+
|
51
|
+
file_must_exist(@page)
|
52
|
+
file_wont_exist(@no_page)
|
53
|
+
end
|
44
54
|
end
|
data/test/test_integration.rb
CHANGED
@@ -45,9 +45,8 @@ describe "when handling requests" do
|
|
45
45
|
@response.headers["Content-Type"].must_equal "text/html"
|
46
46
|
end
|
47
47
|
|
48
|
-
it "returns
|
49
|
-
|
50
|
-
@response.headers["Last-Modified"].must_equal mtime.httpdate
|
48
|
+
it "returns an ETag header" do
|
49
|
+
@response.headers["ETag"].wont_be_nil
|
51
50
|
end
|
52
51
|
|
53
52
|
it "returns correct body" do
|
@@ -291,30 +290,33 @@ describe "when handling requests" do
|
|
291
290
|
end
|
292
291
|
|
293
292
|
|
294
|
-
describe "when handling
|
293
|
+
describe "when handling caching with ETag" do
|
295
294
|
|
296
295
|
before do
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
296
|
+
etag = @request.get("/").headers["ETag"]
|
297
|
+
other = @request.get("/no-extension").headers["ETag"]
|
298
|
+
assert etag.start_with?("W/")
|
299
|
+
assert other.start_with?("W/")
|
300
|
+
|
301
|
+
@correct_etag = { "HTTP_IF_NONE_MATCH" => etag }
|
302
|
+
@other_etag = { "HTTP_IF_NONE_MATCH" => other }
|
301
303
|
end
|
302
304
|
|
303
305
|
it "returns correct status code for unchanged '/'" do
|
304
|
-
@request.get("/", @
|
306
|
+
@request.get("/", @correct_etag).status.must_equal 304
|
305
307
|
end
|
306
308
|
|
307
309
|
it "does not return a Content-Length header for unchanged '/'" do
|
308
|
-
response = @request.get("/", @
|
310
|
+
response = @request.get("/", @correct_etag)
|
309
311
|
response.original_headers["Content-Length"].must_be_nil
|
310
312
|
end
|
311
313
|
|
312
|
-
it "returns correct status code for
|
313
|
-
@request.get("/", @
|
314
|
+
it "returns correct status code for changed '/'" do
|
315
|
+
@request.get("/", @other_etag).status.must_equal 200
|
314
316
|
end
|
315
317
|
|
316
318
|
it "returns correct status code for 404" do
|
317
|
-
@request.get("/not/a/page", @
|
319
|
+
@request.get("/not/a/page", @other_etag).status.must_equal 404
|
318
320
|
end
|
319
321
|
end
|
320
322
|
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lanyon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcus Stollsteimer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '4.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '2.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '4.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rack
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,9 +80,11 @@ extensions: []
|
|
74
80
|
extra_rdoc_files:
|
75
81
|
- README.md
|
76
82
|
- LICENSE
|
83
|
+
- History.md
|
77
84
|
files:
|
78
85
|
- ".yardopts"
|
79
86
|
- Gemfile
|
87
|
+
- History.md
|
80
88
|
- LICENSE
|
81
89
|
- README.md
|
82
90
|
- Rakefile
|