init 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.rspec +1 -1
- data/Gemfile +1 -1
- data/HISTORY.md +8 -1
- data/LICENSE.md +1 -1
- data/README.md +32 -5
- data/Rakefile +1 -1
- data/examples/{mongrel.rb → attachable_daemon.rb} +25 -25
- data/examples/left4dead2.rb +50 -0
- data/examples/murmur.rb +18 -12
- data/examples/source_dedicated.rb +35 -0
- data/init.gemspec +7 -7
- data/lib/aef/init.rb +71 -3
- data/lib/aef/init/version.rb +2 -2
- data/lib/init.rb +1 -1
- data/spec/bin/mock_daemon.rb +1 -1
- data/spec/bin/simple_init.rb +1 -1
- data/spec/init_spec.rb +60 -1
- data/spec/spec_helper.rb +2 -1
- metadata +83 -63
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--
|
1
|
+
--format d
|
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -90,7 +90,7 @@ in a block that only calls it if the script is executed on the commandline.
|
|
90
90
|
|
91
91
|
There is no need to implement the command restart in most cases, as there is one
|
92
92
|
defined by default, which simply calls the commands stop and start in a row.
|
93
|
-
A delay between the two commands can be defined:
|
93
|
+
A delay in seconds between the two commands can be defined:
|
94
94
|
|
95
95
|
~~~~~ ruby
|
96
96
|
class DemoSubclass < Aef::Init
|
@@ -101,7 +101,7 @@ A delay between the two commands can be defined:
|
|
101
101
|
~~~~~
|
102
102
|
|
103
103
|
Notice that in earlier versions the default command was preset to :restart
|
104
|
-
which was not as useful in practice
|
104
|
+
which was not as useful in practice as expected. Many unwanted restarts were
|
105
105
|
triggered because of this, so I don't recommend using this feature any more.
|
106
106
|
|
107
107
|
Still, a default command can be specified which is called if no command is provided on the command-line:
|
@@ -130,7 +130,34 @@ build reusable libraries and keep your code DRY.
|
|
130
130
|
end
|
131
131
|
~~~~~
|
132
132
|
|
133
|
-
|
133
|
+
As of 2.1.0 there is a way to specify lazily-interpreted variables which are
|
134
|
+
inherited by sub classes.
|
135
|
+
|
136
|
+
~~~~~ ruby
|
137
|
+
class MiddleClass < Aef::Init
|
138
|
+
# Setting some variables
|
139
|
+
set(:executable) { 'daemon' }
|
140
|
+
set(:arguments) { '-abc' }
|
141
|
+
|
142
|
+
# Access variables inside the defintion of a new one
|
143
|
+
set(:command) { path + executable }
|
144
|
+
|
145
|
+
# Utilize the variables in command definitions just like local variables
|
146
|
+
def start
|
147
|
+
`#{command} #{arguments}`
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
class LeafClass < MiddleClass
|
152
|
+
# Overrides the previous value 'daemon'
|
153
|
+
set(:daemon) { 'special-daemon' }
|
154
|
+
|
155
|
+
# Sets the needed but previously undefined path variable
|
156
|
+
set(:path) { Pathname.new('/opt/something') }
|
157
|
+
end
|
158
|
+
~~~~~
|
159
|
+
|
160
|
+
See the examples/ folder and spec/bin/simple_init.rb for working example classes.
|
134
161
|
|
135
162
|
Requirements
|
136
163
|
------------
|
@@ -184,7 +211,7 @@ If something goes wrong you should be noticed through failing examples.
|
|
184
211
|
Development
|
185
212
|
-----------
|
186
213
|
|
187
|
-
###
|
214
|
+
### Bug reports and feature requests
|
188
215
|
|
189
216
|
Please use the [issue tracker][issues] on github.com to let me know about errors
|
190
217
|
or ideas for improvement of this software.
|
@@ -244,7 +271,7 @@ to include your changes before reviewing them.
|
|
244
271
|
License
|
245
272
|
-------
|
246
273
|
|
247
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-
|
274
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
248
275
|
|
249
276
|
This file is part of Init.
|
250
277
|
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: UTF-8
|
3
3
|
=begin
|
4
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-
|
4
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
5
5
|
|
6
6
|
This file is part of Init.
|
7
7
|
|
@@ -18,36 +18,36 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
18
|
PERFORMANCE OF THIS SOFTWARE.
|
19
19
|
=end
|
20
20
|
|
21
|
-
require '
|
21
|
+
require 'init'
|
22
22
|
|
23
|
-
class
|
24
|
-
|
25
|
-
APPS = {
|
26
|
-
'my_project' => 8000,
|
27
|
-
'demo_app' => 8001
|
28
|
-
}
|
23
|
+
# A base class for interactive processes run as daemons via tmux.
|
24
|
+
class AttachableDaemon < Aef::Init
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
# An implementation of the start method
|
26
|
+
# Start a new tmux session as a different user and run a command within.
|
33
27
|
def start
|
34
|
-
|
35
|
-
puts "Starting #{app_name} on #{port}..."
|
36
|
-
`mongrel_rails start -d -p #{port} -e production -c #{BASE_DIR + app_name} -P log/mongrel.pid`
|
37
|
-
end
|
28
|
+
`#{sudo} #{tmux} new-session -s "#{session_name}" "#{command}"`
|
38
29
|
end
|
39
30
|
|
40
|
-
#
|
31
|
+
# Kill the tmux session.
|
41
32
|
def stop
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
33
|
+
`#{sudo} #{tmux} kill-server`
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attach to the tmux session.
|
37
|
+
def console
|
38
|
+
`#{sudo} #{tmux} attach`
|
39
|
+
end
|
40
|
+
|
41
|
+
# Start and attach to the tmux session.
|
42
|
+
def cstart
|
43
|
+
start
|
44
|
+
console
|
45
|
+
end
|
46
|
+
|
47
|
+
# Restart and attach to the tmux session.
|
48
|
+
def crestart
|
49
|
+
restart
|
50
|
+
console
|
46
51
|
end
|
47
|
-
end
|
48
52
|
|
49
|
-
# The parser is only executed if the script is executed as a program, never
|
50
|
-
# when the script is required in a ruby program
|
51
|
-
if __FILE__ == $PROGRAM_NAME
|
52
|
-
Mongrel.parse
|
53
53
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
=begin
|
4
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
5
|
+
|
6
|
+
This file is part of Init.
|
7
|
+
|
8
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
9
|
+
purpose with or without fee is hereby granted, provided that the above
|
10
|
+
copyright notice and this permission notice appear in all copies.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
14
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
19
|
+
=end
|
20
|
+
|
21
|
+
# This must be set to an absolute path where source_dedicated.rb is in.
|
22
|
+
$LOAD_PATH << File.expand_path('..', __FILE__)
|
23
|
+
|
24
|
+
require 'source_dedicated'
|
25
|
+
|
26
|
+
### BEGIN INIT INFO
|
27
|
+
# Provides: left4dead2
|
28
|
+
# Required-Start: $local_fs $remote_fs $syslog $named $network $time
|
29
|
+
# Required-Stop: $local_fs $remote_fs $syslog $named $network
|
30
|
+
# Default-Start: 2 3 4 5
|
31
|
+
# Default-Stop: 0 1 6
|
32
|
+
### END INIT INFO
|
33
|
+
|
34
|
+
# An example init script for the dedicated server daemon of the game
|
35
|
+
# Left 4 Dead 2
|
36
|
+
class Left4Dead2 < SourceDedicated
|
37
|
+
set(:working_directory) { Pathname.new('/opt/left4dead2/left4dead2') }
|
38
|
+
|
39
|
+
set(:session_name) { 'left4dead2' }
|
40
|
+
set(:user) { 'l4d2' }
|
41
|
+
|
42
|
+
set(:frequency) { '1234.000000' }
|
43
|
+
set(:tickrate) { 100 }
|
44
|
+
set(:ip_address) { '1.2.3.4' }
|
45
|
+
set(:port) { 27016 }
|
46
|
+
end
|
47
|
+
|
48
|
+
# The parser is only executed if the script is executed as a program, never
|
49
|
+
# when the script is required in a ruby program
|
50
|
+
Left4Dead2.parse if __FILE__ == $PROGRAM_NAME
|
data/examples/murmur.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: UTF-8
|
3
3
|
=begin
|
4
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-
|
4
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
5
5
|
|
6
6
|
This file is part of Init.
|
7
7
|
|
@@ -18,14 +18,22 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
18
|
PERFORMANCE OF THIS SOFTWARE.
|
19
19
|
=end
|
20
20
|
|
21
|
-
|
21
|
+
### BEGIN INIT INFO
|
22
|
+
# Provides: murmur
|
23
|
+
# Required-Start: $local_fs $remote_fs $syslog $named $network $time
|
24
|
+
# Required-Stop: $local_fs $remote_fs $syslog $named $network
|
25
|
+
# Default-Start: 2 3 4 5
|
26
|
+
# Default-Stop: 0 1 6
|
27
|
+
### END INIT INFO
|
22
28
|
|
23
|
-
|
29
|
+
require 'init'
|
30
|
+
|
31
|
+
# An example init script for the server daemon of voice chat application Mumble
|
24
32
|
class Murmur < Aef::Init
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
set(:path) { Pathname('/opt/murmur') }
|
34
|
+
set(:daemon) { path + 'murmur.x86' }
|
35
|
+
set(:pidfile) { Pathname('/var/run/murmur/murmur.pid') }
|
36
|
+
set(:user) { 'mumble' }
|
29
37
|
|
30
38
|
# Defines the seconds to wait between stop and start in the predefined restart
|
31
39
|
# command
|
@@ -36,17 +44,15 @@ class Murmur < Aef::Init
|
|
36
44
|
|
37
45
|
# An implementation of the start method for the mumble daemon
|
38
46
|
def start
|
39
|
-
system("start-stop-daemon --start --chdir #{
|
47
|
+
system("start-stop-daemon --start --chdir #{path} --chuid #{user} --exec #{daemon}")
|
40
48
|
end
|
41
49
|
|
42
50
|
# An implementation of the stop method for the mumble daemon
|
43
51
|
def stop
|
44
|
-
system("start-stop-daemon --stop --pidfile #{
|
52
|
+
system("start-stop-daemon --stop --pidfile #{pidfile}")
|
45
53
|
end
|
46
54
|
end
|
47
55
|
|
48
56
|
# The parser is only executed if the script is executed as a program, never
|
49
57
|
# when the script is required in a ruby program
|
50
|
-
if __FILE__ == $PROGRAM_NAME
|
51
|
-
Murmur.parse
|
52
|
-
end
|
58
|
+
Murmur.parse if __FILE__ == $PROGRAM_NAME
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
=begin
|
4
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
5
|
+
|
6
|
+
This file is part of Init.
|
7
|
+
|
8
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
9
|
+
purpose with or without fee is hereby granted, provided that the above
|
10
|
+
copyright notice and this permission notice appear in all copies.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
14
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
19
|
+
=end
|
20
|
+
|
21
|
+
# This must be set to an absolute path where attachable_daemon.rb is in.
|
22
|
+
$LOAD_PATH << File.expand_path('..', __FILE__)
|
23
|
+
|
24
|
+
require 'attachable_daemon'
|
25
|
+
|
26
|
+
# An intermediate class for Source engine game dedicated server daemons
|
27
|
+
class SourceDedicated < AttachableDaemon
|
28
|
+
set(:sudo) { "sudo -u #{user}" }
|
29
|
+
set(:tmux) { "tmux -S /run/tmux/#{session_name}" }
|
30
|
+
|
31
|
+
set(:wrapper) { "env RDTSC_FREQUENCY=#{frequency}" }
|
32
|
+
set(:executable) { working_directory + 'srcds_run' }
|
33
|
+
set(:arguments) { "-autoupdate -tickrate #{tickrate} -ip #{ip_address} -port #{port}" }
|
34
|
+
set(:command) { "#{wrapper} #{executable} #{arguments}" }
|
35
|
+
end
|
data/init.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-
|
3
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
4
4
|
|
5
5
|
This file is part of Init.
|
6
6
|
|
@@ -43,12 +43,12 @@ scripts in Ruby.
|
|
43
43
|
|
44
44
|
s.required_ruby_version = '>= 1.8.7'
|
45
45
|
|
46
|
-
s.add_development_dependency('bundler'
|
47
|
-
s.add_development_dependency('rake'
|
48
|
-
s.add_development_dependency('rspec', '~> 2.
|
49
|
-
s.add_development_dependency('simplecov', '~> 0.
|
50
|
-
s.add_development_dependency('pry', '~> 0.9.
|
51
|
-
s.add_development_dependency('yard', '~> 0.8.2
|
46
|
+
s.add_development_dependency('bundler')
|
47
|
+
s.add_development_dependency('rake')
|
48
|
+
s.add_development_dependency('rspec', '~> 2.14.1')
|
49
|
+
s.add_development_dependency('simplecov', '~> 0.7.1')
|
50
|
+
s.add_development_dependency('pry', '~> 0.9.12.2')
|
51
|
+
s.add_development_dependency('yard', '~> 0.8.7.2')
|
52
52
|
|
53
53
|
s.cert_chain = "#{ENV['GEM_CERT_CHAIN']}".split(':')
|
54
54
|
s.signing_key = ENV['GEM_SIGNING_KEY']
|
data/lib/aef/init.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-
|
3
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
4
4
|
|
5
5
|
This file is part of Init.
|
6
6
|
|
@@ -35,6 +35,8 @@ module Aef
|
|
35
35
|
# Clean and simple *nix init scripts with Ruby
|
36
36
|
class Init
|
37
37
|
|
38
|
+
VARIABLE_PREFIX = 'aef_init_variable'.freeze
|
39
|
+
|
38
40
|
class << self
|
39
41
|
|
40
42
|
# The default command to be called if no command is specified on the
|
@@ -96,7 +98,8 @@ module Aef
|
|
96
98
|
break if klass == Aef::Init
|
97
99
|
end
|
98
100
|
|
99
|
-
valid_commands = valid_commands.sort.map(&:to_sym)
|
101
|
+
valid_commands = valid_commands.sort.map(&:to_sym)
|
102
|
+
valid_commands.uniq!
|
100
103
|
|
101
104
|
command = command.to_sym
|
102
105
|
|
@@ -105,7 +108,60 @@ module Aef
|
|
105
108
|
elsif valid_commands.include?(command)
|
106
109
|
new.send(command)
|
107
110
|
else
|
108
|
-
puts "Usage: #$PROGRAM_NAME {#{valid_commands.join('|')}}"
|
111
|
+
puts "Usage: #$PROGRAM_NAME {#{valid_commands.join('|')}}"
|
112
|
+
exit false
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Defines a lazy-evaluated class variable.
|
117
|
+
#
|
118
|
+
# @return [Proc] the given block
|
119
|
+
def set(name, &block)
|
120
|
+
instance_variable_set("@#{VARIABLE_PREFIX}_#{name}", block)
|
121
|
+
end
|
122
|
+
|
123
|
+
# Checks if a lazy-evaluated class variable is defined.
|
124
|
+
#
|
125
|
+
# @return [true, false] true if the variable is defined. false otherwise.
|
126
|
+
def set?(name)
|
127
|
+
!!find_variable_recursive(name)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Evaluates a lazy-evaluated class variable.
|
131
|
+
#
|
132
|
+
# @return [Object] the result of the evaluated block
|
133
|
+
def get(name)
|
134
|
+
if klass = find_variable_recursive(name)
|
135
|
+
block = klass.instance_variable_get("@#{VARIABLE_PREFIX}_#{name}")
|
136
|
+
instance_eval &block
|
137
|
+
else
|
138
|
+
nil
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
protected
|
143
|
+
|
144
|
+
# Finds out which class in the class hierarchy defined a given variable,
|
145
|
+
# if at all.
|
146
|
+
#
|
147
|
+
# @return [Class, false] if self contains the given variable self is
|
148
|
+
# returned, otherwise false
|
149
|
+
def find_variable_recursive(name)
|
150
|
+
if instance_variable_defined?("@#{VARIABLE_PREFIX}_#{name}")
|
151
|
+
self
|
152
|
+
elsif superclass.ancestors.include?(Init)
|
153
|
+
superclass.find_variable_recursive(name)
|
154
|
+
else
|
155
|
+
false
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# Makes lazy-evaluated class variables available in public interface
|
160
|
+
def method_missing(name, *arguments)
|
161
|
+
if arguments.empty? && set?(name)
|
162
|
+
get(name)
|
163
|
+
else
|
164
|
+
super
|
109
165
|
end
|
110
166
|
end
|
111
167
|
|
@@ -129,5 +185,17 @@ module Aef
|
|
129
185
|
sleep self.class.stop_start_delay
|
130
186
|
start
|
131
187
|
end
|
188
|
+
|
189
|
+
protected
|
190
|
+
|
191
|
+
# Makes lazy-evaluated class variables available in the instance
|
192
|
+
def method_missing(name, *arguments)
|
193
|
+
if arguments.empty? && self.class.set?(name)
|
194
|
+
self.class.get(name)
|
195
|
+
else
|
196
|
+
super
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
132
200
|
end
|
133
201
|
end
|
data/lib/aef/init/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-
|
3
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
4
4
|
|
5
5
|
This file is part of Init.
|
6
6
|
|
@@ -24,7 +24,7 @@ module Aef
|
|
24
24
|
#
|
25
25
|
# Using Semantic Versioning (2.0.0-rc.1) rules
|
26
26
|
# @see http://semver.org/
|
27
|
-
VERSION = '2.0
|
27
|
+
VERSION = '2.1.0'.freeze
|
28
28
|
|
29
29
|
end
|
30
30
|
end
|
data/lib/init.rb
CHANGED
data/spec/bin/mock_daemon.rb
CHANGED
data/spec/bin/simple_init.rb
CHANGED
data/spec/init_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-
|
3
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
4
4
|
|
5
5
|
This file is part of Init.
|
6
6
|
|
@@ -103,4 +103,63 @@ describe Aef::Init do
|
|
103
103
|
`#{executable} end_protected`.should == usage_information
|
104
104
|
`#{executable} end_private`.should == usage_information
|
105
105
|
end
|
106
|
+
|
107
|
+
describe "lazy-evaluated class variables" do
|
108
|
+
let(:base_class) { Class.new(Aef::Init) }
|
109
|
+
let(:sub_class) { Class.new(base_class) }
|
110
|
+
|
111
|
+
describe ".set" do
|
112
|
+
it "should be definable" do
|
113
|
+
base_class.set(:some_name) { 123 }
|
114
|
+
|
115
|
+
base_class.some_name.should eql 123
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should not evaluate the block at definition" do
|
119
|
+
block = Proc.new { 123 }
|
120
|
+
block.should_not_receive(:call)
|
121
|
+
|
122
|
+
base_class.set(:some_name, &block)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should override equally-named inherited variables" do
|
126
|
+
base_class.set(:some_name) { 123 }
|
127
|
+
|
128
|
+
expect {
|
129
|
+
sub_class.set(:some_name) { 456 }
|
130
|
+
}.to change{ sub_class.get(:some_name) }.from(123).to(456)
|
131
|
+
|
132
|
+
base_class.get(:some_name).should eql(123)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe ".set?" do
|
137
|
+
it "should tell if a variable is is defined or not" do
|
138
|
+
expect {
|
139
|
+
base_class.set(:some_name) { 123 }
|
140
|
+
}.to change{ base_class.set?(:some_name) }.from(false).to(true)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should work with inherited variables" do
|
144
|
+
expect {
|
145
|
+
base_class.set(:some_name) { 123 }
|
146
|
+
}.to change{ sub_class.set?(:some_name) }.from(false).to(true)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe ".get" do
|
151
|
+
it "should return the defined block's evaluated result" do
|
152
|
+
base_class.set(:some_name) { 123 }
|
153
|
+
|
154
|
+
base_class.get(:some_name).should eql 123
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should inherit variables from superclasses" do
|
158
|
+
base_class.set(:some_name) { 123 }
|
159
|
+
|
160
|
+
sub_class.get(:some_name).should eql 123
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
106
165
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-
|
3
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2013
|
4
4
|
|
5
5
|
This file is part of Init.
|
6
6
|
|
@@ -27,6 +27,7 @@ require 'pathname'
|
|
27
27
|
require 'tmpdir'
|
28
28
|
require 'rspec'
|
29
29
|
require 'init'
|
30
|
+
require 'pry'
|
30
31
|
|
31
32
|
module Aef::Init::SpecHelper
|
32
33
|
INTERPRETER = Pathname(RbConfig::CONFIG['bindir']) + RbConfig::CONFIG['ruby_install_name']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: init
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,113 +9,131 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain:
|
12
|
-
- !
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
lCB4ih+sB2AI2IUiYBeoCGctXdBQ020prqop/oTQEudzFk/gyQ686lp06HdLRt+O
|
41
|
-
|
42
|
-
HoQjTIab8vmfgIubjPdIRzokMfHbelvhLi+mQfWVghRhs2jpEfdXbL0w5nNw+trp
|
43
|
-
|
44
|
-
rO70Dw59hduDUOpgpxew+PLbs4vP1tb1QKPG+39C+PZtosbbf1fai0hqYV1txMCx
|
45
|
-
|
46
|
-
55akF+N8NbO6tpVDy6TMagqa10LfEpiQH6dvDHe/xdAqYOCrXKpmqzwu2PI=
|
47
|
-
|
48
|
-
-----END CERTIFICATE-----
|
49
|
-
|
50
|
-
'
|
51
|
-
date: 2012-10-02 00:00:00.000000000 Z
|
12
|
+
- !binary |-
|
13
|
+
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURLRENDQWhDZ0F3SUJB
|
14
|
+
Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREE2TVF3d0NnWURWUVFEREFOaFpX
|
15
|
+
WXgKRlRBVEJnb0praWFKay9Jc1pBRVpGZ1Z5WVhoNWN6RVRNQkVHQ2dtU0pv
|
16
|
+
bVQ4aXhrQVJrV0EyNWxkREFlRncwdwpPVEF5TWpVeU1ETTVNRGhhRncweE1E
|
17
|
+
QXlNalV5TURNNU1EaGFNRG94RERBS0JnTlZCQU1NQTJGbFpqRVZNQk1HCkNn
|
18
|
+
bVNKb21UOGl4a0FSa1dCWEpoZUhsek1STXdFUVlLQ1pJbWlaUHlMR1FCR1JZ
|
19
|
+
RGJtVjBNSUlCSWpBTkJna3EKaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dL
|
20
|
+
Q0FRRUFvWXRqMHFhZDUvTXBiZHR0SVR6QkgwaDFTTmU2ZU83Ugo3cVZlcU5Z
|
21
|
+
dTZxRFFBUTByWWMwSmh1YkpDV1lyWkVKb3JIRUJoVUZVNmNkUWdRT3M3OHdp
|
22
|
+
SmFEZ2tlVTdZZlhCCnEybDEyNWtKOGFIa0ExdWtySzIvRFJ6cDJBSEVtenhI
|
23
|
+
SVlwWFY1LzYzaCtOV2pDUCt1S3ZURUxZc290UzJNS3QKM2Q0M0UwUWFqc1Ba
|
24
|
+
dTJadU5Gd2tyb3FldWU4NzJnTUhVbGRHT1Z5NVd0U2Q5YWp3MnhJL0NvY2lZ
|
25
|
+
Njc0NmRMKwpwWXJpVjNRYVl0Ui9lemVhTHBLQkxzYzVUMVVRMDd0N1hzN21J
|
26
|
+
MjgxdGRtUnZwTGRQNWRRaGp6SW5maW8wQ0p2CjFQZjViWlVqR0cwSzlSVzJH
|
27
|
+
Yi90R1BTWUVFVGlMTXViakg2MU93Qm9vWEtpV1I1Y3M0LzFCUUlEQVFBQm96
|
28
|
+
a3cKTnpBSkJnTlZIUk1FQWpBQU1Bc0dBMVVkRHdRRUF3SUVzREFkQmdOVkhR
|
29
|
+
NEVGZ1FVU1l2amhHMkVXblI1a3g1bApEQWV3WENrSk9WRXdEUVlKS29aSWh2
|
30
|
+
Y05BUUVGQlFBRGdnRUJBQjJyeURiVTRiUXRudW5Ldi9BWHE0Q3VPM0xTCmtp
|
31
|
+
azlYaHllOEUvNWRUY3NnaXRDWkpYQXF4MHJIY0swdTJFSG5qQTVDRGNkRjVK
|
32
|
+
QjdYZ1N2UnJRa0ZXb1cvOUsKbENCNGloK3NCMkFJMklVaVlCZW9DR2N0WGRC
|
33
|
+
UTAyMHBycW9wL29UUUV1ZHpGay9neVE2ODZscDA2SGRMUnQrTwpIb1FqVElh
|
34
|
+
Yjh2bWZnSXVialBkSVJ6b2tNZkhiZWx2aExpK21RZldWZ2hSaHMyanBFZmRY
|
35
|
+
YkwwdzVuTncrdHJwCnJPNzBEdzU5aGR1RFVPcGdweGV3K1BMYnM0dlAxdGIx
|
36
|
+
UUtQRyszOUMrUFp0b3NiYmYxZmFpMGhxWVYxdHhNQ3gKNTVha0YrTjhOYk82
|
37
|
+
dHBWRHk2VE1hZ3FhMTBMZkVwaVFINmR2REhlL3hkQXFZT0NyWEtwbXF6d3Uy
|
38
|
+
UEk9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
|
39
|
+
date: 2013-10-08 00:00:00.000000000 Z
|
52
40
|
dependencies:
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: bundler
|
55
|
-
requirement:
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
56
44
|
none: false
|
57
45
|
requirements:
|
58
|
-
- -
|
46
|
+
- - ! '>='
|
59
47
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
48
|
+
version: '0'
|
61
49
|
type: :development
|
62
50
|
prerelease: false
|
63
|
-
version_requirements:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
64
57
|
- !ruby/object:Gem::Dependency
|
65
58
|
name: rake
|
66
|
-
requirement:
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
67
60
|
none: false
|
68
61
|
requirements:
|
69
|
-
- -
|
62
|
+
- - ! '>='
|
70
63
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0
|
64
|
+
version: '0'
|
72
65
|
type: :development
|
73
66
|
prerelease: false
|
74
|
-
version_requirements:
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
75
73
|
- !ruby/object:Gem::Dependency
|
76
74
|
name: rspec
|
77
|
-
requirement:
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
78
76
|
none: false
|
79
77
|
requirements:
|
80
78
|
- - ~>
|
81
79
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
80
|
+
version: 2.14.1
|
83
81
|
type: :development
|
84
82
|
prerelease: false
|
85
|
-
version_requirements:
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.14.1
|
86
89
|
- !ruby/object:Gem::Dependency
|
87
90
|
name: simplecov
|
88
|
-
requirement:
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
89
92
|
none: false
|
90
93
|
requirements:
|
91
94
|
- - ~>
|
92
95
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.
|
96
|
+
version: 0.7.1
|
94
97
|
type: :development
|
95
98
|
prerelease: false
|
96
|
-
version_requirements:
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 0.7.1
|
97
105
|
- !ruby/object:Gem::Dependency
|
98
106
|
name: pry
|
99
|
-
requirement:
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
100
108
|
none: false
|
101
109
|
requirements:
|
102
110
|
- - ~>
|
103
111
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.9.
|
112
|
+
version: 0.9.12.2
|
105
113
|
type: :development
|
106
114
|
prerelease: false
|
107
|
-
version_requirements:
|
115
|
+
version_requirements: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ~>
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.9.12.2
|
108
121
|
- !ruby/object:Gem::Dependency
|
109
122
|
name: yard
|
110
|
-
requirement:
|
123
|
+
requirement: !ruby/object:Gem::Requirement
|
111
124
|
none: false
|
112
125
|
requirements:
|
113
126
|
- - ~>
|
114
127
|
- !ruby/object:Gem::Version
|
115
|
-
version: 0.8.2
|
128
|
+
version: 0.8.7.2
|
116
129
|
type: :development
|
117
130
|
prerelease: false
|
118
|
-
version_requirements:
|
131
|
+
version_requirements: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ~>
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 0.8.7.2
|
119
137
|
description: ! 'Init is a lightweight framework for writing readable, reusable *nix
|
120
138
|
init
|
121
139
|
|
@@ -139,8 +157,10 @@ files:
|
|
139
157
|
- LICENSE.md
|
140
158
|
- README.md
|
141
159
|
- Rakefile
|
142
|
-
- examples/
|
160
|
+
- examples/attachable_daemon.rb
|
161
|
+
- examples/left4dead2.rb
|
143
162
|
- examples/murmur.rb
|
163
|
+
- examples/source_dedicated.rb
|
144
164
|
- init.gemspec
|
145
165
|
- lib/aef/init.rb
|
146
166
|
- lib/aef/init/version.rb
|
@@ -170,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
190
|
version: '0'
|
171
191
|
requirements: []
|
172
192
|
rubyforge_project:
|
173
|
-
rubygems_version: 1.8.
|
193
|
+
rubygems_version: 1.8.24
|
174
194
|
signing_key:
|
175
195
|
specification_version: 3
|
176
196
|
summary: Clean and simple *nix init scripts with Ruby
|
metadata.gz.sig
CHANGED
Binary file
|