Class: Zizu::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/zizu/cli.rb

Instance Method Summary collapse

Instance Method Details

#compileObject



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
# File 'lib/zizu/cli.rb', line 30

def compile

  excludes  = check_exclusions(options[:exclude])

  unless options[:output].nil?
    dir = create_directory(options[:output])
  end

  basedir = "."

  haml_files = Dir.glob("*.haml")

  init_templates

  haml_files.each do |f|

    if excludes.include?(f)
      next
    else

      html      = haml_to_html(f)

      if dir.nil?
        html_name = f.chomp(".haml") + ".html"
      else
        html_name = dir + f.chomp(".haml") + ".html"
      end

      f = File.open( html_name, "w" )
      f.write(html)
      f.close

      Zizu::success("created #{html_name}")

    end

  end

  unless dir.nil?

    FileUtils.cp_r( "scripts", dir )
    Zizu::success("copying scripts directory")

    FileUtils.cp_r( "styles", dir )
    Zizu::success("copying styles directory")

    FileUtils.cp_r( "images", dir )
    Zizu::success("copying images directory")

  end
 
end

#create(name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/zizu/cli.rb', line 8

def create(name)

  if File.directory?(name)
    Zizu::fatal("directory already exists, init aborted")
  else

    if options[:fork]
      fork(name)
    else
      create_skeleton(name)  
    end

  end

end

#stageObject



84
85
86
87
88
89
90
91
# File 'lib/zizu/cli.rb', line 84

def stage 

  get_rack
  get_bootstrap

  Zizu::info("run the 'rackup' command to start the server locally")

end