Class: Devist::Compiler
- Inherits:
-
Object
- Object
- Devist::Compiler
- Defined in:
- lib/devist/compiler.rb
Overview
compiler.rb This file is a part of the devist package. Halis Duraki <[email protected]>
This is the main compiler class. It takes arguments project (model), changelog (model), and theme name. Object offers a version listing plus save operation and binding to the theme erb.
Instance Method Summary collapse
-
#compile_data ⇒ Object
Compile data.
-
#initialize(project, changelog, theme) ⇒ Compiler
constructor
Init.
-
#save ⇒ Object
Save compiled.
Constructor Details
#initialize(project, changelog, theme) ⇒ Compiler
Init.
14 15 16 17 18 |
# File 'lib/devist/compiler.rb', line 14 def initialize(project, changelog, theme) @project = project @changelog = changelog @theme = theme end |
Instance Method Details
#compile_data ⇒ Object
Compile data.
42 43 44 45 46 47 48 |
# File 'lib/devist/compiler.rb', line 42 def compile_data @changelog.each do |version| print " * Found version #{version.version}; registered ...\n" end save end |
#save ⇒ Object
Save compiled.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/devist/compiler.rb', line 21 def save print " -\n" print " * Trying to compile set ...\n" print " * Creating new export from erb ...\n" asset = "#{__dir__}/export/html/#{@theme}" erb = ERB.new(File.open(asset).read, 0, '>') print " * Injecting parsed results to the erb ...\n" erb.result binding print " * Writing compiled data to changelog file ...\n" File.open("#{Dir.pwd}/changelog.html", 'w') do |f| f.write erb.result binding end print " -\n" print " ** All done! Check changelog.html file in your browser :)\n" end |