Class: Texas::Build::Base
- Inherits:
-
Object
- Object
- Texas::Build::Base
- Includes:
- OutputHelper
- 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 name of the template whose contents should be rendered.
-
#current_template ⇒ Object
Returns the name of the template currently rendered.
-
#master_file ⇒ Object
readonly
Returns the location of the template that is run.
-
#options ⇒ Object
readonly
Returns the options of this build.
-
#ran_templates ⇒ Object
readonly
Returns an array of all templates that have been rendered.
-
#root ⇒ Object
readonly
Returns the path of the current Texas project.
Class Method Summary collapse
Instance Method Summary collapse
-
#__path__ ⇒ Object
Returns the full path of the directory where the build is happening.
-
#config ⇒ Object
Returns the Config object.
-
#dest_file ⇒ Object
Returns the location where the generated PDF file should be after the build.
-
#initialize(_options) ⇒ Base
constructor
A new instance of Base.
-
#run ⇒ Object
Executes the build process.
-
#run_build_task(klass) ⇒ Object
Runs the given build task.
-
#run_build_tasks(*tasks) ⇒ Object
Runs the given build tasks.
-
#store ⇒ Object
Returns an object that can store persistent information throughout the build process.
- #verbose_info ⇒ Object
Methods included from OutputHelper
Constructor Details
#initialize(_options) ⇒ Base
30 31 32 33 34 35 36 37 |
# File 'lib/texas/build/base.rb', line 30 def initialize() = @root = .work_dir @contents_dir = .contents_dir @contents_template = .contents_template @master_file = File.join(__path__, MASTER_TEMPLATE) verbose { verbose_info } end |
Instance Attribute Details
#contents_dir ⇒ Object (readonly)
Returns the value of attribute contents_dir.
19 20 21 |
# File 'lib/texas/build/base.rb', line 19 def contents_dir @contents_dir end |
#contents_template ⇒ Object (readonly)
Returns the name of the template whose contents should be rendered.
22 23 24 |
# File 'lib/texas/build/base.rb', line 22 def contents_template @contents_template end |
#current_template ⇒ Object
Returns the name of the template currently rendered.
25 26 27 |
# File 'lib/texas/build/base.rb', line 25 def current_template @current_template end |
#master_file ⇒ Object (readonly)
Returns the location of the template that is run.
17 18 19 |
# File 'lib/texas/build/base.rb', line 17 def master_file @master_file end |
#options ⇒ Object (readonly)
Returns the options of this build.
14 15 16 |
# File 'lib/texas/build/base.rb', line 14 def end |
#ran_templates ⇒ Object (readonly)
Returns an array of all templates that have been rendered.
28 29 30 |
# File 'lib/texas/build/base.rb', line 28 def ran_templates @ran_templates end |
#root ⇒ Object (readonly)
Returns the path of the current Texas project
11 12 13 |
# File 'lib/texas/build/base.rb', line 11 def root @root end |
Class Method Details
.initialize_tasks ⇒ Object
115 116 117 118 119 120 |
# File 'lib/texas/build/base.rb', line 115 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 |
.tasks(key) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/texas/build/base.rb', line 108 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
Returns the full path of the directory where the build is happening.
41 42 43 |
# File 'lib/texas/build/base.rb', line 41 def __path__ File.join(root, 'tmp', 'build') end |
#config ⇒ Object
Returns the Config object.
62 63 64 |
# File 'lib/texas/build/base.rb', line 62 def config @config ||= Config.create ConfigLoader.new(root, CONFIG_FILE).to_hash, .merge_config end |
#dest_file ⇒ Object
Returns the location where the generated PDF file should be after the build.
68 69 70 |
# File 'lib/texas/build/base.rb', line 68 def dest_file @dest_file ||= File.join(root, "bin", "#{Template.basename contents_template}.pdf") end |
#run ⇒ Object
Executes the build process.
88 89 90 |
# File 'lib/texas/build/base.rb', line 88 def run run_build_tasks before_tasks, basic_tasks, after_tasks end |
#run_build_task(klass) ⇒ Object
Runs the given build task.
80 81 82 83 84 |
# File 'lib/texas/build/base.rb', line 80 def run_build_task(klass) verbose { TraceInfo.new(:build_task, klass, :green) } klass = eval("::Texas::Build::Task::#{klass}") if [Symbol, String].include?(klass.class) klass.new(self).run end |
#run_build_tasks(*tasks) ⇒ Object
Runs the given build tasks.
74 75 76 |
# File 'lib/texas/build/base.rb', line 74 def run_build_tasks(*tasks) tasks.flatten.each { |t| run_build_task t } end |
#store ⇒ Object
Returns an object that can store persistent information throughout the build process.
48 49 50 |
# File 'lib/texas/build/base.rb', line 48 def store @store ||= OpenStruct.new end |
#verbose_info ⇒ Object
92 93 94 95 96 97 |
# File 'lib/texas/build/base.rb', line 92 def verbose_info [ TraceInfo.new("work_dir", .work_dir, :dark), TraceInfo.new("build_path", __path__, :dark), ].join("\n") end |