tengine_support 0.3.8 → 0.3.9

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.8
1
+ 0.3.9
@@ -83,7 +83,11 @@ module Tengine::Support::Config::Definition::HasManyChildren
83
83
  self.children << field
84
84
  end
85
85
  (class << self; self; end).module_eval do
86
- attr_accessor field.__name__
86
+ define_method(field.__name__) do
87
+ instance_variable_get("@#{field.__name__}") ||
88
+ (field.default.respond_to?(:to_proc) ? self.instance_eval(&field.deault) : field.default)
89
+ end
90
+ attr_writer field.__name__
87
91
  end
88
92
  end
89
93
 
@@ -65,7 +65,13 @@ EOS
65
65
  field(:action, "test|load|start|enable|stop|force-stop|status|activate", :type => :string, :default => "start")
66
66
  load_config(:config, "path/to/config_file", :type => :string)
67
67
  add(:process, App1::ProcessConfig)
68
- field(:db, "settings to connect to db", :type => :hash)
68
+ field(:db, "settings to connect to db", :type => :hash, :default => {
69
+ :host => 'localhost',
70
+ :port => 27017,
71
+ :username => nil,
72
+ :password => nil,
73
+ :database => 'tengine_production',
74
+ })
69
75
  group(:event_queue, :hidden => true) do
70
76
  add(:connection, Tengine::Support::Config::Amqp::Connection)
71
77
  add(:exchange , Tengine::Support::Config::Amqp::Exchange, :defaults => {:name => 'tengine_event_exchange'})
@@ -107,7 +113,7 @@ end
107
113
 
108
114
 
109
115
 
110
- # build_suite1 との違いは、Tengine::Support::Config::Definition::Suiteを直接newするのではなく
116
+ # build_suite2 との違いは、Tengine::Support::Config::Definition::Suiteを直接newするのではなく
111
117
  # 継承したものをnewしている点です。それ以外は変わりません
112
118
  def build_suite3(*args)
113
119
  ConfigSuite3.new(*args)
@@ -124,7 +130,15 @@ EOS
124
130
  field(:action, "test|load|start|enable|stop|force-stop|status|activate", :type => :string, :default => "start")
125
131
  load_config(:config, "path/to/config_file", :type => :string)
126
132
  add(:process, App1::ProcessConfig)
127
- add(:db, Tengine::Support::Config::Mongoid::Connection, :defaults => {:database => "tengine_production"})
133
+ # field(:db, "settings to connect to db", :type => :hash,
134
+ # :default => {:database => "tengine_production"})
135
+ field(:db, "settings to connect to db", :type => :hash, :default => {
136
+ :host => 'localhost',
137
+ :port => 27017,
138
+ :username => nil,
139
+ :password => nil,
140
+ :database => 'tengine_production',
141
+ })
128
142
  group(:event_queue, :hidden => true) do
129
143
  add(:connection, Tengine::Support::Config::Amqp::Connection)
130
144
  add(:exchange , Tengine::Support::Config::Amqp::Exchange, :defaults => {:name => 'tengine_event_exchange'})
@@ -71,7 +71,6 @@ describe "dump_skelton" do
71
71
  end
72
72
 
73
73
 
74
- context :suite2 do
75
74
  suite2_skelton = {
76
75
  :action => 'start',
77
76
  :config => nil,
@@ -79,7 +78,13 @@ describe "dump_skelton" do
79
78
  :daemon => nil,
80
79
  :pid_dir => nil,
81
80
  },
82
- :db => nil,
81
+ :db => {
82
+ :host => 'localhost',
83
+ :port => 27017,
84
+ :username => nil,
85
+ :password => nil,
86
+ :database => 'tengine_production',
87
+ },
83
88
  :event_queue => {
84
89
  :connection => {
85
90
  :host => 'localhost',
@@ -122,14 +127,34 @@ describe "dump_skelton" do
122
127
  }.freeze,
123
128
  }
124
129
 
130
+
131
+ context :suite2 do
132
+ subject{ build_suite2 }
125
133
  it do
126
- @suite = build_suite2
127
134
  STDOUT.should_receive(:puts).with(YAML.dump(suite2_skelton))
128
135
  expect{
129
- @suite.parse!(%w[--dump-skelton])
136
+ subject.parse!(%w[--dump-skelton])
130
137
  }.to raise_error(SystemExit)
131
138
  end
139
+ end
132
140
 
141
+ context :suite3 do
142
+ subject{ build_suite3 }
143
+ it do
144
+ STDOUT.should_receive(:puts).with(YAML.dump(suite2_skelton))
145
+ expect{
146
+ subject.parse!(%w[--dump-skelton])
147
+ }.to raise_error(SystemExit)
148
+ end
149
+ it do
150
+ subject.db.should == {
151
+ :host => 'localhost',
152
+ :port => 27017,
153
+ :username => nil,
154
+ :password => nil,
155
+ :database => 'tengine_production',
156
+ }
157
+ end
133
158
  end
134
159
 
135
160
  end
@@ -42,7 +42,7 @@ describe "config" do
42
42
  end
43
43
 
44
44
  shared_examples_for "load_config_file_by_config_option_on_file" do
45
- it { subject.action.should == nil}
45
+ it { subject.action.should == 'start'}
46
46
  it { subject.config.should == nil}
47
47
  it { subject.log_common.level.should == "info"}
48
48
  it { subject.process_stdout_log.level.should == "warn"}
@@ -6,7 +6,7 @@ require 'tengine/support/yaml_with_erb'
6
6
  describe "config" do
7
7
  shared_examples_for "load_spec_01.yml's data common" do
8
8
  describe "accessors" do
9
- it { subject.action.should == nil}
9
+ it { subject.action.should == "start"}
10
10
  it { subject.config.should == nil}
11
11
  it { subject.process.should be_a(App1::ProcessConfig) }
12
12
  it { subject.process.daemon.should == true}
@@ -37,7 +37,7 @@ describe "config" do
37
37
  end
38
38
 
39
39
  describe "like Hash" do
40
- it { subject[:action].should == nil}
40
+ it { subject[:action].should == "start"}
41
41
  it { subject[:config].should == nil}
42
42
  it { subject[:process].should be_a(App1::ProcessConfig) }
43
43
  it { subject[:process][:daemon].should == true}
@@ -91,6 +91,20 @@ describe "config" do
91
91
  end
92
92
  end
93
93
 
94
+ shared_examples_for "load_spec_01.yml's data with db Hash" do
95
+ describe "accessors" do
96
+ it do
97
+ subject.db.should == {
98
+ 'host'=> "localhost",
99
+ 'port' => 27020,
100
+ 'username' => nil,
101
+ 'password' => nil,
102
+ 'database' => "tengine_production"
103
+ }
104
+ end
105
+ end
106
+ end
107
+
94
108
  context "app1 setting" do
95
109
  describe :load do
96
110
  before(:all) do
@@ -119,7 +133,7 @@ describe "config" do
119
133
  end
120
134
  subject{ @suite }
121
135
  it_should_behave_like "load_spec_01.yml's data common"
122
- it_should_behave_like "load_spec_01.yml's data with db config"
136
+ it_should_behave_like "load_spec_01.yml's data with db Hash"
123
137
  end
124
138
 
125
139
  describe :load_file_by_suite3_with_filepath do
@@ -128,7 +142,7 @@ describe "config" do
128
142
  end
129
143
  subject{ @suite }
130
144
  it_should_behave_like "load_spec_01.yml's data common"
131
- it_should_behave_like "load_spec_01.yml's data with db config"
145
+ it_should_behave_like "load_spec_01.yml's data with db Hash"
132
146
  end
133
147
 
134
148
  describe :load_file_by_suite3_with_hash do
@@ -137,7 +151,7 @@ describe "config" do
137
151
  end
138
152
  subject{ @suite }
139
153
  it_should_behave_like "load_spec_01.yml's data common"
140
- it_should_behave_like "load_spec_01.yml's data with db config"
154
+ it_should_behave_like "load_spec_01.yml's data with db Hash"
141
155
  end
142
156
 
143
157
 
@@ -33,7 +33,7 @@ describe "config" do
33
33
  end
34
34
 
35
35
  describe "accessors" do
36
- it { subject.action.should == nil}
36
+ it { subject.action.should == "start"}
37
37
  it { subject.config.should == nil}
38
38
  it { subject.process.should be_a(App1::ProcessConfig) }
39
39
  it { subject.process.daemon.should == nil}
@@ -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"
8
+ s.version = "0.3.9"
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.8
4
+ version: 0.3.9
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: &70128460903100 !ruby/object:Gem::Requirement
27
+ requirement: &70223758524920 !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: *70128460903100
35
+ version_requirements: *70223758524920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70128460901720 !ruby/object:Gem::Requirement
38
+ requirement: &70223758524320 !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: *70128460901720
46
+ version_requirements: *70223758524320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard
49
- requirement: &70128460900180 !ruby/object:Gem::Requirement
49
+ requirement: &70223758523720 !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: *70128460900180
57
+ version_requirements: *70223758523720
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70128460898040 !ruby/object:Gem::Requirement
60
+ requirement: &70223758523180 !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: *70128460898040
68
+ version_requirements: *70223758523180
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &70128460896360 !ruby/object:Gem::Requirement
71
+ requirement: &70223758522660 !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: *70128460896360
79
+ version_requirements: *70223758522660
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &70128460894640 !ruby/object:Gem::Requirement
82
+ requirement: &70223758522060 !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: *70128460894640
90
+ version_requirements: *70223758522060
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: autotest
93
- requirement: &70128460891220 !ruby/object:Gem::Requirement
93
+ requirement: &70223758521460 !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: *70128460891220
101
+ version_requirements: *70223758521460
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdiscount
104
- requirement: &70128458416220 !ruby/object:Gem::Requirement
104
+ requirement: &70223758520860 !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: *70128458416220
112
+ version_requirements: *70223758520860
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: 3648561208823462858
180
+ hash: 952268646322731472
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements: