eastrails 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +0 -0
- data/LICENSE +20 -0
- data/README.md +44 -0
- data/ROADMAP.md +0 -0
- data/bin/eastrails +4 -0
- data/lib/eastrails.rb +12 -0
- data/lib/eastrails/commands/add.rb +31 -0
- data/lib/eastrails/commands/base.rb +18 -0
- data/lib/eastrails/commands/init.rb +63 -0
- data/lib/eastrails/components.rb +18 -0
- data/lib/eastrails/components/base.rb +77 -0
- data/lib/eastrails/components/cancan.rb +12 -0
- data/lib/eastrails/components/capistrano.rb +15 -0
- data/lib/eastrails/components/cucumber.rb +14 -0
- data/lib/eastrails/components/devise.rb +47 -0
- data/lib/eastrails/components/exception_notifier.rb +17 -0
- data/lib/eastrails/components/haml.rb +15 -0
- data/lib/eastrails/components/heroku.rb +29 -0
- data/lib/eastrails/components/jasmine.rb +22 -0
- data/lib/eastrails/components/new_relic.rb +15 -0
- data/lib/eastrails/components/rspec.rb +24 -0
- data/lib/eastrails/components/twitter_bootstrap.rb +16 -0
- data/lib/eastrails/components/vcr.rb +21 -0
- data/lib/eastrails/executor.rb +38 -0
- data/lib/eastrails/generator.rb +13 -0
- data/lib/eastrails/parameters.rb +37 -0
- data/lib/eastrails/scanner/base.rb +17 -0
- data/lib/eastrails/scanner/security.rb +13 -0
- data/lib/eastrails/thor_ext.rb +36 -0
- data/lib/eastrails/version.rb +3 -0
- data/lib/resources/capistrano/deploy.rb +38 -0
- data/lib/resources/default/controllers/welcome_controller.rb +4 -0
- data/lib/resources/default/stylesheets/application-theme-default.css.scss +11 -0
- data/lib/resources/default/stylesheets/application-theme-kickstarter.css.scss +51 -0
- data/lib/resources/default/views/layouts/_messages.html.erb +8 -0
- data/lib/resources/default/views/layouts/_navigation.html.erb +1 -0
- data/lib/resources/default/views/layouts/application.html.erb +35 -0
- data/lib/resources/default/views/welcome/index.html.erb +1 -0
- data/lib/resources/devise/registrations/edit.html.erb +27 -0
- data/lib/resources/devise/registrations/new.html.erb +18 -0
- data/lib/resources/devise/sessions/new.html.erb +16 -0
- data/lib/resources/devise/shared/_links.html.erb +25 -0
- data/lib/resources/navigation/devise.html.erb +20 -0
- data/lib/resources/vcr/features/samples/internet.feature +6 -0
- data/lib/resources/vcr/features/step_definitions/internet_steps.rb +10 -0
- data/lib/resources/vcr/features/support/vcr_cucumber.rb +12 -0
- data/lib/resources/vcr/spec/samples/sample_spec.rb +10 -0
- data/lib/resources/vcr/spec/support/vcr_rspec.rb +13 -0
- metadata +238 -0
data/CHANGELOG.md
ADDED
File without changes
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Carl Lerche, Yehuda Katz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Eastrails generator
|
2
|
+
This is a tool developed by East Agile to simplify the creation of
|
3
|
+
Rails app and the addition of different components to an existing Rails app.
|
4
|
+
|
5
|
+
It provides the following functionalities
|
6
|
+
|
7
|
+
## Create a new rails app
|
8
|
+
```
|
9
|
+
eastrails init <app_name>
|
10
|
+
```
|
11
|
+
We simply bridge that to the rails new app. Prior to that, we create
|
12
|
+
a gemset with the same name of the app and then install everything into
|
13
|
+
that gemset.
|
14
|
+
|
15
|
+
Also you can specify some components for new rails app by passing
|
16
|
+
component names:
|
17
|
+
```
|
18
|
+
eastrails init <app_name> <comma_separated_components_names>
|
19
|
+
```
|
20
|
+
|
21
|
+
Aside, we also provide some aliases:
|
22
|
+
```
|
23
|
+
tdd = rspec,cucumber
|
24
|
+
default = tdd,haml,devise,twitter_bootstrap
|
25
|
+
```
|
26
|
+
For full list supported components, see next section.
|
27
|
+
|
28
|
+
## Adding components
|
29
|
+
Once the project created, you may want to add several components to it:
|
30
|
+
```
|
31
|
+
eastrails add <component_name>
|
32
|
+
```
|
33
|
+
|
34
|
+
These components are supported: Rspec, Cucumber, Heroku, Capistrano,
|
35
|
+
Haml, Devise, New Relic, Jasmine, Exception Notifier, Twitter Boostrap,
|
36
|
+
Cancan, Vcr.
|
37
|
+
Use their underscore form (rspec, new_relic,...) to pass into the `eastrails add` command.
|
38
|
+
With each component, we supply the simplest configuration that make that
|
39
|
+
component available.
|
40
|
+
|
41
|
+
### Check for security holes
|
42
|
+
```
|
43
|
+
eastrails check
|
44
|
+
```
|
data/ROADMAP.md
ADDED
File without changes
|
data/bin/eastrails
ADDED
data/lib/eastrails.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'optparse'
|
3
|
+
require 'thor'
|
4
|
+
require 'active_support/dependencies'
|
5
|
+
|
6
|
+
gem 'rails', '3.2.11'
|
7
|
+
gem 'activesupport', '3.2.11'
|
8
|
+
|
9
|
+
ActiveSupport::Dependencies.autoload_paths << File.expand_path('../', __FILE__)
|
10
|
+
|
11
|
+
module Eastrails
|
12
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Eastrails
|
2
|
+
module Commands
|
3
|
+
class Add < Base
|
4
|
+
def execute
|
5
|
+
components = expand_aliases(parameter.component.split(",")).map do |name|
|
6
|
+
Eastrails::Components.class_for(name).new
|
7
|
+
end
|
8
|
+
components.map(&:add)
|
9
|
+
end
|
10
|
+
|
11
|
+
ALIASES = {
|
12
|
+
"tdd" => ["rspec", "cucumber"],
|
13
|
+
"default" => ["tdd", "haml", "devise", "twitter_bootstrap"]
|
14
|
+
}
|
15
|
+
|
16
|
+
def expand_aliases(names)
|
17
|
+
index = 0
|
18
|
+
while index < names.length
|
19
|
+
name = names[index]
|
20
|
+
if ALIASES[name]
|
21
|
+
names.delete_at index
|
22
|
+
names.insert index, *ALIASES[name]
|
23
|
+
else
|
24
|
+
index += 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
names
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Eastrails
|
2
|
+
module Commands
|
3
|
+
class Base < Eastrails::Generator
|
4
|
+
attr_accessor :parameter
|
5
|
+
|
6
|
+
def initialize(parameter)
|
7
|
+
self.parameter = parameter
|
8
|
+
super()
|
9
|
+
end
|
10
|
+
|
11
|
+
def run_in_shell(cmd)
|
12
|
+
run %{/bin/bash --login -c "#{cmd}"}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Eastrails
|
2
|
+
module Commands
|
3
|
+
class Init < Base
|
4
|
+
include Eastrails::Commands::ThorExt
|
5
|
+
|
6
|
+
def execute
|
7
|
+
params = parameter.args[1..-1]
|
8
|
+
|
9
|
+
app_name = params.first
|
10
|
+
rvm_cmd = "rvm use 1.9.3@#{app_name} --create"
|
11
|
+
eastrails_bin = File.expand_path($0, Dir.pwd)
|
12
|
+
addon_name = if params[1] && !params[1].start_with?("-")
|
13
|
+
params.slice!(1)
|
14
|
+
end
|
15
|
+
theme = multiple_choice(
|
16
|
+
"Please choose a theme: \n",
|
17
|
+
[["Default", "default"], ["Kickstarter", "kickstarter"]]
|
18
|
+
)
|
19
|
+
say_wizard "rails new #{app_name}"
|
20
|
+
run_in_shell %{
|
21
|
+
#{rvm_cmd}
|
22
|
+
gem install rails
|
23
|
+
rails new #{app_name}
|
24
|
+
}
|
25
|
+
|
26
|
+
run_in_shell %{
|
27
|
+
cd #{app_name}
|
28
|
+
git init
|
29
|
+
git add -A
|
30
|
+
git commit -m 'Initialization'
|
31
|
+
}
|
32
|
+
|
33
|
+
remove_file "#{app_name}/public/index.html"
|
34
|
+
|
35
|
+
remove_file "#{app_name}/app/views/layouts/application.html.erb"
|
36
|
+
directory("default/views", "#{app_name}/app/views")
|
37
|
+
directory("default/controllers", "#{app_name}/app/controllers")
|
38
|
+
copy_file("default/stylesheets/application-theme-#{theme}.css.scss",
|
39
|
+
"#{app_name}/app/assets/stylesheets/application-theme.css.scss")
|
40
|
+
|
41
|
+
run_in_shell %{
|
42
|
+
cd #{app_name}
|
43
|
+
git add -A
|
44
|
+
git commit -m 'Make root point to welcome#index'
|
45
|
+
}
|
46
|
+
|
47
|
+
uncomment_lines "#{app_name}/config/routes.rb", /root (:to|to:)/
|
48
|
+
|
49
|
+
if addon_name
|
50
|
+
run_in_shell %{
|
51
|
+
cd #{app_name}
|
52
|
+
#{rvm_cmd}
|
53
|
+
#{eastrails_bin} add #{addon_name}
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
create_file "#{params.first}/.rvmrc" do
|
58
|
+
rvm_cmd + "\n"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Eastrails
|
2
|
+
module Components
|
3
|
+
class << self
|
4
|
+
def class_for(component)
|
5
|
+
("Eastrails::Components::" + component.camelize).constantize
|
6
|
+
rescue NameError => e
|
7
|
+
puts "Unsupported #{component}"
|
8
|
+
supported_components = Dir[File.expand_path("../../components/*.rb", __FILE__)].
|
9
|
+
map { |file_name| File.basename(file_name, ".rb") }.
|
10
|
+
select { |component| component != "base" }.
|
11
|
+
concat(Eastrails::Commands::Add::ALIASES.keys).
|
12
|
+
join(", ")
|
13
|
+
puts "Supported components: #{supported_components}"
|
14
|
+
raise e
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'active_support/core_ext/string'
|
2
|
+
require "haml/html"
|
3
|
+
require "ruby_parser"
|
4
|
+
|
5
|
+
module Eastrails
|
6
|
+
module Components
|
7
|
+
class Base < Eastrails::Generator
|
8
|
+
def add
|
9
|
+
raise "Unimplemented #{self.class.name}#add"
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse_gemfile
|
13
|
+
list_gems = Set.new
|
14
|
+
gemfile_content = File.read("Gemfile")
|
15
|
+
gemfile_content.gsub!(/\r\n?/, "\n")
|
16
|
+
gemfile_content.each_line do |line|
|
17
|
+
if (line = line.strip) =~ /^gem/
|
18
|
+
data = line.match(/gem\s+["']([^"']+)["']/)
|
19
|
+
list_gems.add data[1] if data.length > 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
list_gems.to_a
|
23
|
+
end
|
24
|
+
|
25
|
+
def gems
|
26
|
+
@@gems ||= parse_gemfile
|
27
|
+
end
|
28
|
+
|
29
|
+
def html_to_haml(html)
|
30
|
+
::Haml::HTML.new(html, :erb => true, :xhtml => true).render
|
31
|
+
end
|
32
|
+
def file_html_to_haml(source)
|
33
|
+
begin
|
34
|
+
html = open(source) {|input| input.binmode.read }
|
35
|
+
html_to_haml(html)
|
36
|
+
rescue RubyParser::SyntaxError
|
37
|
+
say_wizard "Ignoring RubyParser::SyntaxError"
|
38
|
+
# special case to accommodate https://github.com/RailsApps/rails-composer/issues/55
|
39
|
+
html = open(source) {|input| input.binmode.read }
|
40
|
+
say_wizard "applying patch" if html.include? "card_month"
|
41
|
+
say_wizard "applying patch" if html.include? "card_year"
|
42
|
+
html = html.gsub(/, {add_month_numbers: true}, {name: nil, id: "card_month"}/, "")
|
43
|
+
html = html.gsub(/, {start_year: Date\.today\.year, end_year: Date\.today\.year\+10}, {name: nil, id: "card_year"}/, "")
|
44
|
+
result = html_to_haml(html)
|
45
|
+
result = result.gsub(/select_month nil/, "select_month nil, {add_month_numbers: true}, {name: nil, id: \"card_month\"}")
|
46
|
+
result = result.gsub(/select_year nil/, "select_year nil, {start_year: Date.today.year, end_year: Date.today.year+10}, {name: nil, id: \"card_year\"}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def dir_html_to_haml(source_dir)
|
51
|
+
Dir[File.expand_path("#{source_dir}/**/*.html.erb")].each do |file_path|
|
52
|
+
destination_path = file_path.gsub(/.erb/, '.haml')
|
53
|
+
File.write(destination_path, file_html_to_haml(file_path))
|
54
|
+
remove_file file_path
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def do_if_installed(*components)
|
59
|
+
if components.any? { |component| component_installed?(component) }
|
60
|
+
yield
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def component_installed?(component)
|
65
|
+
case component
|
66
|
+
when "rspec"
|
67
|
+
File.directory?("spec")
|
68
|
+
when "cucumber"
|
69
|
+
File.directory?("features")
|
70
|
+
when "haml"
|
71
|
+
gems.include? "haml"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Eastrails
|
2
|
+
module Components
|
3
|
+
class Capistrano < Base
|
4
|
+
def add
|
5
|
+
gem "capistrano", :group => :development
|
6
|
+
system "capify ."
|
7
|
+
uncomment_lines 'Capfile', /'deploy\/assets'/
|
8
|
+
copy_file "capistrano/deploy.rb", "config/deploy.rb"
|
9
|
+
puts "==========================="
|
10
|
+
puts "Please change your configuration in config/deploy.rb"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Eastrails
|
2
|
+
module Components
|
3
|
+
class Cucumber < Base
|
4
|
+
def add
|
5
|
+
gem 'cucumber-rails', '>= 1.3.0', :group => :test, :require => false
|
6
|
+
gem 'database_cleaner', :group => :test
|
7
|
+
gem 'capybara', '>= 2.0.1', :group => :test
|
8
|
+
system 'bundle install'
|
9
|
+
system 'rails g cucumber:install -f'
|
10
|
+
gsub_file 'config/cucumber.yml', /std_opts = "/, 'std_opts = "-r features/support/ -r features/step_definitions '
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
module Eastrails
|
4
|
+
module Components
|
5
|
+
class Devise < Base
|
6
|
+
def add
|
7
|
+
unless gems.include?("devise")
|
8
|
+
gem 'devise'
|
9
|
+
system 'bundle install'
|
10
|
+
system 'rails g devise:install'
|
11
|
+
system 'rails g devise User'
|
12
|
+
end
|
13
|
+
|
14
|
+
if File.directory?("spec")
|
15
|
+
FileUtils.mkdir_p("spec/support")
|
16
|
+
create_file 'spec/support/devise.rb' do
|
17
|
+
<<-RUBY
|
18
|
+
RSpec.configure do |config|
|
19
|
+
config.include Devise::TestHelpers, :type => :controller
|
20
|
+
end
|
21
|
+
RUBY
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
unless File.directory?("app/views/devise")
|
26
|
+
directory "devise", "app/views/devise"
|
27
|
+
|
28
|
+
if gems.include?("haml") || gems.include?("haml-rails")
|
29
|
+
dir_html_to_haml("app/views/devise")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
erb_navigation_content = File.read(
|
34
|
+
File.expand_path(find_in_source_paths("navigation/devise.html.erb")))
|
35
|
+
if File.exists?("app/views/layouts/_navigation.html.erb")
|
36
|
+
append_file("app/views/layouts/_navigation.html.erb") do
|
37
|
+
erb_navigation_content
|
38
|
+
end
|
39
|
+
elsif File.exists?("app/views/layouts/_navigation.html.haml")
|
40
|
+
append_file("app/views/layouts/_navigation.html.haml") do
|
41
|
+
html_to_haml(erb_navigation_content)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Eastrails
|
2
|
+
module Components
|
3
|
+
class ExceptionNotifier < Base
|
4
|
+
def add
|
5
|
+
gem "exception_notification", :require => "exception_notifier"
|
6
|
+
inject_into_file "config/environments/production.rb", :after => "::Application.configure do\n" do <<-RUBY
|
7
|
+
config.middleware.use ExceptionNotifier,
|
8
|
+
:email_prefix => "[Exception] ",
|
9
|
+
:sender_address => %{"Exception Notifier" <support@example.com>},
|
10
|
+
:exception_recipients => %w{you@me.com}
|
11
|
+
RUBY
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "haml/html"
|
2
|
+
module Eastrails
|
3
|
+
module Components
|
4
|
+
class Haml < Base
|
5
|
+
include Eastrails::ThorExt
|
6
|
+
|
7
|
+
def add
|
8
|
+
gem "haml-rails", ">= 0.3.5", :group => :development
|
9
|
+
run "bundle install"
|
10
|
+
dir_html_to_haml("app/views")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Eastrails
|
2
|
+
module Components
|
3
|
+
class Heroku < Base
|
4
|
+
def add
|
5
|
+
insert_into_file 'Gemfile', "ruby '1.9.3'\n", :before => /^gem\s+["']rails["']/
|
6
|
+
puts "============================"
|
7
|
+
|
8
|
+
result = `heroku version`
|
9
|
+
if result.index("heroku-toolbelt")
|
10
|
+
system "heroku login"
|
11
|
+
system "heroku create"
|
12
|
+
if gems.index "pg"
|
13
|
+
puts "* Probably you haven't use pg for production"
|
14
|
+
else
|
15
|
+
gem 'pg', :group => :production
|
16
|
+
end
|
17
|
+
puts "Run `git push heroku master` to deploy your code"
|
18
|
+
else
|
19
|
+
puts "You should do followings manually:"
|
20
|
+
puts "- Go to http://heroku.com, sign up (if any) and download Heroku Toolbelt for your OS"
|
21
|
+
puts "- Then add this component again"
|
22
|
+
end
|
23
|
+
|
24
|
+
puts "For more information, see at https://devcenter.heroku.com/articles/rails3"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|