class Textigniter

Textigniter is a command line tool used to generate static websites. The main point of configuration is the config.yml that is set up in a textigniter initialized directory. Textigniter comes default with textile, liquid, less, and coffee-script as parsers to output static content.

If you have and questions/comments, please feel free to contact Kaleb Heitzman at kalebheitzman@me.com. This is more of a personal project and I would recommend you use something more established like Jekyll or Nanoc for productions sites.

Last update: November 23, 2011

Public Class Methods

build(args=nil) click to toggle source

Initialize a new build object

# File lib/textigniter.rb, line 96
def self.build(args=nil)
  # create a new build instance
  @build = Build.new(args)
end
help(args=nil) click to toggle source

Initialize a new help object

# File lib/textigniter.rb, line 102
def self.help(args=nil)
  # create a new help instance
  @help = Help.new(args)
end
init(args=nil) click to toggle source

Initialize a new init object

# File lib/textigniter.rb, line 108
def self.init(args=nil)
  # create a new initialization instance
  @init = Init.new(args)
  # check for environment
  env_exists = @init.env_check
  # unless false run the skeleton
  unless env_exists == false
    @init.skeleton
  else
    # Error message, the directory already exists.
    STDOUT.puts "[FAIL]".red_on_black + " #{$base_path} already exists. \r\n".yellow_on_black
  end
end
list(args=nil) click to toggle source

Initialize a new list object

# File lib/textigniter.rb, line 123
def self.list(args=nil)
  # create a new list instance
  @list = List.new
  # get a file list
  files = @list.get_directory_listing(args)
  # print the file list
  @list.print_directory_listing(files)
end
new() click to toggle source

Contains a switch for arguments passed via the command line

# File lib/textigniter.rb, line 15
  def initialize
    # Globals being created
    #
    # $beginning    Time script began to run
    # $gem_path     Lib path for textigniter.rb
    # $base_path    Base textigniter enviornment
    # $config       config.yml to YAML hash
    # $twd          .textigniter working directory
    # $owd          output workding directory
    # $spec         gemspec file to YAML hash
    
    # get start time
    $beginning = Time.now
    
    # Get command line arguments arguments
    cmd = ARGV[0]
    args = ARGV[1]
    
    # get the gem path
    $gem_path = File.dirname(__FILE__)
    
    # get the base path
    if cmd == "init" || cmd == "build" || cmd == "scrub" || cmd == "view"
      $base_path = "#{Dir::pwd}/#{args}"
    else
      $base_path = Dir::pwd
    end
    
    # Store textigniter enviornment path in a global
    $twd = "#{$base_path}/.textigniter"
              
    # Store configuration information into a global
    if File.exists?("#{$twd}/config.yml")
      # Use the existing site configuration
      $config = YAML::load(File.open("#{$twd}/config.yml"))
    else
      # Pull base site configuration from textigniter gem
      $config = YAML::load(File.open("#{$gem_path}/skeleton/.textigniter/config.yml"))
    end
    
    # Store output environment path in a global
    $owd = "#{$base_path}#{$config['output_environment']}"
    
    # get gemspec info
    specfile = $gem_path.gsub('lib', 'textigniter.gemspec')
    $spec = Gem::Specification::load(specfile)

    # Let's put up some cool ascii art promoting textigniter
    STDOUT.puts %q{
 _            _   _             _ _            
| |_ _____  _| |_(_) __ _ _ __ (_) |_ ___ _ __ 
| __/ _ \ \/ / __| |/ _` | '_ \| | __/ _ \ '__|
| ||  __/>  <| |_| | (_| | | | | | ||  __/ |   
 \__\___/_/\_\\\__|_|\__, |_| |_|_|\__\___|_|    v}.bold.blue + "#{$spec.version}".bold.blue + %q{ 
                    |___/             
}.bold.blue

    # Select method based on cmd
    case cmd
      when "build"
        Textigniter.build(args)
      when "help"
        Textigniter.help(args)
      when "init"
        Textigniter.init(args)
      when "list"
        Textigniter.list(args)
      when "scrub"
        Textigniter.scrub(args)
      when "view"
        Textigniter.view(args)
      else 
        Textigniter.help(args)
    end
    # print out elapsed time
    puts "Time elapsed: ".yellow_on_black + "#{Time.now - $beginning} seconds".white_on_black
    # pretty up
    STDOUT.puts "\r\n"
  end
scrub(args=nil) click to toggle source

Initialize a new scrub object

# File lib/textigniter.rb, line 133
def self.scrub(args=nil)
  # 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
  else
    # create a new scrub instance
    @scrub = Scrub.new(args)
    @scrub.scrub
  end
end
view(args) click to toggle source

Start a server

# File lib/textigniter.rb, line 147
def self.view(args)
  
end