forked from lapluviosilla/prologue
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Collin Schaafsma
committed
Oct 18, 2010
0 parents
commit a13761e
Showing
40 changed files
with
1,567 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pkg/* | ||
*.gem | ||
.bundle | ||
tmp | ||
.idea | ||
.DS_Store |
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,4 @@ | ||
source :gemcutter | ||
|
||
# Specify your gem's dependencies in prologue.gemspec | ||
gemspec |
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,110 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
prologue (0.1.0) | ||
rails (>= 3.0.0) | ||
thor | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
abstract (1.0.0) | ||
actionmailer (3.0.0) | ||
actionpack (= 3.0.0) | ||
mail (~> 2.2.5) | ||
actionpack (3.0.0) | ||
activemodel (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
builder (~> 2.1.2) | ||
erubis (~> 2.6.6) | ||
i18n (~> 0.4.1) | ||
rack (~> 1.2.1) | ||
rack-mount (~> 0.6.12) | ||
rack-test (~> 0.5.4) | ||
tzinfo (~> 0.3.23) | ||
activemodel (3.0.0) | ||
activesupport (= 3.0.0) | ||
builder (~> 2.1.2) | ||
i18n (~> 0.4.1) | ||
activerecord (3.0.0) | ||
activemodel (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
arel (~> 1.0.0) | ||
tzinfo (~> 0.3.23) | ||
activeresource (3.0.0) | ||
activemodel (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
activesupport (3.0.0) | ||
arel (1.0.1) | ||
activesupport (~> 3.0.0) | ||
aruba (0.2.3) | ||
background_process | ||
cucumber (~> 0.9.0) | ||
background_process (1.2) | ||
builder (2.1.2) | ||
cucumber (0.9.2) | ||
builder (~> 2.1.2) | ||
diff-lcs (~> 1.1.2) | ||
gherkin (~> 2.2.5) | ||
json (~> 1.4.6) | ||
term-ansicolor (~> 1.0.5) | ||
diff-lcs (1.1.2) | ||
erubis (2.6.6) | ||
abstract (>= 1.0.0) | ||
gherkin (2.2.9) | ||
json (~> 1.4.6) | ||
term-ansicolor (~> 1.0.5) | ||
i18n (0.4.1) | ||
json (1.4.6) | ||
mail (2.2.7) | ||
activesupport (>= 2.3.6) | ||
mime-types | ||
treetop (>= 1.4.5) | ||
mime-types (1.16) | ||
polyglot (0.3.1) | ||
rack (1.2.1) | ||
rack-mount (0.6.13) | ||
rack (>= 1.0.0) | ||
rack-test (0.5.6) | ||
rack (>= 1.0) | ||
rails (3.0.0) | ||
actionmailer (= 3.0.0) | ||
actionpack (= 3.0.0) | ||
activerecord (= 3.0.0) | ||
activeresource (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
bundler (~> 1.0.0) | ||
railties (= 3.0.0) | ||
railties (3.0.0) | ||
actionpack (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
rake (>= 0.8.4) | ||
thor (~> 0.14.0) | ||
rake (0.8.7) | ||
rspec (2.0.0) | ||
rspec-core (= 2.0.0) | ||
rspec-expectations (= 2.0.0) | ||
rspec-mocks (= 2.0.0) | ||
rspec-core (2.0.0) | ||
rspec-expectations (2.0.0) | ||
diff-lcs (>= 1.1.2) | ||
rspec-mocks (2.0.0) | ||
rspec-core (= 2.0.0) | ||
rspec-expectations (= 2.0.0) | ||
term-ansicolor (1.0.5) | ||
thor (0.14.3) | ||
treetop (1.4.8) | ||
polyglot (>= 0.3.1) | ||
tzinfo (0.3.23) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
aruba | ||
bundler (>= 1.0.0) | ||
cucumber | ||
prologue! | ||
rails (>= 3.0.0) | ||
rspec (~> 2.0.0.beta.22) | ||
thor |
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,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2010 Collin Schaafsma | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,16 @@ | ||
# Prologue | ||
Rails 3 template with Devise. Used by Quick Left to get projects started. | ||
|
||
## Install | ||
|
||
rvm <my_1.9.2_ruby>@<my_rails3_gemset> | ||
rails new <my_app> --skip-testunit --skip-prototype -template=path/to/prologue.rb | ||
cd <my_app> | ||
rake cucumber | ||
rake spec | ||
rails s |
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,2 @@ | ||
require 'bundler' | ||
Bundler::GemHelper.install_tasks |
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,3 @@ | ||
#!/usr/bin/env ruby | ||
require 'prologue/cli' | ||
Prologue::CLI.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Feature: Generate new prologue app | ||
In order to start a new project with prologue | ||
As a CLI | ||
I want to generate a rails3 app with prologue | ||
|
||
@disable-bundler | ||
Scenario: Run prologue new my_app | ||
When I run "prologue new my_app" | ||
Then the output should contain "Building authentication" | ||
And the output should contain "Building roles" | ||
And the output should contain "Building admin" | ||
And the output should contain "Prologue just added like 6 hours to your life." | ||
|
||
@disable-bundler | ||
Scenario: Run prologue new my_app --no-auth | ||
When I run "prologue new my_app --no-auth" | ||
Then the output should not contain "Building authentication" | ||
And the output should not contain "Building roles" | ||
And the output should not contain "Building admin" | ||
And the output should contain "Prologue just added like 6 hours to your life." | ||
|
||
@disable-bundler | ||
Scenario: Run prologue new my_app --no-roles | ||
When I run "prologue new my_app --no-roles" | ||
Then the output should contain "Building authentication" | ||
And the output should not contain "Building roles" | ||
And the output should contain "Building admin" | ||
And the output should contain "Prologue just added like 6 hours to your life." | ||
|
||
@disable-bundler | ||
Scenario: Run prologue new my_app --no-admin | ||
When I run "prologue new my_app --no-admin" | ||
Then the output should contain "Building authentication" | ||
And the output should contain "Building roles" | ||
And the output should not contain "Building admin" | ||
And the output should contain "Prologue just added like 6 hours to your life." | ||
|
||
@disable-bundler | ||
Scenario: Run prologue new my_app --no-admin --no-roles | ||
When I run "prologue new my_app --no-admin --no-roles" | ||
Then the output should contain "Building authentication" | ||
And the output should not contain "Building roles" | ||
And the output should not contain "Building admin" | ||
And the output should contain "Prologue just added like 6 hours to your life." |
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 @@ | ||
require 'aruba' |
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,5 @@ | ||
require 'prologue/error' | ||
|
||
module Prologue | ||
|
||
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,70 @@ | ||
require 'thor' | ||
require 'thor/actions' | ||
require 'active_support/secure_random' | ||
|
||
module Prologue | ||
class CLI < Thor | ||
include Thor::Actions | ||
|
||
desc "new [app]", "Create a new Rails 3 application" | ||
long_desc <<-D | ||
Prologue will ask you a few questions to determine what features you | ||
would like to generate. Based on your answers it will setup a new Rails 3 application. | ||
D | ||
method_option :auth, :type => :boolean, :default => true, :banner => | ||
"Sets up devise for authentication." | ||
method_option :roles, :type => :boolean, :default => true, :banner => | ||
"Sets up cancan for authorization with roles." | ||
method_option :admin, :type => :boolean, :default => true, :banner => | ||
"Sets up very basic admin" | ||
def new(project) | ||
opts = options.dup | ||
|
||
# Can't build an admin or roles without devise | ||
if !opts[:auth] | ||
opts[:admin] = false; | ||
opts[:roles] = false; | ||
end | ||
|
||
# Env vars used in our template | ||
ENV['PROLOGUE_AUTH'] = "true" if opts[:auth] | ||
ENV['PROLOGUE_ADMIN'] = "true" if opts[:admin] | ||
ENV['PROLOGUE_ROLES'] = "true" if opts[:roles] | ||
ENV['PROLOGUE_USER_NAME'] = git_user_name if opts[:admin] | ||
ENV['PROLOGUE_USER_EMAIL'] = git_user_email if opts[:admin] | ||
ENV['PROLOGUE_USER_PASSWORD'] = user_password if opts[:admin] | ||
|
||
exec(<<-COMMAND) | ||
rails new #{project} \ | ||
--template=#{template} \ | ||
--skip-test-unit \ | ||
--skip-prototype | tee ~/Desktop/prologue_log.txt | ||
COMMAND | ||
end | ||
|
||
desc "version", "Prints Prologue's version information" | ||
def version | ||
say "Prologue version #{Prologue::VERSION}" | ||
end | ||
map %w(-v --version) => :version | ||
|
||
private | ||
|
||
def template | ||
File.expand_path(File.dirname(__FILE__) + "/../../templates/bootstrap.rb") | ||
end | ||
|
||
def git_user_name | ||
`git config --global user.name`.chomp || "Quick Left" | ||
end | ||
|
||
def git_user_email | ||
`git config --global user.email`.chomp || "[email protected]" | ||
end | ||
|
||
def user_password | ||
ActiveSupport::SecureRandom.base64(8) | ||
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,23 @@ | ||
module Prologue | ||
class Error < StandardError | ||
end | ||
|
||
# Raised when a task was not found. | ||
# | ||
class UndefinedTaskError < Error | ||
end | ||
|
||
# Raised when a task was found, but not invoked properly. | ||
# | ||
class InvocationError < Error | ||
end | ||
|
||
class UnknownArgumentError < Error | ||
end | ||
|
||
class RequiredArgumentMissingError < InvocationError | ||
end | ||
|
||
class MalformattedArgumentError < InvocationError | ||
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,3 @@ | ||
module Prologue | ||
VERSION = "0.1.0" | ||
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,27 @@ | ||
# -*- encoding: utf-8 -*- | ||
require File.expand_path("../lib/prologue/version", __FILE__) | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "prologue" | ||
s.version = Prologue::VERSION | ||
s.platform = Gem::Platform::RUBY | ||
s.authors = ["Quick Left"] | ||
s.email = ["[email protected]"] | ||
s.homepage = "http://github.com/quickleft/prologue" | ||
s.summary = "prologue-#{s.version}" | ||
s.description = "Generate a Rails 3 app with application templates Quick Left uses to start their projects off right!" | ||
|
||
s.required_rubygems_version = ">= 1.3.6" | ||
s.rubyforge_project = "prologue" | ||
|
||
s.add_dependency "thor" | ||
s.add_dependency('rails', '>= 3.0.0') | ||
s.add_development_dependency "bundler", ">= 1.0.0" | ||
s.add_development_dependency "cucumber" | ||
s.add_development_dependency "aruba" | ||
s.add_development_dependency "rspec", "~> 2.0.0.beta.22" | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact | ||
s.require_path = 'lib' | ||
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,28 @@ | ||
say "Building admin" | ||
generate(:controller, "admin/dashboard index") | ||
|
||
inject_into_file 'config/routes.rb', :after => "devise_for :users\n" do | ||
<<-RUBY | ||
match 'admin' => 'admin/dashboard#index' | ||
RUBY | ||
end | ||
|
||
# Do layout and SASS stuff | ||
apply File.expand_path("../admin/sass.rb", __FILE__) | ||
apply File.expand_path("../admin/layout.rb", __FILE__) | ||
|
||
create_file 'app/controllers/admin/base_controller.rb' do | ||
<<-RUBY | ||
class Admin::BaseController < ApplicationController | ||
layout 'admin' | ||
before_filter :authenticate_user! | ||
end | ||
RUBY | ||
end | ||
|
||
gsub_file 'app/controllers/admin/dashboard_controller.rb', /ApplicationController/, 'Admin::BaseController' | ||
|
||
# make a user admin | ||
apply File.expand_path("../admin/users.rb", __FILE__) | ||
apply File.expand_path("../admin/dashboard_spec.rb", __FILE__) | ||
apply File.expand_path("../admin/users_spec.rb", __FILE__) |
Oops, something went wrong.