Class: Textigniter::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/textigniter/build.rb

Overview

The Build class searches through the textigniter enviornment (Default: /.textigniter) and parses through text files, stylesheets, and javascripts with filters that correlate to the extension of the file. The parsed content is then rendered to the output directory (Default: /public_html)

Defined Under Namespace

Classes: RenderFiles

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Build

Returns a new instance of Build.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/textigniter/build.rb', line 8

def initialize(args)
  # Output a start message
  STDOUT.puts "Building static content".yellow_on_black
  # Check for an existing environment
  unless File.directory?($twd)
    # Output a failure message do to lack of environment and exit
    STDOUT.puts "Textigniter does not exist in this directory ".yellow_on_black + "[FAIL]".red_on_black
    STDOUT.puts "\r\nHint: ".white_on_black + "textigniter init ".bold.white_on_black + " creates a new environment\r\n".white_on_black
    exit
  end
  # get the content list
  content = list.get_build_list('content')
  # process and render unless nil
  unless content.nil?
    # Parse the text
    text_items = Textigniter::Parsers::TextParser.new.process(content)
    # Parse the template
    template_items = Textigniter::Parsers::TemplateParser.new.process(text_items)
    # Render html to file
    RenderFiles.new.render(template_items, 'content')
  end
  # get the styles list
  styles = list.get_build_list('styles')
  # process and render unless nil
  unless styles.nil?
    # Parse the styles
    style_items = Textigniter::Parsers::StyleParser.new.process(styles)
    # Render styles to file
    RenderFiles.new.render(style_items, 'styles')
  end
  # get the scripts list
  scripts = list.get_build_list('scripts')
  # process and render unless nil
  unless scripts.nil?
    # Parse the scripts
    script_items = Textigniter::Parsers::ScriptParser.new.process(scripts)
    # Render scripts to file
    RenderFiles.new.render(script_items, 'scripts')
  end
  # write files to .content.yml
  manifest.write_manifest('content')
  # write files to .styles.yml
  manifest.write_manifest('styles')
  # write files to .scripts.yml
  manifest.write_manifest('scripts')
end

Instance Method Details

#listObject

Textigniter::List object



61
62
63
# File 'lib/textigniter/build.rb', line 61

def list
  @list = Textigniter::List.new
end

#manifestObject

manifest parser



56
57
58
# File 'lib/textigniter/build.rb', line 56

def manifest
  @manifest = Textigniter::Parsers::ManifestParser.new
end