stasis 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gitignore +10 -0
  2. data/LICENSE +18 -0
  3. data/README.md +287 -0
  4. data/Rakefile +109 -0
  5. data/bin/stasis +30 -0
  6. data/config/gemsets.yml +9 -0
  7. data/config/gemspec.yml +17 -0
  8. data/lib/stasis.rb +291 -0
  9. data/lib/stasis/dev_mode.rb +55 -0
  10. data/lib/stasis/gems.rb +154 -0
  11. data/lib/stasis/plugin.rb +76 -0
  12. data/lib/stasis/plugins/before.rb +50 -0
  13. data/lib/stasis/plugins/helpers.rb +29 -0
  14. data/lib/stasis/plugins/ignore.rb +35 -0
  15. data/lib/stasis/plugins/instead.rb +15 -0
  16. data/lib/stasis/plugins/layout.rb +51 -0
  17. data/lib/stasis/plugins/priority.rb +41 -0
  18. data/lib/stasis/plugins/render.rb +71 -0
  19. data/lib/stasis/scope.rb +54 -0
  20. data/lib/stasis/scope/action.rb +25 -0
  21. data/lib/stasis/scope/controller.rb +62 -0
  22. data/lib/stasis/server.rb +90 -0
  23. data/site/arrow.png +0 -0
  24. data/site/controller.rb +72 -0
  25. data/site/github.png +0 -0
  26. data/site/index.html.haml +24 -0
  27. data/site/jquery-1.6.2.js +8982 -0
  28. data/site/stasis.css.scss +226 -0
  29. data/site/stasis.js.coffee +42 -0
  30. data/site/stasis.png +0 -0
  31. data/spec/fixtures/gemsets.yml +9 -0
  32. data/spec/fixtures/gemspec.yml +15 -0
  33. data/spec/fixtures/project/_partial.html.haml +1 -0
  34. data/spec/fixtures/project/before_render_partial.html.haml +1 -0
  35. data/spec/fixtures/project/before_render_text.html.haml +1 -0
  36. data/spec/fixtures/project/controller.rb +83 -0
  37. data/spec/fixtures/project/index.html.haml +16 -0
  38. data/spec/fixtures/project/layout.html.haml +3 -0
  39. data/spec/fixtures/project/layout_action.html.haml +1 -0
  40. data/spec/fixtures/project/layout_action_from_subdirectory.html.haml +1 -0
  41. data/spec/fixtures/project/layout_controller.html.haml +1 -0
  42. data/spec/fixtures/project/layout_controller_from_subdirectory.html.haml +1 -0
  43. data/spec/fixtures/project/no_controller/index.html.haml +12 -0
  44. data/spec/fixtures/project/not_dynamic.html +1 -0
  45. data/spec/fixtures/project/plugin.rb +16 -0
  46. data/spec/fixtures/project/subdirectory/_partial.html.haml +1 -0
  47. data/spec/fixtures/project/subdirectory/before_render_partial.html.haml +1 -0
  48. data/spec/fixtures/project/subdirectory/before_render_text.html.haml +1 -0
  49. data/spec/fixtures/project/subdirectory/controller.rb +66 -0
  50. data/spec/fixtures/project/subdirectory/ignore.html.haml +0 -0
  51. data/spec/fixtures/project/subdirectory/index.html.haml +14 -0
  52. data/spec/fixtures/project/subdirectory/layout.html.haml +3 -0
  53. data/spec/fixtures/project/subdirectory/layout_action.html.haml +1 -0
  54. data/spec/fixtures/project/subdirectory/layout_action_from_root.html.haml +1 -0
  55. data/spec/fixtures/project/subdirectory/layout_controller.html.haml +1 -0
  56. data/spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml +1 -0
  57. data/spec/fixtures/project/time.html.haml +2 -0
  58. data/spec/spec_helper.rb +28 -0
  59. data/spec/stasis/gems_spec.rb +249 -0
  60. data/spec/stasis/plugins/before_spec.rb +53 -0
  61. data/spec/stasis/plugins/helpers_spec.rb +16 -0
  62. data/spec/stasis/plugins/ignore_spec.rb +17 -0
  63. data/spec/stasis/plugins/layout_spec.rb +22 -0
  64. data/spec/stasis/plugins/priority_spec.rb +22 -0
  65. data/spec/stasis/plugins/render_spec.rb +23 -0
  66. data/spec/stasis/server_spec.rb +29 -0
  67. data/spec/stasis_spec.rb +46 -0
  68. data/stasis.gemspec +32 -0
  69. metadata +227 -0
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stasis::Helpers do
4
+
5
+ before(:all) do
6
+ generate
7
+ end
8
+
9
+ it "should display the helper in index.html" do
10
+ $files['index.html'].should =~ /helpers\nroot/
11
+ end
12
+
13
+ it "should display the helper in subdirectory/index.html" do
14
+ $files['subdirectory/index.html'].should =~ /helpers\nsubdirectory/
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stasis::Ignore do
4
+
5
+ before(:all) do
6
+ generate
7
+ end
8
+
9
+ it "should ignore partials" do
10
+ $files['_partial.html'].should == nil
11
+ $files['subdirectory/_partial.html'].should == nil
12
+ end
13
+
14
+ it "should ignore subdirectory/ignore.html.haml" do
15
+ $files['subdirectory/ignore.html'].should == nil
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stasis::Layout do
4
+
5
+ before(:all) do
6
+ generate
7
+ end
8
+
9
+ it "should render root layouts" do
10
+ $files['layout_action.html'].should =~ /layout\nroot\npass/
11
+ $files['layout_action_from_subdirectory.html'].should =~ /layout\nsubdirectory\npass/
12
+ $files['layout_controller.html'].should =~ /layout\nroot\npass/
13
+ $files['layout_controller_from_subdirectory.html'].should =~ /layout\nsubdirectory\npass/
14
+ end
15
+
16
+ it "should render subdirectory layouts" do
17
+ $files['subdirectory/layout_action.html'].should =~ /layout\nsubdirectory\npass/
18
+ $files['subdirectory/layout_action_from_root.html'].should =~ /layout\nroot\npass/
19
+ $files['subdirectory/layout_controller.html'].should =~ /layout\nsubdirectory\npass/
20
+ $files['subdirectory/layout_controller_from_root.html'].should =~ /layout\nroot\npass/
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stasis::Priority do
4
+
5
+ before(:all) do
6
+ generate
7
+ end
8
+
9
+ it "should prioritize to top" do
10
+ # One of these will render a partial, so grabbing the top 3 instead of 2.
11
+ top_3 = $render_order[0..2]
12
+ top_3.any? { |p| p == "#{$fixture}/subdirectory/before_render_partial.html.haml" }.should == true
13
+ top_3.any? { |p| p == "#{$fixture}/before_render_partial.html.haml" }.should == true
14
+ end
15
+
16
+ it "should prioritize to bottom" do
17
+ # These both render two partials each, so grab the bottom 6 instead of 2.
18
+ bot_6 = $render_order[-6..-1]
19
+ bot_6.any? { |p| p == "#{$fixture}/subdirectory/index.html.haml" }.should == true
20
+ bot_6.any? { |p| p == "#{$fixture}/index.html.haml" }.should == true
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stasis::Render do
4
+
5
+ before(:all) do
6
+ generate
7
+ end
8
+
9
+ it "should render partials into index.html" do
10
+ $files['index.html'].should =~ /render from root\nroot/
11
+ $files['index.html'].should =~ /render from subdirectory\nsubdirectory/
12
+ end
13
+
14
+ it "should render partials into subdirectory/index.html" do
15
+ $files['subdirectory/index.html'].should =~ /render from root\nroot/
16
+ $files['subdirectory/index.html'].should =~ /render from subdirectory\nsubdirectory/
17
+ end
18
+
19
+ it "should render partials into no_controller/index.html" do
20
+ $files['no_controller/index.html'].should =~ /render from root\nroot/
21
+ $files['no_controller/index.html'].should =~ /render from subdirectory\nsubdirectory/
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stasis::Server do
4
+
5
+ before(:all) do
6
+ generate
7
+ @thread = Thread.new do
8
+ Stasis::Server.new($fixture, :server => 'localhost:6379/0')
9
+ end
10
+ end
11
+
12
+ after(:all) do
13
+ @thread.kill
14
+ end
15
+
16
+ it "should change time.html" do
17
+ time = $files['time.html'].split("time")[1].strip
18
+ new_time = Stasis::Server.push(
19
+ :paths => [ 'time.html.haml' ],
20
+ :redis => 'localhost:6379/0',
21
+ :return => true
22
+ )['time.html.haml'].split("time")[1].strip
23
+ time.should_not == new_time
24
+ generate_files
25
+ new_time_from_file = $files['time.html'].split("time")[1].strip
26
+ new_time_from_file.should == new_time
27
+ new_time_from_file.should_not == time
28
+ end
29
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe Stasis do
4
+
5
+ before(:all) do
6
+ generate
7
+ end
8
+
9
+ it "should copy files that are not markup" do
10
+ $files['not_dynamic.html'].should =~ /pass/
11
+ end
12
+
13
+ it "should use the custom plugin" do
14
+ $files['custom_plugin.html'].should =~ /pass/
15
+ end
16
+
17
+ describe 'generate with :only option' do
18
+
19
+ before(:each) do
20
+ @index_time = $files['index.html'].split("time")[1].strip
21
+ @time_time = $files['time.html'].split("time")[1].strip
22
+ end
23
+
24
+ describe :string do
25
+
26
+ it "should respect the :only option" do
27
+ generate(:only => 'time.html.haml', :reload => true)
28
+ new_index_time = $files['index.html'].split("time")[1].strip
29
+ new_time_time = $files['time.html'].split("time")[1].strip
30
+ new_index_time.should == @index_time
31
+ new_time_time.should_not == @time_time
32
+ end
33
+ end
34
+
35
+ describe :regex do
36
+
37
+ it "should respect the :only option" do
38
+ generate(:only => /time.html.haml/, :reload => true)
39
+ new_index_time = $files['index.html'].split("time")[1].strip
40
+ new_time_time = $files['time.html'].split("time")[1].strip
41
+ new_index_time.should == @index_time
42
+ new_time_time.should_not == @time_time
43
+ end
44
+ end
45
+ end
46
+ end
data/stasis.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ root = File.expand_path('../', __FILE__)
3
+ lib = "#{root}/lib"
4
+ $:.unshift lib unless $:.include?(lib)
5
+
6
+ require 'stasis/gems'
7
+ Stasis::Gems.gemset ||= ENV['GEMSET'] || :default
8
+
9
+ Gem::Specification.new do |s|
10
+ Stasis::Gems.gemspec.hash.each do |key, value|
11
+ if key == 'name' && Stasis::Gems.gemset != :default
12
+ s.name = "#{value}-#{Stasis::Gems.gemset}"
13
+ elsif key == 'summary' && Stasis::Gems.gemset == :solo
14
+ s.summary = value + " (no dependencies)"
15
+ elsif !%w(dependencies development_dependencies).include?(key)
16
+ s.send "#{key}=", value
17
+ end
18
+ end
19
+
20
+ Stasis::Gems.dependencies.each do |g|
21
+ s.add_dependency g.to_s, Stasis::Gems.versions[g]
22
+ end
23
+
24
+ Stasis::Gems.development_dependencies.each do |g|
25
+ s.add_development_dependency g.to_s, Stasis::Gems.versions[g]
26
+ end
27
+
28
+ s.executables = `cd #{root} && git ls-files bin/*`.split("\n").collect { |f| File.basename(f) }
29
+ s.files = `cd #{root} && git ls-files`.split("\n")
30
+ s.require_paths = %w(lib)
31
+ s.test_files = `cd #{root} && git ls-files -- {features,test,spec}/*`.split("\n")
32
+ end
metadata ADDED
@@ -0,0 +1,227 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stasis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Winton Welsh
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: directory_watcher
16
+ requirement: &70130541611160 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70130541611160
25
+ - !ruby/object:Gem::Dependency
26
+ name: redis
27
+ requirement: &70130541610700 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.2.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70130541610700
36
+ - !ruby/object:Gem::Dependency
37
+ name: slop
38
+ requirement: &70130541610260 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.1.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70130541610260
47
+ - !ruby/object:Gem::Dependency
48
+ name: tilt
49
+ requirement: &70130541609820 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70130541609820
58
+ - !ruby/object:Gem::Dependency
59
+ name: yajl-ruby
60
+ requirement: &70130541609380 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 0.8.2
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70130541609380
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &70130541608800 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: 0.8.7
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70130541608800
80
+ - !ruby/object:Gem::Dependency
81
+ name: rspec
82
+ requirement: &70130541608360 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '1.0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70130541608360
91
+ description: A markup-agnostic static site generator.
92
+ email: mail@wintoni.us
93
+ executables:
94
+ - stasis
95
+ extensions: []
96
+ extra_rdoc_files: []
97
+ files:
98
+ - .gitignore
99
+ - LICENSE
100
+ - README.md
101
+ - Rakefile
102
+ - bin/stasis
103
+ - config/gemsets.yml
104
+ - config/gemspec.yml
105
+ - lib/stasis.rb
106
+ - lib/stasis/dev_mode.rb
107
+ - lib/stasis/gems.rb
108
+ - lib/stasis/plugin.rb
109
+ - lib/stasis/plugins/before.rb
110
+ - lib/stasis/plugins/helpers.rb
111
+ - lib/stasis/plugins/ignore.rb
112
+ - lib/stasis/plugins/instead.rb
113
+ - lib/stasis/plugins/layout.rb
114
+ - lib/stasis/plugins/priority.rb
115
+ - lib/stasis/plugins/render.rb
116
+ - lib/stasis/scope.rb
117
+ - lib/stasis/scope/action.rb
118
+ - lib/stasis/scope/controller.rb
119
+ - lib/stasis/server.rb
120
+ - site/arrow.png
121
+ - site/controller.rb
122
+ - site/github.png
123
+ - site/index.html.haml
124
+ - site/jquery-1.6.2.js
125
+ - site/stasis.css.scss
126
+ - site/stasis.js.coffee
127
+ - site/stasis.png
128
+ - spec/fixtures/gemsets.yml
129
+ - spec/fixtures/gemspec.yml
130
+ - spec/fixtures/project/_partial.html.haml
131
+ - spec/fixtures/project/before_render_partial.html.haml
132
+ - spec/fixtures/project/before_render_text.html.haml
133
+ - spec/fixtures/project/controller.rb
134
+ - spec/fixtures/project/index.html.haml
135
+ - spec/fixtures/project/layout.html.haml
136
+ - spec/fixtures/project/layout_action.html.haml
137
+ - spec/fixtures/project/layout_action_from_subdirectory.html.haml
138
+ - spec/fixtures/project/layout_controller.html.haml
139
+ - spec/fixtures/project/layout_controller_from_subdirectory.html.haml
140
+ - spec/fixtures/project/no_controller/index.html.haml
141
+ - spec/fixtures/project/not_dynamic.html
142
+ - spec/fixtures/project/plugin.rb
143
+ - spec/fixtures/project/subdirectory/_partial.html.haml
144
+ - spec/fixtures/project/subdirectory/before_render_partial.html.haml
145
+ - spec/fixtures/project/subdirectory/before_render_text.html.haml
146
+ - spec/fixtures/project/subdirectory/controller.rb
147
+ - spec/fixtures/project/subdirectory/ignore.html.haml
148
+ - spec/fixtures/project/subdirectory/index.html.haml
149
+ - spec/fixtures/project/subdirectory/layout.html.haml
150
+ - spec/fixtures/project/subdirectory/layout_action.html.haml
151
+ - spec/fixtures/project/subdirectory/layout_action_from_root.html.haml
152
+ - spec/fixtures/project/subdirectory/layout_controller.html.haml
153
+ - spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml
154
+ - spec/fixtures/project/time.html.haml
155
+ - spec/spec_helper.rb
156
+ - spec/stasis/gems_spec.rb
157
+ - spec/stasis/plugins/before_spec.rb
158
+ - spec/stasis/plugins/helpers_spec.rb
159
+ - spec/stasis/plugins/ignore_spec.rb
160
+ - spec/stasis/plugins/layout_spec.rb
161
+ - spec/stasis/plugins/priority_spec.rb
162
+ - spec/stasis/plugins/render_spec.rb
163
+ - spec/stasis/server_spec.rb
164
+ - spec/stasis_spec.rb
165
+ - stasis.gemspec
166
+ homepage: http://wintoni.us
167
+ licenses: []
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ! '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ none: false
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ requirements: []
185
+ rubyforge_project:
186
+ rubygems_version: 1.8.6
187
+ signing_key:
188
+ specification_version: 3
189
+ summary: Markup-agnostic static site generator
190
+ test_files:
191
+ - spec/fixtures/gemsets.yml
192
+ - spec/fixtures/gemspec.yml
193
+ - spec/fixtures/project/_partial.html.haml
194
+ - spec/fixtures/project/before_render_partial.html.haml
195
+ - spec/fixtures/project/before_render_text.html.haml
196
+ - spec/fixtures/project/controller.rb
197
+ - spec/fixtures/project/index.html.haml
198
+ - spec/fixtures/project/layout.html.haml
199
+ - spec/fixtures/project/layout_action.html.haml
200
+ - spec/fixtures/project/layout_action_from_subdirectory.html.haml
201
+ - spec/fixtures/project/layout_controller.html.haml
202
+ - spec/fixtures/project/layout_controller_from_subdirectory.html.haml
203
+ - spec/fixtures/project/no_controller/index.html.haml
204
+ - spec/fixtures/project/not_dynamic.html
205
+ - spec/fixtures/project/plugin.rb
206
+ - spec/fixtures/project/subdirectory/_partial.html.haml
207
+ - spec/fixtures/project/subdirectory/before_render_partial.html.haml
208
+ - spec/fixtures/project/subdirectory/before_render_text.html.haml
209
+ - spec/fixtures/project/subdirectory/controller.rb
210
+ - spec/fixtures/project/subdirectory/ignore.html.haml
211
+ - spec/fixtures/project/subdirectory/index.html.haml
212
+ - spec/fixtures/project/subdirectory/layout.html.haml
213
+ - spec/fixtures/project/subdirectory/layout_action.html.haml
214
+ - spec/fixtures/project/subdirectory/layout_action_from_root.html.haml
215
+ - spec/fixtures/project/subdirectory/layout_controller.html.haml
216
+ - spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml
217
+ - spec/fixtures/project/time.html.haml
218
+ - spec/spec_helper.rb
219
+ - spec/stasis/gems_spec.rb
220
+ - spec/stasis/plugins/before_spec.rb
221
+ - spec/stasis/plugins/helpers_spec.rb
222
+ - spec/stasis/plugins/ignore_spec.rb
223
+ - spec/stasis/plugins/layout_spec.rb
224
+ - spec/stasis/plugins/priority_spec.rb
225
+ - spec/stasis/plugins/render_spec.rb
226
+ - spec/stasis/server_spec.rb
227
+ - spec/stasis_spec.rb