init 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -0,0 +1,12 @@
1
+ # Project metadata
2
+ nbproject
3
+ .idea
4
+
5
+ Gemfile.lock
6
+
7
+ doc
8
+ coverage
9
+ pkg
10
+ .yardoc
11
+ .rbx
12
+ *.rbc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,8 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - rbx-18mode
6
+ - rbx-19mode
7
+ - jruby-18mode
8
+ - jruby-19mode
@@ -0,0 +1,5 @@
1
+ --protected
2
+ --no-private
3
+ -
4
+ HISTORY.md
5
+ LICENSE.md
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
4
+
5
+ This file is part of Init.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ source 'http://rubygems.org'
21
+
22
+ # Specify your gem's dependencies in weekling.gemspec
23
+ gemspec
@@ -1,4 +1,19 @@
1
- === 1.2.1 / 2010-12-02
1
+ 2.0.0 / 2012-03-13
2
+ ==================
3
+
4
+ * 2 major improvement
5
+
6
+ * Changed to ISC based license
7
+ * A default command is no longer set implicitly
8
+
9
+ * 3 minor enhancements
10
+
11
+ * Using singleton class instance variables instead of class variables
12
+ * Slightly restructured project
13
+ * Documentation converted to YARD syntax
14
+
15
+ 1.2.1 / 2010-12-02
16
+ ==================
2
17
 
3
18
  * 1 minor enchancement
4
19
 
@@ -8,7 +23,8 @@
8
23
 
9
24
  * Removed machine local paths from gemspec file
10
25
 
11
- === 1.2.0 / 2010-12-02
26
+ 1.2.0 / 2010-12-02
27
+ ==================
12
28
 
13
29
  * 3 minor enhancements
14
30
 
@@ -20,7 +36,8 @@
20
36
 
21
37
  * Fixed some typos in documentation
22
38
 
23
- === 1.1.0 / 2010-10-04
39
+ 1.1.0 / 2010-10-04
40
+ ==================
24
41
 
25
42
  * 3 minor enhancements
26
43
 
@@ -32,7 +49,8 @@
32
49
 
33
50
  * Files are now correctly namespaced
34
51
 
35
- === 1.0.0 / 2009-03-25
52
+ 1.0.0 / 2009-03-25
53
+ ==================
36
54
 
37
55
  * 1 major enhancement
38
56
 
@@ -0,0 +1,15 @@
1
+ Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
2
+
3
+ Init is licensed under the following ISC-style license:
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,244 @@
1
+ Init
2
+ ====
3
+
4
+ [![Build Status](https://secure.travis-ci.org/aef/init.png)](
5
+ https://secure.travis-ci.org/aef/init)
6
+
7
+ * [Documentation][docs]
8
+ * [Project][project]
9
+
10
+ [docs]: http://rdoc.info/github/aef/init/
11
+ [project]: https://github.com/aef/init/
12
+
13
+ Description
14
+ -----------
15
+
16
+ Init is a lightweight framework for writing readable, reusable *nix init
17
+ scripts in Ruby.
18
+
19
+ Features / Problems
20
+ -------------------
21
+
22
+ This project tries to conform to:
23
+
24
+ * [Semantic Versioning (2.0.0-rc.1)][semver]
25
+ * [Ruby Packaging Standard (0.5-draft)][rps]
26
+ * [Ruby Style Guide][style]
27
+ * [Gem Packaging: Best Practices][gem]
28
+
29
+ [semver]: http://semver.org/
30
+ [rps]: http://chneukirchen.github.com/rps/
31
+ [style]: https://github.com/bbatsov/ruby-style-guide
32
+ [gem]: http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
33
+
34
+ Additional facts:
35
+
36
+ * Written purely in Ruby.
37
+ * Documented with YARD.
38
+ * Intended to be used with Ruby 1.8.7 or higher.
39
+ * Cryptographically signed gem and git tags.
40
+
41
+ Synopsis
42
+ --------
43
+
44
+ This documentation defines the public interface of the software. Don't rely
45
+ on elements marked as private. Those should be hidden in the documentation
46
+ by default.
47
+
48
+ ### Loading
49
+
50
+ In most cases you want to load the library by the following command:
51
+
52
+ ~~~~~ ruby
53
+ require 'init'
54
+ ~~~~~
55
+
56
+ In a bundler Gemfile you should use the following:
57
+
58
+ ~~~~~ ruby
59
+ gem 'init'
60
+ ~~~~~
61
+
62
+ ### Library
63
+
64
+ Simply subclass Aef::Init and define at least a start and a stop method. At the
65
+ end, call the parse method on that class.
66
+
67
+ ~~~~~ ruby
68
+ class DemoSubclass < Aef::Init
69
+ def start
70
+ system('echo start')
71
+ end
72
+
73
+ def stop
74
+ system('echo stop')
75
+ end
76
+ end
77
+
78
+ DemoSubclass.parse
79
+ ~~~~~
80
+
81
+ To be able to call the commands from Ruby you should wrap the parse method call
82
+ in a block that only calls it if the script is executed on the commandline.
83
+
84
+ ~~~~~ ruby
85
+ if __FILE__ == $PROGRAM_NAME
86
+ DemoSubclass.parse
87
+ end
88
+ ~~~~~
89
+
90
+ There is no need to implement the command restart in most cases, as there is one
91
+ defined by default, which simply calls the commands stop and start in a row.
92
+ A delay between the two commands can be defined:
93
+
94
+ ~~~~~ ruby
95
+ class DemoSubclass < Aef::Init
96
+ ...
97
+ stop_start_delay 3
98
+ ...
99
+ end
100
+ ~~~~~
101
+
102
+ Notice that in earlier versions the default command was preset to :restart
103
+ which was not as useful in practice than expected. Many unwanted restarts were
104
+ triggered because of this, so I don't recommend using this feature any more.
105
+
106
+ Still, a default command can be specified which is called if no command is provided on the command-line:
107
+
108
+ ~~~~~ ruby
109
+ class DemoSubclass < Aef::Init
110
+ ...
111
+ default_command :start
112
+ ...
113
+ end
114
+ ~~~~~
115
+
116
+ If you want to share commands between init scripts, you can simply insert an
117
+ intermediate class between Init and the final implementation. This way you can
118
+ build reusable libraries and keep your code DRY.
119
+
120
+ ~~~~~ ruby
121
+ class CommonCommands > Aef::Init
122
+ def common
123
+ system('echo common')
124
+ end
125
+ end
126
+
127
+ class DemoSubclass > CommonCommands
128
+ ...
129
+ end
130
+ ~~~~~
131
+
132
+ See the examples folder and spec/bin/simple_init.rb for working example classes.
133
+
134
+ Requirements
135
+ ------------
136
+
137
+ * Ruby 1.8.7 or higher
138
+
139
+ Installation
140
+ ------------
141
+
142
+ On *nix systems you may need to prefix the command with sudo to get root
143
+ privileges.
144
+
145
+ ### High security (recommended)
146
+
147
+ There is a high security installation option available through rubygems. It is
148
+ highly recommended over the normal installation, although it may be a bit less
149
+ comfortable. To use the installation method, you will need my [gem signing
150
+ public key][gemkey], which I use for cryptographic signatures on all my gems.
151
+
152
+ Add the key to your rubygems' trusted certificates by the following command:
153
+
154
+ gem cert --add aef-gem.pem
155
+
156
+ Now you can install the gem while automatically verifying it's signature by the
157
+ following command:
158
+
159
+ gem install init -P HighSecurity
160
+
161
+ Please notice that you may need other keys for dependent libraries, so you may
162
+ have to install dependencies manually.
163
+
164
+ [gemkey]: http://aef.name/crypto/aef-gem.pem
165
+
166
+ ### Normal
167
+
168
+ gem install init
169
+
170
+ ### Automated testing
171
+
172
+ Go into the root directory of the installed gem and run the following command
173
+ to fetch all development dependencies:
174
+
175
+ bundle
176
+
177
+ Afterwards start the test runner:
178
+
179
+ rake spec
180
+
181
+ If something goes wrong you should be noticed through failing examples.
182
+
183
+ Development
184
+ -----------
185
+
186
+ ### Bugs Reports and Feature Requests
187
+
188
+ Please use the [issue tracker][issues] on github.com to let me know about errors
189
+ or ideas for improvement of this software.
190
+
191
+ [issues]: https://github.com/aef/init/issues/
192
+
193
+ ### Source code
194
+
195
+ This software is developed in the source code management system git hosted
196
+ at github.com. You can download the most recent sourcecode through the
197
+ following command:
198
+
199
+ git clone https://github.com/aef/init.git
200
+
201
+ The final commit before each released gem version will be marked by a tag
202
+ named like the version with a prefixed lower-case "v", as required by Semantic
203
+ Versioning. Every tag will be signed by my [OpenPGP public key][openpgp] which
204
+ enables you to verify your copy of the code cryptographically.
205
+
206
+ [openpgp]: http://aef.name/crypto/aef-openpgp.asc
207
+
208
+ Add the key to your GnuPG keyring by the following command:
209
+
210
+ gpg --import aef-openpgp.asc
211
+
212
+ This command will tell you if your code is of integrity and authentic:
213
+
214
+ git tag -v [TAG NAME]
215
+
216
+ ### Contribution
217
+
218
+ Help on making this software better is always very appreciated. If you want
219
+ your changes to be included in the official release, please clone my project
220
+ on github.com, create a named branch to commit and push your changes into and
221
+ send me a pull request afterwards.
222
+
223
+ Please make sure to write tests for your changes so that I won't break them
224
+ when changing other things on the library. Also notice that I can't promise
225
+ to include your changes before reviewing them.
226
+
227
+ License
228
+ -------
229
+
230
+ Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
231
+
232
+ This file is part of Init.
233
+
234
+ Permission to use, copy, modify, and/or distribute this software for any
235
+ purpose with or without fee is hereby granted, provided that the above
236
+ copyright notice and this permission notice appear in all copies.
237
+
238
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
239
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
240
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
241
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
242
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
243
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
244
+ PERFORMANCE OF THIS SOFTWARE.
data/Rakefile CHANGED
@@ -1,24 +1,48 @@
1
- # -*- ruby -*-
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
2
4
 
3
- $LOAD_PATH.unshift('lib')
5
+ This file is part of Init.
4
6
 
5
- require 'hoe'
6
- require 'aef/init'
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
7
10
 
8
- Hoe.spec 'init' do
9
- developer('Alexander E. Fischer', 'aef@raxys.net')
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
10
19
 
11
- extra_dev_deps << ['rspec', '~> 2.2.0']
12
- extra_dev_deps << ['facets', '~> 2.9.0']
20
+ require 'bundler/gem_tasks'
21
+ require 'rake'
22
+ require 'pathname'
23
+ require 'yard'
24
+ require 'rspec/core/rake_task'
13
25
 
14
- self.version = Aef::Init::VERSION.dup
15
- self.rubyforge_name = 'aef'
16
- self.url = 'https://rubyforge.org/projects/aef/'
17
- self.readme_file = 'README.rdoc'
18
- self.extra_rdoc_files = %w{README.rdoc}
19
- self.spec_extras = {
20
- :rdoc_options => ['--main', 'README.rdoc', '--inline-source', '--line-numbers', '--title', 'Init']
21
- }
26
+ RSpec::Core::RakeTask.new
27
+
28
+ YARD::Rake::YardocTask.new('doc')
29
+
30
+ desc "Removes temporary project files"
31
+ task :clean do
32
+ %w{doc coverage pkg .yardoc .rbx Gemfile.lock}.map{|name| Pathname.new(name) }.each do |path|
33
+ path.rmtree if path.exist?
34
+ end
35
+
36
+ Pathname.glob('*.gem').each &:delete
37
+ Pathname.glob('**/*.rbc').each &:delete
38
+ end
39
+
40
+ desc "Opens an interactive console with the library loaded"
41
+ task :console do
42
+ Bundler.setup
43
+ require 'pry'
44
+ require 'init'
45
+ Pry.start
22
46
  end
23
47
 
24
- # vim: syntax=Ruby
48
+ task :default => :spec
@@ -1,21 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
- #
3
- # Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2010
4
- #
5
- # This file is part of Init.
6
- #
7
- # Init is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
2
+ # encoding: UTF-8
3
+ =begin
4
+ Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
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
19
20
 
20
21
  require 'aef/init'
21
22