shinkansen 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +111 -0
- data/LICENSE +21 -0
- data/README.md +117 -0
- data/Rakefile +2 -0
- data/bin/shinkansen +17 -0
- data/lib/shinkansen.rb +7 -0
- data/lib/shinkansen/cli.rb +42 -0
- data/lib/shinkansen/errors.rb +6 -0
- data/lib/shinkansen/template_runner.rb +29 -0
- data/lib/shinkansen/version.rb +3 -0
- data/shinkansen.gemspec +30 -0
- data/templates/default/bootstrap.rb +44 -0
- data/templates/default/default.rb +36 -0
- data/templates/default/lib/bourbon.rb +12 -0
- data/templates/default/lib/cancan.rb +87 -0
- data/templates/default/lib/clean_routes.rb +8 -0
- data/templates/default/lib/convert_erb_to_haml.rb +9 -0
- data/templates/default/lib/db.rb +2 -0
- data/templates/default/lib/db_seed.rb +2 -0
- data/templates/default/lib/devise.rb +34 -0
- data/templates/default/lib/factory_girl.rb +7 -0
- data/templates/default/lib/friendly_id.rb +1 -0
- data/templates/default/lib/gemfile.rb +55 -0
- data/templates/default/lib/git.rb +0 -0
- data/templates/default/lib/haml_generator.rb +13 -0
- data/templates/default/lib/heroku.rb +19 -0
- data/templates/default/lib/home_controller.rb +10 -0
- data/templates/default/lib/initializers.rb +0 -0
- data/templates/default/lib/livereload.rb +10 -0
- data/templates/default/lib/new_relic.rb +23 -0
- data/templates/default/lib/rails_admin.rb +15 -0
- data/templates/default/lib/rails_clean.rb +11 -0
- data/templates/default/lib/rspec.rb +11 -0
- data/templates/default/lib/rspec_clean.rb +3 -0
- data/templates/default/lib/rvm.rb +8 -0
- metadata +179 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shinkansen (0.9.1)
|
5
|
+
activesupport (= 3.1.0)
|
6
|
+
rails (= 3.1.0)
|
7
|
+
thor (~> 0.14.6)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionmailer (3.1.0)
|
13
|
+
actionpack (= 3.1.0)
|
14
|
+
mail (~> 2.3.0)
|
15
|
+
actionpack (3.1.0)
|
16
|
+
activemodel (= 3.1.0)
|
17
|
+
activesupport (= 3.1.0)
|
18
|
+
builder (~> 3.0.0)
|
19
|
+
erubis (~> 2.7.0)
|
20
|
+
i18n (~> 0.6)
|
21
|
+
rack (~> 1.3.2)
|
22
|
+
rack-cache (~> 1.0.3)
|
23
|
+
rack-mount (~> 0.8.2)
|
24
|
+
rack-test (~> 0.6.1)
|
25
|
+
sprockets (~> 2.0.0)
|
26
|
+
activemodel (3.1.0)
|
27
|
+
activesupport (= 3.1.0)
|
28
|
+
bcrypt-ruby (~> 3.0.0)
|
29
|
+
builder (~> 3.0.0)
|
30
|
+
i18n (~> 0.6)
|
31
|
+
activerecord (3.1.0)
|
32
|
+
activemodel (= 3.1.0)
|
33
|
+
activesupport (= 3.1.0)
|
34
|
+
arel (~> 2.2.1)
|
35
|
+
tzinfo (~> 0.3.29)
|
36
|
+
activeresource (3.1.0)
|
37
|
+
activemodel (= 3.1.0)
|
38
|
+
activesupport (= 3.1.0)
|
39
|
+
activesupport (3.1.0)
|
40
|
+
multi_json (~> 1.0)
|
41
|
+
arel (2.2.1)
|
42
|
+
bcrypt-ruby (3.0.1)
|
43
|
+
builder (3.0.0)
|
44
|
+
diff-lcs (1.1.2)
|
45
|
+
erubis (2.7.0)
|
46
|
+
hike (1.2.1)
|
47
|
+
i18n (0.6.0)
|
48
|
+
json (1.6.5)
|
49
|
+
mail (2.3.0)
|
50
|
+
i18n (>= 0.4.0)
|
51
|
+
mime-types (~> 1.16)
|
52
|
+
treetop (~> 1.4.8)
|
53
|
+
mime-types (1.17.2)
|
54
|
+
multi_json (1.0.4)
|
55
|
+
polyglot (0.3.3)
|
56
|
+
rack (1.3.6)
|
57
|
+
rack-cache (1.0.3)
|
58
|
+
rack (>= 0.4)
|
59
|
+
rack-mount (0.8.3)
|
60
|
+
rack (>= 1.0.0)
|
61
|
+
rack-ssl (1.3.2)
|
62
|
+
rack
|
63
|
+
rack-test (0.6.1)
|
64
|
+
rack (>= 1.0)
|
65
|
+
rails (3.1.0)
|
66
|
+
actionmailer (= 3.1.0)
|
67
|
+
actionpack (= 3.1.0)
|
68
|
+
activerecord (= 3.1.0)
|
69
|
+
activeresource (= 3.1.0)
|
70
|
+
activesupport (= 3.1.0)
|
71
|
+
bundler (~> 1.0)
|
72
|
+
railties (= 3.1.0)
|
73
|
+
railties (3.1.0)
|
74
|
+
actionpack (= 3.1.0)
|
75
|
+
activesupport (= 3.1.0)
|
76
|
+
rack-ssl (~> 1.3.2)
|
77
|
+
rake (>= 0.8.7)
|
78
|
+
rdoc (~> 3.4)
|
79
|
+
thor (~> 0.14.6)
|
80
|
+
rake (0.9.2.2)
|
81
|
+
rdoc (3.12)
|
82
|
+
json (~> 1.4)
|
83
|
+
rspec (2.0.1)
|
84
|
+
rspec-core (~> 2.0.1)
|
85
|
+
rspec-expectations (~> 2.0.1)
|
86
|
+
rspec-mocks (~> 2.0.1)
|
87
|
+
rspec-core (2.0.1)
|
88
|
+
rspec-expectations (2.0.1)
|
89
|
+
diff-lcs (>= 1.1.2)
|
90
|
+
rspec-mocks (2.0.1)
|
91
|
+
rspec-core (~> 2.0.1)
|
92
|
+
rspec-expectations (~> 2.0.1)
|
93
|
+
sprockets (2.0.3)
|
94
|
+
hike (~> 1.2)
|
95
|
+
rack (~> 1.0)
|
96
|
+
tilt (~> 1.1, != 1.3.0)
|
97
|
+
thor (0.14.6)
|
98
|
+
tilt (1.3.3)
|
99
|
+
treetop (1.4.10)
|
100
|
+
polyglot
|
101
|
+
polyglot (>= 0.3.1)
|
102
|
+
tzinfo (0.3.31)
|
103
|
+
|
104
|
+
PLATFORMS
|
105
|
+
ruby
|
106
|
+
|
107
|
+
DEPENDENCIES
|
108
|
+
bundler (~> 1.0.12)
|
109
|
+
shinkansen!
|
110
|
+
rspec (~> 2.0.0)
|
111
|
+
thor
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 We Are Titans
|
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,117 @@
|
|
1
|
+
Shinkansen
|
2
|
+
==========
|
3
|
+
|
4
|
+
Spin up well-configured Rails apps in minutes rather than hours. A personal-flavored fork of [Gypsum](https://github.com/zsiec/gypsum), which itself was a fork of [Prologue](https://github.com/quickleft/prologue).
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
$ gem install shinkansen
|
9
|
+
|
10
|
+
Usage
|
11
|
+
-----
|
12
|
+
$ shinkansen new some_project
|
13
|
+
$ cd some_project
|
14
|
+
$ rails s
|
15
|
+
|
16
|
+
A git repository is initialized and commit to after generating the initial stock Rails app. You can get a sense for which configuration changes Shinkansen has made by doing:
|
17
|
+
|
18
|
+
$ git diff
|
19
|
+
|
20
|
+
Once you've reviewed those changes and are satisfied, you should do an initial:
|
21
|
+
|
22
|
+
$ git add -A
|
23
|
+
$ git commit -m "Initial commit from Shinkansen."
|
24
|
+
|
25
|
+
Thanks
|
26
|
+
------
|
27
|
+
|
28
|
+
Shinkansen is a fork
|
29
|
+
|
30
|
+
|
31
|
+
What's in the Box
|
32
|
+
-----------------
|
33
|
+
|
34
|
+
### Tools of the Trade
|
35
|
+
|
36
|
+
- [Ruby on Rails](http://rubyonrails.org/)
|
37
|
+
- [Haml](http://haml-lang.com/)
|
38
|
+
- [Sass](http://sass-lang.com/)
|
39
|
+
- [CoffeeScript](http://coffeescript.org/)
|
40
|
+
|
41
|
+
All generated ERB files are converted to Haml.
|
42
|
+
|
43
|
+
### Authentication and Authorization
|
44
|
+
Authentication and authorization are provided by [devise](https://github.com/plataformatec/devise) and [cancan](https://github.com/ryanb/cancan). We've also kept Quickleft's out-of-the-box implementation for users having many roles and simple checking of roles like so:
|
45
|
+
|
46
|
+
user.is?(:admin)
|
47
|
+
|
48
|
+
A sample admin user (`admin@example.org`) and regular user (`user@example.org`) is created as well. The password for both accounts is `password!`
|
49
|
+
|
50
|
+
### Admin Console
|
51
|
+
Customers can manage their data easily using [rails_admin](https://github.com/sferik/rails_admin).
|
52
|
+
|
53
|
+
### Helpers
|
54
|
+
|
55
|
+
#### Dates
|
56
|
+
Format your times and dates naturally with [stamp](https://github.com/jeremyw/stamp):
|
57
|
+
|
58
|
+
%p You last signed in on #{current_user.last_sign_in_at.stamp('Saturday, January 1, 2012')}
|
59
|
+
|
60
|
+
#### Grammar
|
61
|
+
Present grammatically correct possessives like *Andrew's* and *Silas'* with [possessive](https://github.com/bclubb/possessive):
|
62
|
+
|
63
|
+
%h2= #{user.name.possessive} Friends
|
64
|
+
|
65
|
+
#### Randomness
|
66
|
+
Fetch random records using [randumb](https://github.com/spilliton/randumb)
|
67
|
+
|
68
|
+
@five_friends = user.friends.random(5)
|
69
|
+
|
70
|
+
#### Cross-Browser CSS3
|
71
|
+
Use CSS3 with confidence with [bourbon's](https://github.com/thoughtbot/bourbon) Sass mixins.
|
72
|
+
|
73
|
+
#### Convert Markdown to HTML
|
74
|
+
Converting Markdown to HTML is a great way to let users format their content, which I use [BlueCloth](https://github.com/ged/bluecloth) for.
|
75
|
+
|
76
|
+
.content
|
77
|
+
= BlueCloth.new(@user.profile).to_html.html_safe
|
78
|
+
|
79
|
+
We typically just role that into a `markdown()` view helper, but haven't included that yet.
|
80
|
+
|
81
|
+
### File Attachments
|
82
|
+
In addition to including [paperclip](https://github.com/thoughtbot/paperclip) by default, I also include [paperclip-s3](https://github.com/nhocki/paperclip-s3) which means you don't need any configuration code for file attachments to work on Heroku. Instead, just create a bucket and register the details like so:
|
83
|
+
|
84
|
+
heroku config:add S3_BUCKET=your_bucket_name
|
85
|
+
heroku config:add S3_KEY=your_access_key
|
86
|
+
heroku config:add S3_SECRET=your_secret_key
|
87
|
+
|
88
|
+
### Scalability
|
89
|
+
Write code that scales better with [delayed_job](https://github.com/tobi/delayed_job).
|
90
|
+
|
91
|
+
|
92
|
+
### Usability
|
93
|
+
|
94
|
+
#### Report on Validation Errors
|
95
|
+
Find out which validation errors you users run into again-and-again with [tripwire_notifier](https://github.com/jeremyw/tripwire_notifier).
|
96
|
+
|
97
|
+
#### Parse Natural Language Dates
|
98
|
+
Or any format really, with [chronic](https://github.com/mojombo/chronic)
|
99
|
+
|
100
|
+
### Responsive Development without Command + Tab
|
101
|
+
Automatic in-browser refreshing on page save with guard-livereload and rack-livereload. When you have a guard process running from the project directory, pages will automatically refresh when you save Haml, assets, view helpers, locales, etc.
|
102
|
+
|
103
|
+
$ guard
|
104
|
+
|
105
|
+
### User-friendly and SEO-friendly URLs
|
106
|
+
That's what [friendly_id](https://github.com/norman/friendly_id) is for. (Note to self, I should add this to users by default as an example.)
|
107
|
+
|
108
|
+
### The Testing Suite
|
109
|
+
|
110
|
+
- rspec
|
111
|
+
- capybara and capybara-webkit
|
112
|
+
- shoulda-matchers
|
113
|
+
- webmock
|
114
|
+
- vcr
|
115
|
+
- email_spec
|
116
|
+
- timecop
|
117
|
+
- factory\_girl\_rails
|
data/Rakefile
ADDED
data/bin/shinkansen
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- mode: ruby -*-
|
3
|
+
|
4
|
+
# Requires
|
5
|
+
begin
|
6
|
+
require 'shinkansen'
|
7
|
+
rescue LoadError
|
8
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
|
9
|
+
require 'rubygems'
|
10
|
+
require 'shinkansen'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Setup Constants
|
14
|
+
Shinkansen::GEM_ROOT = File.expand_path( File.dirname( __FILE__ ) + '/../' )
|
15
|
+
|
16
|
+
# Run
|
17
|
+
Shinkansen::CLI.start
|
data/lib/shinkansen.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/actions'
|
3
|
+
|
4
|
+
module Shinkansen
|
5
|
+
|
6
|
+
class CLI < Thor
|
7
|
+
|
8
|
+
# Includes
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
desc "new [app]", "Create a new Rails 3.1 application"
|
12
|
+
long_desc <<-D
|
13
|
+
Shinkansen will ask you a few questions to determine what features you
|
14
|
+
would like to generate. Based on your answers it will setup a new Rails 3 application.
|
15
|
+
D
|
16
|
+
def new( project , template_name = "default" )
|
17
|
+
|
18
|
+
# Require the template runner
|
19
|
+
require "#{Shinkansen::GEM_ROOT}/templates/#{template_name}/#{template_name}.rb"
|
20
|
+
|
21
|
+
# Invoke the template runner
|
22
|
+
invoke "shinkansen:templates:#{template_name}:on_invocation"
|
23
|
+
|
24
|
+
# Execute the template
|
25
|
+
exec(<<-COMMAND)
|
26
|
+
rails new #{project} \
|
27
|
+
--template=#{Shinkansen::GEM_ROOT}/templates/#{template_name}/bootstrap.rb \
|
28
|
+
--skip-test-unit \
|
29
|
+
--skip-prototype
|
30
|
+
COMMAND
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "version", "Prints Shinkansen's version information"
|
35
|
+
def version
|
36
|
+
say "Shinkansen version #{Shinkansen::VERSION}"
|
37
|
+
end
|
38
|
+
map %w(-v --version) => :version
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/actions'
|
3
|
+
require 'thor/group'
|
4
|
+
|
5
|
+
module Shinkansen
|
6
|
+
|
7
|
+
class TemplateRunner < Thor::Group
|
8
|
+
|
9
|
+
# Define the Standard Arguments in any base template class
|
10
|
+
def self.extended(base)
|
11
|
+
base.class_eval do
|
12
|
+
argument :project , :type => :string
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Includes
|
17
|
+
include Thor::Actions
|
18
|
+
|
19
|
+
# The method to run when the template is invoked. This is used to
|
20
|
+
# parse custom options from the command line or complete any other
|
21
|
+
# setup prior to invoking the system command that will construct
|
22
|
+
# the project.
|
23
|
+
def on_invocation
|
24
|
+
raise Shinkansen::Errors::TemplateRunnerInvocationNotImplementedError.new("Template did not define an on_invocation method!")
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/shinkansen.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/shinkansen/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "shinkansen"
|
6
|
+
s.version = Shinkansen::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Andrew Culver"]
|
9
|
+
s.email = ["andrew.culver@gmail.com"]
|
10
|
+
s.homepage = "http://www.andrewculver.net/"
|
11
|
+
s.summary = "shinkansen-0.1"
|
12
|
+
s.description = "Spin up well-configured Rails apps in minutes rather than hours."
|
13
|
+
|
14
|
+
s.rubyforge_project = "shinkansen"
|
15
|
+
s.required_rubygems_version = "> 1.3.6"
|
16
|
+
|
17
|
+
# Runtime Dependencies
|
18
|
+
s.add_dependency "activesupport"
|
19
|
+
s.add_dependency "thor"
|
20
|
+
s.add_dependency "rails"
|
21
|
+
|
22
|
+
# Development Dependencies
|
23
|
+
s.add_development_dependency "bundler"
|
24
|
+
s.add_development_dependency "rspec"
|
25
|
+
s.add_development_dependency "thor"
|
26
|
+
|
27
|
+
s.files = `git ls-files`.split("\n")
|
28
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
29
|
+
s.require_path = "lib"
|
30
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "net/https"
|
3
|
+
require "uri"
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
say "Building Application with Shinkansen..."
|
7
|
+
|
8
|
+
def get_remote_https_file(source, destination)
|
9
|
+
uri = URI.parse(source)
|
10
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
11
|
+
http.use_ssl = true
|
12
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
13
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
14
|
+
response = http.request(request)
|
15
|
+
path = File.join(destination_root, destination)
|
16
|
+
File.open(path, "w") { |file| file.write(response.body) }
|
17
|
+
end
|
18
|
+
|
19
|
+
git :init
|
20
|
+
run "git add -A"
|
21
|
+
run "git commit -m 'Initial Rails 3.1 commit.'"
|
22
|
+
|
23
|
+
append_file '.gitignore' do <<-FILE
|
24
|
+
.DS_Store
|
25
|
+
config/database.yml
|
26
|
+
public/system/**/**/**/*
|
27
|
+
*.swp
|
28
|
+
FILE
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
files = ['rvm', 'gemfile', 'heroku', 'haml_generator', 'rails_clean', 'rspec', 'friendly_id', 'devise',
|
33
|
+
'cancan', 'db', 'db_seed', 'home_controller', 'initializers', 'clean_routes', 'rspec_clean',
|
34
|
+
'convert_erb_to_haml', 'rails_admin', 'bourbon', 'livereload']
|
35
|
+
|
36
|
+
files.each do |file|
|
37
|
+
apply File.expand_path("../lib/#{file}.rb", __FILE__)
|
38
|
+
end
|
39
|
+
|
40
|
+
say <<-D
|
41
|
+
|
42
|
+
OK, all done.
|
43
|
+
|
44
|
+
D
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Shinkansen
|
2
|
+
|
3
|
+
module Templates
|
4
|
+
|
5
|
+
class Default < Shinkansen::TemplateRunner
|
6
|
+
|
7
|
+
# Descriptions
|
8
|
+
desc "Runs the default shinkansen Rails 3.1 stack task"
|
9
|
+
|
10
|
+
# The method to run when the template is invoked
|
11
|
+
def on_invocation
|
12
|
+
|
13
|
+
# Dup our options so we can modify them
|
14
|
+
opts = options.dup
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def git_user_name
|
21
|
+
`git config --global user.name`.chomp.gsub('"', '\"') || "We Are Titans"
|
22
|
+
end
|
23
|
+
|
24
|
+
def git_user_email
|
25
|
+
`git config --global user.email`.chomp || "team@wearetitans.net"
|
26
|
+
end
|
27
|
+
|
28
|
+
def user_password
|
29
|
+
'asdoajsndokasodnaosdjn'
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
say "Building roles"
|
2
|
+
generate(:model, "role name:string")
|
3
|
+
generate(:model, "user_role user_id:integer role_id:integer")
|
4
|
+
|
5
|
+
inject_into_file 'app/models/user.rb', :after => "class User < ActiveRecord::Base\n" do
|
6
|
+
<<-RUBY
|
7
|
+
|
8
|
+
# roles
|
9
|
+
has_many :user_roles
|
10
|
+
has_many :roles, :through => :user_roles
|
11
|
+
|
12
|
+
RUBY
|
13
|
+
end
|
14
|
+
|
15
|
+
inject_into_file 'app/models/user_role.rb', :after => "class UserRole < ActiveRecord::Base\n" do
|
16
|
+
<<-RUBY
|
17
|
+
belongs_to :user
|
18
|
+
belongs_to :role
|
19
|
+
RUBY
|
20
|
+
end
|
21
|
+
|
22
|
+
inject_into_file 'app/models/role.rb', :after => "class Role < ActiveRecord::Base\n" do
|
23
|
+
<<-RUBY
|
24
|
+
|
25
|
+
# roles
|
26
|
+
has_many :user_roles
|
27
|
+
has_many :users, :through => :user_roles
|
28
|
+
|
29
|
+
def self.sanitize role
|
30
|
+
role.to_s.humanize.split(' ').each{ |word| word.capitalize! }.join(' ')
|
31
|
+
end
|
32
|
+
|
33
|
+
RUBY
|
34
|
+
end
|
35
|
+
|
36
|
+
create_file 'app/models/ability.rb' do
|
37
|
+
<<-RUBY
|
38
|
+
class Ability
|
39
|
+
include CanCan::Ability
|
40
|
+
|
41
|
+
def initialize(user)
|
42
|
+
user ||= User.new # guest user
|
43
|
+
|
44
|
+
if user.role? :admin
|
45
|
+
can :manage, :all
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
RUBY
|
50
|
+
end
|
51
|
+
|
52
|
+
inject_into_file 'app/models/user.rb', :before => "end\n" do
|
53
|
+
<<-RUBY
|
54
|
+
|
55
|
+
def is?(role)
|
56
|
+
return !!self.roles.find_by_name( Role.sanitize role )
|
57
|
+
end
|
58
|
+
|
59
|
+
RUBY
|
60
|
+
end
|
61
|
+
|
62
|
+
inject_into_file 'app/controllers/application_controller.rb', :before => "end\n" do
|
63
|
+
<<-RUBY
|
64
|
+
|
65
|
+
rescue_from CanCan::AccessDenied do |exception|
|
66
|
+
flash[:error] = "Access Denied"
|
67
|
+
redirect_to root_url
|
68
|
+
end
|
69
|
+
RUBY
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
append_file 'db/seeds.rb' do
|
74
|
+
<<-FILE
|
75
|
+
# create an example admin.
|
76
|
+
admin = Role.create! :name => 'Admin'
|
77
|
+
user = User.create(email: 'admin@example.org', password: 'password!', password_confirmation: 'password!')
|
78
|
+
user.roles << admin
|
79
|
+
user.save
|
80
|
+
|
81
|
+
FILE
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
gsub_file 'config/routes.rb', /get \"home\/index\"/, ''
|
2
|
+
gsub_file 'config/routes.rb', /get \"users\/index\"/, ''
|
3
|
+
gsub_file 'config/routes.rb', /get \"users\/new\"/, ''
|
4
|
+
gsub_file 'config/routes.rb', /get \"users\/create\"/, ''
|
5
|
+
gsub_file 'config/routes.rb', /get \"users\/edit\"/, ''
|
6
|
+
gsub_file 'config/routes.rb', /get \"users\/update\"/, ''
|
7
|
+
gsub_file 'config/routes.rb', /get \"users\/destroy\"/, ''
|
8
|
+
gsub_file 'config/routes.rb', /get \"dashboard\/index\"/, ''
|
@@ -0,0 +1,34 @@
|
|
1
|
+
say "Building authentication"
|
2
|
+
gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
|
3
|
+
gsub_file 'config/application.rb', /devise_for :users/, "scope 'accounts'\n devise_for :users\n end"
|
4
|
+
|
5
|
+
run 'rails generate devise:install'
|
6
|
+
run 'rails generate devise:views'
|
7
|
+
run 'rails generate devise User'
|
8
|
+
run 'rm app/models/user.rb'
|
9
|
+
create_file 'app/models/user.rb' do
|
10
|
+
<<-RUBY
|
11
|
+
class User < ActiveRecord::Base
|
12
|
+
devise :database_authenticatable, :token_authenticatable, :recoverable, :rememberable, :trackable
|
13
|
+
validates_presence_of :email
|
14
|
+
validates_uniqueness_of :email, :case_sensitive => false
|
15
|
+
validates_format_of :email, :with => Devise::email_regexp
|
16
|
+
end
|
17
|
+
RUBY
|
18
|
+
end
|
19
|
+
|
20
|
+
generate(:migration, "AddNameToUsers name:string")
|
21
|
+
generate(:migration, "AddCachedSlugToUsers cached_slug:string")
|
22
|
+
generate(:migration, "AddDeletedAtToUsers deleted_at:datetime")
|
23
|
+
|
24
|
+
devise_migration = Dir['db/migrate/*_devise_create_users.rb'].first
|
25
|
+
|
26
|
+
gsub_file devise_migration, /# t.token_authenticatable/, 't.token_authenticatable'
|
27
|
+
|
28
|
+
append_file 'db/seeds.rb' do
|
29
|
+
<<-FILE
|
30
|
+
# Setup initial user so we can get in
|
31
|
+
user = User.create! :name => "Example User", :email => "user@example.org", :password => "password!", :password_confirmation => "password!"
|
32
|
+
user.save
|
33
|
+
FILE
|
34
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
run 'rails generate friendly_id'
|
@@ -0,0 +1,55 @@
|
|
1
|
+
gsub_file 'Gemfile', /gem 'sqlite3'\n/, ''
|
2
|
+
|
3
|
+
append_file 'Gemfile' do <<-FILE
|
4
|
+
|
5
|
+
# Added by Shinkansen
|
6
|
+
gem 'pg'
|
7
|
+
gem 'json'
|
8
|
+
gem 'devise'
|
9
|
+
gem 'cancan'
|
10
|
+
gem 'rails_admin'
|
11
|
+
gem 'awesome_print'
|
12
|
+
gem 'haml-rails'
|
13
|
+
gem 'friendly_id'
|
14
|
+
gem 'tripwire_notifier'
|
15
|
+
gem 'stamp'
|
16
|
+
gem 'chronic'
|
17
|
+
gem 'bluecloth'
|
18
|
+
gem 'heroku'
|
19
|
+
gem 'delayed_job_active_record'
|
20
|
+
gem 'hpricot'
|
21
|
+
gem 'ruby_parser'
|
22
|
+
gem 'randumb'
|
23
|
+
gem 'possessive'
|
24
|
+
gem 'paperclip'
|
25
|
+
gem 'paperclip-s3'
|
26
|
+
gem 'factory_girl_rails'
|
27
|
+
gem 'pry'
|
28
|
+
gem 'bourbon'
|
29
|
+
gem 'bootstrap-sass'
|
30
|
+
|
31
|
+
group :production do
|
32
|
+
gem 'newrelic_rpm'
|
33
|
+
end
|
34
|
+
|
35
|
+
group :test do
|
36
|
+
gem 'rspec-rails'
|
37
|
+
gem 'capybara'
|
38
|
+
gem 'capybara-webkit'
|
39
|
+
gem 'shoulda-matchers'
|
40
|
+
gem 'webmock'
|
41
|
+
gem 'vcr'
|
42
|
+
gem 'email_spec'
|
43
|
+
gem 'timecop'
|
44
|
+
end
|
45
|
+
|
46
|
+
group :development do
|
47
|
+
gem 'sqlite3'
|
48
|
+
gem 'guard-livereload'
|
49
|
+
gem 'rack-livereload'
|
50
|
+
end
|
51
|
+
|
52
|
+
FILE
|
53
|
+
end
|
54
|
+
|
55
|
+
run 'bundle install'
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
initializer('haml.rb') do
|
2
|
+
<<-'FILE'
|
3
|
+
Haml::Template.options[:format] = :html5
|
4
|
+
FILE
|
5
|
+
end
|
6
|
+
|
7
|
+
inject_into_file 'config/application.rb', :after => "# Configure the default encoding used in templates for Ruby 1.9.\n" do
|
8
|
+
<<-RUBY
|
9
|
+
config.generators do |g|
|
10
|
+
g.template_engine :haml
|
11
|
+
end
|
12
|
+
RUBY
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
create_file 'lib/tasks/cron.rake' do
|
3
|
+
<<-RUBY
|
4
|
+
desc "This task is called by the Heroku cron add-on"
|
5
|
+
task :cron => :environment do
|
6
|
+
|
7
|
+
# anything here will be run as often as the cron runs.
|
8
|
+
puts "Doing something."
|
9
|
+
|
10
|
+
# this is how you schedule things hourly.
|
11
|
+
# however, the default add-on only does things daily.
|
12
|
+
if Time.now.hour % 4 == 0 # run every four hours
|
13
|
+
puts "Doing something every four hours."
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
RUBY
|
18
|
+
end
|
19
|
+
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
create_file 'config/newrelic.yml' do
|
2
|
+
<<-FILE
|
3
|
+
production:
|
4
|
+
error_collector:
|
5
|
+
capture_source: true
|
6
|
+
enabled: true
|
7
|
+
ignore_errors: ActionController::RoutingError
|
8
|
+
apdex_t: 0.5
|
9
|
+
ssl: false
|
10
|
+
monitor_mode: true
|
11
|
+
license_key: <%= ENV["NEW_RELIC_LICENSE_KEY"] %>
|
12
|
+
developer_mode: false
|
13
|
+
app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>
|
14
|
+
transaction_tracer:
|
15
|
+
record_sql: obfuscated
|
16
|
+
enabled: true
|
17
|
+
stack_trace_threshold: 0.5
|
18
|
+
transaction_threshold: apdex_f
|
19
|
+
capture_params: false
|
20
|
+
log_level: info
|
21
|
+
FILE
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
run "rails g rails_admin:install"
|
2
|
+
|
3
|
+
inject_into_file "config/initializers/rails_admin.rb", :after => "RailsAdmin.config do |config|\n" do
|
4
|
+
<<-RUBY
|
5
|
+
config.authorize_with :cancan
|
6
|
+
RUBY
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
inject_into_file "app/models/ability.rb", :after => "can :manage, :all\n" do
|
11
|
+
<<-RUBY
|
12
|
+
can :access, :rails_admin
|
13
|
+
RUBY
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
run 'rails generate rspec:install'
|
2
|
+
|
3
|
+
inject_into_file 'config/application.rb', :after => "# Configure the default encoding used in templates for Ruby 1.9.\n" do
|
4
|
+
<<-RUBY
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec
|
7
|
+
end
|
8
|
+
RUBY
|
9
|
+
end
|
10
|
+
|
11
|
+
run 'mkdir spec/factories'
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shinkansen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrew Culver
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: thor
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Spin up well-configured Rails apps in minutes rather than hours.
|
111
|
+
email:
|
112
|
+
- andrew.culver@gmail.com
|
113
|
+
executables:
|
114
|
+
- shinkansen
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- LICENSE
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- bin/shinkansen
|
125
|
+
- lib/shinkansen.rb
|
126
|
+
- lib/shinkansen/cli.rb
|
127
|
+
- lib/shinkansen/errors.rb
|
128
|
+
- lib/shinkansen/template_runner.rb
|
129
|
+
- lib/shinkansen/version.rb
|
130
|
+
- shinkansen.gemspec
|
131
|
+
- templates/default/bootstrap.rb
|
132
|
+
- templates/default/default.rb
|
133
|
+
- templates/default/lib/bourbon.rb
|
134
|
+
- templates/default/lib/cancan.rb
|
135
|
+
- templates/default/lib/clean_routes.rb
|
136
|
+
- templates/default/lib/convert_erb_to_haml.rb
|
137
|
+
- templates/default/lib/db.rb
|
138
|
+
- templates/default/lib/db_seed.rb
|
139
|
+
- templates/default/lib/devise.rb
|
140
|
+
- templates/default/lib/factory_girl.rb
|
141
|
+
- templates/default/lib/friendly_id.rb
|
142
|
+
- templates/default/lib/gemfile.rb
|
143
|
+
- templates/default/lib/git.rb
|
144
|
+
- templates/default/lib/haml_generator.rb
|
145
|
+
- templates/default/lib/heroku.rb
|
146
|
+
- templates/default/lib/home_controller.rb
|
147
|
+
- templates/default/lib/initializers.rb
|
148
|
+
- templates/default/lib/livereload.rb
|
149
|
+
- templates/default/lib/new_relic.rb
|
150
|
+
- templates/default/lib/rails_admin.rb
|
151
|
+
- templates/default/lib/rails_clean.rb
|
152
|
+
- templates/default/lib/rspec.rb
|
153
|
+
- templates/default/lib/rspec_clean.rb
|
154
|
+
- templates/default/lib/rvm.rb
|
155
|
+
homepage: http://www.andrewculver.net/
|
156
|
+
licenses: []
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ! '>'
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 1.3.6
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project: shinkansen
|
175
|
+
rubygems_version: 1.8.24
|
176
|
+
signing_key:
|
177
|
+
specification_version: 3
|
178
|
+
summary: shinkansen-0.1
|
179
|
+
test_files: []
|