Class: Prigner::Spec
- Inherits:
-
Object
- Object
- Prigner::Spec
- Defined in:
- lib/prigner.rb
Overview
Specification class
This class implements the basic attributes for Template specification.
Constant Summary collapse
- DEFAULTS =
Default values.
{ "options" => {}, "directories" => [], "files" => {} }
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Author name of template.
-
#description ⇒ Object
readonly
Template description.
-
#directories ⇒ Object
readonly
List of directories that will be created in project tree.
-
#email ⇒ Object
readonly
Email for more information about template.
-
#files ⇒ Object
readonly
List of files that link a model to result file.
-
#options ⇒ Object
readonly
Options that enables several features in model files.
-
#version ⇒ Object
readonly
Template version.
Class Method Summary collapse
-
.load(specfile) ⇒ Object
Load a Specfile and initialize a new Spec that be used in Template.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Spec
constructor
Initialize the spec using options in Hash.
Constructor Details
#initialize(attributes = {}) ⇒ Spec
Initialize the spec using options in Hash.
Example:
Prigner::Spec.new :author => "Anakin Skywalker",
:email => "[email protected]",
:version => "1.0.0",
:options => {
"lightsaber" => "Enable red light saber",
"force" => "Use the force"
},
:directories => %w{galactic/republic galactic/empire},
:files => {
"son.erb" => "jedi/luke_skywalker.knight"
"chosen.erb" => "rebels/leia_organa.princess"
}
156 157 158 159 160 |
# File 'lib/prigner.rb', line 156 def initialize(attributes = {}) DEFAULTS.update(attributes || {}).each do |attribute, value| instance_variable_set "@#{attribute}", value if self.respond_to? attribute end end |
Instance Attribute Details
#author ⇒ Object (readonly)
Author name of template.
113 114 115 |
# File 'lib/prigner.rb', line 113 def @author end |
#description ⇒ Object (readonly)
Template description.
122 123 124 |
# File 'lib/prigner.rb', line 122 def description @description end |
#directories ⇒ Object (readonly)
List of directories that will be created in project tree.
128 129 130 |
# File 'lib/prigner.rb', line 128 def directories @directories end |
#email ⇒ Object (readonly)
Email for more information about template.
116 117 118 |
# File 'lib/prigner.rb', line 116 def email @email end |
#files ⇒ Object (readonly)
List of files that link a model to result file.
131 132 133 |
# File 'lib/prigner.rb', line 131 def files @files end |
#options ⇒ Object (readonly)
Options that enables several features in model files.
125 126 127 |
# File 'lib/prigner.rb', line 125 def @options end |
#version ⇒ Object (readonly)
Template version.
119 120 121 |
# File 'lib/prigner.rb', line 119 def version @version end |
Class Method Details
.load(specfile) ⇒ Object
Load a Specfile and initialize a new Spec that be used in Template.
163 164 165 166 167 |
# File 'lib/prigner.rb', line 163 def self.load(specfile) new(YAML.load_file(specfile)) rescue Exception => error raise RuntimeError, "Unable to load Specfile." end |