Sha256: bc59e80ccce6a250e9c24d13f2aa1b98eacbc1fb7b230b3d4f1d41a09780cc66

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

#!/usr/bin/env ruby
require 'rubygems'
require 'thor'
require 'fileutils'

require 'swagr'

SkeletonDir = "skeletons"
DefaultSkeletonTarball = "bootstrap_default_130109_0842.zip"
SkeletonTarball = File.join(SkeletonDir, DefaultSkeletonTarball)

StaticDir = PublicDir = "static"
DefaultSubdirs = ["coffee", "views", StaticDir]

class SwagrCommand < Thor

  include Thor::Actions

  def self.source_root
    File.dirname(__FILE__).split("/")[0...-1].join("/")
  end

  desc "update", "Update all templates by re-downloading the latest versions of needed libs"
  def update
    inside File.join("templates", PublicDir, "js") do
      get "http://d3js.org/d3.v3.min.js"
      get "http://coffeescript.org/extras/coffee-script.js"
      get "http://code.jquery.com/jquery-latest.js"
    end
  end

  #desc "run DIR", "Run a swagr app in DIR, only things that override the base app needs to be in DIR"
  #def run(dir)
  #end

  desc "init DIR", "Create a skeleton structure in DIR for customizing a swagr app"
  def init(dir)
    empty_directory dir
    inside dir do
      DefaultSubdirs.each {|subdir| empty_directory(subdir)}
    end
    # Now copy everything in the templates dir into the 
    directory "templates", dir
  end

  desc "create DIR", "Create/setup a swagr app in DIR"
  def create(dir)
    init(dir)
    public_dir = File.join(dir, PublicDir)
    tarball = File.join(public_dir, "skeleton.zip")
    copy_file SkeletonTarball, tarball
    inside public_dir do
      run "unzip skeleton.zip"
      FileUtils.rm_rf "skeleton.zip"
      say "Removed tarball"
    end
  end

end

SwagrCommand.start

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
swagr-0.0.6 bin/swagr
swagr-0.0.5 bin/swagr