prologue 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ tmp
5
+ .idea
6
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in prologue.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,110 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ prologue (0.1.0)
5
+ rails (>= 3.0.0)
6
+ thor
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ abstract (1.0.0)
12
+ actionmailer (3.0.0)
13
+ actionpack (= 3.0.0)
14
+ mail (~> 2.2.5)
15
+ actionpack (3.0.0)
16
+ activemodel (= 3.0.0)
17
+ activesupport (= 3.0.0)
18
+ builder (~> 2.1.2)
19
+ erubis (~> 2.6.6)
20
+ i18n (~> 0.4.1)
21
+ rack (~> 1.2.1)
22
+ rack-mount (~> 0.6.12)
23
+ rack-test (~> 0.5.4)
24
+ tzinfo (~> 0.3.23)
25
+ activemodel (3.0.0)
26
+ activesupport (= 3.0.0)
27
+ builder (~> 2.1.2)
28
+ i18n (~> 0.4.1)
29
+ activerecord (3.0.0)
30
+ activemodel (= 3.0.0)
31
+ activesupport (= 3.0.0)
32
+ arel (~> 1.0.0)
33
+ tzinfo (~> 0.3.23)
34
+ activeresource (3.0.0)
35
+ activemodel (= 3.0.0)
36
+ activesupport (= 3.0.0)
37
+ activesupport (3.0.0)
38
+ arel (1.0.1)
39
+ activesupport (~> 3.0.0)
40
+ aruba (0.2.3)
41
+ background_process
42
+ cucumber (~> 0.9.0)
43
+ background_process (1.2)
44
+ builder (2.1.2)
45
+ cucumber (0.9.2)
46
+ builder (~> 2.1.2)
47
+ diff-lcs (~> 1.1.2)
48
+ gherkin (~> 2.2.5)
49
+ json (~> 1.4.6)
50
+ term-ansicolor (~> 1.0.5)
51
+ diff-lcs (1.1.2)
52
+ erubis (2.6.6)
53
+ abstract (>= 1.0.0)
54
+ gherkin (2.2.9)
55
+ json (~> 1.4.6)
56
+ term-ansicolor (~> 1.0.5)
57
+ i18n (0.4.1)
58
+ json (1.4.6)
59
+ mail (2.2.7)
60
+ activesupport (>= 2.3.6)
61
+ mime-types
62
+ treetop (>= 1.4.5)
63
+ mime-types (1.16)
64
+ polyglot (0.3.1)
65
+ rack (1.2.1)
66
+ rack-mount (0.6.13)
67
+ rack (>= 1.0.0)
68
+ rack-test (0.5.6)
69
+ rack (>= 1.0)
70
+ rails (3.0.0)
71
+ actionmailer (= 3.0.0)
72
+ actionpack (= 3.0.0)
73
+ activerecord (= 3.0.0)
74
+ activeresource (= 3.0.0)
75
+ activesupport (= 3.0.0)
76
+ bundler (~> 1.0.0)
77
+ railties (= 3.0.0)
78
+ railties (3.0.0)
79
+ actionpack (= 3.0.0)
80
+ activesupport (= 3.0.0)
81
+ rake (>= 0.8.4)
82
+ thor (~> 0.14.0)
83
+ rake (0.8.7)
84
+ rspec (2.0.0)
85
+ rspec-core (= 2.0.0)
86
+ rspec-expectations (= 2.0.0)
87
+ rspec-mocks (= 2.0.0)
88
+ rspec-core (2.0.0)
89
+ rspec-expectations (2.0.0)
90
+ diff-lcs (>= 1.1.2)
91
+ rspec-mocks (2.0.0)
92
+ rspec-core (= 2.0.0)
93
+ rspec-expectations (= 2.0.0)
94
+ term-ansicolor (1.0.5)
95
+ thor (0.14.3)
96
+ treetop (1.4.8)
97
+ polyglot (>= 0.3.1)
98
+ tzinfo (0.3.23)
99
+
100
+ PLATFORMS
101
+ ruby
102
+
103
+ DEPENDENCIES
104
+ aruba
105
+ bundler (>= 1.0.0)
106
+ cucumber
107
+ prologue!
108
+ rails (>= 3.0.0)
109
+ rspec (~> 2.0.0.beta.22)
110
+ thor
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Quick Left
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ Prologue
2
+ ===========
3
+ Generate a Rails 3 app with the application templates Quick Left uses to start their projects off right!
4
+
5
+
6
+ ### What you get
7
+
8
+ Prologue provides a base Rails 3 application with Devise and Cancan for authentication and authorization. Roles are
9
+ stored in the database with a HABTM relationship between the role and user models. You also get a basic admin to manage
10
+ users. Prologue also rolls in all of the things we like to have setup in our apps like...
11
+ haml, sass, jquery, cucumber, capybara, mocha, factory_girl, rspec, timecop, autotest, will_paginate, friendly_id, and hoptoad_notifier
12
+
13
+ Everything is configured and ready to rock your next Rails 3 project. We hope it saves you a mess of time!
14
+
15
+
16
+ ### Quick Start
17
+
18
+ gem install prologue
19
+
20
+ prologue new my_app
21
+
22
+
23
+ ### Options
24
+
25
+ prologue new my_app --no-auth
26
+
27
+ prologue new my_app --no-roles
28
+
29
+ prologue new my_app --no-admin
30
+
31
+
32
+ ### Issues
33
+
34
+ Please report issues to the [Prologue issue tracker](http://github.com/quickleft/prologue/issues/).
35
+
36
+
37
+ ### Development
38
+
39
+ bundle install
40
+ bundle exec cucumber
41
+
42
+ Running `bundle exec cucumber` will take some time. It runs the CLI tool with different option combinations and tests
43
+ those outputs with aruba.
44
+
45
+
46
+ ### Patches/Pull Requests
47
+
48
+ * Fork it.
49
+ * Add tests for it.
50
+ * Make your changes.
51
+ * Commit.
52
+ * Send a pull request.
53
+
54
+
55
+ ### Thanks
56
+
57
+ All of the contributors to the many awesome open source projects that make up prologue and allow us to do our job everyday.
58
+ Also, thanks go out to the crew at thoughtbot for writing suspenders. It's what gave us the idea to package up our
59
+ templates into a gem in the first place.
60
+
61
+
62
+ ### Copyright
63
+
64
+ Copyright (c) 2010 Quick Left. See LICENSE for details.
65
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/prologue ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'prologue/cli'
3
+ Prologue::CLI.start
@@ -0,0 +1,44 @@
1
+ Feature: Generate new prologue app
2
+ In order to start a new project with prologue
3
+ As a CLI
4
+ I want to generate a rails3 app with prologue
5
+
6
+ @disable-bundler
7
+ Scenario: Run prologue new my_app
8
+ When I run "prologue new my_app"
9
+ Then the output should contain "Building authentication"
10
+ And the output should contain "Building roles"
11
+ And the output should contain "Building admin"
12
+ And the output should contain "Prologue just added like 6 hours to your life."
13
+
14
+ @disable-bundler
15
+ Scenario: Run prologue new my_app --no-auth
16
+ When I run "prologue new my_app --no-auth"
17
+ Then the output should not contain "Building authentication"
18
+ And the output should not contain "Building roles"
19
+ And the output should not contain "Building admin"
20
+ And the output should contain "Prologue just added like 6 hours to your life."
21
+
22
+ @disable-bundler
23
+ Scenario: Run prologue new my_app --no-roles
24
+ When I run "prologue new my_app --no-roles"
25
+ Then the output should contain "Building authentication"
26
+ And the output should not contain "Building roles"
27
+ And the output should contain "Building admin"
28
+ And the output should contain "Prologue just added like 6 hours to your life."
29
+
30
+ @disable-bundler
31
+ Scenario: Run prologue new my_app --no-admin
32
+ When I run "prologue new my_app --no-admin"
33
+ Then the output should contain "Building authentication"
34
+ And the output should contain "Building roles"
35
+ And the output should not contain "Building admin"
36
+ And the output should contain "Prologue just added like 6 hours to your life."
37
+
38
+ @disable-bundler
39
+ Scenario: Run prologue new my_app --no-admin --no-roles
40
+ When I run "prologue new my_app --no-admin --no-roles"
41
+ Then the output should contain "Building authentication"
42
+ And the output should not contain "Building roles"
43
+ And the output should not contain "Building admin"
44
+ And the output should contain "Prologue just added like 6 hours to your life."
@@ -0,0 +1 @@
1
+ require 'aruba'
@@ -0,0 +1,71 @@
1
+ require 'thor'
2
+ require 'thor/actions'
3
+ require 'active_support/secure_random'
4
+ require 'prologue/version'
5
+
6
+ module Prologue
7
+ class CLI < Thor
8
+ include Thor::Actions
9
+
10
+ desc "new [app]", "Create a new Rails 3 application"
11
+ long_desc <<-D
12
+ Prologue will ask you a few questions to determine what features you
13
+ would like to generate. Based on your answers it will setup a new Rails 3 application.
14
+ D
15
+ method_option :auth, :type => :boolean, :default => true, :banner =>
16
+ "Sets up devise for authentication."
17
+ method_option :roles, :type => :boolean, :default => true, :banner =>
18
+ "Sets up cancan for authorization with roles."
19
+ method_option :admin, :type => :boolean, :default => true, :banner =>
20
+ "Sets up very basic admin"
21
+ def new(project)
22
+ opts = options.dup
23
+
24
+ # Can't build an admin or roles without devise
25
+ if !opts[:auth]
26
+ opts[:admin] = false;
27
+ opts[:roles] = false;
28
+ end
29
+
30
+ # Env vars used in our template
31
+ ENV['PROLOGUE_AUTH'] = "true" if opts[:auth]
32
+ ENV['PROLOGUE_ADMIN'] = "true" if opts[:admin]
33
+ ENV['PROLOGUE_ROLES'] = "true" if opts[:roles]
34
+ ENV['PROLOGUE_USER_NAME'] = git_user_name if opts[:admin]
35
+ ENV['PROLOGUE_USER_EMAIL'] = git_user_email if opts[:admin]
36
+ ENV['PROLOGUE_USER_PASSWORD'] = user_password if opts[:admin]
37
+
38
+ exec(<<-COMMAND)
39
+ rails new #{project} \
40
+ --template=#{template} \
41
+ --skip-test-unit \
42
+ --skip-prototype
43
+ COMMAND
44
+ end
45
+
46
+ desc "version", "Prints Prologue's version information"
47
+ def version
48
+ say "Prologue version #{Prologue::VERSION}"
49
+ end
50
+ map %w(-v --version) => :version
51
+
52
+ private
53
+
54
+ def template
55
+ File.expand_path(File.dirname(__FILE__) + "/../../templates/bootstrap.rb")
56
+ end
57
+
58
+ def git_user_name
59
+ `git config --global user.name`.chomp || "Quick Left"
60
+ end
61
+
62
+ def git_user_email
63
+ `git config --global user.email`.chomp || "me@me.com"
64
+ end
65
+
66
+ def user_password
67
+ ActiveSupport::SecureRandom.base64(8)
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module Prologue
2
+ VERSION = "0.1.0"
3
+ end
data/lib/prologue.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Prologue
2
+
3
+ end
data/prologue.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/prologue/version", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "prologue"
6
+ s.version = Prologue::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Quick Left"]
9
+ s.email = ["info@quickleft.com"]
10
+ s.homepage = "http://github.com/quickleft/prologue"
11
+ s.summary = "prologue-#{s.version}"
12
+ s.description = "Generate a Rails 3 app with application templates Quick Left uses to start their projects off right!"
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "prologue"
16
+
17
+ s.add_dependency "thor"
18
+ s.add_dependency('rails', '>= 3.0.0')
19
+ s.add_development_dependency "bundler", ">= 1.0.0"
20
+ s.add_development_dependency "cucumber"
21
+ s.add_development_dependency "aruba"
22
+ s.add_development_dependency "rspec", "~> 2.0.0.beta.22"
23
+
24
+ s.files = `git ls-files`.split("\n")
25
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
26
+ s.require_path = 'lib'
27
+ end
@@ -0,0 +1,22 @@
1
+ create_file 'spec/controllers/admin/dashboard_controller_spec.rb' do
2
+ <<-'FILE'
3
+ require 'spec_helper'
4
+ include Devise::TestHelpers
5
+
6
+ describe Admin::DashboardController do
7
+ before(:each) do
8
+ @user = @user ||=Factory.create(:admin)
9
+ sign_in @user
10
+ end
11
+
12
+ describe "GET 'index'" do
13
+ it "should be successful" do
14
+ get 'index'
15
+ response.should be_success
16
+ end
17
+ end
18
+
19
+ end
20
+
21
+ FILE
22
+ end
@@ -0,0 +1,75 @@
1
+ create_file 'app/views/admin/dashboard/index.html.haml' do
2
+ <<-FILE
3
+ %h1 #{app_name.humanize} Admin
4
+ FILE
5
+ end
6
+
7
+ run 'mkdir app/views/admin/shared'
8
+
9
+ create_file 'app/views/admin/shared/_header.html.haml' do
10
+ <<-FILE
11
+ %header#main_admin_header
12
+ %h1= link_to '#{app_name.humanize}', root_path
13
+ = render 'admin/shared/messages'
14
+ %nav#main_admin_nav
15
+ %ul
16
+ %li= link_to 'Home', root_path
17
+ %ul#user_admin_nav
18
+ = render 'devise/menu/login_items'
19
+ FILE
20
+ end
21
+
22
+ create_file 'app/views/admin/shared/_messages.html.haml' do
23
+ <<-FILE
24
+ - if flash[:notice]
25
+ %div#messenger{:class => "flasher"}= flash[:notice]
26
+ - if flash[:error]
27
+ %div#error{:class => "flasher"}= flash[:error]
28
+ FILE
29
+ end
30
+
31
+ create_file 'app/views/admin/shared/_footer.html.haml' do
32
+ <<-FILE
33
+ %footer#main_admin_footer
34
+ %a{:href => "http://quickleft.com"}
35
+ #{app_name.humanize}
36
+ FILE
37
+ end
38
+
39
+ create_file 'app/views/admin/shared/_end_scripts.html.haml' do
40
+ <<-FILE
41
+ = javascript_include_tag :defaults
42
+ FILE
43
+ end
44
+
45
+ create_file 'app/views/layouts/admin.html.haml' do
46
+ <<-FILE
47
+ !!! 5
48
+ %html
49
+ %head
50
+ %meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}
51
+ %meta{'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1'}
52
+ %title
53
+ #{app_name.humanize}
54
+ = yield(:title)
55
+ %meta{:name => 'viewport', :content => 'width=device-width; initial-scale=1.0'}
56
+ = csrf_meta_tag
57
+ %link{:rel => "shortcut icon", :href => "/images/favicon.ico", :type => "image/x-icon"}
58
+ /[if lt IE 9]
59
+ %script{:type => "text/javascript", :src => "/javascripts/shiv.js"}
60
+ = stylesheet_link_tag "admin"
61
+ = yield(:head)
62
+ /[if IE 7]
63
+ = stylesheet_link_tag 'ie7', :media => 'all'
64
+ /[if IE 8]
65
+ = stylesheet_link_tag 'ie8', :media => 'all'
66
+ %body
67
+ #container
68
+ = render :partial => "admin/shared/header"
69
+ %section#content
70
+ = yield
71
+ #pusher
72
+ = render :partial => "admin/shared/footer"
73
+ = render :partial => "admin/shared/end_scripts"
74
+ FILE
75
+ end
@@ -0,0 +1,140 @@
1
+ create_file 'public/stylesheets/sass/admin.scss' do
2
+ <<-FILE
3
+ @mixin layout_base {
4
+ @include reset;
5
+ @include container;
6
+ @include user_admin_nav;
7
+ @include main_admin_nav;
8
+ //uncomment for a handy layout guide
9
+ @include layout_guide;
10
+ }
11
+
12
+ @mixin reset {
13
+ /*
14
+ html5doctor.com Reset Stylesheet (Eric Meyer's Reset Reloaded + HTML5 baseline)
15
+ v1.4 2009-07-27 | Authors: Eric Meyer & Richard Clark
16
+ html5doctor.com/html-5-reset-stylesheet/
17
+ */
18
+
19
+ html, body, div, span, object, iframe,
20
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
21
+ abbr, address, cite, code,
22
+ del, dfn, em, img, ins, kbd, q, samp,
23
+ small, strong, sub, sup, var,
24
+ b, i,
25
+ dl, dt, dd, ol, ul, li,
26
+ fieldset, form, label, legend,
27
+ table, caption, tbody, tfoot, thead, tr, th, td,
28
+ article, aside, canvas, details, figcaption, figure,
29
+ footer, header, hgroup, menu, nav, section, summary,
30
+ time, mark, audio, video {
31
+ margin:0;
32
+ padding:0;
33
+ border:0;
34
+ outline:0;
35
+ font-size:100%;
36
+ vertical-align:baseline;
37
+ background:transparent;
38
+ }
39
+
40
+ article, aside, details, figcaption, figure,
41
+ footer, header, hgroup, menu, nav, section {
42
+ display:block;
43
+ }
44
+
45
+ nav ul { list-style:none; }
46
+
47
+ blockquote, q { quotes:none; }
48
+
49
+ blockquote:before, blockquote:after,
50
+ q:before, q:after { content:''; content:none; }
51
+
52
+ a { margin:0; padding:0; font-size:100%; vertical-align:baseline; background:transparent; }
53
+
54
+ ins { background-color:#ff9; color:#000; text-decoration:none; }
55
+
56
+ mark { background-color:#ff9; color:#000; font-style:italic; font-weight:bold; }
57
+
58
+ del { text-decoration: line-through; }
59
+
60
+ abbr[title], dfn[title] { border-bottom:1px dotted; cursor:help; }
61
+
62
+ /* tables still need cellspacing="0" in the markup */
63
+ table { border-collapse:collapse; border-spacing:0; }
64
+
65
+ hr { display:block; height:1px; border:0; border-top:1px solid #ccc; margin:1em 0; padding:0; }
66
+
67
+ input, select { vertical-align:middle; }
68
+ }
69
+
70
+ @mixin clear_left {
71
+ float: left; clear: both;
72
+ }
73
+
74
+ @mixin container($container_size: 950px) {
75
+ #container {
76
+ width: $container_size;
77
+ clear:both;
78
+ padding: 0 20px;
79
+ min-height: 100%;
80
+ height: auto !important;
81
+ height: 100%;
82
+ margin: 0 auto -80px;
83
+ }
84
+ #main_admin_header {
85
+ width: $container_size;
86
+ height: 60px;
87
+ @include clear_left;
88
+ h1 {
89
+ float: left;
90
+ padding: 20px 0 0 0;
91
+ font-size: 24px;
92
+ font-weight: bold;
93
+ }
94
+ }
95
+ #content {
96
+ width: $container_size;
97
+ @include clear_left;
98
+ padding: 10px 0 20px 0;
99
+ }
100
+ #main_admin_footer, #pusher {
101
+ height: 80px;
102
+ clear:both;
103
+ }
104
+ }
105
+
106
+ @mixin user_admin_nav {
107
+ #user_admin_nav {
108
+ float: right;
109
+ padding: 20px 0 0 0;
110
+ }
111
+ }
112
+
113
+ @mixin main_admin_nav {
114
+ #main_admin_nav {
115
+ width: 950px;
116
+ @include clear_left;
117
+ padding: 10px 0;
118
+ ul {
119
+ @include clear_left;
120
+ li {
121
+ float: left;
122
+ padding: 0 15px 0 0;
123
+ }
124
+ }
125
+ }
126
+ }
127
+
128
+ @mixin layout_guide {
129
+ #container { background-color: #e8e6e6; }
130
+ #main_admin_header { background-color: #f7dddd; }
131
+ #main_admin_nav { background-color: #f4ddf7; }
132
+ #content { background-color: #f2f7dd; }
133
+ #main_admin_footer .inner { background-color: #ddf7e7; }
134
+ }
135
+
136
+ @include layout_base;
137
+ FILE
138
+ end
139
+
140
+ run 'sass public/stylesheets/sass/admin.scss public/stylesheets/admin.css'