Class: Meta::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/meta/cli.rb

Instance Method Summary collapse

Instance Method Details

#compileObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/meta/cli.rb', line 13

def compile

  Meta::Catalog.upgrade

  if options[:output].nil?
    dest = "."
  else
    dest = options[:output]
  end

  p = Meta::Page.new(dest)

  p.generate(options[:force])
  p.generate_index(options[:force])

end

#initObject



31
32
33
34
35
36
# File 'lib/meta/cli.rb', line 31

def init

  db_init
  create_skeleton

end

#stageObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/meta/cli.rb', line 39

def stage

  config = File.join( File.dirname(__FILE__), "../../config/config.ru" )

  if File.exists?("config.ru")
    puts "Environment has already been staged, no action taken.".yellow
  else

    FileUtils.cp( config, Dir.pwd )
    puts "Run 'rackup' to start testing.".green

  end

end

#title(file) ⇒ Object



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

def title(file)

  catalog = Meta::Catalog.new

  f = catalog.get_content(file)

  unless f.nil?

    puts "Current Title: #{f[:title]}"
    reply = ask "New Title? ".yellow

    unless reply.empty?

      response = agree(
        "Are you certain that you want to make this change? ") {
        |q| q.default = "n" }

      catalog.update_content_title( file, reply ) if response

    else
      puts "Title cannot be empty, no action taken.".red
    end

  end

end