strelka 0.0.1.pre.193 → 0.0.1.pre.194

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -7,11 +7,9 @@
7
7
  # m2sh.rb -c examples/mongrel2.sqlite load examples/gen-config.rb
8
8
  #
9
9
 
10
- require 'strelka'
11
10
  require 'mongrel2'
12
11
  require 'mongrel2/config/dsl'
13
12
 
14
- Strelka.load_config( 'examples/config.yml' )
15
13
 
16
14
  # samples server
17
15
  server 'examples' do
@@ -29,7 +27,7 @@ server 'examples' do
29
27
 
30
28
  host 'localhost' do
31
29
 
32
- route '/', directory( 'examples/', 'examples.html', 'text/html' )
30
+ route '/', directory( 'examples/static/', 'examples.html', 'text/html' )
33
31
 
34
32
  authdemo = handler( 'tcp://127.0.0.1:9910', 'auth-demo' )
35
33
 
@@ -114,6 +114,7 @@ module Strelka
114
114
  def self::extended( mod )
115
115
  super
116
116
  mod.loaded_plugins = Strelka::PluginRegistry.new
117
+ mod.plugin_path_prefix = mod.name.downcase.gsub( /::/, File::SEPARATOR )
117
118
  end
118
119
 
119
120
 
@@ -129,6 +130,11 @@ module Strelka
129
130
  attr_accessor :plugins_installed_from
130
131
 
131
132
 
133
+ ##
134
+ # The prefix path for loading plugins
135
+ attr_accessor :plugin_path_prefix
136
+
137
+
132
138
  ### Returns +true+ if the plugins for the extended app class have already
133
139
  ### been installed.
134
140
  def plugins_installed?
@@ -140,7 +146,9 @@ module Strelka
140
146
  def inherited( subclass )
141
147
  super
142
148
  @plugins ||= []
149
+
143
150
  subclass.loaded_plugins = self.loaded_plugins
151
+ subclass.plugin_path_prefix = self.plugin_path_prefix
144
152
  subclass.plugins_installed_from = nil
145
153
  subclass.instance_variable_set( :@plugins, @plugins.dup )
146
154
  end
@@ -181,9 +189,8 @@ module Strelka
181
189
  mod = self.loaded_plugins[ name.to_sym ]
182
190
 
183
191
  unless mod.is_a?( Module )
184
- prefix = self.name.gsub( /::/, File::PATH_SEPARATOR )
185
- Strelka.log.debug "Loading plugin from #{prefix}/#{name}"
186
- require "#{prefix}/#{name}"
192
+ pluginpath = File.join( self.plugin_path_prefix, name.to_s )
193
+ require( pluginpath )
187
194
  mod = self.loaded_plugins[ name.to_sym ] or
188
195
  raise "#{name} plugin didn't load correctly."
189
196
  end
@@ -29,20 +29,19 @@ describe "Strelka plugin system" do
29
29
 
30
30
  before( :all ) do
31
31
  setup_logging( :fatal )
32
- @original_registry = Strelka::App.loaded_plugins.dup
32
+ @original_registry = Strelka::Pluggable.loaded_plugins.dup
33
33
  end
34
34
 
35
35
  after( :each ) do
36
- Strelka::App.loaded_plugins.clear
36
+ Strelka::Pluggable.loaded_plugins.clear
37
37
  end
38
38
 
39
39
  after( :all ) do
40
- Strelka::App.loaded_plugins = @original_registry
40
+ Strelka::Pluggable.loaded_plugins = @original_registry
41
41
  reset_logging()
42
42
  end
43
43
 
44
44
 
45
-
46
45
  RSpec::Matchers.define( :order ) do |item|
47
46
  match do |enumerable|
48
47
  raise "%p doesn't include %p" % [ enumerable, item ] unless
@@ -75,13 +74,13 @@ describe "Strelka plugin system" do
75
74
 
76
75
  before( :each ) do
77
76
  @plugin = Module.new do
78
- def self::name; "Strelka::App::TestPlugin"; end
77
+ def self::name; "Strelka::Pluggable::TestPlugin"; end
79
78
  extend Strelka::Plugin
80
79
  end
81
80
  end
82
81
 
83
82
  it "registers itself with a plugin registry" do
84
- Strelka::App.loaded_plugins.should include( @plugin.plugin_name => @plugin )
83
+ Strelka::Pluggable.loaded_plugins.should include( @plugin.plugin_name => @plugin )
85
84
  end
86
85
 
87
86
 
@@ -90,7 +89,7 @@ describe "Strelka plugin system" do
90
89
  before( :each ) do
91
90
  modname = @plugin.plugin_name
92
91
  @before_mod = Module.new do
93
- def self::name; "Strelka::App::BeforeTestPlugin"; end
92
+ def self::name; "Strelka::Pluggable::BeforeTestPlugin"; end
94
93
  extend Strelka::Plugin
95
94
  run_before( modname )
96
95
  end
@@ -98,7 +97,7 @@ describe "Strelka plugin system" do
98
97
 
99
98
 
100
99
  it "sorts before it in the plugin registry" do
101
- Strelka::App.loaded_plugins.tsort.
100
+ Strelka::Pluggable.loaded_plugins.tsort.
102
101
  should order( @plugin.plugin_name ).after( @before_mod.plugin_name )
103
102
  end
104
103
 
@@ -109,7 +108,7 @@ describe "Strelka plugin system" do
109
108
  before( :each ) do
110
109
  modname = @plugin.plugin_name
111
110
  @after_mod = Module.new do
112
- def self::name; "Strelka::App::AfterTestPlugin"; end
111
+ def self::name; "Strelka::Pluggable::AfterTestPlugin"; end
113
112
  extend Strelka::Plugin
114
113
  run_after( modname )
115
114
  end
@@ -117,7 +116,7 @@ describe "Strelka plugin system" do
117
116
 
118
117
 
119
118
  it "sorts after it in the plugin registry" do
120
- Strelka::App.loaded_plugins.tsort.
119
+ Strelka::Pluggable.loaded_plugins.tsort.
121
120
  should order( @plugin.plugin_name ).before( @after_mod.plugin_name )
122
121
  end
123
122
 
@@ -127,16 +126,30 @@ describe "Strelka plugin system" do
127
126
 
128
127
 
129
128
  context "loading" do
129
+
130
+ it "requires plugins from a directory based on the name of the loader" do
131
+ Strelka::Pluggable.should_receive( :require ).
132
+ with( 'strelka/pluggable/scheduler' ).
133
+ and_return do
134
+ Module.new do
135
+ def self::name; "Strelka::Pluggable::Scheduler"; end
136
+ extend Strelka::Plugin
137
+ end
138
+ end
139
+
140
+ Class.new( Strelka::Pluggable ) { plugin :scheduler }
141
+ end
142
+
130
143
  it "appends class methods if the plugin has them" do
131
144
  plugin = Module.new do
132
- def self::name; "Strelka::App::ClassMethodsTestPlugin"; end
145
+ def self::name; "Strelka::Pluggable::ClassMethodsTestPlugin"; end
133
146
  include Strelka::Plugin
134
147
  module ClassMethods
135
148
  def a_class_method; return "yep."; end
136
149
  end
137
150
  end
138
151
 
139
- app = Class.new( Strelka::App )
152
+ app = Class.new( Strelka::Pluggable )
140
153
  app.register_plugin( plugin )
141
154
 
142
155
  app.a_class_method.should == "yep."
@@ -144,7 +157,7 @@ describe "Strelka plugin system" do
144
157
 
145
158
  it "adds class-instance variables to the class if the plugin has them" do
146
159
  plugin = Module.new do
147
- def self::name; "Strelka::App::ClassInstanceMethodsTestPlugin"; end
160
+ def self::name; "Strelka::Pluggable::ClassInstanceMethodsTestPlugin"; end
148
161
  include Strelka::Plugin
149
162
  module ClassMethods
150
163
  @testing_value = :default
@@ -152,20 +165,20 @@ describe "Strelka plugin system" do
152
165
  end
153
166
  end
154
167
 
155
- app = Class.new( Strelka::App )
168
+ app = Class.new( Strelka::Pluggable )
156
169
  app.register_plugin( plugin )
157
170
 
158
171
  app.testing_value.should == :default
159
172
  app.testing_value = :not_the_default
160
173
  app.testing_value.should == :not_the_default
161
174
  end
175
+
162
176
  end
163
177
 
164
178
 
165
179
  context "plugin/plugins declarative" do
166
180
 
167
181
  before( :each ) do
168
- @pluggable_class = Strelka::Pluggable
169
182
  @routing_plugin = Module.new do
170
183
  def self::name; "Strelka::Pluggable::Routing"; end
171
184
  extend Strelka::Plugin
@@ -186,7 +199,7 @@ describe "Strelka plugin system" do
186
199
 
187
200
 
188
201
  it "can declare a single plugin to load" do
189
- klass = Class.new( @pluggable_class ) do
202
+ klass = Class.new( Strelka::Pluggable ) do
190
203
  plugin :routing
191
204
  end
192
205
  klass.install_plugins
@@ -195,7 +208,7 @@ describe "Strelka plugin system" do
195
208
  end
196
209
 
197
210
  it "can declare a list of plugins to load" do
198
- klass = Class.new( @pluggable_class ) do
211
+ klass = Class.new( Strelka::Pluggable ) do
199
212
  plugins :templating, :routing
200
213
  end
201
214
  klass.install_plugins
@@ -203,7 +216,7 @@ describe "Strelka plugin system" do
203
216
  end
204
217
 
205
218
  it "installs the plugins in the right order even if they're loaded at separate times" do
206
- superclass = Class.new( @pluggable_class ) do
219
+ superclass = Class.new( Strelka::Pluggable ) do
207
220
  plugin :routing
208
221
  end
209
222
  subclass = Class.new( superclass ) do
@@ -215,7 +228,7 @@ describe "Strelka plugin system" do
215
228
  end
216
229
 
217
230
  it "adds information about where plugins were installed" do
218
- klass = Class.new( @pluggable_class ) do
231
+ klass = Class.new( Strelka::Pluggable ) do
219
232
  plugin :routing
220
233
  end
221
234
  klass.plugins_installed_from.should be_nil()
@@ -223,20 +236,11 @@ describe "Strelka plugin system" do
223
236
  klass.plugins_installed_from.should =~ /#{__FILE__}:#{__LINE__ - 1}/
224
237
  end
225
238
 
226
- end
227
-
228
-
229
- context "Plugins loaded in a superclass" do
230
-
231
- before( :each ) do
232
- @superclass = Class.new( Strelka::Pluggable ) do
239
+ it "are inherited by subclasses" do
240
+ parentclass = Class.new( Strelka::Pluggable ) do
233
241
  plugin :routing
234
242
  end
235
- end
236
-
237
-
238
- it "are inherited by subclasses" do
239
- subclass = Class.new( @superclass ) do
243
+ subclass = Class.new( parentclass ) do
240
244
  route_some_stuff
241
245
  end
242
246
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strelka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.193
4
+ version: 0.0.1.pre.194
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
metadata.gz.sig CHANGED
Binary file