nginx-conf 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/lib/nginx-conf.rb +1 -1
- data/lib/nginx-conf/compiler.rb +5 -2
- data/lib/nginx-conf/conf.rb +27 -13
- data/lib/nginx-conf/nginx_conf.rb +7 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2113222f57826f4a385670b75ba8d1dfc9f6818b
|
4
|
+
data.tar.gz: c574ef777215010cd02131bbdbaf4aec78361006
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08721857af181bb9cfc9b31ff2114ea725626ab8b82a4d70b08e54ef96df3a2dd13d5da2798299864ed5ae42bbe49e08782bb84eea0a651d58662d25dd97a069
|
7
|
+
data.tar.gz: 389e9ff5ce26f3d784e0b0964a0dd769b7e956ec000715be958eeb527e3a6238ef433020f0d3cb5c3464169d8ce2706fce4eb416f8db3934e1bd900c7ebfad67
|
data/lib/nginx-conf.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require_relative 'nginx-conf/
|
1
|
+
require_relative 'nginx-conf/nginx_conf'
|
data/lib/nginx-conf/compiler.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
class Compiler
|
2
2
|
@@spaces = ' ' * 4
|
3
3
|
|
4
|
+
def initialize repeats
|
5
|
+
@repeats = repeats
|
6
|
+
end
|
7
|
+
|
4
8
|
def compile hash
|
5
9
|
@indents = 0
|
6
10
|
compile_hash_without_brackets hash
|
@@ -29,8 +33,7 @@ class Compiler
|
|
29
33
|
|
30
34
|
def compile_hash_without_brackets hash
|
31
35
|
hash.map do |key, values|
|
32
|
-
|
33
|
-
when :server, :load_module
|
36
|
+
if @repeats.include? key
|
34
37
|
values.map do |config|
|
35
38
|
compile_hash_item key, [config]
|
36
39
|
end.join()
|
data/lib/nginx-conf/conf.rb
CHANGED
@@ -1,25 +1,39 @@
|
|
1
1
|
require_relative 'compiler'
|
2
2
|
|
3
3
|
|
4
|
-
class NginxConf
|
5
|
-
def initialize hash
|
6
|
-
raise if [:http, :load_module].any? { |k| hash.has_key? k }
|
7
|
-
@hash = hash.merge({load_module: [], http: {server: []}})
|
8
|
-
end
|
9
4
|
|
10
|
-
|
11
|
-
|
5
|
+
class Conf
|
6
|
+
def initialize repeats, &block
|
7
|
+
@repeats = repeats
|
8
|
+
@attrs = {}
|
9
|
+
instance_eval(&block)
|
12
10
|
end
|
13
11
|
|
14
|
-
def
|
15
|
-
|
12
|
+
def method_missing name, *args, &block
|
13
|
+
if not (args or block)
|
14
|
+
@attrs[name]
|
15
|
+
end
|
16
|
+
|
17
|
+
if block
|
18
|
+
args.push Conf.new(@repeats, &block).to_hash
|
19
|
+
end
|
20
|
+
|
21
|
+
value = args.length == 1 ? args[0] : args
|
22
|
+
|
23
|
+
if @repeats.include? name and @attrs.include? name
|
24
|
+
@attrs[name].push value
|
25
|
+
elsif @repeats.include? name
|
26
|
+
@attrs[name] = [value]
|
27
|
+
else
|
28
|
+
@attrs[name] = value
|
29
|
+
end
|
16
30
|
end
|
17
31
|
|
18
|
-
def
|
19
|
-
|
32
|
+
def to_hash
|
33
|
+
@attrs
|
20
34
|
end
|
21
35
|
|
22
|
-
def
|
23
|
-
@
|
36
|
+
def to_s
|
37
|
+
Compiler.new(@repeats).compile(@attrs)
|
24
38
|
end
|
25
39
|
end
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nginx-conf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yota Toyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: nginx.conf generator
|
14
|
-
types
|
13
|
+
description: nginx.conf generator with pretty DSL
|
15
14
|
email: raviqqe@gmail.com
|
16
15
|
executables: []
|
17
16
|
extensions: []
|
@@ -20,6 +19,7 @@ files:
|
|
20
19
|
- lib/nginx-conf.rb
|
21
20
|
- lib/nginx-conf/compiler.rb
|
22
21
|
- lib/nginx-conf/conf.rb
|
22
|
+
- lib/nginx-conf/nginx_conf.rb
|
23
23
|
homepage: https://github.com/raviqqe/nginx-conf.rb
|
24
24
|
licenses:
|
25
25
|
- Unlicense
|
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
42
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.
|
43
|
+
rubygems_version: 2.5.1
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: nginx.conf generator
|