Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require File.dirname(__FILE__) + "/../lib/simba" | ||
arguments = ARGV.any? ? ARGV : ['-h'] | ||
Simba::SkeletonGenerator.start(arguments) | ||
Simba::Command.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,5 @@ | ||
require "thor" | ||
require "thor/group" | ||
require "securerandom" | ||
require_relative "simba/version" | ||
require "simba/command" | ||
require "simba/version" | ||
|
||
module Simba | ||
class SkeletonGenerator < Thor::Group | ||
include Thor::Actions | ||
|
||
def self.source_root | ||
File.dirname(__FILE__) | ||
end | ||
|
||
def self.banner | ||
"simba [app_name]" | ||
end | ||
|
||
desc "Description:\n\n\tsimba is a generator for sinatra applications." | ||
|
||
argument :name, :desc => "The name of your sinatra app" | ||
class_option :skip_bundle, | ||
:default => false, | ||
:type => :boolean, | ||
:desc => "Skip bundle install when creating app skeleton" | ||
|
||
def setup_skeleton | ||
self.destination_root = name | ||
@class_name = name | ||
@session_secret = SecureRandom.hex 16 | ||
directory("../template/", self.destination_root) | ||
end | ||
|
||
def bundle_dependencies | ||
unless options[:skip_bundle] | ||
say "Bundling application dependencies using bundler." | ||
in_root do | ||
run 'bundle install' | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "thor" | ||
|
||
module Simba | ||
class Command < Thor | ||
include Thor::Actions | ||
map "-v" => :version | ||
|
||
def self.source_root | ||
File.dirname(__FILE__) | ||
end | ||
|
||
desc "version", "show version" | ||
def version | ||
puts Simba::VERSION | ||
end | ||
|
||
desc "new", "create the skeleton of project" | ||
def new(name) | ||
directory('templates', name) | ||
end | ||
end | ||
end |