rails_templater 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/TODO.textile +7 -0
- data/bin/templater +6 -0
- data/lib/rails_templater/cli.rb +13 -0
- data/lib/rails_templater/version.rb +3 -0
- data/lib/rails_templater.rb +10 -0
- data/lib/template/core_extensions.rb +53 -0
- data/lib/template/recipes/cucumber.rb +22 -0
- data/lib/template/recipes/default.rb +19 -0
- data/lib/template/recipes/design.rb +16 -0
- data/lib/template/recipes/factory_girl.rb +5 -0
- data/lib/template/recipes/haml.rb +5 -0
- data/lib/template/recipes/jquery.rb +7 -0
- data/lib/template/recipes/mongoid.rb +7 -0
- data/lib/template/recipes/remarkable.rb +6 -0
- data/lib/template/recipes/rspec.rb +12 -0
- data/lib/template/snippets/cucumber/factory_girl +5 -0
- data/lib/template/snippets/rails/generators +4 -0
- data/lib/template/snippets/rspec/mongoid +5 -0
- data/lib/template/templater.rb +21 -0
- data/lib/template/templates/git/gitignore +8 -0
- data/lib/template/templates/haml/app/views/layouts/application.html.haml +9 -0
- data/lib/template/templates/mongoid/features/step_definitions/mongoid_steps.rb +4 -0
- data/lib/template/templates/mongoid/features/support/hooks.rb +3 -0
- data/rails_templater.gemspec +25 -0
- metadata +139 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg/*
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Kevin Faustino
|
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,42 @@
|
|
1
|
+
# Rails Templater
|
2
|
+
|
3
|
+
This is a template which allows creating new Ruby on Rails 3 applications quickly using some opinionated defaults. It is inspired by ffmike's [BigOldRailsTemplate](http://github.com/ffmike/BigOldRailsTemplate) Rails 2 template project.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
gem install rails_templater
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
At the command prompt, create a new Rails application using the *templater* command:
|
12
|
+
|
13
|
+
templater myapp_name
|
14
|
+
|
15
|
+
## Generated Application
|
16
|
+
|
17
|
+
Rails Templater will generate the following:
|
18
|
+
|
19
|
+
### Ruby on Rails
|
20
|
+
|
21
|
+
* Uses [Haml](http://haml-lang.com) as the template engine
|
22
|
+
* Uses [Sass](http://sass-lang.com) for generating CSS
|
23
|
+
* [jQuery](http://jquery.com/) for JavaScript over Prototype
|
24
|
+
* Optionally uses [Compass](http://compass-style.org) for design with the blueprint/semantic framework
|
25
|
+
|
26
|
+
## Database
|
27
|
+
|
28
|
+
* Uses [Mongoid](http://mongoid.org/) as the Object Document Mapper
|
29
|
+
* TODO: Optionally add the ability for other databases
|
30
|
+
|
31
|
+
## Testing
|
32
|
+
|
33
|
+
* [RSpec](http://github.com/rspec/rspec) for testing
|
34
|
+
* [factory_girl](http://github.com/thoughtbot/factory_girl) for fixture replacement
|
35
|
+
* [remarkable](http://github.com/remarkable/remarkable) for ActiveModel RSpec matchers
|
36
|
+
* Optionally uses [Cucumber](http://github.com/aslakhellesoy/cucumber-rails) for integration tests
|
37
|
+
|
38
|
+
## Note on Patches/Pull Requests
|
39
|
+
|
40
|
+
* Fork the project.
|
41
|
+
* Make your feature addition or bug fix in a branch.
|
42
|
+
* Send me a pull request.
|
data/Rakefile
ADDED
data/TODO.textile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
h1. TODO
|
2
|
+
|
3
|
+
* Write a generator for FactoryGirl which uses the 2.0.0 syntax
|
4
|
+
* Clean up questions to users during template run
|
5
|
+
* Make choices agnostic
|
6
|
+
* Add a choice to load a local configuration YAML with defaults for template input
|
7
|
+
* Update Mongoid to RC once stabalized
|
data/bin/templater
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'thor/group'
|
2
|
+
|
3
|
+
module RailsTemplater
|
4
|
+
class Cli < Thor::Group
|
5
|
+
argument :application_name, :type => :string, :desc => "The name of the rails application"
|
6
|
+
desc "Generates a new Rails application with templater'"
|
7
|
+
|
8
|
+
def run_templater
|
9
|
+
system("rails new #{application_name} -JOT -m #{RailsTemplater::template_path}")
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generators
|
3
|
+
module Actions
|
4
|
+
|
5
|
+
attr_accessor :post_bundler_strategies
|
6
|
+
attr_reader :template_options
|
7
|
+
|
8
|
+
def initialize_templater
|
9
|
+
@post_bundler_strategies = []
|
10
|
+
@template_options = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute_post_bundler_strategies
|
14
|
+
post_bundler_strategies.each {|strategy| strategy.call }
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_options
|
18
|
+
say "Would you like to use a design framework?\n", Thor::Shell::Color::BLUE
|
19
|
+
print_table [ ['Option','Framework'], ['1', 'Compass with blueprint semantic'] ], :ident => 2
|
20
|
+
design_input = ask("Option: ", Thor::Shell::Color::BLUE)
|
21
|
+
@template_options[:design] = case design_input
|
22
|
+
when "1"
|
23
|
+
:compass
|
24
|
+
else
|
25
|
+
:none
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def recipe(name)
|
30
|
+
File.join File.dirname(__FILE__), 'recipes', "#{name}.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
def load_snippet(name, group)
|
34
|
+
path = File.expand_path name, snippet_path(group)
|
35
|
+
File.read path
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_template(name, group)
|
39
|
+
path = File.expand_path name, template_path(group)
|
40
|
+
File.read path
|
41
|
+
end
|
42
|
+
|
43
|
+
def snippet_path(name)
|
44
|
+
File.join(File.dirname(__FILE__), 'snippets', name)
|
45
|
+
end
|
46
|
+
|
47
|
+
def template_path(name)
|
48
|
+
File.join(File.dirname(__FILE__), 'templates', name)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
gem 'capybara', '0.4.0', :group => :test
|
2
|
+
gem 'cucumber-rails', :group => :test
|
3
|
+
gem 'launchy', :group => :test
|
4
|
+
|
5
|
+
post_bundler_strategies << lambda do
|
6
|
+
generate 'cucumber:install --rspec --capybara --skip-database'
|
7
|
+
|
8
|
+
gsub_file 'features/support/env.rb',
|
9
|
+
"require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript", ''
|
10
|
+
|
11
|
+
inject_into_file "features/support/env.rb",
|
12
|
+
"\nCapybara.save_and_open_page_path = 'tmp/capybara/'",
|
13
|
+
:after => 'Capybara.default_selector = :css'
|
14
|
+
|
15
|
+
inject_into_file "features/support/env.rb", load_snippet('factory_girl', 'cucumber'), :after => 'ActionController::Base.allow_rescue = false'
|
16
|
+
|
17
|
+
# Mongoid truncation strategy
|
18
|
+
create_file 'features/support/hooks.rb', load_template('features/support/hooks.rb', 'mongoid')
|
19
|
+
|
20
|
+
# Compliment to factory_girl step definitions
|
21
|
+
create_file 'features/step_definitions/mongoid_steps.rb', load_template('features/step_definitions/mongoid_steps.rb', 'mongoid')
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Delete all unnecessary files
|
2
|
+
remove_file "README"
|
3
|
+
remove_file "public/index.html"
|
4
|
+
remove_file "public/robots.txt"
|
5
|
+
remove_file "public/images/rails.png"
|
6
|
+
|
7
|
+
create_file 'README'
|
8
|
+
create_file 'log/.gitkeep'
|
9
|
+
create_file 'tmp/.gitkeep'
|
10
|
+
|
11
|
+
gsub_file 'config/application.rb', 'require "rails/test_unit/railtie"', '# require "rails/test_unit/railtie"'
|
12
|
+
|
13
|
+
get "http://html5shiv.googlecode.com/svn/trunk/html5.js", "public/javascripts/html5.js"
|
14
|
+
|
15
|
+
git :init
|
16
|
+
|
17
|
+
append_file '.gitignore', load_template('gitignore','git')
|
18
|
+
|
19
|
+
gem 'rails3-generators'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
if template_options[:design] == :compass
|
2
|
+
gem 'compass'
|
3
|
+
|
4
|
+
# TODO: support more than one framework from compass
|
5
|
+
compass_sass_dir = "app/stylesheets"
|
6
|
+
compass_css_dir = "public/stylesheets/compiled"
|
7
|
+
|
8
|
+
compass_command = "compass init rails . --using blueprint/semantic --css-dir=#{compass_css_dir} --sass-dir=#{compass_sass_dir} "
|
9
|
+
|
10
|
+
post_bundler_strategies << lambda do
|
11
|
+
puts "Beginning Compass setup"
|
12
|
+
run compass_command
|
13
|
+
puts "Compass has been setup"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
gem 'remarkable_activemodel', '>=4.0.0.alpha4', :group => :test
|
2
|
+
gem 'remarkable_mongoid', :group => :test
|
3
|
+
|
4
|
+
post_bundler_strategies << lambda do
|
5
|
+
inject_into_file 'spec/spec_helper.rb', "\nrequire 'remarkable/active_model'\nrequire 'remarkable/mongoid'", :after => "require 'rspec/rails'"
|
6
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
gem 'rspec-rails', '>= 2.4.1', :group => [:development]
|
2
|
+
|
3
|
+
post_bundler_strategies << lambda do
|
4
|
+
generate 'rspec:install'
|
5
|
+
|
6
|
+
spec_helper_path = 'spec/spec_helper.rb'
|
7
|
+
|
8
|
+
gsub_file spec_helper_path, 'config.fixture_path = "#{::Rails.root}/spec/fixtures"', ''
|
9
|
+
gsub_file spec_helper_path, /(config.use_transactional_fixtures = true)/, '# \1'
|
10
|
+
inject_into_file spec_helper_path, load_snippet('mongoid', 'rspec'), :after => "# config.use_transactional_fixtures = true\n"
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'core_extensions.rb')
|
2
|
+
|
3
|
+
initialize_templater
|
4
|
+
|
5
|
+
required_recipes = %w(default mongoid jquery haml rspec factory_girl remarkable)
|
6
|
+
required_recipes.each {|required_recipe| apply recipe(required_recipe)}
|
7
|
+
|
8
|
+
say("\nInitial generation complete\n", Thor::Shell::Color::YELLOW)
|
9
|
+
|
10
|
+
load_options
|
11
|
+
apply(recipe('cucumber')) if yes?("\nWould you like to add integration testing with Cucumber? [y|n]: ", Thor::Shell::Color::BLUE)
|
12
|
+
apply recipe('design')
|
13
|
+
|
14
|
+
run 'bundle install'
|
15
|
+
|
16
|
+
execute_post_bundler_strategies
|
17
|
+
|
18
|
+
environment load_snippet('generators', 'rails')
|
19
|
+
|
20
|
+
git :add => "."
|
21
|
+
git :commit => "-m 'Initial commit'"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/rails_templater/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "rails_templater"
|
6
|
+
s.version = RailsTemplater::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Kevin Faustino"]
|
9
|
+
s.email = ["kevin.faustino@gmail.com"]
|
10
|
+
s.homepage = "http://rubygems.org/gems/rails_templater"
|
11
|
+
s.summary = "Template generator for Ruby on Rails 3 applications"
|
12
|
+
s.description = "Template generator for Ruby on Rails 3 applications"
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "rails_templater"
|
16
|
+
|
17
|
+
s.add_dependency "rails", "~> 3.0.3"
|
18
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
22
|
+
s.require_path = 'lib'
|
23
|
+
|
24
|
+
s.add_dependency("thor", ["~> 0.14.6"])
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_templater
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Kevin Faustino
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-13 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rails
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
- 3
|
32
|
+
version: 3.0.3
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: bundler
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 0
|
46
|
+
- 0
|
47
|
+
version: 1.0.0
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: thor
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
- 14
|
61
|
+
- 6
|
62
|
+
version: 0.14.6
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
65
|
+
description: Template generator for Ruby on Rails 3 applications
|
66
|
+
email:
|
67
|
+
- kevin.faustino@gmail.com
|
68
|
+
executables:
|
69
|
+
- templater
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
extra_rdoc_files: []
|
73
|
+
|
74
|
+
files:
|
75
|
+
- .gitignore
|
76
|
+
- Gemfile
|
77
|
+
- LICENSE
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- TODO.textile
|
81
|
+
- bin/templater
|
82
|
+
- lib/rails_templater.rb
|
83
|
+
- lib/rails_templater/cli.rb
|
84
|
+
- lib/rails_templater/version.rb
|
85
|
+
- lib/template/core_extensions.rb
|
86
|
+
- lib/template/recipes/cucumber.rb
|
87
|
+
- lib/template/recipes/default.rb
|
88
|
+
- lib/template/recipes/design.rb
|
89
|
+
- lib/template/recipes/factory_girl.rb
|
90
|
+
- lib/template/recipes/haml.rb
|
91
|
+
- lib/template/recipes/jquery.rb
|
92
|
+
- lib/template/recipes/mongoid.rb
|
93
|
+
- lib/template/recipes/remarkable.rb
|
94
|
+
- lib/template/recipes/rspec.rb
|
95
|
+
- lib/template/snippets/cucumber/factory_girl
|
96
|
+
- lib/template/snippets/rails/generators
|
97
|
+
- lib/template/snippets/rspec/mongoid
|
98
|
+
- lib/template/templater.rb
|
99
|
+
- lib/template/templates/git/gitignore
|
100
|
+
- lib/template/templates/haml/app/views/layouts/application.html.haml
|
101
|
+
- lib/template/templates/mongoid/features/step_definitions/mongoid_steps.rb
|
102
|
+
- lib/template/templates/mongoid/features/support/hooks.rb
|
103
|
+
- rails_templater.gemspec
|
104
|
+
has_rdoc: true
|
105
|
+
homepage: http://rubygems.org/gems/rails_templater
|
106
|
+
licenses: []
|
107
|
+
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
version: "0"
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
segments:
|
127
|
+
- 1
|
128
|
+
- 3
|
129
|
+
- 6
|
130
|
+
version: 1.3.6
|
131
|
+
requirements: []
|
132
|
+
|
133
|
+
rubyforge_project: rails_templater
|
134
|
+
rubygems_version: 1.3.7
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: Template generator for Ruby on Rails 3 applications
|
138
|
+
test_files: []
|
139
|
+
|