stasis 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/LICENSE +18 -0
- data/README.md +287 -0
- data/Rakefile +109 -0
- data/bin/stasis +30 -0
- data/config/gemsets.yml +9 -0
- data/config/gemspec.yml +17 -0
- data/lib/stasis.rb +291 -0
- data/lib/stasis/dev_mode.rb +55 -0
- data/lib/stasis/gems.rb +154 -0
- data/lib/stasis/plugin.rb +76 -0
- data/lib/stasis/plugins/before.rb +50 -0
- data/lib/stasis/plugins/helpers.rb +29 -0
- data/lib/stasis/plugins/ignore.rb +35 -0
- data/lib/stasis/plugins/instead.rb +15 -0
- data/lib/stasis/plugins/layout.rb +51 -0
- data/lib/stasis/plugins/priority.rb +41 -0
- data/lib/stasis/plugins/render.rb +71 -0
- data/lib/stasis/scope.rb +54 -0
- data/lib/stasis/scope/action.rb +25 -0
- data/lib/stasis/scope/controller.rb +62 -0
- data/lib/stasis/server.rb +90 -0
- data/site/arrow.png +0 -0
- data/site/controller.rb +72 -0
- data/site/github.png +0 -0
- data/site/index.html.haml +24 -0
- data/site/jquery-1.6.2.js +8982 -0
- data/site/stasis.css.scss +226 -0
- data/site/stasis.js.coffee +42 -0
- data/site/stasis.png +0 -0
- data/spec/fixtures/gemsets.yml +9 -0
- data/spec/fixtures/gemspec.yml +15 -0
- data/spec/fixtures/project/_partial.html.haml +1 -0
- data/spec/fixtures/project/before_render_partial.html.haml +1 -0
- data/spec/fixtures/project/before_render_text.html.haml +1 -0
- data/spec/fixtures/project/controller.rb +83 -0
- data/spec/fixtures/project/index.html.haml +16 -0
- data/spec/fixtures/project/layout.html.haml +3 -0
- data/spec/fixtures/project/layout_action.html.haml +1 -0
- data/spec/fixtures/project/layout_action_from_subdirectory.html.haml +1 -0
- data/spec/fixtures/project/layout_controller.html.haml +1 -0
- data/spec/fixtures/project/layout_controller_from_subdirectory.html.haml +1 -0
- data/spec/fixtures/project/no_controller/index.html.haml +12 -0
- data/spec/fixtures/project/not_dynamic.html +1 -0
- data/spec/fixtures/project/plugin.rb +16 -0
- data/spec/fixtures/project/subdirectory/_partial.html.haml +1 -0
- data/spec/fixtures/project/subdirectory/before_render_partial.html.haml +1 -0
- data/spec/fixtures/project/subdirectory/before_render_text.html.haml +1 -0
- data/spec/fixtures/project/subdirectory/controller.rb +66 -0
- data/spec/fixtures/project/subdirectory/ignore.html.haml +0 -0
- data/spec/fixtures/project/subdirectory/index.html.haml +14 -0
- data/spec/fixtures/project/subdirectory/layout.html.haml +3 -0
- data/spec/fixtures/project/subdirectory/layout_action.html.haml +1 -0
- data/spec/fixtures/project/subdirectory/layout_action_from_root.html.haml +1 -0
- data/spec/fixtures/project/subdirectory/layout_controller.html.haml +1 -0
- data/spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml +1 -0
- data/spec/fixtures/project/time.html.haml +2 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/stasis/gems_spec.rb +249 -0
- data/spec/stasis/plugins/before_spec.rb +53 -0
- data/spec/stasis/plugins/helpers_spec.rb +16 -0
- data/spec/stasis/plugins/ignore_spec.rb +17 -0
- data/spec/stasis/plugins/layout_spec.rb +22 -0
- data/spec/stasis/plugins/priority_spec.rb +22 -0
- data/spec/stasis/plugins/render_spec.rb +23 -0
- data/spec/stasis/server_spec.rb +29 -0
- data/spec/stasis_spec.rb +46 -0
- data/stasis.gemspec +32 -0
- metadata +227 -0
@@ -0,0 +1 @@
|
|
1
|
+
subdirectory
|
@@ -0,0 +1 @@
|
|
1
|
+
fail
|
@@ -0,0 +1 @@
|
|
1
|
+
fail
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Subdirectory controller
|
2
|
+
# -----------------------
|
3
|
+
|
4
|
+
# Before
|
5
|
+
|
6
|
+
before 'index.html.haml' do
|
7
|
+
@before_index_literal = :subdirectory
|
8
|
+
end
|
9
|
+
|
10
|
+
before /index\.html/ do
|
11
|
+
@before_index_regexp = :subdirectory
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
@before_all = :subdirectory
|
16
|
+
end
|
17
|
+
|
18
|
+
before 'fail' do
|
19
|
+
@fail = true
|
20
|
+
end
|
21
|
+
|
22
|
+
before /fail/ do
|
23
|
+
@fail = true
|
24
|
+
end
|
25
|
+
|
26
|
+
before 'before_render_text.html.haml' do
|
27
|
+
instead render(:text => 'subdirectory')
|
28
|
+
end
|
29
|
+
|
30
|
+
before 'before_render_partial.html.haml', 'before_non_existent.html' do
|
31
|
+
instead render(:path => '_partial.html.haml')
|
32
|
+
end
|
33
|
+
|
34
|
+
# Helpers
|
35
|
+
|
36
|
+
helpers do
|
37
|
+
def helper
|
38
|
+
:subdirectory
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Ignore
|
43
|
+
|
44
|
+
ignore 'ignore.html.haml'
|
45
|
+
|
46
|
+
# Layout
|
47
|
+
|
48
|
+
layout(
|
49
|
+
'layout_controller.html.haml' => 'layout.html.haml',
|
50
|
+
'layout_controller_from_root.html.haml' => '/layout.html.haml'
|
51
|
+
)
|
52
|
+
|
53
|
+
before 'layout_action.html.haml' do
|
54
|
+
layout 'layout.html.haml'
|
55
|
+
end
|
56
|
+
|
57
|
+
before 'layout_action_from_root.html.haml' do
|
58
|
+
layout '/layout.html.haml'
|
59
|
+
end
|
60
|
+
|
61
|
+
# Priority
|
62
|
+
|
63
|
+
priority(
|
64
|
+
'/before_render_partial.html.haml' => 1,
|
65
|
+
'index.html.haml' => -1
|
66
|
+
)
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
@before_index_literal
|
2
|
+
= @before_index_literal
|
3
|
+
@before_index_regexp
|
4
|
+
= @before_index_regexp
|
5
|
+
@before_all
|
6
|
+
= @before_all
|
7
|
+
@fail
|
8
|
+
= !@fail.nil?
|
9
|
+
helpers
|
10
|
+
= helper
|
11
|
+
render from root
|
12
|
+
= render '/_partial.html.haml'
|
13
|
+
render from subdirectory
|
14
|
+
= render '_partial.html.haml'
|
@@ -0,0 +1 @@
|
|
1
|
+
pass
|
@@ -0,0 +1 @@
|
|
1
|
+
pass
|
@@ -0,0 +1 @@
|
|
1
|
+
pass
|
@@ -0,0 +1 @@
|
|
1
|
+
pass
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
$root = File.expand_path('../../', __FILE__)
|
4
|
+
require "#{$root}/lib/stasis/gems"
|
5
|
+
|
6
|
+
Stasis::Gems.activate :rspec
|
7
|
+
|
8
|
+
require "#{$root}/lib/stasis"
|
9
|
+
|
10
|
+
def generate(options={})
|
11
|
+
$files = nil if options[:reload]
|
12
|
+
$fixture = "#{$root}/spec/fixtures/project"
|
13
|
+
unless $files
|
14
|
+
$stasis ||= Stasis.new($fixture)
|
15
|
+
$stasis.render(*options[:only])
|
16
|
+
generate_files
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate_files
|
21
|
+
pub = "#{$fixture}/public"
|
22
|
+
$files = Dir["#{pub}/**/*"].inject({}) do |hash, path|
|
23
|
+
if File.file?(path)
|
24
|
+
hash[path[pub.length+1..-1]] = File.read(path)
|
25
|
+
end
|
26
|
+
hash
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Stasis::Gems do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@old_config = Stasis::Gems.config
|
7
|
+
|
8
|
+
Stasis::Gems.config.gemspec = "#{$root}/spec/fixtures/gemspec.yml"
|
9
|
+
Stasis::Gems.config.gemsets = [
|
10
|
+
"#{$root}/spec/fixtures/gemsets.yml"
|
11
|
+
]
|
12
|
+
Stasis::Gems.config.warn = true
|
13
|
+
|
14
|
+
Stasis::Gems.gemspec true
|
15
|
+
Stasis::Gems.gemset = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
after(:each) do
|
19
|
+
Stasis::Gems.config = @old_config
|
20
|
+
end
|
21
|
+
|
22
|
+
describe :activate do
|
23
|
+
it "should activate gems" do
|
24
|
+
Stasis::Gems.stub!(:gem)
|
25
|
+
Stasis::Gems.should_receive(:gem).with('rspec', '=1.3.1')
|
26
|
+
Stasis::Gems.should_receive(:gem).with('rake', '=0.8.7')
|
27
|
+
Stasis::Gems.activate :rspec, 'rake'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe :gemset= do
|
32
|
+
before(:each) do
|
33
|
+
Stasis::Gems.config.gemsets = [
|
34
|
+
{
|
35
|
+
:name => {
|
36
|
+
:rake => '>0.8.6',
|
37
|
+
:default => {
|
38
|
+
:externals => '=1.0.2'
|
39
|
+
}
|
40
|
+
}
|
41
|
+
},
|
42
|
+
"#{$root}/spec/fixtures/gemsets.yml"
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
describe :default do
|
47
|
+
before(:each) do
|
48
|
+
Stasis::Gems.gemset = :default
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should set @gemset" do
|
52
|
+
Stasis::Gems.gemset.should == :default
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should set @gemsets" do
|
56
|
+
Stasis::Gems.gemsets.should == {
|
57
|
+
:name => {
|
58
|
+
:rake => ">0.8.6",
|
59
|
+
:default => {
|
60
|
+
:externals => '=1.0.2',
|
61
|
+
:mysql => "=2.8.1",
|
62
|
+
:rspec => "=1.3.1"
|
63
|
+
},
|
64
|
+
:rspec2 => {
|
65
|
+
:mysql2 => "=0.2.6",
|
66
|
+
:rspec => "=2.3.0"
|
67
|
+
},
|
68
|
+
:solo => nil
|
69
|
+
}
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should set Gems.versions" do
|
74
|
+
Stasis::Gems.versions.should == {
|
75
|
+
:externals => "=1.0.2",
|
76
|
+
:mysql => "=2.8.1",
|
77
|
+
:rake => ">0.8.6",
|
78
|
+
:rspec => "=1.3.1"
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return proper values for Gems.dependencies" do
|
83
|
+
Stasis::Gems.dependencies.should == [ :rake, :mysql ]
|
84
|
+
Stasis::Gems.development_dependencies.should == []
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return proper values for Gems.gemset_names" do
|
88
|
+
Stasis::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe :rspec2 do
|
93
|
+
before(:each) do
|
94
|
+
Stasis::Gems.gemset = "rspec2"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should set @gemset" do
|
98
|
+
Stasis::Gems.gemset.should == :rspec2
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should set @gemsets" do
|
102
|
+
Stasis::Gems.gemsets.should == {
|
103
|
+
:name => {
|
104
|
+
:rake => ">0.8.6",
|
105
|
+
:default => {
|
106
|
+
:externals => '=1.0.2',
|
107
|
+
:mysql => "=2.8.1",
|
108
|
+
:rspec => "=1.3.1"
|
109
|
+
},
|
110
|
+
:rspec2 => {
|
111
|
+
:mysql2=>"=0.2.6",
|
112
|
+
:rspec => "=2.3.0"
|
113
|
+
},
|
114
|
+
:solo => nil
|
115
|
+
}
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should set Gems.versions" do
|
120
|
+
Stasis::Gems.versions.should == {
|
121
|
+
:mysql2 => "=0.2.6",
|
122
|
+
:rake => ">0.8.6",
|
123
|
+
:rspec => "=2.3.0"
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should return proper values for Gems.dependencies" do
|
128
|
+
Stasis::Gems.dependencies.should == [ :rake, :mysql2 ]
|
129
|
+
Stasis::Gems.development_dependencies.should == []
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should return proper values for Gems.gemset_names" do
|
133
|
+
Stasis::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe :solo do
|
138
|
+
before(:each) do
|
139
|
+
Stasis::Gems.gemset = :solo
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should set @gemset" do
|
143
|
+
Stasis::Gems.gemset.should == :solo
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should set @gemsets" do
|
147
|
+
Stasis::Gems.gemsets.should == {
|
148
|
+
:name => {
|
149
|
+
:rake => ">0.8.6",
|
150
|
+
:default => {
|
151
|
+
:externals => '=1.0.2',
|
152
|
+
:mysql => "=2.8.1",
|
153
|
+
:rspec => "=1.3.1"
|
154
|
+
},
|
155
|
+
:rspec2 => {
|
156
|
+
:mysql2=>"=0.2.6",
|
157
|
+
:rspec => "=2.3.0"
|
158
|
+
},
|
159
|
+
:solo => nil
|
160
|
+
}
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should set Gems.versions" do
|
165
|
+
Stasis::Gems.versions.should == {:rake=>">0.8.6"}
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should return proper values for Gems.dependencies" do
|
169
|
+
Stasis::Gems.dependencies.should == [:rake]
|
170
|
+
Stasis::Gems.development_dependencies.should == []
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should return proper values for Gems.gemset_names" do
|
174
|
+
Stasis::Gems.gemset_names.should == [ :default, :rspec2, :solo ]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe :nil do
|
179
|
+
before(:each) do
|
180
|
+
Stasis::Gems.gemset = nil
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should set everything to nil" do
|
184
|
+
Stasis::Gems.gemset.should == nil
|
185
|
+
Stasis::Gems.gemsets.should == nil
|
186
|
+
Stasis::Gems.versions.should == nil
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe :gemset_from_loaded_specs do
|
192
|
+
before(:each) do
|
193
|
+
Gem.stub!(:loaded_specs)
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should return the correct gemset for name gem" do
|
197
|
+
Gem.should_receive(:loaded_specs).and_return({ "name" => nil })
|
198
|
+
Stasis::Gems.send(:gemset_from_loaded_specs).should == :default
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should return the correct gemset for name-rspec gem" do
|
202
|
+
Gem.should_receive(:loaded_specs).and_return({ "name-rspec2" => nil })
|
203
|
+
Stasis::Gems.send(:gemset_from_loaded_specs).should == :rspec2
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe :reload_gemspec do
|
208
|
+
it "should populate @gemspec" do
|
209
|
+
Stasis::Gems.gemspec.hash.should == {
|
210
|
+
"name" => "name",
|
211
|
+
"version" => "0.1.0",
|
212
|
+
"authors" => ["Author"],
|
213
|
+
"email" => "email@email.com",
|
214
|
+
"homepage" => "http://github.com/author/name",
|
215
|
+
"summary" => "Summary",
|
216
|
+
"description" => "Description",
|
217
|
+
"dependencies" => [
|
218
|
+
"rake",
|
219
|
+
{ "default" => [ "mysql" ] },
|
220
|
+
{ "rspec2" => [ "mysql2" ] }
|
221
|
+
],
|
222
|
+
"development_dependencies" => nil
|
223
|
+
}
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should create methods from keys of @gemspec" do
|
227
|
+
Stasis::Gems.gemspec.name.should == "name"
|
228
|
+
Stasis::Gems.gemspec.version.should == "0.1.0"
|
229
|
+
Stasis::Gems.gemspec.authors.should == ["Author"]
|
230
|
+
Stasis::Gems.gemspec.email.should == "email@email.com"
|
231
|
+
Stasis::Gems.gemspec.homepage.should == "http://github.com/author/name"
|
232
|
+
Stasis::Gems.gemspec.summary.should == "Summary"
|
233
|
+
Stasis::Gems.gemspec.description.should == "Description"
|
234
|
+
Stasis::Gems.gemspec.dependencies.should == [
|
235
|
+
"rake",
|
236
|
+
{ "default" => ["mysql"] },
|
237
|
+
{ "rspec2" => [ "mysql2" ] }
|
238
|
+
]
|
239
|
+
Stasis::Gems.gemspec.development_dependencies.should == nil
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should produce a valid gemspec" do
|
243
|
+
Stasis::Gems.gemset = :default
|
244
|
+
gemspec = File.expand_path("../../../stasis.gemspec", __FILE__)
|
245
|
+
gemspec = eval(File.read(gemspec), binding, gemspec)
|
246
|
+
gemspec.validate.should == true
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Stasis::Before do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
generate
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should set class variables for index.html" do
|
10
|
+
$files['index.html'].should =~ /@before_index_literal\nroot/
|
11
|
+
$files['index.html'].should =~ /@before_index_regexp\nroot/
|
12
|
+
$files['index.html'].should =~ /@before_all\nroot/
|
13
|
+
$files['index.html'].should =~ /@fail\nfalse/
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should set class variables for subdirectory/index.html" do
|
17
|
+
$files['subdirectory/index.html'].should =~ /@before_index_literal\nsubdirectory/
|
18
|
+
$files['subdirectory/index.html'].should =~ /@before_index_regexp\nsubdirectory/
|
19
|
+
$files['subdirectory/index.html'].should =~ /@before_all\nsubdirectory/
|
20
|
+
$files['subdirectory/index.html'].should =~ /@fail\nfalse/
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should set class variables for no_controller/index.html" do
|
24
|
+
$files['no_controller/index.html'].should =~ /@before_index_literal\nno_controller/
|
25
|
+
$files['no_controller/index.html'].should =~ /@before_index_regexp\nroot/
|
26
|
+
$files['no_controller/index.html'].should =~ /@before_all\nroot/
|
27
|
+
$files['no_controller/index.html'].should =~ /@fail\nfalse/
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should render text to before_render_text.html" do
|
31
|
+
$files['before_render_text.html'].should =~ /root/
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should render text to subdirectory/before_render_text.html" do
|
35
|
+
$files['subdirectory/before_render_text.html'].should =~ /subdirectory/
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should render partial to before_render_text.html" do
|
39
|
+
$files['before_render_partial.html'].should =~ /root/
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should render partial to subdirectory/before_render_text.html" do
|
43
|
+
$files['subdirectory/before_render_partial.html'].should =~ /subdirectory/
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should render partial to before_non_existent.html" do
|
47
|
+
$files['before_non_existent.html'].should =~ /root/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should render partial to subdirectory/before_non_existent.html" do
|
51
|
+
$files['subdirectory/before_non_existent.html'].should =~ /subdirectory/
|
52
|
+
end
|
53
|
+
end
|