nginxtra 1.2.3.6 → 1.2.3.7
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/nginxtra +1 -1
- data/bin/nginxtra_rails +1 -1
- data/lib/nginxtra/config.rb +51 -35
- data/lib/nginxtra/version.rb +1 -1
- metadata +4 -4
data/bin/nginxtra
CHANGED
data/bin/nginxtra_rails
CHANGED
data/lib/nginxtra/config.rb
CHANGED
@@ -146,7 +146,7 @@ module Nginxtra
|
|
146
146
|
# Define a new config file with the given filename and the block
|
147
147
|
# to define it with.
|
148
148
|
def file(filename, &block)
|
149
|
-
@files[filename] = Nginxtra::Config::ConfigFile.new
|
149
|
+
@files[filename] = Nginxtra::Config::ConfigFile.new filename, self, &block
|
150
150
|
end
|
151
151
|
|
152
152
|
# Retrieve the files that have been defined.
|
@@ -312,7 +312,8 @@ module Nginxtra
|
|
312
312
|
|
313
313
|
# Represents a config file being defined by nginxtra.conf.rb.
|
314
314
|
class ConfigFile
|
315
|
-
def initialize(config, &block)
|
315
|
+
def initialize(filename, config, &block)
|
316
|
+
@filename = filename
|
316
317
|
@config = config
|
317
318
|
@indentation = Nginxtra::Config::Indentation.new :indent_size => 4
|
318
319
|
@file_contents = []
|
@@ -335,7 +336,9 @@ module Nginxtra
|
|
335
336
|
# config_line "worker_processes 42"
|
336
337
|
# end
|
337
338
|
def config_line(contents)
|
339
|
+
empty_config_line if @end_of_block
|
338
340
|
@begin_of_block = false
|
341
|
+
@end_of_block = false
|
339
342
|
bare_config_line "#{contents};"
|
340
343
|
end
|
341
344
|
|
@@ -348,12 +351,14 @@ module Nginxtra
|
|
348
351
|
# end
|
349
352
|
def bare_config_line(contents)
|
350
353
|
@begin_of_block = false
|
354
|
+
@end_of_block = false
|
351
355
|
@file_contents << "#{@indentation}#{contents}"
|
352
356
|
end
|
353
357
|
|
354
358
|
# Add an empty config line to the resulting config file.
|
355
359
|
def empty_config_line
|
356
360
|
@begin_of_block = false
|
361
|
+
@end_of_block = false
|
357
362
|
@file_contents << ""
|
358
363
|
end
|
359
364
|
|
@@ -377,6 +382,7 @@ module Nginxtra
|
|
377
382
|
yield if block_given?
|
378
383
|
@indentation - 1
|
379
384
|
bare_config_line "}"
|
385
|
+
@end_of_block = true
|
380
386
|
end
|
381
387
|
|
382
388
|
# Process the given template. Optionally, include options (as
|
@@ -413,12 +419,10 @@ module Nginxtra
|
|
413
419
|
# Any arguments the the method will be joined with the method name
|
414
420
|
# with a space to produce the output.
|
415
421
|
def method_missing(method, *args, &block)
|
416
|
-
|
417
|
-
|
418
|
-
if block
|
419
|
-
config_block values, &block
|
422
|
+
if partial? method
|
423
|
+
invoke_partial method, args, block
|
420
424
|
else
|
421
|
-
|
425
|
+
process_config_block_or_line method, args, block
|
422
426
|
end
|
423
427
|
end
|
424
428
|
|
@@ -437,6 +441,41 @@ module Nginxtra
|
|
437
441
|
def passenger_on!
|
438
442
|
config_line %{passenger_enabled on}
|
439
443
|
end
|
444
|
+
|
445
|
+
private
|
446
|
+
def partial?(partial_name)
|
447
|
+
@config.partial_paths.any? do |path|
|
448
|
+
File.exists? File.join(path, "#{@filename}/#{partial_name}.rb")
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
def invoke_partial(partial_name, args, block)
|
453
|
+
partial_path = @config.partial_paths.map do |path|
|
454
|
+
File.join path, "#{@filename}/#{partial_name}.rb"
|
455
|
+
end.find do |path|
|
456
|
+
File.exists? path
|
457
|
+
end
|
458
|
+
|
459
|
+
if args.empty?
|
460
|
+
partial_options = {}
|
461
|
+
elsif args.length == 1 && args.first.kind_of?(Hash)
|
462
|
+
partial_options = args.first
|
463
|
+
else
|
464
|
+
raise InvalidConfig.new("Invalid partial arguments", :header => "Invalid partial arguments!", :message => "You can only pass 0 arguments or 1 hash to a partial!")
|
465
|
+
end
|
466
|
+
|
467
|
+
process_template! partial_path, partial_options, block
|
468
|
+
end
|
469
|
+
|
470
|
+
def process_config_block_or_line(name, args, block)
|
471
|
+
values = [name, *args].join " "
|
472
|
+
|
473
|
+
if block
|
474
|
+
config_block values, &block
|
475
|
+
else
|
476
|
+
config_line values
|
477
|
+
end
|
478
|
+
end
|
440
479
|
end
|
441
480
|
|
442
481
|
# A class for encapsulating simple configuration.
|
@@ -444,8 +483,7 @@ module Nginxtra
|
|
444
483
|
def initialize(config, options = {}, &block)
|
445
484
|
@config = config
|
446
485
|
@options = options
|
447
|
-
@
|
448
|
-
instance_eval &block
|
486
|
+
@block = block
|
449
487
|
end
|
450
488
|
|
451
489
|
# Process the simple config.
|
@@ -489,37 +527,15 @@ module Nginxtra
|
|
489
527
|
def process_files!(files)
|
490
528
|
files.each do |x|
|
491
529
|
path = x[:path]
|
492
|
-
|
493
|
-
config = @config
|
530
|
+
filename = x[:config_file]
|
494
531
|
options = @options
|
495
|
-
|
496
|
-
|
497
|
-
yielder = proc do
|
498
|
-
invoked_partials.each do |partial|
|
499
|
-
method, args, block = partial
|
500
|
-
partial_options = {}
|
501
|
-
partial_options = args.first if args.length > 0 && args.first.kind_of?(Hash)
|
502
|
-
|
503
|
-
config.partial_paths.each do |path|
|
504
|
-
partial_path = File.join path, "#{file_name}/#{method}.rb"
|
505
|
-
|
506
|
-
if File.exists? partial_path
|
507
|
-
process_template! partial_path, partial_options, block
|
508
|
-
break
|
509
|
-
end
|
510
|
-
end
|
511
|
-
end
|
512
|
-
end
|
532
|
+
block = @block
|
513
533
|
|
514
|
-
@config.file
|
515
|
-
process_template! path, options,
|
534
|
+
@config.file filename do
|
535
|
+
process_template! path, options, block
|
516
536
|
end
|
517
537
|
end
|
518
538
|
end
|
519
|
-
|
520
|
-
def method_missing(method, *args, &block)
|
521
|
-
@invoked_partials << [method, args, block]
|
522
|
-
end
|
523
539
|
end
|
524
540
|
|
525
541
|
class Indentation
|
data/lib/nginxtra/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nginxtra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.3.
|
4
|
+
version: 1.2.3.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &8618220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.16.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *8618220
|
25
25
|
description: This gem is intended to provide an easy to use configuration file that
|
26
26
|
will automatically be used to compile nginx and configure the configuration.
|
27
27
|
email: reasonnumber@gmail.com
|