Sha256: 5540e3c8df27211c958b258f35f8b331e211b4d293b8c5c38a747582d435f759

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])

require 'optparse'
require 'frank'

production = false

opts = OptionParser.new do |opts|
  opts.banner = "Usage: frankout [OPTIONS] directory\n",
                "Compiles and dumps a project and it\'s static files to given directory\n",
                "Example: frankout --production html_dump\n\n"
  
  opts.separator 'Options:'
  
  opts.on('--production', 'Production ready dump i.e. ([FOLDER]/index.html)') do |handler|
    production = true
  end
  
  opts.on( '-h', '--help', 'Display this help' ) do
    puts opts
    exit
  end
end

opts.parse!

if ARGV.empty?
  puts opts
  exit
end

output_folder = ARGV.first

if File.exists? output_folder
  print "'#{output_folder}' \033[31malready exists...\033[0m do you want to overwrite it? (y|n) "
  resp = STDIN.gets.chomp.strip
  exit if resp.downcase.strip != 'y'
  FileUtils.rm_rf(output_folder)
end

begin
  settings = YAML.load_file('settings.yml')
  proj_dir = Dir.pwd
  
  Frank::Output.new do
    settings.each do |name, value|
      set name.to_s, value
    end
    set :environment, :output
    set :output_folder, output_folder
    set :proj_dir, proj_dir
  end.dump(production)
  
rescue Errno::ENOENT
  puts "Frank could not find settings.yml."
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
frank-0.3.2 bin/frankout