jeckyl 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Bugs.rdoc +6 -0
- data/Gemfile +6 -0
- data/History.txt +74 -0
- data/Intro.txt +5 -0
- data/LICENCE.rdoc +159 -0
- data/bin/jeckyl +239 -0
- data/lib/jeckyl/errors.rb +35 -0
- data/lib/jeckyl/version.rb +13 -0
- data/lib/jeckyl.rb +619 -0
- data/spec/check_config_spec.rb +57 -0
- data/spec/jeckyl_spec.rb +202 -0
- data/spec/spec_helper.rb +11 -0
- data/test/conf.d/a_few_params +2 -0
- data/test/conf.d/bad_filename +2 -0
- data/test/conf.d/bclass.rb +2 -0
- data/test/conf.d/defaults.rb +0 -0
- data/test/conf.d/jeckyl +46 -0
- data/test/conf.d/jeckyl_check +46 -0
- data/test/conf.d/merger.rb +31 -0
- data/test/conf.d/no_such_file +2 -0
- data/test/conf.d/not_a_bool +1 -0
- data/test/conf.d/not_a_flag +1 -0
- data/test/conf.d/not_a_float +1 -0
- data/test/conf.d/not_a_hash +1 -0
- data/test/conf.d/not_a_member +1 -0
- data/test/conf.d/not_a_pattern +1 -0
- data/test/conf.d/not_a_set +1 -0
- data/test/conf.d/not_a_string +1 -0
- data/test/conf.d/not_an_array +1 -0
- data/test/conf.d/not_an_email +1 -0
- data/test/conf.d/not_an_integer_array +1 -0
- data/test/conf.d/out_of_range +1 -0
- data/test/conf.d/sloppy_params +5 -0
- data/test/conf.d/syntax_error +3 -0
- data/test/conf.d/unknown_param +2 -0
- data/test/conf.d/unwritable_dir +1 -0
- data/test/conf.d/wrong_type +2 -0
- data/test/reports/not_ok.txt +1 -0
- data/test/reports/ok.txt +1 -0
- data/test/test_class.rb +32 -0
- data/test/test_configurator.rb +105 -0
- data/test/test_configurator_errors.rb +105 -0
- data/test/test_subclass.rb +11 -0
- metadata +144 -0
data/Bugs.rdoc
ADDED
data/Gemfile
ADDED
data/History.txt
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# @markup rdoc
|
2
|
+
# @title Change Log
|
3
|
+
# @author Robert Sharp
|
4
|
+
|
5
|
+
== History
|
6
|
+
|
7
|
+
[jeckyl-0.2.1 20-Sep-2012]
|
8
|
+
|
9
|
+
Tidy up documentation.
|
10
|
+
|
11
|
+
[jeckyl-0.2.0 19-Sep-2012]
|
12
|
+
|
13
|
+
Clean up code and documentation and enable parameter methods to be separated by class.
|
14
|
+
|
15
|
+
[jeckyl-0.1.11 23-Jul-2012]
|
16
|
+
|
17
|
+
Added comment command to jeckyl to produce just comments for yard
|
18
|
+
|
19
|
+
[jeckyl-0.1.10 18-June-2012]
|
20
|
+
|
21
|
+
Added complement and intersection methods and deprecated new Jeckyl::Service in favour of
|
22
|
+
including these options with the services they relate to (Jelly::Options, for example). Tidyied
|
23
|
+
up documentation.
|
24
|
+
|
25
|
+
[jeckyl-0.1.9 6-June-2012]
|
26
|
+
|
27
|
+
Included require 'jeckyl' in service.rb
|
28
|
+
|
29
|
+
[jeckyl-0.1.8 2-June-2012]
|
30
|
+
|
31
|
+
Made sure Jeckyl::Service inherits from Jeckyl::Options!
|
32
|
+
|
33
|
+
[jeckyl-0.1.7 1-June-2012]
|
34
|
+
|
35
|
+
Added Jeckyl::Service as a class which already defines all of the config options needed
|
36
|
+
for a Jerbil::Service
|
37
|
+
|
38
|
+
[jeckyl-0.1.6 19-Dec-2011]
|
39
|
+
|
40
|
+
Correct silly typo in config_file change
|
41
|
+
|
42
|
+
[jeckyl-0.1.5 19-Dec-2011]
|
43
|
+
|
44
|
+
Add :config_file to self to remember where the config file is
|
45
|
+
|
46
|
+
[jeckyl-0.1.4 25-July-2011]
|
47
|
+
|
48
|
+
changed ignore_errors_on_default to true as the default
|
49
|
+
|
50
|
+
[jeckyl-0.1.3 23-June-2011]
|
51
|
+
|
52
|
+
Minor tweak to get string handling working properly for generating configs
|
53
|
+
|
54
|
+
[jeckyl-0.1.2 23-June-2011]
|
55
|
+
|
56
|
+
Update to check that defaults meet specified rules properly, and handle strings and symbols when generating files
|
57
|
+
|
58
|
+
[jeckyl-0.1.1 26-Apr-2011]
|
59
|
+
|
60
|
+
Added ConfigRoot as the default root for config files
|
61
|
+
|
62
|
+
[jeckyl-0.1.0 18-Apr-2011]
|
63
|
+
|
64
|
+
Changed structure to module-based due to superclass mismatch errors. This version of
|
65
|
+
Jeckyl is not backward compatible.
|
66
|
+
|
67
|
+
[jeckyl-0.0.4 14-Apr-2011]
|
68
|
+
|
69
|
+
Minor Update to fix a superclass error caused by requiring version before the first
|
70
|
+
declaration of the Jeckyl class.
|
71
|
+
|
72
|
+
[jeckyl-0.0.3a 11-Apr-2011]
|
73
|
+
|
74
|
+
Another slight change
|
data/Intro.txt
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Jeckyl can be used to create a parameters hash from a simple config file written in Ruby, having run whatever checks you want
|
2
|
+
on the file to ensure the values passed in are valid. All you need to do is define a class inheriting from Jeckyl, methods for
|
3
|
+
each parameter, its default, whatever checking rules are appropriate and even a comment for generating templates etc.
|
4
|
+
This is then used to parse a Ruby config file and create the parameters hash. Jeckyl
|
5
|
+
comes complete with a utility to check a config file against a given class and to generate a default file for you to tailor.
|
data/LICENCE.rdoc
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
Copyright (c) 2011 Robert Sharp
|
2
|
+
|
3
|
+
This software is licensed for use under the Open Software Licence v. 3.0
|
4
|
+
The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
|
5
|
+
and below. Under the terms of this licence, all derivative works
|
6
|
+
must themselves be licensed under the Open Software Licence v. 3.0
|
7
|
+
|
8
|
+
Open Source Initiative OSI - The Open Software Licence 3.0:Licensing
|
9
|
+
[OSI Approved Licence]
|
10
|
+
Open Software Licence ("OSL") v. 3.0
|
11
|
+
|
12
|
+
This Open Software Licence (the "Licence") applies to any original work of authorship
|
13
|
+
(the "Original Work") whose owner (the "Licensor") has placed the following licensing
|
14
|
+
notice adjacent to the copyright notice for the Original Work:
|
15
|
+
|
16
|
+
Licensed under the Open Software Licence version 3.0
|
17
|
+
|
18
|
+
1) Grant of Copyright Licence. Licensor grants You a worldwide, royalty-free, non-exclusive,
|
19
|
+
sublicensable license, for the duration of the copyright, to do the following:
|
20
|
+
|
21
|
+
a) to reproduce the Original Work in copies, either alone or as part of a collective work;
|
22
|
+
|
23
|
+
b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby
|
24
|
+
creating derivative works ("Derivative Works") based upon the Original Work;
|
25
|
+
|
26
|
+
c) to distribute or communicate copies of the Original Work and Derivative Works to
|
27
|
+
the public, with the proviso that copies of Original Work or Derivative Works that
|
28
|
+
You distribute or communicate shall be licensed under this Open Software Licence;
|
29
|
+
|
30
|
+
d) to perform the Original Work publicly; and
|
31
|
+
|
32
|
+
e) to display the Original Work publicly.
|
33
|
+
|
34
|
+
2) Grant of Patent Licence. Licensor grants You a worldwide, royalty-free, non-exclusive,
|
35
|
+
sublicensable license, under patent claims owned or controlled by the Licensor that are
|
36
|
+
embodied in the Original Work as furnished by the Licensor, for the duration of the
|
37
|
+
patents, to make, use, sell, offer for sale, have made, and import the Original Work
|
38
|
+
and Derivative Works.
|
39
|
+
|
40
|
+
3) Grant of Source Code Licence. The term "Source Code" means the preferred form of
|
41
|
+
the Original Work for making modifications to it and all available documentation
|
42
|
+
describing how to modify the Original Work. Licensor agrees to provide a machine-readable
|
43
|
+
copy of the Source Code of the Original Work along with each copy of the Original Work
|
44
|
+
that Licensor distributes. Licensor reserves the right to satisfy this obligation by
|
45
|
+
placing a machine-readable copy of the Source Code in an information repository reasonably
|
46
|
+
calculated to permit inexpensive and convenient access by You for as long as Licensor
|
47
|
+
continues to distribute the Original Work.
|
48
|
+
|
49
|
+
4) Exclusions From Licence Grant. Neither the names of Licensor, nor the names of
|
50
|
+
any contributors to the Original Work, nor any of their trademarks or service marks,
|
51
|
+
may be used to endorse or promote products derived from this Original Work without
|
52
|
+
express prior permission of the Licensor. Except as expressly stated herein, nothing
|
53
|
+
in this Licence grants any license to Licensor's trademarks, copyrights, patents,
|
54
|
+
trade secrets or any other intellectual property. No patent license is granted to
|
55
|
+
make, use, sell, offer for sale, have made, or import embodiments of any patent claims
|
56
|
+
other than the licensed claims defined in Section 2. No license is granted to the
|
57
|
+
trademarks of Licensor even if such marks are included in the Original Work. Nothing
|
58
|
+
in this Licence shall be interpreted to prohibit Licensor from licensing under terms
|
59
|
+
different from this Licence any Original Work that Licensor otherwise would have a
|
60
|
+
right to license.
|
61
|
+
|
62
|
+
5) External Deployment. The term "External Deployment" means the use, distribution,
|
63
|
+
or communication of the Original Work or Derivative Works in any way such that the
|
64
|
+
Original Work or Derivative Works may be used by anyone other than You, whether those
|
65
|
+
works are distributed or communicated to those persons or made available as an application
|
66
|
+
intended for use over a network. As an express condition for the grants of license hereunder,
|
67
|
+
You must treat any External Deployment by You of the Original Work or a Derivative Work
|
68
|
+
as a distribution under section 1(c).
|
69
|
+
|
70
|
+
6) Attribution Rights. You must retain, in the Source Code of any Derivative Works
|
71
|
+
that You create, all copyright, patent, or trademark notices from the Source Code of
|
72
|
+
the Original Work, as well as any notices of licensing and any descriptive text identified
|
73
|
+
therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works
|
74
|
+
that You create to carry a prominent Attribution Notice reasonably calculated to inform
|
75
|
+
recipients that You have modified the Original Work.
|
76
|
+
|
77
|
+
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright
|
78
|
+
in and to the Original Work and the patent rights granted herein by Licensor are owned by
|
79
|
+
the Licensor or are sublicensed to You under the terms of this Licence with the permission
|
80
|
+
of the contributor(s) of those copyrights and patent rights. Except as expressly stated in
|
81
|
+
the immediately preceding sentence, the Original Work is provided under this Licence on an
|
82
|
+
"AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation,
|
83
|
+
the warranties of non-infringement, merchantability or fitness for a particular purpose.
|
84
|
+
THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY
|
85
|
+
constitutes an essential part of this Licence. No license to the Original Work is granted
|
86
|
+
by this Licence except under this disclaimer.
|
87
|
+
|
88
|
+
8) Limitation of Liability. Under no circumstances and under no legal theory, whether
|
89
|
+
in tort (including negligence), contract, or otherwise, shall the Licensor be liable
|
90
|
+
to anyone for any indirect, special, incidental, or consequential damages of any character
|
91
|
+
arising as a result of this Licence or the use of the Original Work including, without
|
92
|
+
limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction,
|
93
|
+
or any and all other commercial damages or losses. This limitation of liability shall not
|
94
|
+
apply to the extent applicable law prohibits such limitation.
|
95
|
+
|
96
|
+
9) Acceptance and Termination. If, at any time, You expressly assented to this Licence,
|
97
|
+
that assent indicates your clear and irrevocable acceptance of this Licence and all of its
|
98
|
+
terms and conditions. If You distribute or communicate copies of the Original Work or a
|
99
|
+
Derivative Work, You must make a reasonable effort under the circumstances to obtain the
|
100
|
+
express assent of recipients to the terms of this Licence. This Licence conditions your
|
101
|
+
rights to undertake the activities listed in Section 1, including your right to create
|
102
|
+
Derivative Works based upon the Original Work, and doing so without honoring these
|
103
|
+
terms and conditions is prohibited by copyright law and international treaty. Nothing
|
104
|
+
in this Licence is intended to affect copyright exceptions and limitations (including
|
105
|
+
"fair use" or "fair dealing"). This Licence shall terminate immediately and You may no
|
106
|
+
longer exercise any of the rights granted to You by this Licence upon your failure to
|
107
|
+
honor the conditions in Section 1(c).
|
108
|
+
|
109
|
+
10) Termination for Patent Action. This Licence shall terminate automatically and
|
110
|
+
You may no longer exercise any of the rights granted to You by this Licence as of
|
111
|
+
the date You commence an action, including a cross-claim or counterclaim, against
|
112
|
+
Licensor or any licensee alleging that the Original Work infringes a patent. This
|
113
|
+
termination provision shall not apply for an action alleging patent infringement
|
114
|
+
by combinations of the Original Work with other software or hardware.
|
115
|
+
|
116
|
+
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this Licence
|
117
|
+
may be brought only in the courts of a jurisdiction wherein the Licensor resides or
|
118
|
+
in which Licensor conducts its primary business, and under the laws of that jurisdiction
|
119
|
+
excluding its conflict-of-law provisions. The application of the United Nations Convention
|
120
|
+
on Contracts for the International Sale of Goods is expressly excluded. Any use of
|
121
|
+
the Original Work outside the scope of this Licence or after its termination shall be
|
122
|
+
subject to the requirements and penalties of copyright or patent law in the appropriate
|
123
|
+
jurisdiction. This section shall survive the termination of this Licence.
|
124
|
+
|
125
|
+
12) Attorneys' Fees. In any action to enforce the terms of this Licence or seeking
|
126
|
+
damages relating thereto, the prevailing party shall be entitled to recover its costs
|
127
|
+
and expenses, including, without limitation, reasonable attorneys' fees and costs
|
128
|
+
incurred in connection with such action, including any appeal of such action. This
|
129
|
+
section shall survive the termination of this Licence.
|
130
|
+
|
131
|
+
13) Miscellaneous. If any provision of this Licence is held to be unenforceable,
|
132
|
+
such provision shall be reformed only to the extent necessary to make it enforceable.
|
133
|
+
|
134
|
+
14) Definition of "You" in This Licence. "You" throughout this Licence, whether in
|
135
|
+
upper or lower case, means an individual or a legal entity exercising rights under,
|
136
|
+
and complying with all of the terms of, this Licence. For legal entities, "You" includes
|
137
|
+
any entity that controls, is controlled by, or is under common control with you. For
|
138
|
+
purposes of this definition, "control" means (i) the power, direct or indirect, to cause
|
139
|
+
the direction or management of such entity, whether by contract or otherwise, or (ii)
|
140
|
+
ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
|
141
|
+
ownership of such entity.
|
142
|
+
|
143
|
+
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or
|
144
|
+
conditioned by this Licence or by law, and Licensor promises not to interfere with or be
|
145
|
+
responsible for such uses by You.
|
146
|
+
|
147
|
+
16) Modification of This Licence. This Licence is Copyright © 2005 Lawrence Rosen.
|
148
|
+
Permission is granted to copy, distribute, or communicate this Licence without modification.
|
149
|
+
Nothing in this Licence permits You to modify this Licence as applied to the Original Work
|
150
|
+
or to Derivative Works. However, You may modify the text of this Licence and copy, distribute
|
151
|
+
or communicate your modified version (the "Modified Licence") and apply it to other original
|
152
|
+
works of authorship subject to the following conditions: (i) You may not indicate in any way
|
153
|
+
that your Modified Licence is the "Open Software Licence" or "OSL" and you may not use those
|
154
|
+
names in the name of your Modified Licence; (ii) You must replace the notice specified in the
|
155
|
+
first paragraph above with the notice "Licensed under <insert your license name here>" or
|
156
|
+
with a notice of your own that is not confusingly similar to the notice in this Licence;
|
157
|
+
and (iii) You may not claim that your original works are open source software unless your
|
158
|
+
Modified Licence has been approved by Open Source Initiative (OSI) and You comply with
|
159
|
+
its license review and certification process.
|
data/bin/jeckyl
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
#!/usr/bin/env ruby18
|
2
|
+
#
|
3
|
+
# Description
|
4
|
+
#
|
5
|
+
# Author:: Robert Sharp
|
6
|
+
# Copyright:: Copyright (c) 2010 Robert Sharp
|
7
|
+
# License:: Open Software Licence v3.0
|
8
|
+
#
|
9
|
+
# This software is licensed for use under the Open Software Licence v. 3.0
|
10
|
+
# The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
|
11
|
+
# and in the file copyright.txt. Under the terms of this licence, all derivative works
|
12
|
+
# must themselves be licensed under the Open Software Licence v. 3.0
|
13
|
+
#
|
14
|
+
#
|
15
|
+
# replace this to point to your config class
|
16
|
+
# require 'my_jeckyl_configurator'
|
17
|
+
require 'rubygems' # want to find classes that might be in gems
|
18
|
+
require 'jeckyl'
|
19
|
+
require 'jeckyl/errors'
|
20
|
+
require 'thor'
|
21
|
+
require 'thor/group'
|
22
|
+
require 'colored'
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
# the Command Line Interface for jeckyl to allow users to generate
|
27
|
+
# config files, generate a simple template or check a config file
|
28
|
+
class JeckylCLI < Thor
|
29
|
+
|
30
|
+
default_task :usage
|
31
|
+
|
32
|
+
desc "usage", "You are looking at it"
|
33
|
+
def usage
|
34
|
+
puts "Useful tasks for managing Jeckyl config files."
|
35
|
+
puts ""
|
36
|
+
help
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "list", "list all the config classes involved in a given class"
|
40
|
+
def list(cfile)
|
41
|
+
require cfile
|
42
|
+
classes = Jeckyl::Options.descendants
|
43
|
+
display_classes(classes)
|
44
|
+
rescue LoadError
|
45
|
+
puts "Error: could not load #{cfile}".red.bold
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
desc "config", "generate config file for the given config class"
|
50
|
+
method_option :class, :aliases=>'-C', :type=>:numeric, :desc=>'select class by index'
|
51
|
+
method_option :concat, :aliases=>'-k', :desc=>'concat all classes, starting with the oldest'
|
52
|
+
def config(cfile, my_class_name=nil)
|
53
|
+
|
54
|
+
require cfile # catch LoadError if cfile does not load
|
55
|
+
|
56
|
+
my_class_index = options[:class] || 0
|
57
|
+
my_class_index += -1 if my_class_index > 0
|
58
|
+
|
59
|
+
|
60
|
+
classes = Jeckyl::Options.descendants
|
61
|
+
|
62
|
+
if options[:concat].nil? && classes[my_class_index].nil? then
|
63
|
+
$stderr.puts "Index #{my_class_index + 1} is invalid. Please select a valid index".red.bold
|
64
|
+
display_classes(classes)
|
65
|
+
return false
|
66
|
+
end
|
67
|
+
|
68
|
+
$stderr.puts "There are #{classes.length} sets of configs, use 'jeckyl list' to list them or -k to generate them all".yellow if classes.length > 1
|
69
|
+
|
70
|
+
my_classes = []
|
71
|
+
if options[:concat] then
|
72
|
+
classes.each_index {|i| my_classes.unshift i}
|
73
|
+
else
|
74
|
+
my_classes << my_class_index
|
75
|
+
end
|
76
|
+
|
77
|
+
my_classes.each do |ci|
|
78
|
+
puts "#"
|
79
|
+
puts "# Configuration Options for: #{classes[ci].name}"
|
80
|
+
puts "#"
|
81
|
+
puts
|
82
|
+
classes[ci].generate_config(true)
|
83
|
+
end
|
84
|
+
|
85
|
+
unless options[:concat] || classes.length == 1
|
86
|
+
puts ""
|
87
|
+
puts "# There are also parameters in:"
|
88
|
+
classes.each do |klass|
|
89
|
+
puts "# #{klass.name}"unless klass == classes[my_class_index]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
rescue LoadError
|
94
|
+
puts "Error: could not load #{cfile}".red.bold
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "klass", "generate a simple class template"
|
98
|
+
def klass(name, parent="Jeckyl::Config")
|
99
|
+
puts <<EOTXT
|
100
|
+
# Simple framework for defining Jeckyl options to put into a config hash
|
101
|
+
|
102
|
+
module #{name}
|
103
|
+
|
104
|
+
# configuration parameters for #{name}
|
105
|
+
#
|
106
|
+
# @see file:<PATH_TO_CONFIG_MARKDOWN_FILE> #{name} Parameter Descriptions
|
107
|
+
#
|
108
|
+
class Config < #{parent}
|
109
|
+
|
110
|
+
def configure_a_parameter(val)
|
111
|
+
default "default"
|
112
|
+
comment "Comment line",
|
113
|
+
"more comments"
|
114
|
+
a_type_of(String)
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
EOTXT
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
desc "check", "check the given config file is valid for the given class"
|
125
|
+
def check(klass_file, conf_file)
|
126
|
+
|
127
|
+
require klass_file # catch LoadError if cfile does not load
|
128
|
+
|
129
|
+
my_class_index = 0 # assume there is only one
|
130
|
+
|
131
|
+
classes = Jeckyl::Options.descendants
|
132
|
+
|
133
|
+
|
134
|
+
classes[my_class_index].check_config(conf_file)
|
135
|
+
|
136
|
+
rescue LoadError
|
137
|
+
puts "Error: could not load #{cfile}".red
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
desc "markdown", "display the comments from a class in markdown format"
|
142
|
+
method_option :class, :aliases=>'-C', :type=>:numeric, :desc=>'select class by index'
|
143
|
+
method_option :concat, :aliases=>'-k', :desc=>'concat all classes, starting with the oldest'
|
144
|
+
def markdown(cfile)
|
145
|
+
|
146
|
+
require cfile # catch LoadError if cfile does not load
|
147
|
+
|
148
|
+
my_class_index = options[:class] || 0
|
149
|
+
my_class_index += -1 if my_class_index > 0
|
150
|
+
|
151
|
+
|
152
|
+
classes = Jeckyl::Options.descendants
|
153
|
+
|
154
|
+
if options[:concat].nil? && classes[my_class_index].nil? then
|
155
|
+
$stderr.puts "Index #{my_class_index + 1} is invalid. Please select a valid index".red.bold
|
156
|
+
display_classes(classes)
|
157
|
+
return false
|
158
|
+
end
|
159
|
+
|
160
|
+
$stderr.puts "There are #{classes.length} sets of configs, use 'jeckyl list' to list them or -k to generate them all".yellow if classes.length > 1
|
161
|
+
|
162
|
+
my_classes = []
|
163
|
+
if options[:concat] then
|
164
|
+
classes.each_index {|i| my_classes << i}
|
165
|
+
else
|
166
|
+
my_classes << my_class_index
|
167
|
+
end
|
168
|
+
|
169
|
+
first = true
|
170
|
+
sublevel = 2
|
171
|
+
|
172
|
+
my_classes.each do |ci|
|
173
|
+
my_class = classes[ci]
|
174
|
+
my_configurator = my_class.new(nil, :local=>true)
|
175
|
+
|
176
|
+
if first then
|
177
|
+
puts "# #{my_class.name} Parameters"
|
178
|
+
puts ""
|
179
|
+
puts "The following parameters are defined in {#{my_class.name}} and should be used"
|
180
|
+
puts "in a configuration file. A default config file can be generated using:"
|
181
|
+
puts ""
|
182
|
+
puts " jeckyl config #{File.expand_path(cfile)}"
|
183
|
+
else
|
184
|
+
puts "## Additional Parameters from #{my_class.name}"
|
185
|
+
puts ""
|
186
|
+
puts "The following additional parameters are defined in #{my_class.name}, which"
|
187
|
+
puts "is an ancestor of this config class. See separate documentation for more details."
|
188
|
+
sublevel = 3
|
189
|
+
end
|
190
|
+
first = false
|
191
|
+
puts ""
|
192
|
+
|
193
|
+
puts "#" * sublevel + " Parameters"
|
194
|
+
puts ""
|
195
|
+
|
196
|
+
my_configurator.comments.each do |param, comment|
|
197
|
+
puts " * **#{param}**"
|
198
|
+
puts " "
|
199
|
+
comment.each {|line| puts " #{line}"}
|
200
|
+
puts ""
|
201
|
+
if my_configurator.defaults.has_key?(param) then
|
202
|
+
puts " Default: #{my_configurator.defaults[param].inspect}"
|
203
|
+
else
|
204
|
+
puts " No default set"
|
205
|
+
end
|
206
|
+
puts ""
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
unless options[:concat] || classes.length == 1
|
211
|
+
puts ""
|
212
|
+
puts "## See Also"
|
213
|
+
puts ""
|
214
|
+
puts "There are also parameters in:"
|
215
|
+
puts ""
|
216
|
+
classes.each do |klass|
|
217
|
+
puts " * #{klass.name}"unless klass == classes[my_class_index]
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
rescue LoadError
|
222
|
+
puts "Error: could not load #{cfile}".red
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
no_tasks do
|
227
|
+
def display_classes(classes)
|
228
|
+
$stderr.puts "The following classes are available:".green
|
229
|
+
count = 1
|
230
|
+
classes.each do |klass|
|
231
|
+
$stderr.puts " #{count}. #{klass.name}"
|
232
|
+
count += 1
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
JeckylCLI.start
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# Description
|
3
|
+
#
|
4
|
+
# Author:: Robert Sharp
|
5
|
+
# Copyright:: Copyright (c) 2011 Robert Sharp
|
6
|
+
# License:: Open Software Licence v3.0
|
7
|
+
#
|
8
|
+
# This software is licensed for use under the Open Software Licence v. 3.0
|
9
|
+
# The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
|
10
|
+
# and in the file copyright.txt. Under the terms of this licence, all derivative works
|
11
|
+
# must themselves be licensed under the Open Software Licence v. 3.0
|
12
|
+
#
|
13
|
+
#
|
14
|
+
|
15
|
+
module Jeckyl
|
16
|
+
|
17
|
+
# A standard class for all Jeckyl exceptions
|
18
|
+
class JeckylError < Exception; end
|
19
|
+
|
20
|
+
# the config file given does not exist
|
21
|
+
class ConfigFileMissing < JeckylError; end
|
22
|
+
|
23
|
+
# the config file has a syntax error
|
24
|
+
class ConfigSyntaxError < JeckylError; end
|
25
|
+
|
26
|
+
# a config parameter was incorrect
|
27
|
+
class ConfigError < JeckylError; end
|
28
|
+
|
29
|
+
# the given config parameter is not known
|
30
|
+
class UnknownParameter < JeckylError; end
|
31
|
+
|
32
|
+
# could not open the specified report file
|
33
|
+
class ReportFileError < JeckylError; end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Created by Jevoom
|
2
|
+
#
|
3
|
+
# 20-Sep-2012
|
4
|
+
# Tidy up documentation.
|
5
|
+
|
6
|
+
module Jeckyl
|
7
|
+
# version set to 0.2.1
|
8
|
+
Version = '0.2.1'
|
9
|
+
# date set to 20-Sep-2012
|
10
|
+
Version_Date = '20-Sep-2012'
|
11
|
+
#ident string set to: jeckyl-0.2.1 20-Sep-2012
|
12
|
+
Ident = 'jeckyl-0.2.1 20-Sep-2012'
|
13
|
+
end
|