Class: Meta::CLI
Instance Method Summary collapse
Instance Method Details
#compile ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/meta/cli.rb', line 13 def compile if [:output].nil? dest = "." else dest = [:output] end p = Meta::Page.new(dest) p.generate([:force]) p.generate_main([:force]) end |
#init ⇒ Object
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 |
# File 'lib/meta/cli.rb', line 29 def init f = File.join( File.dirname(__FILE__), "../../db/site.sqlite3" ) if File.exists?("site.sqlite3") puts "Warning: All index data will be lost!".red reply = agree("Database already exists, overwrite?".red) { |q| q.default = "n" } if reply FileUtils.cp( f, Dir.pwd ) puts "Database re-initialized".green else puts "Database not initialized".red end else FileUtils.cp( f, Dir.pwd ) puts "Database initialized".green end end |
#stage ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/meta/cli.rb', line 56 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 |
#test ⇒ Object
100 101 102 103 104 105 |
# File 'lib/meta/cli.rb', line 100 def test p = Meta::Page.new p.generate_main end |
#title(file) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/meta/cli.rb', line 72 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 |