strelka 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,15 +19,16 @@ require 'strelka/discovery'
19
19
  describe Strelka::Discovery do
20
20
 
21
21
  before( :all ) do
22
- Mongrel2::Config.db = Mongrel2::Config.in_memory_db
23
- Mongrel2::Config.init_database
22
+ @real_discovered_apps = described_class.instance_variable_get( :@discovered_apps )
23
+ end
24
24
 
25
- # Skip loading the 'strelka' gem, which probably doesn't exist in the right version
26
- # in the dev environment
27
- strelkaspec = make_gemspec( 'strelka', Strelka::VERSION, false )
28
- loaded_specs = Gem.instance_variable_get( :@loaded_specs )
29
- loaded_specs['strelka'] = strelkaspec
25
+ after( :all ) do
26
+ described_class.instance_variable_set( :@discovered_apps, @real_discovered_apps )
27
+ end
30
28
 
29
+ before( :each ) do
30
+ described_class.instance_variable_set( :@discovered_apps, nil )
31
+ described_class.configure
31
32
  end
32
33
 
33
34
 
@@ -38,101 +39,88 @@ describe Strelka::Discovery do
38
39
  # Examples
39
40
  #
40
41
 
41
- it "has a method for loading app class/es from a file" do
42
-
43
- app_file = 'an_app.rb'
44
- app_path = Pathname( app_file ).expand_path
45
- app_class = nil
42
+ it "provides a mechanism for registering apps" do
43
+ described_class.register_app( 'foo', 'a/path/to/foo.rb' )
44
+ described_class.register_app( 'bar', 'a/path/to/bar.rb' )
46
45
 
47
- expect( Kernel ).to receive( :load ).with( app_path.to_s ) do
48
- app_class = Class.new( discoverable_class )
49
- end
50
- expect( described_class.load(app_file) ).to eq( [ app_class ] )
46
+ expect( described_class.discovered_apps ).to include(
47
+ 'foo' => 'a/path/to/foo.rb',
48
+ 'bar' => 'a/path/to/bar.rb'
49
+ )
51
50
  end
52
51
 
53
52
 
54
- it "defaults to loading as a file when finding an app"
55
-
53
+ it "raises an error if two apps try to register with the same name" do
54
+ described_class.register_app( 'foo', 'a/path/to/foo.rb' )
55
+ expect {
56
+ described_class.register_app( 'foo', 'a/path/to/bar.rb' )
57
+ }.to raise_error( /can't register a second 'foo' app/i )
58
+ end
56
59
 
57
- it "has a method for discovering installed Strelka app files" do
58
- specs = {}
59
- specs[:donkey] = make_gemspec( 'donkey', '1.0.0' )
60
- specs[:rabbit_old] = make_gemspec( 'rabbit', '1.0.0' )
61
- specs[:rabbit_new] = make_gemspec( 'rabbit', '1.0.8' )
62
- specs[:bear] = make_gemspec( 'bear', '1.0.0', false )
63
- specs[:giraffe] = make_gemspec( 'giraffe', '1.0.0' )
64
60
 
65
- expect( Gem::Specification ).to receive( :each ).once do |&block|
66
- specs.values.each {|val| block.call(val) }
67
- end
61
+ it "uses Rubygems discovery to find apps" do
62
+ expect( Gem ).to receive( :find_latest_files ).with( 'strelka/apps.rb' ).
63
+ and_return([
64
+ '/some/directory/with/strelka/apps.rb',
65
+ '/some/other/directory/with/strelka/apps.rb'
66
+ ])
67
+ expect( Kernel ).to receive( :load ).twice do |file|
68
+ case file
69
+ when %r{some/directory}
70
+ described_class.register_app( 'foo', 'a/path/to/foo.rb' )
71
+ when %r{other/directory}
72
+ described_class.register_app( 'bar', 'a/path/to/bar.rb' )
73
+ end
74
+ end
68
75
 
69
- donkey_path = specs[:donkey].full_gem_path
70
- rabbit_path = specs[:rabbit_new].full_gem_path
71
- giraffe_path = specs[:giraffe].full_gem_path
72
-
73
- expect( Dir ).to receive( :glob ).with( 'data/*/{apps,handlers}/**/*' ).
74
- and_return( [] )
75
- expect( Dir ).to receive( :glob ).with( "#{giraffe_path}/data/giraffe/{apps,handlers}/**/*" ).
76
- and_return([ "#{giraffe_path}/data/giraffe/apps/app" ])
77
- expect( Dir ).to receive( :glob ).with( "#{rabbit_path}/data/rabbit/{apps,handlers}/**/*" ).
78
- and_return([ "#{rabbit_path}/data/rabbit/apps/subdir/app1.rb",
79
- "#{rabbit_path}/data/rabbit/apps/subdir/app2.rb" ])
80
- expect( Dir ).to receive( :glob ).with( "#{donkey_path}/data/donkey/{apps,handlers}/**/*" ).
81
- and_return([ "#{donkey_path}/data/donkey/apps/app.rb" ])
82
-
83
- app_paths = described_class.discover_paths
84
-
85
- expect( app_paths.size ).to eq( 4 )
86
- expect( app_paths ).to include(
87
- 'donkey' => [Pathname("#{donkey_path}/data/donkey/apps/app.rb")],
88
- 'rabbit' => [Pathname("#{rabbit_path}/data/rabbit/apps/subdir/app1.rb"),
89
- Pathname("#{rabbit_path}/data/rabbit/apps/subdir/app2.rb")],
90
- 'giraffe' => [Pathname("#{giraffe_path}/data/giraffe/apps/app")]
76
+ expect( described_class.discovered_apps ).to include(
77
+ 'foo' => 'a/path/to/foo.rb',
78
+ 'bar' => 'a/path/to/bar.rb'
91
79
  )
92
80
  end
93
81
 
94
82
 
95
- it "has a method for loading discovered app classes from installed Strelka app files" do
96
- gemspec = make_gemspec( 'blood-orgy', '0.0.3' )
97
- expect( Gem::Specification ).to receive( :each ).and_yield( gemspec ).at_least( :once )
83
+ it "can be configured to look for a different discovery file" do
84
+ acme_discovery_files = [
85
+ '/some/directory/with/acme/apps.rb',
86
+ '/some/other/directory/with/acme/apps.rb'
87
+ ]
98
88
 
99
- expect( Dir ).to receive( :glob ).with( 'data/*/{apps,handlers}/**/*' ).
100
- and_return( [] )
101
- expect( Dir ).to receive( :glob ).with( "#{gemspec.full_gem_path}/data/blood-orgy/{apps,handlers}/**/*" ).
102
- and_return([ "#{gemspec.full_gem_path}/data/blood-orgy/apps/kurzweil" ])
89
+ expect( Gem ).to receive( :find_latest_files ).with( 'acme/apps.rb' ).
90
+ and_return( acme_discovery_files )
103
91
 
104
- expect( described_class ).to receive( :gem ).with( 'blood-orgy' )
105
- expect( Kernel ).to receive( :load ).
106
- with( "#{gemspec.full_gem_path}/data/blood-orgy/apps/kurzweil" ) do
107
- Class.new( discoverable_class )
108
- true
109
- end
110
-
111
- app_classes = described_class.discover
112
- expect( app_classes.size ).to eq( 1 )
113
- expect( app_classes.first ).to be_a( Class )
114
- expect( app_classes.first ).to be < discoverable_class
92
+ described_class.configure( app_discovery_file: 'acme/apps.rb' )
93
+ expect( described_class.app_discovery_files ).to eq( acme_discovery_files )
115
94
  end
116
95
 
117
96
 
118
- it "handles exceptions while loading discovered apps" do
119
- gemspec = make_gemspec( 'blood-orgy', '0.0.3' )
120
- expect( Gem::Specification ).to receive( :each ).and_yield( gemspec ).at_least( :once )
97
+ it "can return the app class associated with an application name" do
98
+ described_class.register_app( 'foo', 'a/path/to/foo.rb' )
121
99
 
122
- expect( Dir ).to receive( :glob ).with( 'data/*/{apps,handlers}/**/*' ).
123
- and_return( [] )
124
- expect( Dir ).to receive( :glob ).with( "#{gemspec.full_gem_path}/data/blood-orgy/{apps,handlers}/**/*" ).
125
- and_return([ "#{gemspec.full_gem_path}/data/blood-orgy/apps/kurzweil" ])
100
+ app_class = nil
101
+ expect( Kernel ).to receive( :load ) do |path|
102
+ expect( path ).to eq( 'a/path/to/foo.rb' )
126
103
 
127
- expect( described_class ).to receive( :gem ).with( 'blood-orgy' )
128
- expect( Kernel ).to receive( :load ).
129
- with( "#{gemspec.full_gem_path}/data/blood-orgy/apps/kurzweil" ).
130
- and_raise( SyntaxError.new("kurzweil:1: syntax error, unexpected coffeeshop philosopher") )
104
+ app_class = Class.new( discoverable_class )
105
+ end
131
106
 
132
- app_classes = Strelka::Discovery.discover
133
- expect( app_classes ).to be_empty()
107
+ expect( described_class.load('foo') ).to eq( app_class )
134
108
  end
135
109
 
136
110
 
111
+ it "only returns the first class even if the file declares two" do
112
+ described_class.register_app( 'foo', 'a/path/to/foo.rb' )
113
+
114
+ app_class = app_class2 = nil
115
+ expect( Kernel ).to receive( :load ) do |path|
116
+ expect( path ).to eq( 'a/path/to/foo.rb' )
117
+
118
+ app_class = Class.new( discoverable_class )
119
+ app_class2 = Class.new( discoverable_class )
120
+ end
121
+
122
+ expect( described_class.load('foo') ).to eq( app_class )
123
+ end
124
+
137
125
  end
138
126
 
data/spec/strelka_spec.rb CHANGED
@@ -19,17 +19,5 @@ describe Strelka do
19
19
  end
20
20
  end
21
21
 
22
- it "provides syntactic sugar for looking up an app class by name" do
23
- mox_app = nil
24
- expect( Pathname ).to receive( :glob ).
25
- with( 'data/*/{apps,handlers}/**/*' ).
26
- and_return([ Pathname('data/mox/apps/moxthefox') ])
27
-
28
- expect( Kernel ).to receive( :load ).
29
- with( File.expand_path 'data/mox/apps/moxthefox' ) { mox_app = Class.new(Strelka::App) }
30
-
31
- expect( described_class::App('moxthefox') ).to be( mox_app )
32
- end
33
-
34
22
  end
35
23
 
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.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mahlon E. Smith
@@ -11,27 +11,32 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIDbDCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA+MQwwCgYDVQQDDANnZWQx
14
+ MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MQwwCgYDVQQDDANnZWQx
15
15
  GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
16
- HhcNMTUwNDAxMjEyNDEzWhcNMTYwMzMxMjEyNDEzWjA+MQwwCgYDVQQDDANnZWQx
16
+ HhcNMTYwODIwMTgxNzQyWhcNMTcwODIwMTgxNzQyWjA+MQwwCgYDVQQDDANnZWQx
17
17
  GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
18
- ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDb92mkyYwuGBg1oRxt2tkH
19
- +Uo3LAsaL/APBfSLzy8o3+B3AUHKCjMUaVeBoZdWtMHB75X3VQlvXfZMyBxj59Vo
20
- cDthr3zdao4HnyrzAIQf7BO5Y8KBwVD+yyXCD/N65TTwqsQnO3ie7U5/9ut1rnNr
21
- OkOzAscMwk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----END CERTIFICATE-----
34
- date: 2016-01-20 00:00:00.000000000 Z
39
+ date: 2016-11-05 00:00:00.000000000 Z
35
40
  dependencies:
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: configurability
@@ -109,20 +114,14 @@ dependencies:
109
114
  requirements:
110
115
  - - "~>"
111
116
  - !ruby/object:Gem::Version
112
- version: '0.43'
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: 0.43.1
117
+ version: '0.44'
116
118
  type: :runtime
117
119
  prerelease: false
118
120
  version_requirements: !ruby/object:Gem::Requirement
119
121
  requirements:
120
122
  - - "~>"
121
123
  - !ruby/object:Gem::Version
122
- version: '0.43'
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: 0.43.1
124
+ version: '0.44'
126
125
  - !ruby/object:Gem::Dependency
127
126
  name: pluggability
128
127
  requirement: !ruby/object:Gem::Requirement
@@ -213,14 +212,14 @@ dependencies:
213
212
  requirements:
214
213
  - - "~>"
215
214
  - !ruby/object:Gem::Version
216
- version: '0.7'
215
+ version: '0.8'
217
216
  type: :development
218
217
  prerelease: false
219
218
  version_requirements: !ruby/object:Gem::Requirement
220
219
  requirements:
221
220
  - - "~>"
222
221
  - !ruby/object:Gem::Version
223
- version: '0.7'
222
+ version: '0.8'
224
223
  - !ruby/object:Gem::Dependency
225
224
  name: hoe-highline
226
225
  requirement: !ruby/object:Gem::Requirement
@@ -236,75 +235,75 @@ dependencies:
236
235
  - !ruby/object:Gem::Version
237
236
  version: '0.2'
238
237
  - !ruby/object:Gem::Dependency
239
- name: rdoc
238
+ name: rspec
240
239
  requirement: !ruby/object:Gem::Requirement
241
240
  requirements:
242
241
  - - "~>"
243
242
  - !ruby/object:Gem::Version
244
- version: '4.0'
243
+ version: '3.0'
245
244
  type: :development
246
245
  prerelease: false
247
246
  version_requirements: !ruby/object:Gem::Requirement
248
247
  requirements:
249
248
  - - "~>"
250
249
  - !ruby/object:Gem::Version
251
- version: '4.0'
250
+ version: '3.0'
252
251
  - !ruby/object:Gem::Dependency
253
- name: rspec
252
+ name: simplecov
254
253
  requirement: !ruby/object:Gem::Requirement
255
254
  requirements:
256
255
  - - "~>"
257
256
  - !ruby/object:Gem::Version
258
- version: '3.0'
257
+ version: '0.7'
259
258
  type: :development
260
259
  prerelease: false
261
260
  version_requirements: !ruby/object:Gem::Requirement
262
261
  requirements:
263
262
  - - "~>"
264
263
  - !ruby/object:Gem::Version
265
- version: '3.0'
264
+ version: '0.7'
266
265
  - !ruby/object:Gem::Dependency
267
- name: simplecov
266
+ name: rdoc-generator-fivefish
268
267
  requirement: !ruby/object:Gem::Requirement
269
268
  requirements:
270
269
  - - "~>"
271
270
  - !ruby/object:Gem::Version
272
- version: '0.7'
271
+ version: '0.1'
273
272
  type: :development
274
273
  prerelease: false
275
274
  version_requirements: !ruby/object:Gem::Requirement
276
275
  requirements:
277
276
  - - "~>"
278
277
  - !ruby/object:Gem::Version
279
- version: '0.7'
278
+ version: '0.1'
280
279
  - !ruby/object:Gem::Dependency
281
- name: rdoc-generator-fivefish
280
+ name: rdoc
282
281
  requirement: !ruby/object:Gem::Requirement
283
282
  requirements:
284
283
  - - "~>"
285
284
  - !ruby/object:Gem::Version
286
- version: '0.1'
285
+ version: '4.0'
287
286
  type: :development
288
287
  prerelease: false
289
288
  version_requirements: !ruby/object:Gem::Requirement
290
289
  requirements:
291
290
  - - "~>"
292
291
  - !ruby/object:Gem::Version
293
- version: '0.1'
292
+ version: '4.0'
294
293
  - !ruby/object:Gem::Dependency
295
294
  name: hoe
296
295
  requirement: !ruby/object:Gem::Requirement
297
296
  requirements:
298
297
  - - "~>"
299
298
  - !ruby/object:Gem::Version
300
- version: '3.14'
299
+ version: '3.15'
301
300
  type: :development
302
301
  prerelease: false
303
302
  version_requirements: !ruby/object:Gem::Requirement
304
303
  requirements:
305
304
  - - "~>"
306
305
  - !ruby/object:Gem::Version
307
- version: '3.14'
306
+ version: '3.15'
308
307
  description: |-
309
308
  Strelka is a framework for creating and deploying
310
309
  Mongrel2[http://mongrel2.org/] web applications in Ruby.
@@ -385,6 +384,10 @@ files:
385
384
  - lib/strelka/authprovider/basic.rb
386
385
  - lib/strelka/authprovider/hostaccess.rb
387
386
  - lib/strelka/behavior/plugin.rb
387
+ - lib/strelka/cli.rb
388
+ - lib/strelka/command/config.rb
389
+ - lib/strelka/command/discover.rb
390
+ - lib/strelka/command/start.rb
388
391
  - lib/strelka/constants.rb
389
392
  - lib/strelka/cookie.rb
390
393
  - lib/strelka/cookieset.rb
@@ -438,6 +441,7 @@ files:
438
441
  - spec/strelka/authprovider/basic_spec.rb
439
442
  - spec/strelka/authprovider/hostaccess_spec.rb
440
443
  - spec/strelka/authprovider_spec.rb
444
+ - spec/strelka/cli_spec.rb
441
445
  - spec/strelka/cookie_spec.rb
442
446
  - spec/strelka/cookieset_spec.rb
443
447
  - spec/strelka/discovery_spec.rb
@@ -477,7 +481,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
477
481
  requirements:
478
482
  - - ">="
479
483
  - !ruby/object:Gem::Version
480
- version: 2.0.0
484
+ version: 2.2.0
481
485
  required_rubygems_version: !ruby/object:Gem::Requirement
482
486
  requirements:
483
487
  - - ">="
@@ -485,7 +489,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
485
489
  version: '0'
486
490
  requirements: []
487
491
  rubyforge_project:
488
- rubygems_version: 2.4.8
492
+ rubygems_version: 2.6.7
489
493
  signing_key:
490
494
  specification_version: 4
491
495
  summary: Strelka is a framework for creating and deploying Mongrel2[http://mongrel2.org/]
metadata.gz.sig CHANGED
Binary file