stasis 0.1.23 → 0.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,6 +3,8 @@ Stasis
3
3
 
4
4
  Stasis is a dynamic framework for static sites.
5
5
 
6
+ [![Build Status](https://secure.travis-ci.org/winton/stasis.png)](http://travis-ci.org/winton/stasis)
7
+
6
8
  Install
7
9
  -------
8
10
 
@@ -266,44 +268,6 @@ Stasis uses [Tilt](https://github.com/rtomayko/tilt) to support the following te
266
268
  WikiCloth (Wiki markup) .wiki, .mediawiki, .mw
267
269
  Yajl .yajl
268
270
 
269
- ### Server Mode
270
-
271
- Stasis can run as a server that uses [redis](http://redis.io) to wait for render jobs.
272
-
273
- Stasis server that uses redis on port 6379:
274
-
275
- <!-- highlight:-s language:console -->
276
-
277
- $ stasis -s localhost:6379/0
278
-
279
- Push to the server (in Ruby):
280
-
281
- Stasis::Server.push(
282
- # Paths to render
283
- :paths => [ "index.html.haml", "subdirectory" ],
284
-
285
- # Made available to views as `params`
286
- :params => {},
287
-
288
- # Redis address
289
- :redis => "localhost:6379/0",
290
-
291
- # Return rendered templates (false by default)
292
- :return => false,
293
-
294
- # Block until templates generate (false by default)
295
- :wait => false,
296
-
297
- # Write to the filesystem (true by default)
298
- :write => true,
299
-
300
- # Cache ttl for returned templates (nil by default)
301
- :ttl => nil,
302
-
303
- # Force write even if cached (false by default)
304
- :force => false
305
- )
306
-
307
271
  ### This Web Site
308
272
 
309
273
  [Take a look at the Stasis project](https://github.com/winton/stasis/tree/master/site) that automatically generated this web site from the project [README](https://github.com/winton/stasis/blob/master/README.md).
data/bin/stasis CHANGED
@@ -2,18 +2,17 @@
2
2
 
3
3
  require File.expand_path(File.dirname(__FILE__) + "/../lib/stasis")
4
4
 
5
- gem "slop", "~> 2.1.0"
5
+ gem "slop", "3.3.2"
6
6
  require 'slop'
7
7
 
8
- slop = Slop.parse :help => true do
9
- on :d, :development, "Development mode\t\t(auto-regenerate)", :optional => true, :as => Integer
10
- on :o, :only, "Only generate specific files\t(comma-separated)", :optional => true, :as => Array
11
- on :p, :public, "Public directory path", :optional => true
12
- on :s, :server, "Server mode\t\t\t(default redis host: localhost:6379/0)", :optional => true, :default => "localhost:6379/0"
8
+ slop = Slop.parse :help => true, :optional_arguments => true do
9
+ on :d, :development, "Development mode", :as => Integer
10
+ on :o, :only, "Only generate specific files (comma-separated)", :as => Array
11
+ on :p, :public, "Public directory path"
13
12
  end
14
13
 
14
+ exit if slop.help?
15
15
  options = slop.to_hash
16
- options.delete(:server) unless slop.server?
17
16
 
18
17
  if slop.development?
19
18
  require 'stasis/dev_mode'
@@ -22,9 +21,6 @@ elsif slop.only? && slop.public?
22
21
  Stasis.new(Dir.pwd, slop[:public], options).render(*slop[:only])
23
22
  elsif slop.only?
24
23
  Stasis.new(Dir.pwd, options).render(*slop[:only])
25
- elsif slop.server?
26
- require 'stasis/server'
27
- Stasis::Server.new(Dir.pwd, options)
28
24
  elsif slop.public?
29
25
  Stasis.new(Dir.pwd, slop[:public], options).render(*(slop[:only].to_a))
30
26
  else
@@ -0,0 +1,20 @@
1
+ class String
2
+
3
+ # Colors
4
+
5
+ def blue
6
+ "\e[34m#{self}\e[0m"
7
+ end
8
+
9
+ def green
10
+ "\e[32m#{self}\e[0m"
11
+ end
12
+
13
+ def red
14
+ "\e[31m#{self}\e[0m"
15
+ end
16
+
17
+ def yellow
18
+ "\e[33m#{self}\e[0m"
19
+ end
20
+ end
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  # Activate the [Tilt][ti] gem.
20
20
 
21
- gem "tilt", "~> 1.3.3"
21
+ gem "tilt", "1.3.3"
22
22
 
23
23
  # Add the project directory to the load paths.
24
24
 
@@ -28,6 +28,8 @@ $:.unshift File.dirname(__FILE__)
28
28
  # 'stasis/server'. Those are demand-loaded when the corresponding command-line
29
29
  # options are passed.
30
30
 
31
+ require 'ext/string'
32
+
31
33
  require 'stasis/options'
32
34
  require 'stasis/plugin'
33
35
 
@@ -115,7 +117,7 @@ class Stasis
115
117
  @controller = Controller.new(self)
116
118
 
117
119
  # Reload controllers
118
- Dir["#{@root}/**/controller.rb"].each do |path|
120
+ Dir["#{@root}/**/controller.rb"].sort.each do |path|
119
121
  @controller._add(path) unless path[0..@destination.length-1] == @destination
120
122
  end
121
123
  end
@@ -179,6 +181,9 @@ class Stasis
179
181
  Tilt.mappings.keys.detect do |ext|
180
182
  File.extname(@path)[1..-1] == ext
181
183
  end
184
+
185
+ # Change current working directory.
186
+ Dir.chdir(File.dirname(@path))
182
187
 
183
188
  # Trigger all plugin `before_render` events.
184
189
  trigger(:before_render)
@@ -186,9 +191,6 @@ class Stasis
186
191
  # Skip if `@path` set to `nil`.
187
192
  next unless @path
188
193
 
189
- # Change current working directory.
190
- Dir.chdir(File.dirname(@path))
191
-
192
194
  # Render the view.
193
195
  view =
194
196
  # If the path has an extension supported by [Tilt][ti]...
@@ -294,8 +296,10 @@ class Stasis
294
296
  # Add a plugin to all existing controller instances. This method should be called by
295
297
  # all external plugins.
296
298
  def self.register(plugin)
297
- @instances.each do |stasis|
298
- stasis.add_plugin(plugin)
299
+ if @instances
300
+ @instances.each do |stasis|
301
+ stasis.add_plugin(plugin)
302
+ end
299
303
  end
300
304
  end
301
305
 
@@ -1,4 +1,4 @@
1
- gem "directory_watcher", "~> 1.4.1"
1
+ gem 'directory_watcher', '1.4.1'
2
2
  require 'directory_watcher'
3
3
 
4
4
  require 'logger'
@@ -10,43 +10,48 @@ class Stasis
10
10
  def initialize(dir, options={})
11
11
  trap("INT") { exit }
12
12
 
13
- puts "\nDevelopment mode enabled: #{dir}"
13
+ puts "\nDevelopment mode enabled: ".green + dir
14
14
  $stdout.flush
15
15
 
16
- @dir = dir
17
16
  @options = options
18
17
  @options[:development] ||= true
19
18
 
20
- @stasis = Stasis.new(*[ @dir, @options[:public], @options ].compact)
19
+ @stasis = Stasis.new(*[ dir, @options[:public], @options ].compact)
21
20
 
22
- dw = DirectoryWatcher.new(@stasis.root)
23
- dw.interval = 0.1
24
-
25
- Dir.chdir(@stasis.root) do
26
- within_public = @stasis.destination[0..@stasis.root.length-1] == @stasis.root
27
- rel_public = @stasis.destination[@stasis.root.length+1..-1] rescue nil
28
- dw.glob = Dir["*"].inject(["*"]) do |array, path|
29
- if File.directory?(path) && (!within_public || path != rel_public)
30
- array << "#{path}/**/*"
21
+ glob =
22
+ Dir.chdir(@stasis.root) do
23
+ # If destination is within root
24
+ if @stasis.destination[0..@stasis.root.length] == "#{@stasis.root}/"
25
+ relative = @stasis.destination[@stasis.root.length+1..-1] rescue nil
26
+ Dir["*"].inject(["*"]) do |array, path|
27
+ if File.directory?(path) && path != relative
28
+ array.push("#{path}/**/*")
29
+ end
30
+ array
31
+ end
32
+ else
33
+ [ "*", "**/*" ]
31
34
  end
32
- array
33
35
  end
34
- end
35
36
 
37
+ dw = DirectoryWatcher.new(@stasis.root)
36
38
  dw.add_observer { render }
39
+ dw.glob = glob
40
+ dw.interval = 0.1
37
41
  dw.start
38
42
 
39
- if options[:development].is_a?(::Integer)
43
+ if @options[:development].is_a?(::Integer)
40
44
  mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
41
45
  mime_types.store 'js', 'application/javascript'
42
46
 
43
- outfile = (RUBY_PLATFORM =~ /mswin|mingw/) ? 'NUL:' : '/dev/null'
44
47
  server = WEBrick::HTTPServer.new(
45
48
  :AccessLog => [ nil, nil ],
46
49
  :DocumentRoot => @stasis.destination,
47
- :Logger => WEBrick::Log.new(outfile),
50
+ :Logger => WEBrick::Log.new(
51
+ (RUBY_PLATFORM =~ /mswin|mingw/) ? 'NUL:' : '/dev/null'
52
+ ),
48
53
  :MimeTypes => mime_types,
49
- :Port => options[:development]
54
+ :Port => @options[:development]
50
55
  )
51
56
 
52
57
  ['INT', 'TERM'].each do |signal|
@@ -55,24 +60,24 @@ class Stasis
55
60
 
56
61
  server.start
57
62
  else
58
- loop { sleep 1000 }
63
+ loop { sleep 1 }
59
64
  end
60
65
  end
61
66
 
62
67
  private
63
68
 
64
69
  def render
65
- puts "\n[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] Regenerating #{@options[:only] ? @options[:only].join(', ') : 'project'}..."
70
+ puts "\n[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}]" + " Regenerating #{@options[:only] ? @options[:only].join(', ') : 'project'}...".yellow
66
71
  begin
67
72
  @stasis.load_paths
68
73
  @stasis.trigger(:reset)
69
74
  @stasis.load_controllers
70
75
  @stasis.render(*[ @options[:only] ].flatten.compact)
71
76
  rescue Exception => e
72
- puts "\n[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] Error: #{e.message}`"
77
+ puts "\n[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}]" + " Error: #{e.message}`".red
73
78
  puts "\t#{e.backtrace.join("\n\t")}"
74
79
  else
75
- puts "\n[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] Complete"
80
+ puts "\n[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}]" + " Complete".green
76
81
  end
77
82
  $stdout.flush
78
83
  end
@@ -41,6 +41,10 @@ before 'before_non_existent.html' do
41
41
  instead render(:path => '_partial.html.haml')
42
42
  end
43
43
 
44
+ before 'before_render_locals.html.haml' do
45
+ instead render(:path => '_locals.html.haml', :locals => { :x => true })
46
+ end
47
+
44
48
  # Helpers
45
49
 
46
50
  helpers do
@@ -0,0 +1 @@
1
+ = render :path => '_locals.html.haml', :locals => { :x => true }
@@ -31,6 +31,10 @@ before 'before_render_partial.html.haml', 'before_non_existent.html' do
31
31
  instead render(:path => '_partial.html.haml')
32
32
  end
33
33
 
34
+ before 'before_render_locals.html.haml' do
35
+ instead render(:path => '_locals.html.haml', :locals => { :x => true })
36
+ end
37
+
34
38
  # Helpers
35
39
 
36
40
  helpers do
@@ -0,0 +1 @@
1
+ = render :path => '_locals.html.haml', :locals => { :x => true }
@@ -20,4 +20,20 @@ describe Stasis::Render do
20
20
  $files['no_controller/index.html'].should =~ /render from root\nroot/
21
21
  $files['no_controller/index.html'].should =~ /render from subdirectory\nsubdirectory/
22
22
  end
23
+
24
+ it "should render locals into before_render_locals.html" do
25
+ $files['before_render_locals.html'].should =~ /true/
26
+ end
27
+
28
+ it "should render locals into subdirectory/before_render_locals.html" do
29
+ $files['subdirectory/before_render_locals.html'].should =~ /true/
30
+ end
31
+
32
+ it "should render locals into render_locals.html" do
33
+ $files['render_locals.html'].should =~ /true/
34
+ end
35
+
36
+ it "should render locals into subdirectory/render_locals.html" do
37
+ $files['subdirectory/render_locals.html'].should =~ /true/
38
+ end
23
39
  end
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "stasis"
9
- s.version = '0.1.23'
9
+ s.version = '0.2.0.pre'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ 'Winton Welsh' ]
12
12
  s.email = [ 'mail@wintoni.us' ]
@@ -27,9 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency "rocco"
28
28
  s.add_development_dependency "rspec", "~> 1.0"
29
29
 
30
- s.add_dependency "directory_watcher", "~> 1.4.1"
31
- s.add_dependency "redis", "~> 2.2.2"
32
- s.add_dependency "slop", "~> 2.1.0"
33
- s.add_dependency "tilt", "~> 1.3.3"
34
- s.add_dependency "yajl-ruby", "~> 1.0.0"
30
+ s.add_dependency "directory_watcher", "1.4.1"
31
+ s.add_dependency "slop", "3.3.2"
32
+ s.add_dependency "tilt", "1.3.3"
35
33
  end
metadata CHANGED
@@ -1,211 +1,184 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: stasis
3
- version: !ruby/object:Gem::Version
4
- hash: 53
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 23
10
- version: 0.1.23
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0.pre
5
+ prerelease: 6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Winton Welsh
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-05-21 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
- none: false
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- hash: 3
27
- segments:
28
- - 0
29
- version: "0"
30
- prerelease: false
31
- type: :development
12
+ date: 2012-07-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
32
15
  name: albino
33
- requirement: *id001
34
- - !ruby/object:Gem::Dependency
35
- version_requirements: &id002 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
36
17
  none: false
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- hash: 3
41
- segments:
42
- - 0
43
- version: "0"
44
- prerelease: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
45
22
  type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
46
31
  name: coffee-script
47
- requirement: *id002
48
- - !ruby/object:Gem::Dependency
49
- version_requirements: &id003 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
50
33
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- hash: 3
55
- segments:
56
- - 0
57
- version: "0"
58
- prerelease: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
59
38
  type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
60
47
  name: haml
61
- requirement: *id003
62
- - !ruby/object:Gem::Dependency
63
- version_requirements: &id004 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
64
49
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- hash: 3
69
- segments:
70
- - 0
71
- version: "0"
72
- prerelease: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
73
54
  type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
74
63
  name: nokogiri
75
- requirement: *id004
76
- - !ruby/object:Gem::Dependency
77
- version_requirements: &id005 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
78
65
  none: false
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- hash: 3
83
- segments:
84
- - 0
85
- version: "0"
86
- prerelease: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
87
70
  type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
88
79
  name: rake
89
- requirement: *id005
90
- - !ruby/object:Gem::Dependency
91
- version_requirements: &id006 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
92
81
  none: false
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- hash: 3
97
- segments:
98
- - 0
99
- version: "0"
100
- prerelease: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
101
86
  type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
102
95
  name: rocco
103
- requirement: *id006
104
- - !ruby/object:Gem::Dependency
105
- version_requirements: &id007 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
106
97
  none: false
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- hash: 15
111
- segments:
112
- - 1
113
- - 0
114
- version: "1.0"
115
- prerelease: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
116
102
  type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
117
111
  name: rspec
118
- requirement: *id007
119
- - !ruby/object:Gem::Dependency
120
- version_requirements: &id008 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
121
113
  none: false
122
- requirements:
114
+ requirements:
123
115
  - - ~>
124
- - !ruby/object:Gem::Version
125
- hash: 5
126
- segments:
127
- - 1
128
- - 4
129
- - 1
130
- version: 1.4.1
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :development
131
119
  prerelease: false
132
- type: :runtime
133
- name: directory_watcher
134
- requirement: *id008
135
- - !ruby/object:Gem::Dependency
136
- version_requirements: &id009 !ruby/object:Gem::Requirement
120
+ version_requirements: !ruby/object:Gem::Requirement
137
121
  none: false
138
- requirements:
122
+ requirements:
139
123
  - - ~>
140
- - !ruby/object:Gem::Version
141
- hash: 3
142
- segments:
143
- - 2
144
- - 2
145
- - 2
146
- version: 2.2.2
147
- prerelease: false
148
- type: :runtime
149
- name: redis
150
- requirement: *id009
151
- - !ruby/object:Gem::Dependency
152
- version_requirements: &id010 !ruby/object:Gem::Requirement
124
+ - !ruby/object:Gem::Version
125
+ version: '1.0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: directory_watcher
128
+ requirement: !ruby/object:Gem::Requirement
153
129
  none: false
154
- requirements:
155
- - - ~>
156
- - !ruby/object:Gem::Version
157
- hash: 11
158
- segments:
159
- - 2
160
- - 1
161
- - 0
162
- version: 2.1.0
163
- prerelease: false
130
+ requirements:
131
+ - - '='
132
+ - !ruby/object:Gem::Version
133
+ version: 1.4.1
164
134
  type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - '='
140
+ - !ruby/object:Gem::Version
141
+ version: 1.4.1
142
+ - !ruby/object:Gem::Dependency
165
143
  name: slop
166
- requirement: *id010
167
- - !ruby/object:Gem::Dependency
168
- version_requirements: &id011 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
169
145
  none: false
170
- requirements:
171
- - - ~>
172
- - !ruby/object:Gem::Version
173
- hash: 29
174
- segments:
175
- - 1
176
- - 3
177
- - 3
178
- version: 1.3.3
179
- prerelease: false
146
+ requirements:
147
+ - - '='
148
+ - !ruby/object:Gem::Version
149
+ version: 3.3.2
180
150
  type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - '='
156
+ - !ruby/object:Gem::Version
157
+ version: 3.3.2
158
+ - !ruby/object:Gem::Dependency
181
159
  name: tilt
182
- requirement: *id011
183
- - !ruby/object:Gem::Dependency
184
- version_requirements: &id012 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
185
161
  none: false
186
- requirements:
187
- - - ~>
188
- - !ruby/object:Gem::Version
189
- hash: 23
190
- segments:
191
- - 1
192
- - 0
193
- - 0
194
- version: 1.0.0
195
- prerelease: false
162
+ requirements:
163
+ - - '='
164
+ - !ruby/object:Gem::Version
165
+ version: 1.3.3
196
166
  type: :runtime
197
- name: yajl-ruby
198
- requirement: *id012
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 1.3.3
199
174
  description: Stasis is a dynamic framework for static sites.
200
- email:
175
+ email:
201
176
  - mail@wintoni.us
202
- executables:
177
+ executables:
203
178
  - stasis
204
179
  extensions: []
205
-
206
180
  extra_rdoc_files: []
207
-
208
- files:
181
+ files:
209
182
  - .gitignore
210
183
  - .travis.yml
211
184
  - Gemfile
@@ -213,6 +186,7 @@ files:
213
186
  - README.md
214
187
  - Rakefile
215
188
  - bin/stasis
189
+ - lib/ext/string.rb
216
190
  - lib/stasis.rb
217
191
  - lib/stasis/dev_mode.rb
218
192
  - lib/stasis/options.rb
@@ -227,7 +201,6 @@ files:
227
201
  - lib/stasis/scope.rb
228
202
  - lib/stasis/scope/action.rb
229
203
  - lib/stasis/scope/controller.rb
230
- - lib/stasis/server.rb
231
204
  - site/arrow.png
232
205
  - site/controller.rb
233
206
  - site/github.png
@@ -237,7 +210,9 @@ files:
237
210
  - site/stasis.js.coffee
238
211
  - site/stasis.png
239
212
  - spec/fixtures/project/.dotfile
213
+ - spec/fixtures/project/_locals.html.haml
240
214
  - spec/fixtures/project/_partial.html.haml
215
+ - spec/fixtures/project/before_render_locals.html.haml
241
216
  - spec/fixtures/project/before_render_partial.html.haml
242
217
  - spec/fixtures/project/before_render_text.html.haml
243
218
  - spec/fixtures/project/controller.rb
@@ -254,7 +229,10 @@ files:
254
229
  - spec/fixtures/project/not_dynamic.html
255
230
  - spec/fixtures/project/params.html.haml
256
231
  - spec/fixtures/project/plugin.rb
232
+ - spec/fixtures/project/render_locals.html.haml
233
+ - spec/fixtures/project/subdirectory/_locals.html.haml
257
234
  - spec/fixtures/project/subdirectory/_partial.html.haml
235
+ - spec/fixtures/project/subdirectory/before_render_locals.html.haml
258
236
  - spec/fixtures/project/subdirectory/before_render_partial.html.haml
259
237
  - spec/fixtures/project/subdirectory/before_render_text.html.haml
260
238
  - spec/fixtures/project/subdirectory/controller.rb
@@ -265,6 +243,7 @@ files:
265
243
  - spec/fixtures/project/subdirectory/layout_action_from_root.html.haml
266
244
  - spec/fixtures/project/subdirectory/layout_controller.html.haml
267
245
  - spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml
246
+ - spec/fixtures/project/subdirectory/render_locals.html.haml
268
247
  - spec/fixtures/project/time.html.haml
269
248
  - spec/spec_helper.rb
270
249
  - spec/stasis/plugins/before_spec.rb
@@ -273,45 +252,40 @@ files:
273
252
  - spec/stasis/plugins/layout_spec.rb
274
253
  - spec/stasis/plugins/priority_spec.rb
275
254
  - spec/stasis/plugins/render_spec.rb
276
- - spec/stasis/server_spec.rb
277
255
  - spec/stasis_spec.rb
278
256
  - stasis.gemspec
279
257
  homepage: http://stasis.me
280
258
  licenses: []
281
-
282
259
  post_install_message:
283
260
  rdoc_options: []
284
-
285
- require_paths:
261
+ require_paths:
286
262
  - lib
287
- required_ruby_version: !ruby/object:Gem::Requirement
263
+ required_ruby_version: !ruby/object:Gem::Requirement
288
264
  none: false
289
- requirements:
290
- - - ">="
291
- - !ruby/object:Gem::Version
292
- hash: 3
293
- segments:
265
+ requirements:
266
+ - - ! '>='
267
+ - !ruby/object:Gem::Version
268
+ version: '0'
269
+ segments:
294
270
  - 0
295
- version: "0"
296
- required_rubygems_version: !ruby/object:Gem::Requirement
271
+ hash: -658786105732867218
272
+ required_rubygems_version: !ruby/object:Gem::Requirement
297
273
  none: false
298
- requirements:
299
- - - ">="
300
- - !ruby/object:Gem::Version
301
- hash: 3
302
- segments:
303
- - 0
304
- version: "0"
274
+ requirements:
275
+ - - ! '>'
276
+ - !ruby/object:Gem::Version
277
+ version: 1.3.1
305
278
  requirements: []
306
-
307
279
  rubyforge_project:
308
280
  rubygems_version: 1.8.24
309
281
  signing_key:
310
282
  specification_version: 3
311
283
  summary: Static sites made powerful
312
- test_files:
284
+ test_files:
313
285
  - spec/fixtures/project/.dotfile
286
+ - spec/fixtures/project/_locals.html.haml
314
287
  - spec/fixtures/project/_partial.html.haml
288
+ - spec/fixtures/project/before_render_locals.html.haml
315
289
  - spec/fixtures/project/before_render_partial.html.haml
316
290
  - spec/fixtures/project/before_render_text.html.haml
317
291
  - spec/fixtures/project/controller.rb
@@ -328,7 +302,10 @@ test_files:
328
302
  - spec/fixtures/project/not_dynamic.html
329
303
  - spec/fixtures/project/params.html.haml
330
304
  - spec/fixtures/project/plugin.rb
305
+ - spec/fixtures/project/render_locals.html.haml
306
+ - spec/fixtures/project/subdirectory/_locals.html.haml
331
307
  - spec/fixtures/project/subdirectory/_partial.html.haml
308
+ - spec/fixtures/project/subdirectory/before_render_locals.html.haml
332
309
  - spec/fixtures/project/subdirectory/before_render_partial.html.haml
333
310
  - spec/fixtures/project/subdirectory/before_render_text.html.haml
334
311
  - spec/fixtures/project/subdirectory/controller.rb
@@ -339,6 +316,7 @@ test_files:
339
316
  - spec/fixtures/project/subdirectory/layout_action_from_root.html.haml
340
317
  - spec/fixtures/project/subdirectory/layout_controller.html.haml
341
318
  - spec/fixtures/project/subdirectory/layout_controller_from_root.html.haml
319
+ - spec/fixtures/project/subdirectory/render_locals.html.haml
342
320
  - spec/fixtures/project/time.html.haml
343
321
  - spec/spec_helper.rb
344
322
  - spec/stasis/plugins/before_spec.rb
@@ -347,5 +325,4 @@ test_files:
347
325
  - spec/stasis/plugins/layout_spec.rb
348
326
  - spec/stasis/plugins/priority_spec.rb
349
327
  - spec/stasis/plugins/render_spec.rb
350
- - spec/stasis/server_spec.rb
351
328
  - spec/stasis_spec.rb
@@ -1,116 +0,0 @@
1
- gem "redis", "~> 2.2.2"
2
- gem "yajl-ruby", "~> 1.0.0"
3
-
4
- require 'digest/sha1'
5
- require 'redis'
6
- require 'yajl'
7
-
8
- class Stasis
9
- class Server
10
-
11
- def initialize(root, options={})
12
- puts "\nStarting Stasis server (redis @ #{options[:server]})..."
13
-
14
- redis = Redis.connect(:url => "redis://#{options[:server]}")
15
- stasis = Stasis.new(*[ root, options[:public], options ].compact)
16
- retries = 0
17
-
18
- begin
19
- while true
20
- sleep(1.0 / 1000.0)
21
- request = redis.lpop('stasis:requests')
22
-
23
- if request
24
- files = {}
25
- request = Yajl::Parser.parse(request)
26
- paths = request['paths']
27
-
28
- unless request['force']
29
- paths = request['paths'].reject do |path|
30
- files[path] = redis.get("stasis:caches:#{root}:#{path}")
31
- end
32
- end
33
-
34
- if paths.empty? && !request['paths'].empty?
35
- new_files = {}
36
- else
37
- params = request['paths'] + [
38
- {
39
- :collect => request['return'] || request['force'],
40
- :params => request['params'],
41
- :write => request['write']
42
- }
43
- ]
44
- new_files = stasis.render(*params) || {}
45
- end
46
-
47
- if request['ttl']
48
- new_files.each do |path, body|
49
- key = "stasis:caches:#{root}:#{path}"
50
- redis.set(key, body)
51
- redis.expire(key, request['ttl'])
52
- end
53
- end
54
-
55
- if request['return']
56
- request['wait'] = true
57
- end
58
-
59
- if request['wait']
60
- response = files.merge(new_files)
61
- redis.publish(self.class.response_key(request['id']), Yajl::Encoder.encode(response))
62
- end
63
- end
64
- end
65
- rescue Interrupt
66
- shut_down
67
- rescue Exception => e
68
- puts "\nError: #{e.message}"
69
- puts "\t#{e.backtrace.join("\n\t")}"
70
- retries += 1
71
- shut_down if retries >= 10
72
- retry
73
- end
74
- end
75
-
76
- def shut_down
77
- puts "\nShutting down Stasis server..."
78
- exit
79
- end
80
-
81
- class <<self
82
- def push(options)
83
- options[:id] = Digest::SHA1.hexdigest("#{options['paths']}#{rand}")
84
- redis_url = "redis://#{options.delete(:redis) || "localhost:6379/0"}"
85
- response = nil
86
-
87
- redis_1 = Redis.connect(:url => redis_url)
88
- redis_2 = Redis.connect(:url => redis_url)
89
-
90
- if options[:return] || options[:wait]
91
- redis_1.subscribe(response_key(options[:id])) do |on|
92
- on.subscribe do |channel, subscriptions|
93
- redis_2.rpush("stasis:requests", Yajl::Encoder.encode(options))
94
- end
95
-
96
- on.message do |channel, message|
97
- response = Yajl::Parser.parse(message)
98
- redis_1.unsubscribe
99
- end
100
- end
101
- else
102
- redis_1.rpush("stasis:requests", Yajl::Encoder.encode(options))
103
- end
104
-
105
- redis_1.quit
106
- redis_2.quit
107
-
108
- response
109
- end
110
-
111
- def response_key(id)
112
- "stasis:response:#{id}"
113
- end
114
- end
115
- end
116
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
- require 'stasis/server'
3
-
4
- describe Stasis::Server do
5
-
6
- before(:all) do
7
- generate
8
- @thread = Thread.new do
9
- Stasis::Server.new($fixture, :server => 'localhost:6379/0')
10
- end
11
- end
12
-
13
- after(:all) do
14
- @thread.kill
15
- end
16
-
17
- it "should change time.html" do
18
- time = $files['time.html'].split("time")[1].strip
19
- new_time = Stasis::Server.push(
20
- :paths => [ 'time.html.haml' ],
21
- :redis => 'localhost:6379/0',
22
- :return => true
23
- )['time.html.haml'].split("time")[1].strip
24
- time.should_not == new_time
25
- generate_files
26
- new_time_from_file = $files['time.html'].split("time")[1].strip
27
- new_time_from_file.should == new_time
28
- new_time_from_file.should_not == time
29
- end
30
-
31
- it "should pass params" do
32
- params = Stasis::Server.push(
33
- :paths => [ 'params.html.haml' ],
34
- :params => { :test => true },
35
- :redis => 'localhost:6379/0',
36
- :return => true
37
- )['params.html.haml'].split("params")[1].strip
38
- eval(params).should == { :test => true }
39
- end
40
-
41
- it "should expire after ttl" do
42
- time = Stasis::Server.push(
43
- :paths => [ 'time.html.haml' ],
44
- :redis => 'localhost:6379/0',
45
- :return => true,
46
- :ttl => 1,
47
- :write => false
48
- )['time.html.haml'].split("time")[1].strip
49
- time2 = Stasis::Server.push(
50
- :paths => [ 'time.html.haml' ],
51
- :redis => 'localhost:6379/0',
52
- :return => true,
53
- :write => false
54
- )['time.html.haml'].split("time")[1].strip
55
- time.should == time2
56
- sleep 2
57
- time3 = Stasis::Server.push(
58
- :paths => [ 'time.html.haml' ],
59
- :redis => 'localhost:6379/0',
60
- :return => true,
61
- :write => false
62
- )['time.html.haml'].split("time")[1].strip
63
- time2.should_not == time3
64
- end
65
- end