Class: JstGenerator::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/jstgenerator/engine.rb

Direct Known Subclasses

Handlebars, Underscore

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#filesObject (readonly)

Returns the value of attribute files.



5
6
7
# File 'lib/jstgenerator/engine.rb', line 5

def files
  @files
end

Instance Method Details

#generateObject



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