tengine_support 0.3.11 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.11
1
+ 0.3.12
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'tengine/support/config'
3
+ require 'active_support/hash_with_indifferent_access'
3
4
 
4
5
  class Tengine::Support::Config::Logger
5
6
  include Tengine::Support::Config::Definition
@@ -19,18 +20,22 @@ class Tengine::Support::Config::Logger
19
20
  # field :formatter, 'Logging formatter, as a Proc that will take four arguments and return the formatted message.',
20
21
  # :type => :proc, :hidden => true
21
22
 
22
- def new_logger
23
- case output
23
+ def new_logger(options = {})
24
+ options = ActiveSupport::HashWithIndifferentAccess.new(to_hash).update(options || {})
25
+ case output = options[:output]
24
26
  when "NULL" then return Tengine::Support::NullLogger.new
25
27
  when "STDOUT" then dev = STDOUT
26
28
  when "STDERR" then dev = STDERR
27
29
  else dev = output
28
30
  end
31
+ rotation = options[:rotation]
29
32
  shift_age = (rotation =~ /\A\d+\Z/) ? rotation.to_i : rotation
30
- result = ::Logger.new(dev, shift_age, rotation_size)
31
- result.level = ::Logger.const_get(level.to_s.upcase)
32
- result.datetime_format = self.datetime_format if self.datetime_format
33
- result.progname = self.progname if self.progname
33
+ result = ::Logger.new(dev, shift_age, options[:rotation_size])
34
+ result.level = ::Logger.const_get(options[:level].to_s.upcase)
35
+ dtf = options[:datetime_format]
36
+ result.datetime_format = dtf if dtf
37
+ progname = options[:progname]
38
+ result.progname = progname if progname
34
39
  result
35
40
  end
36
41
 
@@ -97,6 +97,18 @@ describe 'Tengine::Support::Config::Logger' do
97
97
  its(:progname){ should == nil}
98
98
  end
99
99
 
100
+ context "各属性の設定と引数を指定が両方ある場合" do
101
+ before{ @tempfile = Tempfile.new("test.log") }
102
+ after { @tempfile.close }
103
+ it "引数に指定されたオプションを優先" do
104
+ mock_logger = Logger.new("/dev/null")
105
+ Logger.should_receive(:new).with($stdout, nil, nil).and_return(mock_logger)
106
+ Tengine::Support::Config::Logger.new.tap{|c|
107
+ c.output = @tempfile.path
108
+ }.instantiate_children.new_logger(:output => $stdout)
109
+ end
110
+ end
111
+
100
112
  context "各属性を設定を指定する場合" do
101
113
  before{ @tempfile = Tempfile.new("test.log") }
102
114
  after { @tempfile.close }
@@ -143,7 +155,7 @@ describe 'Tengine::Support::Config::Logger' do
143
155
  end
144
156
 
145
157
  it "STDOUTの場合" do
146
- config = Tengine::Support::Config::Logger.new
158
+ config = Tengine::Support::Config::Logger.new.instantiate_children
147
159
  config.output = "STDOUT"
148
160
  config.level = "warn"
149
161
  config.rotation = nil
@@ -159,7 +171,7 @@ describe 'Tengine::Support::Config::Logger' do
159
171
  end
160
172
 
161
173
  it "STDERRの場合" do
162
- config = Tengine::Support::Config::Logger.new
174
+ config = Tengine::Support::Config::Logger.new.instantiate_children
163
175
  config.output = "STDERR"
164
176
  config.level = "warn"
165
177
  config.rotation = nil
@@ -171,7 +183,7 @@ describe 'Tengine::Support::Config::Logger' do
171
183
  end
172
184
 
173
185
  it "NULLの場合" do
174
- config = Tengine::Support::Config::Logger.new
186
+ config = Tengine::Support::Config::Logger.new.instantiate_children
175
187
  config.output = "NULL"
176
188
  config.level = "warn"
177
189
  config.rotation = nil
@@ -191,7 +203,7 @@ describe 'Tengine::Support::Config::Logger' do
191
203
 
192
204
  %w[daily weekly monthly].each do |shift_age|
193
205
  it "shift_age が #{shift_age}" do
194
- config = Tengine::Support::Config::Logger.new
206
+ config = Tengine::Support::Config::Logger.new.instantiate_children
195
207
  config.output = @filepath
196
208
  config.level = "info"
197
209
  config.rotation = shift_age
@@ -204,7 +216,7 @@ describe 'Tengine::Support::Config::Logger' do
204
216
  end
205
217
 
206
218
  it "shift_ageが整数値" do
207
- config = Tengine::Support::Config::Logger.new
219
+ config = Tengine::Support::Config::Logger.new.instantiate_children
208
220
  config.output = @filepath
209
221
  config.level = "info"
210
222
  config.rotation = "3"
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "tengine_support"
8
- s.version = "0.3.11"
8
+ s.version = "0.3.12"
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"]
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.11
4
+ version: 0.3.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -24,7 +24,7 @@ date: 2011-11-19 00:00:00.000000000Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70216845797360 !ruby/object:Gem::Requirement
27
+ requirement: &70214217947760 !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: *70216845797360
35
+ version_requirements: *70214217947760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70216845796800 !ruby/object:Gem::Requirement
38
+ requirement: &70214217946120 !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: *70216845796800
46
+ version_requirements: *70214217946120
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &70216845796300 !ruby/object:Gem::Requirement
49
+ requirement: &70214217945180 !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: *70216845796300
57
+ version_requirements: *70214217945180
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70216845795800 !ruby/object:Gem::Requirement
60
+ requirement: &70214217944200 !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: *70216845795800
68
+ version_requirements: *70214217944200
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &70216845795300 !ruby/object:Gem::Requirement
71
+ requirement: &70214217927660 !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: *70216845795300
79
+ version_requirements: *70214217927660
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &70216845787120 !ruby/object:Gem::Requirement
82
+ requirement: &70214217926460 !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: *70216845787120
90
+ version_requirements: *70214217926460
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: autotest
93
- requirement: &70216845786560 !ruby/object:Gem::Requirement
93
+ requirement: &70214217924640 !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: *70216845786560
101
+ version_requirements: *70214217924640
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdiscount
104
- requirement: &70216845786080 !ruby/object:Gem::Requirement
104
+ requirement: &70214217922500 !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: *70216845786080
112
+ version_requirements: *70214217922500
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
@@ -177,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  segments:
179
179
  - 0
180
- hash: 2994922577368363732
180
+ hash: -155991243744560425
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements: