rails-embryo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.md +9 -0
- data/License.txt +21 -0
- data/README.md +106 -0
- data/bin/rails-embryo +34 -0
- data/lib/embryo/capybara.rb +22 -0
- data/lib/embryo/default_view.rb +58 -0
- data/lib/embryo/factory_girl.rb +19 -0
- data/lib/embryo/filesystem.rb +53 -0
- data/lib/embryo/gemfile.rb +39 -0
- data/lib/embryo/poltergeist.rb +18 -0
- data/lib/embryo/rspec.rb +40 -0
- data/lib/embryo/ruby_version.rb +12 -0
- data/lib/embryo/template_support.rb +79 -0
- data/lib/embryo/test_support.rb +19 -0
- data/lib/rails-embryo/version.rb +5 -0
- data/lib/rails-embryo.rb +49 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3e95ed36619f324f4d2a2687983b012c5b2e303
|
4
|
+
data.tar.gz: 0068e1973549f5910562b6ae20484991a9a9adbb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9f07b225afedc42452afe8c64a7535c944eb1585d2cf7e6f65a6f0cebaeee22146273109274192fb02c53a6f4e4d87aa540037bf9b689e6ff735b563477bb36
|
7
|
+
data.tar.gz: 1959432c41fa440bbd6d59f40edca46ecabe923b03fd1448caa38d4a5e7772c4d6114f1c30cd06b23e992c9167d28f2c57ef5cb40b849c53bcdfc30c79ab4601
|
data/History.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
### Version 0.1.0
|
2
|
+
2014-6-10
|
3
|
+
|
4
|
+
* Templating enhancements with Haml and Bootstrap
|
5
|
+
* Testing enhancements with RSpec, FactoryGirl, Capybara, and
|
6
|
+
Poltergeist
|
7
|
+
* Ruby version and gemset configuration
|
8
|
+
* "embryo" generator to enhance a stock Rails app
|
9
|
+
* "rails-embryo" binary to generate a new Rails app with enhancements
|
data/License.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Brian Auton
|
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,106 @@
|
|
1
|
+
# rails-embryo
|
2
|
+
|
3
|
+
Rails-embryo is a Ruby gem that helps get a new Rails application up and
|
4
|
+
running quickly. In just one step, it adds many of the the tweaks and
|
5
|
+
best practices that I typically spend time tediously adding to any new
|
6
|
+
Rails project.
|
7
|
+
|
8
|
+
The features it adds are based on my personal
|
9
|
+
preferences and development habits, and will probably be made more
|
10
|
+
configurable in the future.
|
11
|
+
|
12
|
+
### Requirements
|
13
|
+
|
14
|
+
* Ruby 1.9.3 or newer
|
15
|
+
* Rails 4.1.1 or newer
|
16
|
+
|
17
|
+
### Getting Started
|
18
|
+
|
19
|
+
Make sure the gem is installed in your current environment (this will
|
20
|
+
also install Rails 4.1.1 if it's not already present).
|
21
|
+
|
22
|
+
gem install rails-embryo
|
23
|
+
|
24
|
+
Once rails-embryo is installed, you can run "rails-embryo new" the
|
25
|
+
same way you would normally run "rails new".
|
26
|
+
|
27
|
+
rails-embryo new my_project
|
28
|
+
|
29
|
+
This will create a new application called "My Project" in a directory
|
30
|
+
called my_project. It's the same skeleton Rails app you would get from
|
31
|
+
"rails new", but with additional rails-embryo-specific enhancements
|
32
|
+
(described below).
|
33
|
+
|
34
|
+
The enhancements include .ruby-version and .ruby-gemset files, so if
|
35
|
+
your system is configured with a Ruby version manager that looks for
|
36
|
+
those files, you should be able to change into the project directory
|
37
|
+
and then run Bundler to configure the gems for your new application.
|
38
|
+
|
39
|
+
cd my_project
|
40
|
+
bundle install
|
41
|
+
|
42
|
+
Your new application will have a working test suite, and you can run
|
43
|
+
it by invoking RSpec (or Rake, but RSpec is faster).
|
44
|
+
|
45
|
+
rspec
|
46
|
+
|
47
|
+
It's also ready to run with the Rails server, so fire up the server
|
48
|
+
and visit localhost:3000 to see your application's
|
49
|
+
Bootstrap-enhanced landing page.
|
50
|
+
|
51
|
+
rails server
|
52
|
+
|
53
|
+
### Running the Generators Directly
|
54
|
+
|
55
|
+
You can also install the rails-embryo enhancements by adding the gem
|
56
|
+
to an existing Rails application and running the "embryo" generator:
|
57
|
+
|
58
|
+
rails generate embryo
|
59
|
+
|
60
|
+
### Enhancements Added
|
61
|
+
|
62
|
+
All of the following enhancements are added by rails-embryo.
|
63
|
+
|
64
|
+
#### Views and Templating
|
65
|
+
|
66
|
+
[Haml](http://haml.info/) and [Bootstrap](http://getbootstrap.com/)
|
67
|
+
are installed, along with a new application layout that replaces the
|
68
|
+
default .erb layout and adds a Bootstrap menu bar to the top of the
|
69
|
+
page.
|
70
|
+
|
71
|
+
A basic "Dashboard" controller with index action is created, so unlike
|
72
|
+
Rails' familiar "welcome aboard" page, you'll have a view that
|
73
|
+
actually uses the application layout. The "Welcome" message on this
|
74
|
+
page is served from a simple `render :text` call in the controller, so
|
75
|
+
the application still won't have any views yet.
|
76
|
+
|
77
|
+
#### Testing Tools
|
78
|
+
|
79
|
+
The latest
|
80
|
+
[RSpec](http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3)
|
81
|
+
is installed, along with a working controller test for the
|
82
|
+
`Welcome#index`
|
83
|
+
action. [FactoryGirl](https://github.com/thoughtbot/factory_girl) is
|
84
|
+
configured and ready for you to add your own factories.
|
85
|
+
|
86
|
+
For acceptance testing,
|
87
|
+
[Capybara](https://github.com/jnicklas/capybara) is installed, along
|
88
|
+
with a simple end-to-end spec that uses it to test the `Welcome#index`
|
89
|
+
action. [Poltergeist](https://github.com/teampoltergeist/poltergeist)
|
90
|
+
is configured and ready for JavaScript-enabled testing; just add `js:
|
91
|
+
true` to any RSpec `scenario` blocks that require JavaScript.
|
92
|
+
|
93
|
+
#### Other Enhancements
|
94
|
+
|
95
|
+
A .ruby-version file is created that specifies Ruby 2.1.2, and a
|
96
|
+
.ruby-gemset file is created with a gemset that has the same name as
|
97
|
+
your application directory. These can be safely ignored on systems
|
98
|
+
that aren't automatically configured to switch Ruby versions and/or
|
99
|
+
gemsets based on these files.
|
100
|
+
|
101
|
+
Some files that normally have lots of documentation comments added
|
102
|
+
when they are first generated (e.g. Gemfile, routes.rb, and others)
|
103
|
+
will have all comments removed by rails-futurizer. These comments may
|
104
|
+
be helpful for new users, but they may be more of a distraction for
|
105
|
+
experienced developers, and they tend to get out of date as Rails and
|
106
|
+
other gems are updated.
|
data/bin/rails-embryo
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "rake"
|
3
|
+
|
4
|
+
task "embryo_new", :path do |task, args|
|
5
|
+
verbose false
|
6
|
+
path = args[:path]
|
7
|
+
if File.exists?(path) && (Dir.entries(path) - [".", ".."]).any?
|
8
|
+
puts "Rerunning Rails app generator in existing application..."
|
9
|
+
sh "rails new #{path} --skip-bundle"
|
10
|
+
puts "Reapplying Embryo extensions to existing application..."
|
11
|
+
sh "cd #{path}; rails g embryo"
|
12
|
+
else
|
13
|
+
puts "Generating standard Rails application..."
|
14
|
+
sh "rails new #{path} --skip-bundle"
|
15
|
+
puts "Adding Embryo extensions to generated application..."
|
16
|
+
sh "cd #{path}; rails g embryo --force"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if ARGV[0] == "new"
|
21
|
+
if ARGV[1]
|
22
|
+
Rake.application["embryo_new"].invoke ARGV[1]
|
23
|
+
else
|
24
|
+
puts 'Missing required argument ("rails-embryo help" for info)'
|
25
|
+
end
|
26
|
+
else
|
27
|
+
puts 'Usage: rails-embryo COMMAND [ARGS]
|
28
|
+
|
29
|
+
Available commands:
|
30
|
+
help Show this message
|
31
|
+
new PATH Create a new Rails application in PATH with rails-embryo
|
32
|
+
enhancements. "rails-embryo new my_app" creates a new
|
33
|
+
application called MyApp in "./my_app"'
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Embryo
|
2
|
+
class Capybara
|
3
|
+
def initialize(filesystem)
|
4
|
+
@filesystem = filesystem
|
5
|
+
end
|
6
|
+
|
7
|
+
def install
|
8
|
+
@filesystem.require_gem "capybara", "~> 2.0", group: :test
|
9
|
+
@filesystem.require_gem "launchy", "~> 2.0", group: :test
|
10
|
+
@filesystem.write "spec/support/capybara.rb", capybara_helper_data
|
11
|
+
end
|
12
|
+
|
13
|
+
def capybara_helper_data
|
14
|
+
'require "capybara/rails"
|
15
|
+
require "capybara/rspec"
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.include Capybara::DSL, type: :feature
|
18
|
+
end
|
19
|
+
'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Embryo
|
2
|
+
class DefaultView
|
3
|
+
def initialize(filesystem)
|
4
|
+
@filesystem = filesystem
|
5
|
+
end
|
6
|
+
|
7
|
+
def install
|
8
|
+
@filesystem.write "config/routes.rb", routes_data
|
9
|
+
@filesystem.write "app/controllers/dashboard_controller.rb", controller_data
|
10
|
+
@filesystem.write "spec/controllers/dashboard_controller_spec.rb", controller_spec_data
|
11
|
+
@filesystem.write "spec/features/dashboard_spec.rb", feature_spec_data
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def controller_data
|
17
|
+
'class DashboardController < ApplicationController
|
18
|
+
def index
|
19
|
+
render text: "Welcome", layout: "application"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
'
|
23
|
+
end
|
24
|
+
|
25
|
+
def routes_data
|
26
|
+
'Rails.application.routes.draw do
|
27
|
+
root "dashboard#index"
|
28
|
+
end
|
29
|
+
'
|
30
|
+
end
|
31
|
+
|
32
|
+
def controller_spec_data
|
33
|
+
'require "rails_helper.rb"
|
34
|
+
|
35
|
+
describe DashboardController do
|
36
|
+
describe "#index" do
|
37
|
+
it "succeeds" do
|
38
|
+
get :index
|
39
|
+
expect(response).to be_success
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
'
|
44
|
+
end
|
45
|
+
|
46
|
+
def feature_spec_data
|
47
|
+
'require "rails_helper.rb"
|
48
|
+
|
49
|
+
feature "Dashboard" do
|
50
|
+
scenario "index view" do
|
51
|
+
visit "/"
|
52
|
+
expect(page).to have_content "Welcome"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Embryo
|
2
|
+
class FactoryGirl
|
3
|
+
def initialize(filesystem)
|
4
|
+
@filesystem = filesystem
|
5
|
+
end
|
6
|
+
|
7
|
+
def install
|
8
|
+
@filesystem.require_gem "factory_girl_rails", "~> 4.0", group: :test
|
9
|
+
@filesystem.write "spec/support/factory_girl.rb", factory_girl_helper_data
|
10
|
+
end
|
11
|
+
|
12
|
+
def factory_girl_helper_data
|
13
|
+
'RSpec.configure do |config|
|
14
|
+
config.include FactoryGirl::Syntax::Methods
|
15
|
+
end
|
16
|
+
'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "embryo/gemfile"
|
2
|
+
require "tmpdir"
|
3
|
+
require "active_support/inflector"
|
4
|
+
|
5
|
+
module Embryo
|
6
|
+
class Filesystem
|
7
|
+
def initialize(generator, *write_options)
|
8
|
+
@generator = generator
|
9
|
+
@write_options = write_options
|
10
|
+
@write_cache = {}
|
11
|
+
@gemfile = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def commit_changes
|
15
|
+
@gemfile.write(*@write_options) if @gemfile
|
16
|
+
sorted_cache.each do |path, data|
|
17
|
+
if data
|
18
|
+
@generator.create_file path, data, *@write_options
|
19
|
+
else
|
20
|
+
@generator.remove_file path, *@write_options if File.exist? path
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def sorted_cache
|
26
|
+
@write_cache.sort.to_h
|
27
|
+
end
|
28
|
+
|
29
|
+
def require_gem(*args)
|
30
|
+
gemfile.require_gem(*args)
|
31
|
+
end
|
32
|
+
|
33
|
+
def gemfile
|
34
|
+
@gemfile ||= Gemfile.current generator: @generator
|
35
|
+
end
|
36
|
+
|
37
|
+
def write(path, data)
|
38
|
+
@write_cache[path] = data
|
39
|
+
end
|
40
|
+
|
41
|
+
def delete(path)
|
42
|
+
@write_cache[path] = nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def application_name
|
46
|
+
File.basename Dir.getwd
|
47
|
+
end
|
48
|
+
|
49
|
+
def application_human_name
|
50
|
+
application_name.titleize
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Embryo
|
2
|
+
class Gemfile
|
3
|
+
attr_accessor :path, :data
|
4
|
+
|
5
|
+
def initialize(path, generator: nil)
|
6
|
+
@path = path
|
7
|
+
@generator = generator
|
8
|
+
@data = File.exist?(path) ? File.read(path) : ""
|
9
|
+
end
|
10
|
+
|
11
|
+
def remove_noise
|
12
|
+
@data = @data.each_line.select { |line| line[0] != "#" }.join
|
13
|
+
@data.gsub!(/\n\n+/, "\n\n")
|
14
|
+
@data.gsub!(/\n+$/, "\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
def require_gem(name, version, options = {})
|
18
|
+
remove_gem name
|
19
|
+
@data << "\n" unless @data[-1] == "\n"
|
20
|
+
@data << "gem '#{name}', '#{version}'"
|
21
|
+
options.each { |key, value| @data << ", #{key}: #{value.inspect}" }
|
22
|
+
@data << "\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
def remove_gem(name)
|
26
|
+
@data = @data.each_line.reject do |line|
|
27
|
+
line.match(/ *gem +'#{name}'/) or line.match(/ *gem +"#{name}"/)
|
28
|
+
end.join
|
29
|
+
end
|
30
|
+
|
31
|
+
def write(force: false)
|
32
|
+
@generator.create_file path, data, force: force
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.current(generator: nil)
|
36
|
+
new "Gemfile", generator: generator
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Embryo
|
2
|
+
class Poltergeist
|
3
|
+
def initialize(filesystem)
|
4
|
+
@filesystem = filesystem
|
5
|
+
end
|
6
|
+
|
7
|
+
def install
|
8
|
+
@filesystem.require_gem "poltergeist", "~> 1.0", group: :test
|
9
|
+
@filesystem.write "spec/support/poltergeist.rb", poltergeist_helper_data
|
10
|
+
end
|
11
|
+
|
12
|
+
def poltergeist_helper_data
|
13
|
+
'require "capybara/poltergeist"
|
14
|
+
Capybara.javascript_driver = :poltergeist
|
15
|
+
'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/embryo/rspec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Embryo
|
2
|
+
class Rspec
|
3
|
+
def initialize(filesystem)
|
4
|
+
@filesystem = filesystem
|
5
|
+
end
|
6
|
+
|
7
|
+
def install
|
8
|
+
@filesystem.require_gem "rspec-rails", "~> 3.0", group: :test
|
9
|
+
@filesystem.write "spec/spec_helper.rb", spec_helper_data
|
10
|
+
@filesystem.write "spec/rails_helper.rb", rails_helper_data
|
11
|
+
end
|
12
|
+
|
13
|
+
def spec_helper_data
|
14
|
+
'RSpec.configure do |config|
|
15
|
+
config.color = true
|
16
|
+
config.order = :random
|
17
|
+
config.mock_with :rspec do |mocks|
|
18
|
+
mocks.verify_partial_doubles = true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
'
|
22
|
+
end
|
23
|
+
|
24
|
+
def rails_helper_data
|
25
|
+
'ENV["RAILS_ENV"] ||= "test"
|
26
|
+
require "spec_helper"
|
27
|
+
require File.expand_path("../../config/environment", __FILE__)
|
28
|
+
require "rspec/rails"
|
29
|
+
|
30
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
31
|
+
ActiveRecord::Migration.maintain_test_schema!
|
32
|
+
|
33
|
+
RSpec.configure do |config|
|
34
|
+
config.use_transactional_fixtures = true
|
35
|
+
config.infer_spec_type_from_file_location!
|
36
|
+
end
|
37
|
+
'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Embryo
|
2
|
+
class TemplateSupport
|
3
|
+
def initialize(filesystem)
|
4
|
+
@filesystem = filesystem
|
5
|
+
end
|
6
|
+
|
7
|
+
def install
|
8
|
+
@filesystem.require_gem "haml", "~> 4.0"
|
9
|
+
@filesystem.require_gem "haml-rails", ">= 0"
|
10
|
+
@filesystem.require_gem "bootstrap-sass", "~> 3.0"
|
11
|
+
@filesystem.write "app/views/layouts/application.html.haml", layout_data
|
12
|
+
@filesystem.write "app/views/layouts/_navigation.html.haml", navigation_data
|
13
|
+
@filesystem.write "app/views/layouts/_messages.html.haml", messages_data
|
14
|
+
@filesystem.write "app/assets/javascripts/application.js", javascript_data
|
15
|
+
@filesystem.write "app/assets/stylesheets/bootstrap-custom.css.scss", stylesheet_data
|
16
|
+
@filesystem.delete "app/views/layouts/application.html.erb"
|
17
|
+
end
|
18
|
+
|
19
|
+
def layout_data
|
20
|
+
'!!! 5
|
21
|
+
%html(lang="en")
|
22
|
+
%head
|
23
|
+
%meta(charset="utf-8")
|
24
|
+
%meta(http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1")
|
25
|
+
%meta(name="viewport" content="width=device-width, initial-scale=1.0")
|
26
|
+
%title ' + @filesystem.application_human_name + '
|
27
|
+
= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true
|
28
|
+
= javascript_include_tag "application", "data_turbolinks_track" => true
|
29
|
+
= csrf_meta_tags
|
30
|
+
%body(role="document")
|
31
|
+
= render "layouts/navigation"
|
32
|
+
.container(role="main")
|
33
|
+
= render "layouts/messages"
|
34
|
+
= yield
|
35
|
+
'
|
36
|
+
end
|
37
|
+
|
38
|
+
def navigation_data
|
39
|
+
'.navbar.navbar-inverse.navbar-fixed-top(role="navigation")
|
40
|
+
.container
|
41
|
+
.navbar-header
|
42
|
+
%button.navbar-toggle(type="button" data-toggle="collapse" data-target=".navbar-collapse")
|
43
|
+
%span.sr-only Toggle navigation
|
44
|
+
%span.icon-bar
|
45
|
+
%span.icon-bar
|
46
|
+
%span.icon-bar
|
47
|
+
= link_to "' + @filesystem.application_human_name + '", root_path, class: "navbar-brand"
|
48
|
+
.navbar-collapse.collapse
|
49
|
+
%ul.nav.navbar-nav
|
50
|
+
%li= link_to "Home", root_path
|
51
|
+
'
|
52
|
+
end
|
53
|
+
|
54
|
+
def messages_data
|
55
|
+
'- {notice: "success", alert: "danger"}.each do |flash_key, alert_type|
|
56
|
+
- if flash[flash_key].present?
|
57
|
+
.alert(class="alert-#{alert_type}")
|
58
|
+
%button.close(type="button" data-dismiss="alert" aria-hidden="true") ×
|
59
|
+
= flash[flash_key]
|
60
|
+
'
|
61
|
+
end
|
62
|
+
|
63
|
+
def javascript_data
|
64
|
+
'//= require jquery
|
65
|
+
//= require jquery_ujs
|
66
|
+
//= require bootstrap
|
67
|
+
//= require turbolinks
|
68
|
+
//= require_tree .
|
69
|
+
'
|
70
|
+
end
|
71
|
+
|
72
|
+
def stylesheet_data
|
73
|
+
'@import "bootstrap";
|
74
|
+
@import "bootstrap/theme";
|
75
|
+
body { padding-top: 70px; }
|
76
|
+
'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "embryo/rspec"
|
2
|
+
require "embryo/factory_girl"
|
3
|
+
require "embryo/capybara"
|
4
|
+
require "embryo/poltergeist"
|
5
|
+
|
6
|
+
module Embryo
|
7
|
+
class TestSupport
|
8
|
+
def initialize(filesystem)
|
9
|
+
@filesystem = filesystem
|
10
|
+
end
|
11
|
+
|
12
|
+
def install
|
13
|
+
Rspec.new(@filesystem).install
|
14
|
+
FactoryGirl.new(@filesystem).install
|
15
|
+
Capybara.new(@filesystem).install
|
16
|
+
Poltergeist.new(@filesystem).install
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/rails-embryo.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
require "rails/generators/app_base"
|
3
|
+
require "embryo/filesystem"
|
4
|
+
require "embryo/ruby_version"
|
5
|
+
require "embryo/test_support"
|
6
|
+
require "embryo/template_support"
|
7
|
+
require "embryo/default_view"
|
8
|
+
|
9
|
+
class EmbryoGenerator < Rails::Generators::Base
|
10
|
+
def install(force: false, bundle: false)
|
11
|
+
@force = force || options.force?
|
12
|
+
clean_files
|
13
|
+
add_embryo_gem
|
14
|
+
Embryo::RubyVersion.new(filesystem).install
|
15
|
+
Embryo::TestSupport.new(filesystem).install
|
16
|
+
Embryo::TemplateSupport.new(filesystem).install
|
17
|
+
Embryo::DefaultView.new(filesystem).install
|
18
|
+
filesystem.commit_changes
|
19
|
+
update_bundle if bundle
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def clean_files
|
25
|
+
gemfile.remove_noise
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_embryo_gem
|
29
|
+
filesystem.require_gem "rails-embryo", "~> #{Rails::Embryo::VERSION}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def filesystem
|
33
|
+
@filesystem ||= Embryo::Filesystem.new self, force: @force
|
34
|
+
end
|
35
|
+
|
36
|
+
def gemfile
|
37
|
+
filesystem.gemfile
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_bundle
|
41
|
+
command = "bundle install"
|
42
|
+
if `which bundle`.strip.present?
|
43
|
+
say_status :run, command
|
44
|
+
`#{command}`
|
45
|
+
else
|
46
|
+
say_status :skip, command, :yellow
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-embryo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Auton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- brianauton@gmail.com
|
58
|
+
executables:
|
59
|
+
- rails-embryo
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- History.md
|
64
|
+
- License.txt
|
65
|
+
- README.md
|
66
|
+
- bin/rails-embryo
|
67
|
+
- lib/embryo/capybara.rb
|
68
|
+
- lib/embryo/default_view.rb
|
69
|
+
- lib/embryo/factory_girl.rb
|
70
|
+
- lib/embryo/filesystem.rb
|
71
|
+
- lib/embryo/gemfile.rb
|
72
|
+
- lib/embryo/poltergeist.rb
|
73
|
+
- lib/embryo/rspec.rb
|
74
|
+
- lib/embryo/ruby_version.rb
|
75
|
+
- lib/embryo/template_support.rb
|
76
|
+
- lib/embryo/test_support.rb
|
77
|
+
- lib/rails-embryo.rb
|
78
|
+
- lib/rails-embryo/version.rb
|
79
|
+
homepage: http://github.com/brianauton/rails-embryo
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.6
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.2.2
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Generators for quick setup of advanced Rails practices
|
103
|
+
test_files: []
|