rack-jekyll 0.3.5 → 0.3.7

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.
@@ -0,0 +1,19 @@
1
+ module Rack
2
+ class Jekyll
3
+ def mime(path_info)
4
+ if path_info !~ /html$/i
5
+ ext = $1 if path_info =~ /(\.\S+)$/
6
+ Mime.mime_type((ext.nil? ? ".html" : ext))
7
+ else
8
+ Mime.mime_type(".html")
9
+ end
10
+ end
11
+
12
+ def file_info(path)
13
+ expand_path = ::File.expand_path(path)
14
+ ::File.open(expand_path, 'r') do |f|
15
+ {:body => f.read, :time => f.mtime.httpdate, :expand_path => expand_path}
16
+ end
17
+ end
18
+ end
19
+ end
@@ -37,6 +37,6 @@ module Rack
37
37
  ext = $1 if path_info =~ /(\.\S+)$/
38
38
  Mime.mime_type((ext.nil? ? ".html" : ext))
39
39
  end
40
- end
40
+ end
41
41
  end
42
42
  end
@@ -1,7 +1,7 @@
1
1
  module Rack
2
2
  class Jekyll
3
3
  def self.version
4
- '0.3.5'
4
+ '0.3.7'
5
5
  end
6
6
  end
7
7
  end
data/lib/rack/jekyll.rb CHANGED
@@ -1,40 +1,42 @@
1
1
  require "rack"
2
+ require "yaml"
2
3
  require "rack/request"
3
4
  require "rack/response"
5
+ require File.join(File.dirname(__FILE__), 'jekyll', 'helpers')
6
+ require File.join(File.dirname(__FILE__), 'jekyll', 'version')
4
7
 
5
8
  module Rack
6
9
  class Jekyll
10
+ @compiling = false
7
11
 
8
12
  def initialize(opts = {})
9
- if ::File.exist?(Dir.pwd + "/_config.yml")
10
- @config = ::YAML.load(::File.read(Dir.pwd + "/_config.yml"))
11
- @config = (@config.class == FalseClass ? {} : @config)
12
- if @config[:destination].nil?
13
- @path = opts[:destination].nil? ? "_site" : opts[:destination]
14
- else
15
- opts.merge!(@config)
16
- @path = @config[:destination].nil? ? "_site" : @config[:destination]
17
- end
13
+ config_file = '_config.yml'
14
+ if ::File.exist?(config_file)
15
+ config = YAML.load_file(config_file)
16
+ @path = (config[:destination].nil? && "_site") || config[:destination]
17
+
18
+ @files = ::Dir[@path + "/**/*"].inspect
19
+ @files unless ENV['RACK_DEBUG']
18
20
  end
19
- @files = ::Dir[@path + "/**/*"].inspect
20
- p @files if ENV['RACK_DEBUG'] == "true"
21
+
21
22
  @mimes = Rack::Mime::MIME_TYPES.map{|k,v| /#{k.gsub('.','\.')}$/i }
22
- @compiling = false
23
+
23
24
  if ::Dir[@path + "/**/*"].empty?
24
- begin
25
- require "jekyll"
26
- options = ::Jekyll.configuration(opts)
27
- site = ::Jekyll::Site.new(options)
28
- @compiling = true
29
- site.process
30
- rescue LoadError => boom
31
- @compiling = false
32
- end
25
+ require "jekyll"
26
+ options = ::Jekyll.configuration(opts)
27
+ site = ::Jekyll::Site.new(options)
28
+ site.process
29
+
30
+ @compiling = true
31
+ else
32
+ @compiling = false
33
33
  end
34
34
  end
35
+
35
36
  def call(env)
36
- request = Request.new(env)
37
- path_info = request.path_info
37
+ @request = Rack::Request.new(env)
38
+ @response = Rack::Response.new
39
+ path_info = @request.path_info
38
40
  if @files.include?(path_info)
39
41
  if path_info =~ /(\/?)$/
40
42
  if @mimes.collect {|regex| path_info =~ regex }.compact.empty?
@@ -47,37 +49,21 @@ module Rack
47
49
  body = file[:body]
48
50
  time = file[:time]
49
51
 
50
- if time == request.env['HTTP_IF_MODIFIED_SINCE']
51
- [304, {'Last-Modified' => time}, []]
52
+ if time == @request.env['HTTP_IF_MODIFIED_SINCE']
53
+ [@response.status, {'Last-Modified' => time}, []]
52
54
  else
53
- [200, {"Content-Type" => mime, "Content-length" => body.length.to_s, 'Last-Modified' => time}, [body]]
55
+ [@response.status, {"Content-Type" => mime, "Content-length" => body.length.to_s, 'Last-Modified' => time}, [body]]
54
56
  end
55
57
 
56
58
  else
57
59
  status, body, path_info = ::File.exist?(@path+"/404.html") ? [404,file_info(@path+"/404.html")[:body],"404.html"] : [404,"Not found","404.html"]
58
60
  mime = mime(path_info)
59
61
  if !@compiling
60
- [status, {"Content-Type" => mime, "Content-Type" => body.length.to_s}, [body]]
62
+ [status, {"Content-Type" => mime, "Content-length" => body.length.to_s}, [body]]
61
63
  else
62
64
  [200, {"Content-Type" => "text/plain"}, ["This site is currently generating pages. Please reload this page after 10 secs."]]
63
65
  end
64
66
  end
65
- end
66
-
67
- def file_info(path)
68
- expand_path = ::File.expand_path(path)
69
- ::File.open(expand_path, 'r') do |f|
70
- {:body => f.read, :time => f.mtime.httpdate, :expand_path => expand_path}
71
- end
72
- end
73
-
74
- def mime(path_info)
75
- if path_info !~ /html$/i
76
- ext = $1 if path_info =~ /(\.\S+)$/
77
- Mime.mime_type((ext.nil? ? ".html" : ext))
78
- else
79
- Mime.mime_type(".html")
80
- end
81
- end
67
+ end
82
68
  end
83
- end
69
+ end
metadata CHANGED
@@ -1,55 +1,48 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 5
9
- version: 0.3.5
4
+ prerelease:
5
+ version: 0.3.7
10
6
  platform: ruby
11
7
  authors:
12
8
  - Bryan Goines
9
+ - "Ad\xC3\xA3o Raul"
13
10
  autorequire:
14
11
  bindir: bin
15
12
  cert_chain: []
16
13
 
17
- date: 2010-04-01 00:00:00 -05:00
18
- default_executable:
14
+ date: 2011-07-15 00:00:00 Z
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
21
17
  name: jekyll
22
18
  prerelease: false
23
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
24
21
  requirements:
25
- - - ">="
22
+ - - ~>
26
23
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
24
+ version: 0.6.2
30
25
  type: :runtime
31
26
  version_requirements: *id001
32
27
  - !ruby/object:Gem::Dependency
33
28
  name: rack
34
29
  prerelease: false
35
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
36
32
  requirements:
37
- - - ">="
33
+ - - ~>
38
34
  - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
35
+ version: 1.2.1
42
36
  type: :runtime
43
37
  version_requirements: *id002
44
38
  - !ruby/object:Gem::Dependency
45
39
  name: bacon
46
40
  prerelease: false
47
41
  requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
48
43
  requirements:
49
44
  - - ">="
50
45
  - !ruby/object:Gem::Version
51
- segments:
52
- - 0
53
46
  version: "0"
54
47
  type: :development
55
48
  version_requirements: *id003
@@ -66,9 +59,9 @@ files:
66
59
  - LICENSE
67
60
  - lib/rack/jekyll.rb
68
61
  - lib/rack/jekyll/test.rb
62
+ - lib/rack/jekyll/helpers.rb
69
63
  - lib/rack/jekyll/version.rb
70
- has_rdoc: true
71
- homepage: http://github.com/bry4n/rack-jekyll
64
+ homepage: http://github.com/adaoraul/rack-jekyll
72
65
  licenses: []
73
66
 
74
67
  post_install_message:
@@ -77,25 +70,23 @@ rdoc_options: []
77
70
  require_paths:
78
71
  - lib
79
72
  required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
80
74
  requirements:
81
75
  - - ">="
82
76
  - !ruby/object:Gem::Version
83
- segments:
84
- - 0
85
77
  version: "0"
86
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
87
80
  requirements:
88
81
  - - ">="
89
82
  - !ruby/object:Gem::Version
90
- segments:
91
- - 0
92
- version: "0"
83
+ version: 1.3.6
93
84
  requirements: []
94
85
 
95
86
  rubyforge_project: rack-jekyll
96
- rubygems_version: 1.3.6
87
+ rubygems_version: 1.8.4
97
88
  signing_key:
98
- specification_version: 1
89
+ specification_version: 3
99
90
  summary: rack-jekyll
100
91
  test_files: []
101
92