chuusha 0.1.1 → 0.2.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.
- data/lib/chuusha.rb +9 -6
- metadata +8 -20
data/lib/chuusha.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'erubis'
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
5
|
module Chuusha
|
5
6
|
class Rack
|
6
|
-
def initialize(app, root_dir, config=nil)
|
7
|
+
def initialize(app, root_dir, config=nil, output_dir = nil)
|
7
8
|
@app = app
|
8
9
|
@root_dir = root_dir
|
9
10
|
@config = Config.new(config)
|
11
|
+
@output_dir = output_dir || root_dir
|
10
12
|
cache_everything if @config.cache_on_load?
|
11
13
|
end
|
12
14
|
|
13
15
|
def call(env)
|
14
|
-
renderer = Renderer.new(@config, @root_dir + env["PATH_INFO"])
|
16
|
+
renderer = Renderer.new(@config, @root_dir + env["PATH_INFO"], @output_dir)
|
15
17
|
return renderer.respond if renderer.template_exists?
|
16
18
|
@app.call(env)
|
17
19
|
end
|
@@ -19,7 +21,7 @@ module Chuusha
|
|
19
21
|
private
|
20
22
|
def cache_everything
|
21
23
|
template_files.each do |file|
|
22
|
-
renderer = Renderer.new(@config, file)
|
24
|
+
renderer = Renderer.new(@config, file, @output_dir)
|
23
25
|
renderer.write_cached_copy
|
24
26
|
end
|
25
27
|
end
|
@@ -76,10 +78,10 @@ module Chuusha
|
|
76
78
|
end
|
77
79
|
|
78
80
|
class Renderer
|
79
|
-
def initialize(config, path)
|
81
|
+
def initialize(config, path, output_dir)
|
80
82
|
@config = config
|
81
|
-
@outfile = path
|
82
|
-
@path =
|
83
|
+
@outfile = File.join(output_dir, File.basename(path))
|
84
|
+
@path = path + ".erb"
|
83
85
|
@evaluated = nil
|
84
86
|
end
|
85
87
|
|
@@ -94,6 +96,7 @@ module Chuusha
|
|
94
96
|
end
|
95
97
|
|
96
98
|
def write_cached_copy
|
99
|
+
FileUtils.mkdir_p(File.dirname(@outfile))
|
97
100
|
::File.open(@outfile, "w") { |f| f.write evaluated }
|
98
101
|
end
|
99
102
|
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chuusha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
version: 0.1.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Trotter Cashion
|
@@ -14,20 +10,17 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-03-10 00:00:00 -05:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
21
17
|
name: rack
|
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
|
-
- 1
|
29
|
-
- 1
|
30
|
-
- 0
|
31
24
|
version: 1.1.0
|
32
25
|
type: :runtime
|
33
26
|
version_requirements: *id001
|
@@ -35,13 +28,10 @@ dependencies:
|
|
35
28
|
name: erubis
|
36
29
|
prerelease: false
|
37
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
38
32
|
requirements:
|
39
33
|
- - ">="
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 2
|
43
|
-
- 6
|
44
|
-
- 5
|
45
35
|
version: 2.6.5
|
46
36
|
type: :runtime
|
47
37
|
version_requirements: *id002
|
@@ -65,23 +55,21 @@ rdoc_options: []
|
|
65
55
|
require_paths:
|
66
56
|
- lib
|
67
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
68
59
|
requirements:
|
69
60
|
- - ">="
|
70
61
|
- !ruby/object:Gem::Version
|
71
|
-
segments:
|
72
|
-
- 0
|
73
62
|
version: "0"
|
74
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
75
65
|
requirements:
|
76
66
|
- - ">="
|
77
67
|
- !ruby/object:Gem::Version
|
78
|
-
segments:
|
79
|
-
- 0
|
80
68
|
version: "0"
|
81
69
|
requirements: []
|
82
70
|
|
83
71
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.5.0
|
85
73
|
signing_key:
|
86
74
|
specification_version: 3
|
87
75
|
summary: Run templates through erb and cache the resulting static file
|