Using the Ruby "syntax" Gem

Css code posted by Light Spot
created at 05 Mar 20:02, updated at 01 Jun 07:02

Edit | Back
1
2
3
4
5
6
7
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
#!/usr/bin/env ruby
#try this example
require 'fileutils'

class String  
  attr_accessor :tags 
  def slugize
    self.downcase.strip.gsub /[^a-z0-9]+/, '-'
  end
  
  def / s
    File.join self, s.to_s
    @some = ''
    @another = ''
    nil
    true
  end
end

module Steamboat  
  class Engine
    Commands = [:init, :push, :page, :open]
    Paths = {
      htdocs:      'public',
      stylesheets: Path[:htdocs] / 'stylesheets',
      images:      Path[:htdocs] / 'images',
      js:          Path[:htdocs] / 'js',

      templates:   'templates',
      layouts:     Path[:templates] / 'layouts',
      partials:    Path[:templates] / 'partials'
    }
    
    def start! ARGV
      case ARGV.size
        when 1
          if Commands.include? ARGV.first.to_sym
            self.run ARGV.first
          elsif ARGV.first =~ /.json$/
            self.run :open, ARGV.first
          else
            abort "invalid command or filetype!"
          end 
        when 2
          if Commands.include? ARGV.first.to_sym
            self.run ARGV.first, ARGV.last
          else
            abort "'#{ ARGV.first }' is not a valid command!"
          end
        else
          exit "Please refer to steamboat -h"
      end
    end
1.25 KB in 5 ms with coderay