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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c84c1a698fbc54f0d0a02297957a8622036aa30
4
- data.tar.gz: 9188437aeac7bc69af55b9e2030f81adc083e0dc
3
+ metadata.gz: 0e17ba8083556f9aa05105223303a5016d35c989
4
+ data.tar.gz: abaf22a5ae32d30e79c29d7f981688823f454d50
5
5
  SHA512:
6
- metadata.gz: ba31536e3c4b1ef74fc1f54acda3c4500788f9dbc0f384ab63e32dad6956d57f74d32100f3c26ccd97fb8fe32e9a43dd02289455ce4a7f6689b2b30a4963a4ac
7
- data.tar.gz: c0ba43239bf3ab0026ae81b56054f6a88ae5a8eb18288898a8dfd26e5dce329c79e4c23b89853a70e87fd21c0d457aff32c7a94a0ea5a4a36eac96b66f6639fa
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", "~> 2.0"
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
@@ -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>
@@ -1,4 +1,4 @@
1
1
  module Lanyon
2
- VERSION = '0.2.3'
3
- DATE = '2016-02-06'
2
+ VERSION = "0.3.0"
3
+ DATE = "2016-03-14"
4
4
  end
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
@@ -2,7 +2,6 @@ require "minitest/autorun"
2
2
  require "fileutils"
3
3
  require "stringio"
4
4
  require "rack/mock"
5
- require "time"
6
5
 
7
6
  require "lanyon"
8
7
 
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
@@ -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 correct Last-Modified header" do
49
- mtime = File.mtime(@destdir + "/index.html")
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 If-Modified-Since requests" do
293
+ describe "when handling caching with ETag" do
295
294
 
296
295
  before do
297
- modify_time = @request.get("/").headers["Last-Modified"]
298
- earlier_time = (Time.parse(modify_time) - 3600).httpdate
299
- @modify_time_header = { "HTTP_IF_MODIFIED_SINCE" => modify_time }
300
- @earlier_time_header = { "HTTP_IF_MODIFIED_SINCE" => earlier_time }
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("/", @modify_time_header).status.must_equal 304
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("/", @modify_time_header)
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 updated '/'" do
313
- @request.get("/", @earlier_time_header).status.must_equal 200
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", @earlier_time_header).status.must_equal 404
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.2.3
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-02-06 00:00:00.000000000 Z
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