tengine_support 0.3.17 → 0.3.18
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/tengine/support/config/definition/has_many_children.rb +30 -19
- data/spec/support/suite.rb +2 -1
- data/spec/tengine/support/config_spec/load_spec.rb +10 -0
- data/spec/tengine/support/config_spec/load_spec_01_with_other_settings.yml.erb +48 -0
- data/tengine_support.gemspec +2 -1
- metadata +19 -18
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.18
|
@@ -6,9 +6,9 @@ module Tengine::Support::Config::Definition::HasManyChildren
|
|
6
6
|
@children ||= []
|
7
7
|
end
|
8
8
|
|
9
|
-
def child_by_name(
|
10
|
-
|
11
|
-
children.detect{|child| child.__name__ ==
|
9
|
+
def child_by_name(name)
|
10
|
+
name = name.to_sym if name.respond_to?(:to_sym)
|
11
|
+
children.detect{|child| child.__name__ == name}
|
12
12
|
end
|
13
13
|
|
14
14
|
def find(name_array)
|
@@ -21,16 +21,16 @@ module Tengine::Support::Config::Definition::HasManyChildren
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def add(
|
24
|
+
def add(name, klass, options = {}, &block)
|
25
25
|
result = klass.new
|
26
26
|
result.__parent__ = self
|
27
|
-
result.__name__ =
|
27
|
+
result.__name__ = name
|
28
28
|
result.instantiate_children
|
29
29
|
|
30
30
|
dependencies = options[:dependencies] || {}
|
31
31
|
klass.definition_reference_names.each do |res_name|
|
32
32
|
name_array = dependencies[res_name]
|
33
|
-
raise "missing dependency of #{
|
33
|
+
raise "missing dependency of #{name.inspect} in :dependencies options to add(#{name.inspect}, #{klass.name}...)" unless name_array
|
34
34
|
obj = root.find(Array(name_array))
|
35
35
|
raise "#{name_array.inspect} not found" unless obj
|
36
36
|
result.send("#{res_name}=", obj)
|
@@ -49,30 +49,30 @@ module Tengine::Support::Config::Definition::HasManyChildren
|
|
49
49
|
end
|
50
50
|
|
51
51
|
children << result
|
52
|
-
(class << self; self; end).class_eval{ define_method(
|
52
|
+
(class << self; self; end).class_eval{ define_method(name){ result } }
|
53
53
|
result.instance_eval(&block) if block
|
54
54
|
result
|
55
55
|
end
|
56
56
|
|
57
|
-
def group(
|
58
|
-
result = Tengine::Support::Config::Definition::Group.new(
|
57
|
+
def group(name, options = {}, &block)
|
58
|
+
result = Tengine::Support::Config::Definition::Group.new(name, options)
|
59
59
|
result.__parent__ = self
|
60
|
-
(class << self; self; end).class_eval{ define_method(
|
60
|
+
(class << self; self; end).class_eval{ define_method(name){ result } }
|
61
61
|
children << result
|
62
62
|
result.instance_eval(&block) if block
|
63
63
|
result
|
64
64
|
end
|
65
65
|
|
66
|
-
def field(
|
66
|
+
def field(name, *args, &block)
|
67
67
|
attrs = args.last.is_a?(Hash) ? args.pop : {}
|
68
68
|
attrs[:description] = args.first unless args.empty?
|
69
69
|
attrs.update({
|
70
|
-
:__name__ =>
|
70
|
+
:__name__ => name,
|
71
71
|
:__parent__ => self,
|
72
72
|
:__block__ => block,
|
73
73
|
:__type__ => attrs[:__type__] || :field,
|
74
74
|
})
|
75
|
-
if field = children.detect{|child| child.__name__ ==
|
75
|
+
if field = children.detect{|child| child.__name__ == name}
|
76
76
|
new_field = field.dup
|
77
77
|
new_field.update(attrs)
|
78
78
|
idx = self.children.index(field)
|
@@ -100,10 +100,16 @@ module Tengine::Support::Config::Definition::HasManyChildren
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
def
|
103
|
+
def ignore(*names)
|
104
|
+
@ignoreds ||= []
|
105
|
+
names = names.flatten.map(&:to_sym)
|
106
|
+
@ignoreds.concat(names)
|
107
|
+
end
|
108
|
+
|
109
|
+
def action(name, *args, &block)
|
104
110
|
attrs = args.last.is_a?(Hash) ? args.pop : {}
|
105
111
|
attrs.update({
|
106
|
-
:__name__ =>
|
112
|
+
:__name__ => name,
|
107
113
|
:__parent__ => self,
|
108
114
|
:__block__ => block,
|
109
115
|
:__type__ => :action,
|
@@ -149,11 +155,16 @@ module Tengine::Support::Config::Definition::HasManyChildren
|
|
149
155
|
end
|
150
156
|
|
151
157
|
def load(hash)
|
152
|
-
hash.each do |
|
153
|
-
|
154
|
-
|
158
|
+
hash.each do |name, value|
|
159
|
+
name = name.to_sym
|
160
|
+
next if @ignoreds && @ignoreds.include?(name)
|
161
|
+
child = child_by_name(name)
|
162
|
+
unless child
|
163
|
+
where = respond_to?(:__name__) ? " on " + __name__.inspect : ""
|
164
|
+
raise "child not found for #{name.inspect}#{where}"
|
165
|
+
end
|
155
166
|
if child.is_a?(Tengine::Support::Config::Definition::Field)
|
156
|
-
self.send("#{
|
167
|
+
self.send("#{name}=", value)
|
157
168
|
else
|
158
169
|
child.load(value)
|
159
170
|
end
|
data/spec/support/suite.rb
CHANGED
@@ -34,6 +34,7 @@ EOS
|
|
34
34
|
add(:process_stderr_log, App1::LoggerConfig,
|
35
35
|
:parameters => { :logger_name => "#{File.basename(__FILE__, '.*')}_stderr" },
|
36
36
|
:dependencies => { :process_config => :process, :log_common => :log_common,}, &hide_about_rotation)
|
37
|
+
ignore(:app2_settings, :app3_settings)
|
37
38
|
separator("\nGeneral:")
|
38
39
|
__action__(:version, "show version"){ STDOUT.puts "1.1.1"; exit }
|
39
40
|
__action__(:dump_skelton, "dump skelton of config"){ STDOUT.puts YAML.dump(root.to_hash); exit }
|
@@ -53,7 +54,7 @@ EOS
|
|
53
54
|
end
|
54
55
|
|
55
56
|
# build_suite1 との違いは、:dbが Tengine::Support::Config::Mongoid::Connectionではなくて、
|
56
|
-
# 単なるhashのfield
|
57
|
+
# 単なるhashのfieldとして定義している点と ignore(:app2_settings, :app3_settings) の定義がない点です。
|
57
58
|
def build_suite2
|
58
59
|
Tengine::Support::Config.suite do
|
59
60
|
banner <<EOS
|
@@ -126,6 +126,16 @@ describe "config" do
|
|
126
126
|
it_should_behave_like "load_spec_01.yml's data with db config"
|
127
127
|
end
|
128
128
|
|
129
|
+
describe :load_file do
|
130
|
+
before(:all) do
|
131
|
+
@suite = build_suite1
|
132
|
+
@suite.load_file(File.expand_path('load_spec_01_with_other_settings.yml.erb', File.dirname(__FILE__)))
|
133
|
+
end
|
134
|
+
subject{ @suite }
|
135
|
+
it_should_behave_like "load_spec_01.yml's data common"
|
136
|
+
it_should_behave_like "load_spec_01.yml's data with db config"
|
137
|
+
end
|
138
|
+
|
129
139
|
describe :load_file_by_suite3 do
|
130
140
|
before(:all) do
|
131
141
|
@suite = build_suite3
|
@@ -0,0 +1,48 @@
|
|
1
|
+
process:
|
2
|
+
daemon: true
|
3
|
+
pid_dir: "./tmp/pids"
|
4
|
+
|
5
|
+
db:
|
6
|
+
host: 'localhost'
|
7
|
+
port: 27020
|
8
|
+
username:
|
9
|
+
password:
|
10
|
+
database: 'tengine_production'
|
11
|
+
|
12
|
+
event_queue:
|
13
|
+
connection:
|
14
|
+
host: 'rabbitmq1'
|
15
|
+
port: 5672
|
16
|
+
# vhost:
|
17
|
+
# user:
|
18
|
+
# pass:
|
19
|
+
exchange:
|
20
|
+
name: 'tengine_event_exchange'
|
21
|
+
type: 'direct'
|
22
|
+
durable: true
|
23
|
+
queue:
|
24
|
+
name: 'tengine_event_queue'
|
25
|
+
durable: true
|
26
|
+
|
27
|
+
log_common:
|
28
|
+
rotation: 5
|
29
|
+
rotation_size: <%= 1024 * 1024 * 1024 %>
|
30
|
+
level: 'info'
|
31
|
+
|
32
|
+
application_log:
|
33
|
+
output: "log/application.log"
|
34
|
+
rotation: 'daily'
|
35
|
+
level: 'debug'
|
36
|
+
|
37
|
+
process_stdout_log:
|
38
|
+
output: "log/stdout.log"
|
39
|
+
level: 'warn'
|
40
|
+
|
41
|
+
process_stderr_log:
|
42
|
+
output: "log/stderr.log"
|
43
|
+
level: 'info'
|
44
|
+
|
45
|
+
app2_settings: foo
|
46
|
+
app3_settings:
|
47
|
+
foo: 10
|
48
|
+
bar: 20
|
data/tengine_support.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "tengine_support"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.18"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["saishu", "w-irie", "taigou", "totty", "hiroshinakao", "g-morita", "guemon", "aoetk", "hattori-at-nt", "t-yamada", "y-karashima", "akm"]
|
@@ -57,6 +57,7 @@ Gem::Specification.new do |s|
|
|
57
57
|
"spec/tengine/support/config_spec/load_config_file_by_config_option_spec.rb",
|
58
58
|
"spec/tengine/support/config_spec/load_spec.rb",
|
59
59
|
"spec/tengine/support/config_spec/load_spec_01.yml.erb",
|
60
|
+
"spec/tengine/support/config_spec/load_spec_01_with_other_settings.yml.erb",
|
60
61
|
"spec/tengine/support/config_spec/load_spec_02.yml.erb",
|
61
62
|
"spec/tengine/support/config_spec/parse_spec.rb",
|
62
63
|
"spec/tengine/support/core_ext/array/deep_dup_spec.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tengine_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -24,7 +24,7 @@ date: 2011-11-23 00:00:00.000000000Z
|
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70145159644480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70145159644480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70145159644000 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.6.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70145159644000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &70145159643420 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.7.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70145159643420
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &70145159642880 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.0.18
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70145159642880
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jeweler
|
71
|
-
requirement: &
|
71
|
+
requirement: &70145159642280 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.6.4
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70145159642280
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: simplecov
|
82
|
-
requirement: &
|
82
|
+
requirement: &70145159641680 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.5.3
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70145159641680
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: autotest
|
93
|
-
requirement: &
|
93
|
+
requirement: &70145159641100 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70145159641100
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rdiscount
|
104
|
-
requirement: &
|
104
|
+
requirement: &70145159640520 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70145159640520
|
113
113
|
description: tengine_support provides utility classes/modules which is not included
|
114
114
|
in active_support. It doesn't depend on other tengine gems.
|
115
115
|
email: tengine@nautilus-technologies.com
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- spec/tengine/support/config_spec/load_config_file_by_config_option_spec.rb
|
160
160
|
- spec/tengine/support/config_spec/load_spec.rb
|
161
161
|
- spec/tengine/support/config_spec/load_spec_01.yml.erb
|
162
|
+
- spec/tengine/support/config_spec/load_spec_01_with_other_settings.yml.erb
|
162
163
|
- spec/tengine/support/config_spec/load_spec_02.yml.erb
|
163
164
|
- spec/tengine/support/config_spec/parse_spec.rb
|
164
165
|
- spec/tengine/support/core_ext/array/deep_dup_spec.rb
|
@@ -186,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
187
|
version: '0'
|
187
188
|
segments:
|
188
189
|
- 0
|
189
|
-
hash:
|
190
|
+
hash: 643492627916563818
|
190
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
192
|
none: false
|
192
193
|
requirements:
|