Module: Ink::Command
Constant Summary collapse
- COMMANDS =
%w[help list show version]
Instance Method Summary collapse
- #base ⇒ Object
- #help ⇒ Object
- #list ⇒ Object
- #names ⇒ Object
- #run! ⇒ Object
- #show ⇒ Object
- #version ⇒ Object
Instance Method Details
#base ⇒ Object
28 29 30 |
# File 'lib/ink/command.rb', line 28 def base File.join(Pathname.new(File.dirname(__FILE__)).realpath, "..", "..", "stylesheets") end |
#help ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/ink/command.rb', line 18 def help puts <<-TXT Usage: ink help # Display helper info ink list # List all available stylesheets ink show [NAME] # Display the stylesheet for the specified name ink version # Prints the ink's version information TXT end |
#list ⇒ Object
53 54 55 56 |
# File 'lib/ink/command.rb', line 53 def list puts "Available stylesheets:" puts names.collect {|name| " * #{name}"}.join("\n") end |
#names ⇒ Object
49 50 51 |
# File 'lib/ink/command.rb', line 49 def names Dir["#{base}/*.css"].collect {|file| File.basename(file).gsub(/\.css$/, "") } end |
#run! ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ink/command.rb', line 7 def run! command = ARGV[0] unless COMMANDS.include?(command) help exit 1 end send(command) end |
#show ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ink/command.rb', line 36 def show name = ARGV[1] unless names.include?(name) puts "ERROR: #{name.inspect} is not a valid name." puts "" list exit 1 end puts File.read(base + "/#{name}.css") end |