stasis 0.1.20 → 0.1.21
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/bin/stasis +2 -0
- data/lib/stasis.rb +19 -20
- data/lib/stasis/dev_mode.rb +4 -3
- data/lib/stasis/plugin.rb +10 -1
- data/spec/stasis/server_spec.rb +1 -0
- data/stasis.gemspec +1 -1
- metadata +4 -4
data/bin/stasis
CHANGED
@@ -16,12 +16,14 @@ options = slop.to_hash
|
|
16
16
|
options.delete(:server) unless slop.server?
|
17
17
|
|
18
18
|
if slop.development?
|
19
|
+
require 'stasis/dev_mode'
|
19
20
|
Stasis::DevMode.new(Dir.pwd, options)
|
20
21
|
elsif slop.only? && slop.public?
|
21
22
|
Stasis.new(Dir.pwd, slop[:public], options).render(*slop[:only])
|
22
23
|
elsif slop.only?
|
23
24
|
Stasis.new(Dir.pwd, options).render(*slop[:only])
|
24
25
|
elsif slop.server?
|
26
|
+
require 'stasis/server'
|
25
27
|
Stasis::Server.new(Dir.pwd, options)
|
26
28
|
elsif slop.public?
|
27
29
|
Stasis.new(Dir.pwd, slop[:public], options).render(*(slop[:only].to_a))
|
data/lib/stasis.rb
CHANGED
@@ -24,12 +24,12 @@ gem "tilt", "~> 1.3.3"
|
|
24
24
|
|
25
25
|
$:.unshift File.dirname(__FILE__)
|
26
26
|
|
27
|
-
# Require all Stasis library files
|
27
|
+
# Require all Stasis library files, except for 'stasis/dev_mode' and
|
28
|
+
# 'stasis/server'. Those are demand-loaded when the corresponding command-line
|
29
|
+
# options are passed.
|
28
30
|
|
29
|
-
require 'stasis/dev_mode'
|
30
31
|
require 'stasis/options'
|
31
32
|
require 'stasis/plugin'
|
32
|
-
require 'stasis/server'
|
33
33
|
|
34
34
|
require 'stasis/scope'
|
35
35
|
require 'stasis/scope/action'
|
@@ -82,8 +82,9 @@ class Stasis
|
|
82
82
|
load_paths unless options[:development]
|
83
83
|
|
84
84
|
# Create plugin instances.
|
85
|
-
@plugins =
|
85
|
+
@plugins = Plugin.plugins.collect { |klass| klass.new(self) }
|
86
86
|
|
87
|
+
self.class.register_instance(self)
|
87
88
|
load_controllers
|
88
89
|
end
|
89
90
|
|
@@ -93,7 +94,7 @@ class Stasis
|
|
93
94
|
|
94
95
|
# Reject paths that are directories or within the destination directory.
|
95
96
|
@paths.reject! do |path|
|
96
|
-
!File.file?(path) || path[0..@destination.length
|
97
|
+
!File.file?(path) || path[0..@destination.length] == @destination+'/'
|
97
98
|
end
|
98
99
|
|
99
100
|
# Reject paths that are controllers.
|
@@ -270,13 +271,22 @@ class Stasis
|
|
270
271
|
collect if render_options[:collect]
|
271
272
|
end
|
272
273
|
|
274
|
+
def self.register_instance(inst)
|
275
|
+
@instances ||= []
|
276
|
+
@instances << inst
|
277
|
+
end
|
278
|
+
|
279
|
+
def add_plugin(plugin)
|
280
|
+
plugin = plugin.new(self)
|
281
|
+
plugins << plugin
|
282
|
+
controller._bind_plugin(plugin, :controller_method)
|
283
|
+
end
|
284
|
+
|
273
285
|
# Add a plugin to all existing controller instances. This method should be called by
|
274
286
|
# all external plugins.
|
275
287
|
def self.register(plugin)
|
276
|
-
|
277
|
-
|
278
|
-
stasis.plugins << plugin
|
279
|
-
stasis.controller._bind_plugin(plugin, :controller_method)
|
288
|
+
@instances.each do |stasis|
|
289
|
+
stasis.add_plugin(plugin)
|
280
290
|
end
|
281
291
|
end
|
282
292
|
|
@@ -296,15 +306,4 @@ class Stasis
|
|
296
306
|
end
|
297
307
|
priorities.uniq.sort.each(&block)
|
298
308
|
end
|
299
|
-
|
300
|
-
# Returns an `Array` of `Stasis::Plugin` classes.
|
301
|
-
def find_plugins
|
302
|
-
plugins = []
|
303
|
-
ObjectSpace.each_object(Class) do |klass|
|
304
|
-
if klass < ::Stasis::Plugin
|
305
|
-
plugins << klass
|
306
|
-
end
|
307
|
-
end
|
308
|
-
plugins
|
309
|
-
end
|
310
309
|
end
|
data/lib/stasis/dev_mode.rb
CHANGED
@@ -38,11 +38,12 @@ class Stasis
|
|
38
38
|
if options[:development].is_a?(::Integer)
|
39
39
|
mime_types = WEBrick::HTTPUtils::DefaultMimeTypes
|
40
40
|
mime_types.store 'js', 'application/javascript'
|
41
|
-
|
42
|
-
|
41
|
+
|
42
|
+
outfile = (RUBY_PLATFORM =~ /mswin|mingw/) ? 'NUL:' : '/dev/null'
|
43
|
+
server = WEBrick::HTTPServer.new(
|
43
44
|
:AccessLog => [ nil, nil ],
|
44
45
|
:DocumentRoot => @stasis.destination,
|
45
|
-
:Logger => WEBrick::Log.new(
|
46
|
+
:Logger => WEBrick::Log.new(outfile),
|
46
47
|
:MimeTypes => mime_types,
|
47
48
|
:Port => options[:development]
|
48
49
|
)
|
data/lib/stasis/plugin.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
class Stasis
|
2
2
|
class Plugin
|
3
|
-
class <<self
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def inherited(subclass)
|
6
|
+
@plugins ||= []
|
7
|
+
@plugins << subclass
|
8
|
+
end
|
9
|
+
|
10
|
+
def plugins
|
11
|
+
(@plugins || []).dup
|
12
|
+
end
|
4
13
|
|
5
14
|
# `Hash` -- Keys are the "bind as" method names and values are the actual method
|
6
15
|
# names on the `Plugin` instance.
|
data/spec/stasis/server_spec.rb
CHANGED
data/stasis.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stasis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 49
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 21
|
10
|
+
version: 0.1.21
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Winton Welsh
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-03-28 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|