tengine_support 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/NULL +1 -0
- data/VERSION +1 -1
- data/lib/tengine/support/config/definition/has_many_children.rb +18 -0
- data/lib/tengine/support/config/definition.rb +8 -0
- data/lib/tengine/support/config/logger.rb +2 -1
- data/lib/tengine/support/null_logger.rb +10 -0
- data/lib/tengine/support.rb +1 -0
- data/spec/tengine_support/config/logger_spec.rb +11 -1
- data/spec/tengine_support/config_spec/load_spec.rb +55 -1
- data/spec/tengine_support/config_spec/parse_spec.rb +4 -4
- data/spec/tengine_support/null_logger_spec.rb +13 -0
- data/tengine_support.gemspec +4 -1
- metadata +21 -18
data/NULL
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Logfile created on 2011-11-18 16:34:49 +0900 by logger.rb/v1.2.7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
@@ -153,4 +153,22 @@ module Tengine::Support::Config::Definition::HasManyChildren
|
|
153
153
|
obj.is_a?(Proc) ? self.instance_eval(&obj) : obj
|
154
154
|
end
|
155
155
|
|
156
|
+
def [](child_name)
|
157
|
+
child = child_by_name(child_name)
|
158
|
+
if child.is_a?(Tengine::Support::Config::Definition::Field)
|
159
|
+
self.send(child_name)
|
160
|
+
else
|
161
|
+
child
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def []=(child_name, value)
|
166
|
+
child = child_by_name(child_name)
|
167
|
+
if child.is_a?(Tengine::Support::Config::Definition::Field)
|
168
|
+
self.send("#{child_name}=", value)
|
169
|
+
else
|
170
|
+
raise ArgumentError, "can't replace #{child_name.inspect}"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
156
174
|
end
|
@@ -153,4 +153,12 @@ module Tengine::Support::Config::Definition
|
|
153
153
|
def action?; false; end
|
154
154
|
def separator?; false; end
|
155
155
|
|
156
|
+
def [](child_name)
|
157
|
+
self.send(child_name)
|
158
|
+
end
|
159
|
+
|
160
|
+
def []=(child_name, value)
|
161
|
+
self.send("#{child_name}=", value)
|
162
|
+
end
|
163
|
+
|
156
164
|
end
|
@@ -3,13 +3,14 @@ require 'tengine/support/config'
|
|
3
3
|
class Tengine::Support::Config::Logger
|
4
4
|
include Tengine::Support::Config::Definition
|
5
5
|
|
6
|
-
field :output, 'file path or "STDOUT" / "STDERR".', :type => :string
|
6
|
+
field :output, 'file path or "STDOUT" / "STDERR" / "NULL".', :type => :string
|
7
7
|
field :rotation, 'rotation file count or daily,weekly,monthly.', :type => :string
|
8
8
|
field :rotation_size, 'number of max log file size.', :type => :integer
|
9
9
|
field :level, 'debug/info/warn/error/fatal.', :type => :string
|
10
10
|
|
11
11
|
def new_logger
|
12
12
|
case output
|
13
|
+
when "NULL" then return Tengine::Support::NullLogger.new
|
13
14
|
when "STDOUT" then dev = STDOUT
|
14
15
|
when "STDERR" then dev = STDERR
|
15
16
|
else dev = output
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/support'
|
3
|
+
|
4
|
+
# NullLoggerはロガーのNull Objectです。
|
5
|
+
# Loggerと同じインタフェースを持ちますが何も動作しません。
|
6
|
+
class Tengine::Support::NullLogger
|
7
|
+
%w[debug info warn error fatal].each do |log_level|
|
8
|
+
class_eval("def #{log_level}(*args); end")
|
9
|
+
end
|
10
|
+
end
|
data/lib/tengine/support.rb
CHANGED
@@ -12,7 +12,7 @@ describe 'Tengine::Support::Config::Logger' do
|
|
12
12
|
it { subject.should be_a(Tengine::Support::Config::Definition::Field)}
|
13
13
|
its(:type){ should == :string }
|
14
14
|
its(:__name__){ should == :output }
|
15
|
-
its(:description){ should == 'file path or "STDOUT" / "STDERR".'}
|
15
|
+
its(:description){ should == 'file path or "STDOUT" / "STDERR" / "NULL".'}
|
16
16
|
its(:default){ should == nil}
|
17
17
|
end
|
18
18
|
end
|
@@ -47,6 +47,16 @@ describe 'Tengine::Support::Config::Logger' do
|
|
47
47
|
config.new_logger.should == logger
|
48
48
|
end
|
49
49
|
|
50
|
+
it "NULLの場合" do
|
51
|
+
config = Tengine::Support::Config::Logger.new
|
52
|
+
config.output = "NULL"
|
53
|
+
config.level = "warn"
|
54
|
+
config.rotation = nil
|
55
|
+
config.rotation_size = nil
|
56
|
+
Tengine::Support::NullLogger.should_receive(:new).and_return(:logger)
|
57
|
+
config.new_logger.should == :logger
|
58
|
+
end
|
59
|
+
|
50
60
|
context "ファイル名の場合" do
|
51
61
|
before do
|
52
62
|
@tempfile = Tempfile.new("test.log")
|
@@ -35,8 +35,40 @@ describe "config" do
|
|
35
35
|
it { subject.process_stderr_log.rotation_size.should == 1024 * 1024 * 1024}
|
36
36
|
it { subject.process_stderr_log.level.should == "info"}
|
37
37
|
end
|
38
|
+
|
39
|
+
describe "like Hash" do
|
40
|
+
it { subject[:action].should == nil}
|
41
|
+
it { subject[:config].should == nil}
|
42
|
+
it { subject[:process].should be_a(App1::ProcessConfig) }
|
43
|
+
it { subject[:process][:daemon].should == true}
|
44
|
+
it { subject[:process][:pid_dir].should == "./tmp/pids"}
|
45
|
+
it { subject[:event_queue][:connection][:host].should == "rabbitmq1"}
|
46
|
+
it { subject[:event_queue][:connection][:port].should == 5672}
|
47
|
+
it { subject[:event_queue][:exchange][:name].should == "tengine_event_exchange"}
|
48
|
+
it { subject[:event_queue][:exchange][:type].should == 'direct'}
|
49
|
+
it { subject[:event_queue][:exchange][:durable].should == true}
|
50
|
+
it { subject[:event_queue][:queue][:name].should == "tengine_event_queue"}
|
51
|
+
it { subject[:event_queue][:queue][:durable].should == true}
|
52
|
+
it { subject[:log_common][:output].should == nil}
|
53
|
+
it { subject[:log_common][:rotation].should == 5}
|
54
|
+
it { subject[:log_common][:rotation_size].should == 1024 * 1024 * 1024}
|
55
|
+
it { subject[:log_common][:level].should == "info"}
|
56
|
+
it { subject[:application_log][:output].should == "log/application.log"}
|
57
|
+
it { subject[:application_log][:rotation].should == 'daily'}
|
58
|
+
it { subject[:application_log][:rotation_size].should == 1024 * 1024 * 1024}
|
59
|
+
it { subject[:application_log][:level].should == "debug"}
|
60
|
+
it { subject[:process_stdout_log][:output].should == "log/stdout.log"}
|
61
|
+
it { subject[:process_stdout_log][:rotation].should == 5}
|
62
|
+
it { subject[:process_stdout_log][:rotation_size].should == 1024 * 1024 * 1024}
|
63
|
+
it { subject[:process_stdout_log][:level].should == "warn"}
|
64
|
+
it { subject[:process_stderr_log][:output].should == "log/stderr.log"}
|
65
|
+
it { subject[:process_stderr_log][:rotation].should == 5}
|
66
|
+
it { subject[:process_stderr_log][:rotation_size].should == 1024 * 1024 * 1024}
|
67
|
+
it { subject[:process_stderr_log][:level].should == "info"}
|
68
|
+
end
|
38
69
|
end
|
39
70
|
|
71
|
+
|
40
72
|
shared_examples_for "load_spec_01.yml's data with db config" do
|
41
73
|
describe "accessors" do
|
42
74
|
it { subject.db.should be_a(Tengine::Support::Config::Mongoid::Connection) }
|
@@ -67,7 +99,29 @@ describe "config" do
|
|
67
99
|
subject{ @suite }
|
68
100
|
it_should_behave_like "load_spec_01.yml's data common"
|
69
101
|
it_should_behave_like "load_spec_01.yml's data with db config"
|
70
|
-
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
context "set like a Hash" do
|
106
|
+
before do
|
107
|
+
@suite = build_suite1
|
108
|
+
@suite.load_file(File.expand_path('load_spec_01.yml.erb', File.dirname(__FILE__)))
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#[]=" do
|
112
|
+
it "set value to field" do
|
113
|
+
@suite[:event_queue][:connection][:port] = 2765
|
114
|
+
@suite[:event_queue][:connection][:port].should == 2765
|
115
|
+
end
|
116
|
+
|
117
|
+
it "set value to group" do
|
118
|
+
event_queue = @suite[:event_queue]
|
119
|
+
expect{
|
120
|
+
event_queue[:connection] = :hoge
|
121
|
+
}.to raise_error(ArgumentError, "can't replace :connection")
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
71
125
|
end
|
72
126
|
|
73
127
|
context "hash for db settings" do
|
@@ -91,22 +91,22 @@ db:
|
|
91
91
|
--db-database=VAL database name to connect db. default: "tengine_production"
|
92
92
|
|
93
93
|
log_common:
|
94
|
-
--log-common-output=VAL file path or "STDOUT" / "STDERR".
|
94
|
+
--log-common-output=VAL file path or "STDOUT" / "STDERR" / "NULL".
|
95
95
|
--log-common-level=VAL debug/info/warn/error/fatal. default: "info"
|
96
96
|
|
97
97
|
application_log:
|
98
|
-
--application-log-output=VAL file path or "STDOUT" / "STDERR". if daemon process then "./log/.log" else "STDOUT" default: "STDOUT"
|
98
|
+
--application-log-output=VAL file path or "STDOUT" / "STDERR" / "NULL". if daemon process then "./log/.log" else "STDOUT" default: "STDOUT"
|
99
99
|
--application-log-level=VAL debug/info/warn/error/fatal. value of --log-common-level default: "info"
|
100
100
|
|
101
101
|
process_stdout_log:
|
102
102
|
--process-stdout-log-output=VAL
|
103
|
-
file path or "STDOUT" / "STDERR". if daemon process then "./log/.log" else "STDOUT" default: "STDOUT"
|
103
|
+
file path or "STDOUT" / "STDERR" / "NULL". if daemon process then "./log/.log" else "STDOUT" default: "STDOUT"
|
104
104
|
--process-stdout-log-level=VAL
|
105
105
|
debug/info/warn/error/fatal. value of --log-common-level default: "info"
|
106
106
|
|
107
107
|
process_stderr_log:
|
108
108
|
--process-stderr-log-output=VAL
|
109
|
-
file path or "STDOUT" / "STDERR". if daemon process then "./log/.log" else "STDOUT" default: "STDOUT"
|
109
|
+
file path or "STDOUT" / "STDERR" / "NULL". if daemon process then "./log/.log" else "STDOUT" default: "STDOUT"
|
110
110
|
--process-stderr-log-level=VAL
|
111
111
|
debug/info/warn/error/fatal. value of --log-common-level default: "info"
|
112
112
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
|
+
|
4
|
+
describe Tengine::Support::NullLogger do
|
5
|
+
context "使用可能なメソッド" do
|
6
|
+
subject{ Tengine::Support::NullLogger.new }
|
7
|
+
it{ subject.debug("foo") }
|
8
|
+
it{ subject.info("foo") }
|
9
|
+
it{ subject.warn("foo") }
|
10
|
+
it{ subject.error("foo") }
|
11
|
+
it{ subject.fatal("foo") }
|
12
|
+
end
|
13
|
+
end
|
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.5"
|
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"]
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
".rspec",
|
21
21
|
".travis.yml",
|
22
22
|
"Gemfile",
|
23
|
+
"NULL",
|
23
24
|
"README.md",
|
24
25
|
"Rakefile",
|
25
26
|
"VERSION",
|
@@ -36,6 +37,7 @@ Gem::Specification.new do |s|
|
|
36
37
|
"lib/tengine/support/config/definition/suite.rb",
|
37
38
|
"lib/tengine/support/config/logger.rb",
|
38
39
|
"lib/tengine/support/config/mongoid.rb",
|
40
|
+
"lib/tengine/support/null_logger.rb",
|
39
41
|
"lib/tengine/support/yaml_with_erb.rb",
|
40
42
|
"lib/tengine_support.rb",
|
41
43
|
"spec/spec_helper.rb",
|
@@ -51,6 +53,7 @@ Gem::Specification.new do |s|
|
|
51
53
|
"spec/tengine_support/config_spec/load_spec_01.yml.erb",
|
52
54
|
"spec/tengine_support/config_spec/load_spec_02.yml.erb",
|
53
55
|
"spec/tengine_support/config_spec/parse_spec.rb",
|
56
|
+
"spec/tengine_support/null_logger_spec.rb",
|
54
57
|
"spec/tengine_support/yaml_with_erb_spec.rb",
|
55
58
|
"spec/tengine_support/yaml_with_erb_spec/test1.yml.erb",
|
56
59
|
"spec/tengine_support/yaml_with_erb_spec/test2_with_erb.yml",
|
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.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -24,7 +24,7 @@ date: 2011-11-18 00:00:00.000000000Z
|
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &2155333380 !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: *2155333380
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2155332900 !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: *2155332900
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &2155332400 !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: *2155332400
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bundler
|
60
|
-
requirement: &
|
60
|
+
requirement: &2155331920 !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: *2155331920
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: jeweler
|
71
|
-
requirement: &
|
71
|
+
requirement: &2155331440 !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: *2155331440
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: simplecov
|
82
|
-
requirement: &
|
82
|
+
requirement: &2155258140 !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: *2155258140
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: autotest
|
93
|
-
requirement: &
|
93
|
+
requirement: &2155257520 !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: *2155257520
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rdiscount
|
104
|
-
requirement: &
|
104
|
+
requirement: &2155257040 !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: *2155257040
|
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
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- .rspec
|
123
123
|
- .travis.yml
|
124
124
|
- Gemfile
|
125
|
+
- 'NULL'
|
125
126
|
- README.md
|
126
127
|
- Rakefile
|
127
128
|
- VERSION
|
@@ -138,6 +139,7 @@ files:
|
|
138
139
|
- lib/tengine/support/config/definition/suite.rb
|
139
140
|
- lib/tengine/support/config/logger.rb
|
140
141
|
- lib/tengine/support/config/mongoid.rb
|
142
|
+
- lib/tengine/support/null_logger.rb
|
141
143
|
- lib/tengine/support/yaml_with_erb.rb
|
142
144
|
- lib/tengine_support.rb
|
143
145
|
- spec/spec_helper.rb
|
@@ -153,6 +155,7 @@ files:
|
|
153
155
|
- spec/tengine_support/config_spec/load_spec_01.yml.erb
|
154
156
|
- spec/tengine_support/config_spec/load_spec_02.yml.erb
|
155
157
|
- spec/tengine_support/config_spec/parse_spec.rb
|
158
|
+
- spec/tengine_support/null_logger_spec.rb
|
156
159
|
- spec/tengine_support/yaml_with_erb_spec.rb
|
157
160
|
- spec/tengine_support/yaml_with_erb_spec/test1.yml.erb
|
158
161
|
- spec/tengine_support/yaml_with_erb_spec/test2_with_erb.yml
|
@@ -174,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
177
|
version: '0'
|
175
178
|
segments:
|
176
179
|
- 0
|
177
|
-
hash:
|
180
|
+
hash: -3661991772208996840
|
178
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
182
|
none: false
|
180
183
|
requirements:
|