Class: TableSetter::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/table_setter/command.rb

Constant Summary

"table-setter is a Sinatra application for rendering and processing CSVs from google docs into HTML.\n\nUsage:\ntable-setter COMMAND path/to/table-setter/assets OPTIONS\n\ncommands:\nstart    run the development server, for deployment use config.ru\ninstall  copy the table-setter assets into the the directory\nexport   statically build tables in the ./out/\n\noptions:\n"

Instance Method Summary

Constructor Details

- (Command) initialize

A new instance of Command



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/table_setter/command.rb', line 25

def initialize
  @prefix = ""
  parse_options
  command = ARGV.shift
  @directory = ARGV.shift || '.'
  TableSetter.configure @directory
  case command
  when 'start' then start_server
  when 'install' then install_assets
  when 'build' then build_out
  else puts 
  end
end

Instance Method Details

- (Object) build_out



54
55
56
57
58
59
60
61
62
# File 'lib/table_setter/command.rb', line 54

def build_out
  @out_dir = File.join(TableSetter.config_path, 'out', @prefix)
  puts "\nBuilding your TableSetter files...\n\n"
  app = build_rack
  request = Rack::MockRequest.new(app)
  build_index request
  build_assets
  build_tables request
end

- (Object) install_assets



44
45
46
47
48
49
50
# File 'lib/table_setter/command.rb', line 44

def install_assets
  FileUtils.mkdir_p @directory unless File.exists? @directory
  puts "\nInstalling TableSetter files...\n\n"
  base_files.each do |path|
    copy_file path, File.join(TableSetter.config_path, path.gsub(ROOT + "/template/", "/"))
  end
end

- (Object) start_server



39
40
41
42
# File 'lib/table_setter/command.rb', line 39

def start_server
  app = build_rack
  Rack::Handler::Thin.run app, :Port => "3000"
end