Class: Texas::Build::Base
- Inherits:
-
Object
- Object
- Texas::Build::Base
- Defined in:
- lib/texas/build/base.rb
Direct Known Subclasses
Constant Summary collapse
- CONFIG_FILE =
".texasrc"
- MASTER_TEMPLATE =
"master.tex"
Instance Attribute Summary collapse
-
#contents_dir ⇒ Object
readonly
Returns the value of attribute contents_dir.
-
#contents_template ⇒ Object
readonly
Returns the value of attribute contents_template.
-
#current_template ⇒ Object
Returns the value of attribute current_template.
-
#master_file ⇒ Object
readonly
Returns the value of attribute master_file.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#ran_templates ⇒ Object
readonly
Returns the value of attribute ran_templates.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #__path__ ⇒ Object
- #config ⇒ Object
- #dest_file ⇒ Object
- #document_struct ⇒ Object
-
#initialize(_options) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
- #run_build_task(klass) ⇒ Object
- #run_build_tasks(*tasks) ⇒ Object
- #store ⇒ Object
Constructor Details
#initialize(_options) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/texas/build/base.rb', line 13 def initialize() @options = @root = .work_dir @contents_dir = .contents_dir @contents_template = .contents_template @master_file = File.join(__path__, MASTER_TEMPLATE) verbose { "Starting #{self.class}" } verbose { "[i] work_dir: #{.work_dir}".dark } verbose { "[i] contents_dir: #{@contents_dir}".dark } verbose { "[i] contents_template: #{@contents_template}".dark } verbose { "[i] build_path: #{@build_path}".dark } end |
Instance Attribute Details
#contents_dir ⇒ Object (readonly)
Returns the value of attribute contents_dir.
10 11 12 |
# File 'lib/texas/build/base.rb', line 10 def contents_dir @contents_dir end |
#contents_template ⇒ Object (readonly)
Returns the value of attribute contents_template.
10 11 12 |
# File 'lib/texas/build/base.rb', line 10 def contents_template @contents_template end |
#current_template ⇒ Object
Returns the value of attribute current_template.
11 12 13 |
# File 'lib/texas/build/base.rb', line 11 def current_template @current_template end |
#master_file ⇒ Object (readonly)
Returns the value of attribute master_file.
10 11 12 |
# File 'lib/texas/build/base.rb', line 10 def master_file @master_file end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/texas/build/base.rb', line 9 def @options end |
#ran_templates ⇒ Object (readonly)
Returns the value of attribute ran_templates.
11 12 13 |
# File 'lib/texas/build/base.rb', line 11 def ran_templates @ran_templates end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
9 10 11 |
# File 'lib/texas/build/base.rb', line 9 def root @root end |
Class Method Details
.initialize_tasks ⇒ Object
97 98 99 100 101 102 |
# File 'lib/texas/build/base.rb', line 97 def initialize_tasks @@tasks[self.to_s] = {} (@@tasks[self.superclass.to_s] || {}).each do |k, v| @@tasks[self.to_s][k] = v.dup end end |
.run(options) ⇒ Object
84 85 86 87 88 |
# File 'lib/texas/build/base.rb', line 84 def run() instance = self.new() instance.run instance end |
.tasks(key) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/texas/build/base.rb', line 90 def tasks(key) @@tasks ||= {} initialize_tasks if @@tasks[self.to_s].nil? @@tasks[self.to_s][key] ||= [] @@tasks[self.to_s][key] end |
Instance Method Details
#__path__ ⇒ Object
27 28 29 |
# File 'lib/texas/build/base.rb', line 27 def __path__ File.join(root, 'tmp', 'build') end |
#config ⇒ Object
51 52 53 54 55 56 |
# File 'lib/texas/build/base.rb', line 51 def config @config ||= begin filename = File.join(root, CONFIG_FILE) File.exist?(filename) ? YAML.load_file(filename) : {} end end |
#dest_file ⇒ Object
58 59 60 |
# File 'lib/texas/build/base.rb', line 58 def dest_file @dest_file ||= File.join(root, "bin", "#{Template.basename contents_template}.pdf") end |
#document_struct ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/texas/build/base.rb', line 41 def document_struct @document_struct ||= begin hash = config["document"] || {} if .merge_config hash.merge! config[.merge_config] end OpenStruct.new(hash) end end |
#run ⇒ Object
71 72 73 |
# File 'lib/texas/build/base.rb', line 71 def run run_build_tasks before_tasks, basic_tasks, after_tasks end |
#run_build_task(klass) ⇒ Object
66 67 68 69 |
# File 'lib/texas/build/base.rb', line 66 def run_build_task(klass) klass = eval("::Texas::Build::Task::#{klass}") if [Symbol, String].include?(klass.class) klass.new(self).run end |
#run_build_tasks(*tasks) ⇒ Object
62 63 64 |
# File 'lib/texas/build/base.rb', line 62 def run_build_tasks(*tasks) tasks.flatten.each { |t| run_build_task t } end |
#store ⇒ Object
31 32 33 |
# File 'lib/texas/build/base.rb', line 31 def store @store ||= OpenStruct.new end |