Class: JstGenerator::Engine
- Inherits:
-
Object
- Object
- JstGenerator::Engine
- Defined in:
- lib/jstgenerator/engine.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(opts = {}) ⇒ Engine
constructor
A new instance of Engine.
Constructor Details
#initialize(opts = {}) ⇒ Engine
Returns a new instance of Engine.
6 7 8 9 10 |
# File 'lib/jstgenerator/engine.rb', line 6 def initialize(opts = {}) @dir_glob = opts.fetch(:dir_glob) { "**/*.hb" } @jst_path = opts.fetch(:jst_path) { "jst.js" } @files = Dir[@dir_glob] end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
5 6 7 |
# File 'lib/jstgenerator/engine.rb', line 5 def files @files end |
Instance Method Details
#generate ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/jstgenerator/engine.rb', line 13 def generate @jst_contents = [jst_heading] load_source @files.each do |file| content = process_template(file) @jst_contents.push(content) end create_jst_file(@jst_contents.join("\n")) end |