bear 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +110 -0
- data/LICENSE +21 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bear.gemspec +27 -0
- data/bin/bear +4 -0
- data/features/new.feature +24 -0
- data/features/support/setup.rb +1 -0
- data/lib/bear.rb +6 -0
- data/lib/bear/cli.rb +71 -0
- data/lib/bear/version.rb +3 -0
- data/templates/admin.rb +23 -0
- data/templates/admin/cucumber.rb +76 -0
- data/templates/admin/dashboard_spec.rb +23 -0
- data/templates/admin/layout.rb +28 -0
- data/templates/admin/users.rb +115 -0
- data/templates/admin/users_spec.rb +30 -0
- data/templates/application_layout.rb +65 -0
- data/templates/bootstrap.rb +100 -0
- data/templates/clean_routes.rb +8 -0
- data/templates/db.rb +2 -0
- data/templates/db_seed.rb +1 -0
- data/templates/devise.rb +112 -0
- data/templates/devise/cucumber.rb +116 -0
- data/templates/gemfile.rb +36 -0
- data/templates/haml_generator.rb +7 -0
- data/templates/home_controller.rb +9 -0
- data/templates/initializers.rb +24 -0
- data/templates/jammit.rb +20 -0
- data/templates/js.rb +58 -0
- data/templates/rails_clean.rb +5 -0
- data/templates/rspec_clean.rb +3 -0
- data/templates/sass.rb +459 -0
- data/templates/test_suite.rb +41 -0
- metadata +185 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
prologue (0.3.1)
|
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.1)
|
13
|
+
actionpack (= 3.0.1)
|
14
|
+
mail (~> 2.2.5)
|
15
|
+
actionpack (3.0.1)
|
16
|
+
activemodel (= 3.0.1)
|
17
|
+
activesupport (= 3.0.1)
|
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.1)
|
26
|
+
activesupport (= 3.0.1)
|
27
|
+
builder (~> 2.1.2)
|
28
|
+
i18n (~> 0.4.1)
|
29
|
+
activerecord (3.0.1)
|
30
|
+
activemodel (= 3.0.1)
|
31
|
+
activesupport (= 3.0.1)
|
32
|
+
arel (~> 1.0.0)
|
33
|
+
tzinfo (~> 0.3.23)
|
34
|
+
activeresource (3.0.1)
|
35
|
+
activemodel (= 3.0.1)
|
36
|
+
activesupport (= 3.0.1)
|
37
|
+
activesupport (3.0.1)
|
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.3)
|
46
|
+
builder (~> 2.1.2)
|
47
|
+
diff-lcs (~> 1.1.2)
|
48
|
+
gherkin (~> 2.2.9)
|
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.1)
|
71
|
+
actionmailer (= 3.0.1)
|
72
|
+
actionpack (= 3.0.1)
|
73
|
+
activerecord (= 3.0.1)
|
74
|
+
activeresource (= 3.0.1)
|
75
|
+
activesupport (= 3.0.1)
|
76
|
+
bundler (~> 1.0.0)
|
77
|
+
railties (= 3.0.1)
|
78
|
+
railties (3.0.1)
|
79
|
+
actionpack (= 3.0.1)
|
80
|
+
activesupport (= 3.0.1)
|
81
|
+
rake (>= 0.8.4)
|
82
|
+
thor (~> 0.14.0)
|
83
|
+
rake (0.8.7)
|
84
|
+
rspec (2.0.1)
|
85
|
+
rspec-core (~> 2.0.1)
|
86
|
+
rspec-expectations (~> 2.0.1)
|
87
|
+
rspec-mocks (~> 2.0.1)
|
88
|
+
rspec-core (2.0.1)
|
89
|
+
rspec-expectations (2.0.1)
|
90
|
+
diff-lcs (>= 1.1.2)
|
91
|
+
rspec-mocks (2.0.1)
|
92
|
+
rspec-core (~> 2.0.1)
|
93
|
+
rspec-expectations (~> 2.0.1)
|
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)
|
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,36 @@
|
|
1
|
+
Bear
|
2
|
+
===========
|
3
|
+
Generate a Rails 3 app.
|
4
|
+
|
5
|
+
Started with the Quick Left Prologue gem and made it fit my needs.
|
6
|
+
|
7
|
+
### What you get
|
8
|
+
|
9
|
+
bistro_car, cucumber, devise, fabrication, faker, formtastic, haml, jammit, mocha, rspec-rails, sass shoulda, timecop
|
10
|
+
|
11
|
+
### Quick Start
|
12
|
+
|
13
|
+
gem install bear
|
14
|
+
bear new my_app
|
15
|
+
|
16
|
+
|
17
|
+
### Options
|
18
|
+
|
19
|
+
bear new my_app --no-auth
|
20
|
+
bear new my_app --no-admin
|
21
|
+
|
22
|
+
|
23
|
+
### Testing generated app
|
24
|
+
|
25
|
+
rake spec
|
26
|
+
rake cucumber
|
27
|
+
bundle exec autotest
|
28
|
+
|
29
|
+
|
30
|
+
### Patches/Pull Requests
|
31
|
+
|
32
|
+
* Fork it.
|
33
|
+
* Add tests for it.
|
34
|
+
* Make your changes.
|
35
|
+
* Commit.
|
36
|
+
* Send a pull request.
|
data/Rakefile
ADDED
data/bear.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/bear/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "bear"
|
6
|
+
s.version = Bear::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Russ Smith"]
|
9
|
+
s.email = ["russ@bashme.org"]
|
10
|
+
s.homepage = "http://github.com/russ/bear"
|
11
|
+
s.summary = "bear-#{s.version}"
|
12
|
+
s.description = "Generate a Rails 3 app with application templates."
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "bear"
|
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"
|
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
|
data/bin/bear
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
@disable-bundler
|
2
|
+
Feature: Generate new bear app
|
3
|
+
In order to start a new project with bear
|
4
|
+
As a CLI
|
5
|
+
I want to generate a rails3 app with bear
|
6
|
+
|
7
|
+
Scenario: Run bear new my_app
|
8
|
+
When I run "bear new my_app"
|
9
|
+
Then the output should contain "Building authentication"
|
10
|
+
And the output should contain "Building admin"
|
11
|
+
And the output should contain "Bear says RAWR!!!"
|
12
|
+
|
13
|
+
Scenario: Run bear new my_app --no-auth
|
14
|
+
When I run "bear new my_app --no-auth"
|
15
|
+
Then the output should not contain "Building authentication"
|
16
|
+
And the output should not contain "Building admin"
|
17
|
+
And the output should contain "Bear says RAWR!!!"
|
18
|
+
|
19
|
+
Scenario: Run bear new my_app --no-admin
|
20
|
+
When I run "bear new my_app --no-admin"
|
21
|
+
Then the output should contain "Building authentication"
|
22
|
+
And the output should contain "Building roles"
|
23
|
+
And the output should not contain "Building admin"
|
24
|
+
And the output should contain "Bear says RAWR!!!"
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba'
|
data/lib/bear.rb
ADDED
data/lib/bear/cli.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/actions'
|
3
|
+
require 'active_support/secure_random'
|
4
|
+
|
5
|
+
module Bear
|
6
|
+
class CLI < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
desc "new [app]", "Create a new Rails 3 application"
|
10
|
+
long_desc <<-D
|
11
|
+
Bear will ask you a few questions to determine what features you
|
12
|
+
would like to generate. Based on your answers it will setup a new Rails 3 application.
|
13
|
+
D
|
14
|
+
method_option :auth, :type => :boolean, :default => true, :banner =>
|
15
|
+
"Sets up devise for authentication."
|
16
|
+
method_option :roles, :type => :boolean, :default => true, :banner =>
|
17
|
+
"Sets up cancan for authorization with roles."
|
18
|
+
method_option :admin, :type => :boolean, :default => true, :banner =>
|
19
|
+
"Sets up very basic admin"
|
20
|
+
def new(project)
|
21
|
+
opts = options.dup
|
22
|
+
|
23
|
+
# Can't build an admin or roles without devise
|
24
|
+
if !opts[:auth]
|
25
|
+
opts[:admin] = false;
|
26
|
+
opts[:roles] = false;
|
27
|
+
end
|
28
|
+
|
29
|
+
# Env vars used in our template
|
30
|
+
ENV['BEAR_AUTH'] = "true" if opts[:auth]
|
31
|
+
ENV['BEAR_ADMIN'] = "true" if opts[:admin]
|
32
|
+
ENV['BEAR_ROLES'] = "true" if opts[:roles]
|
33
|
+
ENV['BEAR_USER_NAME'] = git_user_name if opts[:admin]
|
34
|
+
ENV['BEAR_USER_EMAIL'] = git_user_email if opts[:admin]
|
35
|
+
ENV['BEAR_USER_PASSWORD'] = user_password if opts[:admin]
|
36
|
+
|
37
|
+
exec(<<-COMMAND)
|
38
|
+
rails new #{project} \
|
39
|
+
--template=#{template} \
|
40
|
+
--skip-test-unit \
|
41
|
+
--skip-prototype \
|
42
|
+
--database=mysql
|
43
|
+
COMMAND
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "version", "Prints Bear's version information"
|
47
|
+
def version
|
48
|
+
say "Bear version #{Bear::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
|
data/lib/bear/version.rb
ADDED
data/templates/admin.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
say "Building admin"
|
2
|
+
generate(:controller, "admin/dashboard index")
|
3
|
+
route("match 'admin' => 'admin/dashboard#index'")
|
4
|
+
|
5
|
+
# Do layout and SASS stuff
|
6
|
+
apply File.expand_path("../admin/layout.rb", __FILE__)
|
7
|
+
|
8
|
+
create_file 'app/controllers/admin/base_controller.rb' do
|
9
|
+
<<-RUBY
|
10
|
+
class Admin::BaseController < ApplicationController
|
11
|
+
layout "admin"
|
12
|
+
before_filter :authenticate_user!
|
13
|
+
end
|
14
|
+
RUBY
|
15
|
+
end
|
16
|
+
|
17
|
+
gsub_file "app/controllers/admin/dashboard_controller.rb", /ApplicationController/, "Admin::BaseController"
|
18
|
+
|
19
|
+
# make a user admin
|
20
|
+
apply File.expand_path("../admin/users.rb", __FILE__)
|
21
|
+
apply File.expand_path("../admin/dashboard_spec.rb", __FILE__)
|
22
|
+
apply File.expand_path("../admin/users_spec.rb", __FILE__)
|
23
|
+
apply File.expand_path("../admin/cucumber.rb", __FILE__)
|
@@ -0,0 +1,76 @@
|
|
1
|
+
inject_into_file 'features/support/paths.rb', :after => "case page_name\n" do
|
2
|
+
<<-'FILE'
|
3
|
+
|
4
|
+
when /the admin/
|
5
|
+
'/admin'
|
6
|
+
|
7
|
+
when /the add user page/
|
8
|
+
'/admin/users/new'
|
9
|
+
FILE
|
10
|
+
end
|
11
|
+
|
12
|
+
create_file 'features/admin.feature' do
|
13
|
+
<<-'FILE'
|
14
|
+
Feature: Admin dashboard
|
15
|
+
As an administrator
|
16
|
+
I want to manage the application
|
17
|
+
So that I can have full control over the site
|
18
|
+
|
19
|
+
Scenario: Login as an admin
|
20
|
+
Given a logged in admin user
|
21
|
+
When I am on the admin
|
22
|
+
Then I should see "Admin"
|
23
|
+
FILE
|
24
|
+
end
|
25
|
+
|
26
|
+
create_file 'features/user_admin.feature' do
|
27
|
+
<<-'FILE'
|
28
|
+
Feature: Administer users
|
29
|
+
As an administrator
|
30
|
+
I want to manage the users
|
31
|
+
So that I can provide support for them
|
32
|
+
|
33
|
+
Background:
|
34
|
+
Given the following role records
|
35
|
+
| name |
|
36
|
+
| Member |
|
37
|
+
|
38
|
+
Scenario: Create, update, delete a user in the admin
|
39
|
+
Given a logged in admin user
|
40
|
+
When I am on the add user page
|
41
|
+
And I fill in "Name" with "Big Boi"
|
42
|
+
And I fill in "Email" with "big@sirluciousleftfoot.com"
|
43
|
+
And I fill in "Password" with "Ch!coDusty$"
|
44
|
+
And I fill in "Password confirmation" with "Ch!coDusty$"
|
45
|
+
And I check "Member"
|
46
|
+
And I press "Save"
|
47
|
+
Then I should see "User created!"
|
48
|
+
And I should see "Big Boi"
|
49
|
+
|
50
|
+
When I follow "Big Boi"
|
51
|
+
Then the "Name" field should contain "Big Boi"
|
52
|
+
And the "Email" field should contain "big@sirluciousleftfoot.com"
|
53
|
+
And the "Member" checkbox should be checked
|
54
|
+
And the "Admin" checkbox should not be checked
|
55
|
+
|
56
|
+
Then I fill in "Name" with "Bigger Boi"
|
57
|
+
And I fill in "Email" with "bigger@sirluciousleftfoot.com"
|
58
|
+
And I uncheck "Member"
|
59
|
+
And I check "Admin"
|
60
|
+
And I press "Save"
|
61
|
+
Then I should see "Successfully updated Bigger Boi."
|
62
|
+
|
63
|
+
When I follow "Bigger Boi"
|
64
|
+
Then the "Name" field should contain "Bigger Boi"
|
65
|
+
And the "Email" field should contain "bigger@sirluciousleftfoot.com"
|
66
|
+
And the "Member" checkbox should not be checked
|
67
|
+
And the "Admin" checkbox should be checked
|
68
|
+
Then I press "Save"
|
69
|
+
|
70
|
+
Then I follow "Delete"
|
71
|
+
Then I should see "User deleted."
|
72
|
+
And I should not see "Bigger Boi"
|
73
|
+
|
74
|
+
|
75
|
+
FILE
|
76
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
run "rm spec/controllers/admin/dashboard_controller_spec.rb"
|
2
|
+
|
3
|
+
create_file "spec/controllers/admin/dashboard_controller_spec.rb" do
|
4
|
+
<<-'FILE'
|
5
|
+
require "spec_helper"
|
6
|
+
include Devise::TestHelpers
|
7
|
+
|
8
|
+
describe Admin::DashboardController do
|
9
|
+
let(:admin) { Fabricate(:admin) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
sign_in(admin)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "GET 'index'" do
|
16
|
+
it "should be successful" do
|
17
|
+
get "index"
|
18
|
+
response.should be_success
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
FILE
|
23
|
+
end
|