Class: Textigniter
- Inherits:
-
Object
- Object
- Textigniter
- Defined in:
- lib/textigniter.rb
Overview
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 [email protected]. 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
Defined Under Namespace
Classes: Build, Help, Init, List, Parsers, Plugins, Scrub
Class Method Summary collapse
-
.build(args = nil) ⇒ Object
Initialize a new build object.
-
.help(args = nil) ⇒ Object
Initialize a new help object.
-
.init(args = nil) ⇒ Object
Initialize a new init object.
-
.list(args = nil) ⇒ Object
Initialize a new list object.
-
.scrub(args = nil) ⇒ Object
Initialize a new scrub object.
-
.view(args) ⇒ Object
Start a server.
Instance Method Summary collapse
-
#initialize ⇒ Textigniter
constructor
Contains a switch for arguments passed via the command line.
Constructor Details
#initialize ⇒ Textigniter
Contains a switch for arguments passed via the command line
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# 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 |
Class Method Details
.build(args = nil) ⇒ Object
Initialize a new build object
96 97 98 99 |
# File 'lib/textigniter.rb', line 96 def self.build(args=nil) # create a new build instance @build = Build.new(args) end |
.help(args = nil) ⇒ Object
Initialize a new help object
102 103 104 105 |
# File 'lib/textigniter.rb', line 102 def self.help(args=nil) # create a new help instance @help = Help.new(args) end |
.init(args = nil) ⇒ Object
Initialize a new init object
108 109 110 111 112 113 114 115 116 117 118 119 120 |
# 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) ⇒ Object
Initialize a new list object
123 124 125 126 127 128 129 130 |
# 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 |
.scrub(args = nil) ⇒ Object
Initialize a new scrub object
133 134 135 136 137 138 139 140 141 142 143 144 |
# 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) ⇒ Object
Start a server
147 148 149 |
# File 'lib/textigniter.rb', line 147 def self.view(args) end |