rails_templatizer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ 0.0.1 (2011-07-07)
2
+ ------------------
3
+ * created template and added all recipes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rails_templatizer.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ Rails Templatizer
2
+ ==============
3
+
4
+ Generates a new rails application fully customized to your needs. It will create and configure an application based on your choices.
5
+
6
+ Compability
7
+ ===========
8
+
9
+ Tested on Rails 3.0.x and Ruby 1.9.2
10
+
11
+ Installation
12
+ ============
13
+
14
+ * Add to your Gemfile:
15
+ gem "rails_templatizer"
16
+
17
+ * Run following command for instructions:
18
+ rails_templatizer --help
19
+
20
+ Todo
21
+ ====
22
+
23
+ - Add more choices and alternatives
24
+
25
+ License
26
+ =======
27
+
28
+ [MIT](MIT-LICENSE)
29
+
30
+ Copyright (c) 2011 Patrick Bartels.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require "rails_templatizer/version"
4
+
5
+ rvm_ruby = ARGV[0]
6
+ app_name = ARGV[1]
7
+ options = ARGV[2..10]
8
+ if !(rvm_ruby && app_name) || (ARGV[0] == '--help')
9
+ puts <<-USAGE
10
+ Rails Templatizer #{RailsTemplatizer::VERSION}
11
+
12
+ Usage:
13
+ rails_templatizer RVM_RUBY APP_NAME [options]
14
+
15
+ Options:
16
+ -r # Skip RVM
17
+ # default: false
18
+
19
+ Example:
20
+ rails_templatizer 1.9.2-p136 blog
21
+ USAGE
22
+ exit
23
+ end
24
+
25
+ # TODO remove after testing!
26
+ # options = ['-r']
27
+
28
+ USE_RVM = !options.include?('-r')
29
+
30
+ ## RVM
31
+ if USE_RVM
32
+ rvm_lib_path = "#{`echo $rvm_path`.strip}/lib"
33
+ $LOAD_PATH.unshift(rvm_lib_path) unless $LOAD_PATH.include?(rvm_lib_path)
34
+ require 'rvm'
35
+
36
+ @env = RVM::Environment.new(rvm_ruby)
37
+ @env.gemset_create(app_name)
38
+ @env.gemset_use!(app_name)
39
+
40
+ ## Gems
41
+
42
+ # Check for gem prerequisites
43
+ %w{
44
+ bundler rails
45
+ warden devise cancan sass haml haml-rails nifty-generators formtastic rspec-rails factory_girl_rails
46
+ spork jasmine faker redgreen autotest-fsevent autotest-growl rails3-generators jammit jquery-rails colored
47
+ capistrano compass}.each do |component|
48
+ unless Gem.available?(component)
49
+ print "Installing #{component}... "
50
+ print "done\n" if @env.system("gem", "install", component)
51
+ else
52
+ puts "Already installed #{component}."
53
+ end
54
+ end
55
+ end
56
+
57
+ template_file = File.join(File.expand_path(File.dirname(__FILE__)), '..', 'recipes', 'app_template.rb')
58
+ system("rails new #{app_name} -JT -d mysql -m #{template_file}")
@@ -0,0 +1,3 @@
1
+ module RailsTemplatizer
2
+ # Your code goes here...
3
+ end
@@ -0,0 +1,3 @@
1
+ module RailsTemplatizer
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rails_templatizer/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rails_templatizer"
7
+ s.version = RailsTemplatizer::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Patrick Bartels"]
10
+ s.email = ["patrick@bartels.ug"]
11
+ s.homepage = %q{http://bartels.ug}
12
+ s.summary = %q{Rails Templatizer summary}
13
+ s.description = %q{Rails Templatizer description}
14
+
15
+ s.rubyforge_project = "rails_templatizer"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,100 @@
1
+ ## Check for gem prerequisites
2
+ %w{colored}.each do |component|
3
+ unless Gem.available?(component)
4
+ run "gem install #{component} -q"
5
+ Gem.refresh
6
+ Gem.activate(component)
7
+ end
8
+ end
9
+
10
+ require 'colored'
11
+ puts "\n All required gems installed\n".yellow
12
+
13
+ puts "\n Applying application specific changes".yellow
14
+ apply File.join File.dirname(__FILE__), "application.rb"
15
+
16
+ puts "\n Applying HAML and SASS specific changes".yellow
17
+ apply File.join File.dirname(__FILE__), "haml_and_sass.rb"
18
+
19
+ puts "\n Applying JQuery specific changes".yellow
20
+ apply File.join File.dirname(__FILE__), "jquery.rb"
21
+
22
+ puts "\n Applying Formtastic specific changes".yellow
23
+ apply File.join File.dirname(__FILE__), "formtastic.rb"
24
+
25
+ puts "\n Applying RSpec specific changes".yellow
26
+ apply File.join File.dirname(__FILE__), "rspec.rb"
27
+
28
+ puts "\n Applying FactoryGirl specific changes".yellow
29
+ apply File.join File.dirname(__FILE__), "factory_girl.rb"
30
+
31
+ inject_into_file('config/application.rb', :after => "config.filter_parameters += [:password, :password_confirmation]") do
32
+ %q{
33
+ config.generators do |g|
34
+ g.stylesheets false
35
+ g.form_builder :formtastic
36
+ g.template_engine :haml
37
+ g.test_framework :rspec, :fixture => true, :views => false
38
+ g.integration_tool :rspec, :fixture => true, :views => true
39
+ g.fixture_replacement :factory_girl, :dir => "spec/factories"
40
+ end
41
+
42
+ # Global Sass Option
43
+ Sass::Plugin.options[:template_location] = { 'app/stylesheets' => 'public/stylesheets' }
44
+ }
45
+ end
46
+
47
+ puts "\n Applying Rails 3 Generators specific changes".yellow
48
+ apply File.join File.dirname(__FILE__), "rails3_generators.rb"
49
+
50
+ puts "\n Applying Devise, Warden and Cancan specific changes".yellow
51
+ apply File.join File.dirname(__FILE__), "authentication.rb"
52
+
53
+ puts "\n Applying Nifty Generators specific changes".yellow
54
+ apply File.join File.dirname(__FILE__), "nifty_generators.rb"
55
+
56
+ puts "\n Applying Auotest specific changes".yellow
57
+ apply File.join File.dirname(__FILE__), "autotest.rb"
58
+
59
+ puts "\n Applying Jasmine specific changes".yellow
60
+ apply File.join File.dirname(__FILE__), "jasmine.rb"
61
+
62
+ puts "\n Applying Spork specific changes".yellow
63
+ apply File.join File.dirname(__FILE__), "spork.rb"
64
+
65
+ puts "\n Applying Jammit specific changes".yellow
66
+ apply File.join File.dirname(__FILE__), "jammit.rb"
67
+
68
+ puts "\n Applying RVM specific changes".yellow
69
+ apply File.join File.dirname(__FILE__), "rvm.rb"
70
+
71
+ puts "\n Applying Faker specific changes".yellow
72
+ apply File.join File.dirname(__FILE__), "faker.rb"
73
+
74
+ puts "\n Applying Welcome Controller specific changes".yellow
75
+ apply File.join File.dirname(__FILE__), "welcome.rb"
76
+
77
+ puts "\n Clearing default index".yellow
78
+ remove_file "public/index.html"
79
+ remove_file "public/images/rails.png"
80
+
81
+ puts "\n Applying Javascript specific changes".yellow
82
+ apply File.join File.dirname(__FILE__), "javascript.rb"
83
+
84
+ puts "\n Applying Capistrano specific changes".yellow
85
+ apply File.join File.dirname(__FILE__), "capistrano.rb"
86
+
87
+ puts "\n Applying Compass specific changes".yellow
88
+ apply File.join File.dirname(__FILE__), "compass.rb"
89
+
90
+ puts "\n Applying Friendly ID specific changes".yellow
91
+ apply File.join File.dirname(__FILE__), "friendly_id.rb"
92
+
93
+ puts "\n Running bundle install".yellow
94
+ run "bundle install > /dev/null"
95
+
96
+ puts "\n Applying Git specific changes".yellow
97
+ apply File.join File.dirname(__FILE__), "git.rb"
98
+
99
+ puts "\n Runing all migrations".yellow
100
+ run "rake db:migrate"
@@ -0,0 +1 @@
1
+ gsub_file 'config/application.rb', /:password\]/, ':password, :password_confirmation]'
@@ -0,0 +1,89 @@
1
+ # Warden and Devise for security
2
+ gem 'warden', '1.0.4'
3
+ gem 'devise', '1.3.0'
4
+ # Cancan for authorization management
5
+ gem 'cancan'
6
+
7
+ generate "devise:install -q"
8
+ generate "devise:views"
9
+ generate "devise User"
10
+ generate "cancan:ability"
11
+
12
+ # Insert devise specific configuration
13
+ inject_into_file('config/environments/development.rb', :after => %[config.action_mailer.raise_delivery_errors = false]) do
14
+ %q{
15
+
16
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
17
+ }
18
+ end
19
+
20
+ inject_into_file('config/environments/production.rb', :after => %[# config.action_mailer.raise_delivery_errors = false]) do
21
+ %q{
22
+
23
+ # TODO set actual host of application
24
+ # config.action_mailer.default_url_options = { :host => 'localhost:3000' }
25
+ }
26
+ end
27
+
28
+ inject_into_file('config/environments/test.rb', :after => %[config.action_mailer.delivery_method = :test]) do
29
+ %q{
30
+
31
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
32
+ }
33
+ end
34
+
35
+ ## Devise routes
36
+ inject_into_file('config/routes.rb', :after => %[devise_for :users]) do
37
+ %q{
38
+
39
+ devise_scope :user do
40
+ get "signup", :to => "devise/registrations#new"
41
+ get "login", :to => "devise/sessions#new"
42
+ get "logout", :to => "devise/sessions#destroy"
43
+ end
44
+ }
45
+ end
46
+
47
+ ## Login files
48
+ # signin = <<-SIGNIN
49
+ # <h2>Login</h2>
50
+ #
51
+ # <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
52
+ # <%= f.inputs do %>
53
+ # <%= f.input :email, :as => :email %>
54
+ # <%= f.input :password, :as => :password %>
55
+ # <% if devise_mapping.rememberable? -%>
56
+ # <%= f.input :remember_me, :as => :boolean %>
57
+ # <% end -%>
58
+ # <% end %>
59
+ # <%= f.buttons do %>
60
+ # <%= f.commit_button "Login" %>
61
+ # <% end %>
62
+ # <% end %>
63
+ #
64
+ # <%= render :partial => "devise/shared/links" %>
65
+ # SIGNIN
66
+ #
67
+ # remove_file "app/views/devise/sessions/new.html.erb"
68
+ # create_file "app/views/devise/sessions/new.html.erb", signin
69
+
70
+ # signup = <<-SIGNUP
71
+ # <h2>Signup</h2>
72
+ #
73
+ # <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
74
+ # <%= devise_error_messages! %>
75
+ # <%= f.inputs do %>
76
+ # <%= f.input :email, :as => :email %>
77
+ # <%= f.input :password, :as => :password %>
78
+ # <% end %>
79
+ # <%= f.buttons do %>
80
+ # <%= f.commit_button "Signup" %>
81
+ # <% end %>
82
+ # <% end %>
83
+ #
84
+ # <%= render :partial => "devise/shared/links" %>
85
+ # SIGNUP
86
+ #
87
+ # remove_file "app/views/devise/registrations/new.html.erb"
88
+ # create_file "app/views/devise/registrations/new.html.erb", signup
89
+
@@ -0,0 +1,13 @@
1
+ gem "ZenTest", :group => [:test]
2
+ gem "autotest-rails", :group => [:test]
3
+ gem "redgreen", :group => [:test]
4
+ gem "autotest-fsevent", :group => [:test]
5
+ gem "autotest-growl", :group => [:test]
6
+
7
+ # Enable redgreen in autotest
8
+ autotest = <<-AUTOTEST
9
+ require 'redgreen/autotest'
10
+ require 'autotest/growl'
11
+ require 'autotest/fsevent'
12
+ AUTOTEST
13
+ create_file '.autotest', autotest
@@ -0,0 +1,3 @@
1
+ gem 'capistrano'
2
+
3
+ capify!
@@ -0,0 +1,5 @@
1
+ gem 'compass'
2
+
3
+ run "compass init rails --syntax sass --force > /dev/null"
4
+
5
+ remove_file 'app/stylesheets/ie.sass'
@@ -0,0 +1,8 @@
1
+ gem "factory_girl_rails", :group => [:test]
2
+
3
+ # Modify spec_helper
4
+ inject_into_file('spec/spec_helper.rb', :after => "require 'rspec/rails'") do
5
+ %q{
6
+ require 'factory_girl'
7
+ }
8
+ end
data/recipes/faker.rb ADDED
@@ -0,0 +1 @@
1
+ gem "faker", :group => [:test]
@@ -0,0 +1,3 @@
1
+ gem 'formtastic', '2.0.0.rc1'
2
+
3
+ generate 'formtastic:install'
@@ -0,0 +1,15 @@
1
+ gem "friendly_id", "~> 3.2.1"
2
+ generate "friendly_id"
3
+
4
+ inject_into_file('app/models/user.rb', :after => %[class User < ActiveRecord::Base]) do
5
+ %q{
6
+ has_friendly_id :login, :use_slug => true
7
+ }
8
+ end
9
+
10
+ inject_into_file('db/migrate/*_devise_create_users.rb', :after => %[ t.trackable]) do
11
+ %q{
12
+ # Friendly ID attribute
13
+ t.string :cached_slug
14
+ }
15
+ end
data/recipes/git.rb ADDED
@@ -0,0 +1,23 @@
1
+ ## Git
2
+
3
+ gitignore = <<-END
4
+ .bundle
5
+ .DS_Store
6
+ config/database.yml
7
+ coverage/*
8
+ db/*.sqlite3
9
+ log/*.log
10
+ mkmf.log
11
+ public/stylesheets/*
12
+ publc/system/*
13
+ rdoc/*
14
+ tmp/**/*
15
+ END
16
+
17
+ # Re-Make gitignore
18
+ remove_file ".gitignore"
19
+ create_file ".gitignore", gitignore
20
+
21
+ git :init => "-q"
22
+ git :add => "."
23
+ git :commit => "-a -q -m 'Initial application'"
@@ -0,0 +1,28 @@
1
+ # HAML and SASS for Templating
2
+ gem 'sass'
3
+ gem 'haml'
4
+ gem 'haml-rails'
5
+
6
+ # Make the SASS directory and base file
7
+ empty_directory "app/stylesheets"
8
+ default_style = <<-LAYOUT
9
+ body
10
+ text-align: left
11
+ font-size: 12px
12
+
13
+ a, a:hover, a:visited
14
+ color: blue
15
+
16
+ .horizontal-list li
17
+ display: inline
18
+
19
+ .horizontal-list li a
20
+ padding: 0.1em
21
+
22
+ #hd h1
23
+ font-size: 1.5em
24
+
25
+ .login-bar
26
+ float: right
27
+ LAYOUT
28
+ create_file "app/stylesheets/application.sass", default_style
data/recipes/jammit.rb ADDED
@@ -0,0 +1,34 @@
1
+ gem "jammit"
2
+
3
+ ## Jammit assets
4
+ assets = <<-ASSETS
5
+ package_assets: off
6
+ template_function: _.template
7
+ javascripts:
8
+ app:
9
+ # - public/javascripts/vendor/excanvas.js
10
+ - public/javascripts/vendor/jquery.min.js
11
+ - public/javascripts/vendor/jquery-ui.min.js
12
+ # - public/javascripts/vendor/jquery.jsPlumb-1.2.5-all-min.js
13
+ - public/javascripts/vendor/underscore-min.js
14
+ - public/javascripts/vendor/backbone-min.js
15
+ - public/javascripts/vendor/autoresize.jquery.js
16
+ - public/javascripts/application.js
17
+ - public/javascripts/vendor/jquery.dotimeout.js
18
+ # - public/javascripts/models/Node.js
19
+ - public/javascripts/models/*.js
20
+ - public/javascripts/**/*.js
21
+ - app/views/**/*.jst
22
+ templates_js:
23
+ - app/views/**/*.jst
24
+
25
+ stylesheets:
26
+ app:
27
+ - public/stylesheets/reset.css
28
+ - public/stylesheets/mixins.css
29
+ - public/stylesheets/*.css
30
+
31
+ ASSETS
32
+
33
+ remove_file "config/assets.yml"
34
+ create_file "config/assets.yml", assets
@@ -0,0 +1,6 @@
1
+ gem "jasmine", :group => [:test]
2
+
3
+ # Initialize Jasmine
4
+ run "bundle exec jasmine init > /dev/null"
5
+
6
+ remove_file "lib/tasks/jasmine.rake"
@@ -0,0 +1,14 @@
1
+ # Make a blank application javascript file
2
+ remove_file "public/javascripts/application.js"
3
+ create_file "public/javascripts/application.js"
4
+
5
+ ## Backbone Directory Structure
6
+ empty_directory "public/javascripts/vendor"
7
+ empty_directory "public/javascripts/models"
8
+ empty_directory "public/javascripts/collections"
9
+ empty_directory "public/javascripts/controllers"
10
+ empty_directory "public/javascripts/views"
11
+
12
+ # Javascript Assets
13
+ get "http://documentcloud.github.com/underscore/underscore-min.js", "public/javascripts/vendor/underscore-min.js"
14
+ get "http://documentcloud.github.com/backbone/backbone-min.js", "public/javascripts/vendor/backbone-min.js"
data/recipes/jquery.rb ADDED
@@ -0,0 +1,4 @@
1
+ gem 'jquery-rails'
2
+
3
+ # Install latest jQuery JS
4
+ generate "jquery:install"
@@ -0,0 +1,8 @@
1
+ gem 'nifty-generators'
2
+
3
+ # Generate config file
4
+ generate 'nifty:config'
5
+
6
+ ## Layout
7
+ generate 'nifty:layout --haml'
8
+ remove_file 'app/views/layouts/application.html.erb'
@@ -0,0 +1 @@
1
+ gem 'rails3-generators', '0.17.4', :group => [:development]
data/recipes/rspec.rb ADDED
@@ -0,0 +1,7 @@
1
+ gem "rspec-rails", ">= 2.5.0", :group => [:test]
2
+
3
+ # Run all the generators
4
+ generate "rspec:install"
5
+
6
+ # Create .rspec config file
7
+ run "echo '--format documentation' >> .rspec"
data/recipes/rvm.rb ADDED
@@ -0,0 +1,15 @@
1
+ rvm_list = `rvm list`.gsub(Regexp.new("\e\\[.?.?.?m"), '')
2
+
3
+ current_ruby = rvm_list.match(/=> ([^ ]+)/)[1]
4
+ desired_ruby = ask("Please select RVM version: [#{current_ruby}]".red)
5
+ desired_ruby = current_ruby if desired_ruby.blank?
6
+
7
+ gemset_name = ask("Please name gemset: [#{@app_name}]".red)
8
+ gemset_name = @app_name if gemset_name.blank?
9
+
10
+ run "rvm #{desired_ruby} gemset create #{gemset_name}"
11
+ @rvm = "rvm use #{desired_ruby}@#{gemset_name}"
12
+
13
+ file '.rvmrc', @rvm
14
+
15
+ run "rvm rvmrc trust #{@app_path}"
data/recipes/spork.rb ADDED
@@ -0,0 +1,4 @@
1
+ gem "spork", ">= 0.9.0.rc", :group => [:test]
2
+
3
+ # Bootrap spork
4
+ run "spork -b > /dev/null"
@@ -0,0 +1,7 @@
1
+ # Setup a basic Welcome Controller as the default route
2
+ generate "controller Welcome index"
3
+ inject_into_file('config/routes.rb', :after => %[# root :to => "welcome#index"]) do
4
+ %q{
5
+ root :to => "welcome#index"
6
+ }
7
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_templatizer
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Patrick Bartels
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-07-07 00:00:00 +12:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: Rails Templatizer description
18
+ email:
19
+ - patrick@bartels.ug
20
+ executables:
21
+ - rails_templatizer
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - .gitignore
28
+ - CHANGELOG.md
29
+ - Gemfile
30
+ - README.md
31
+ - Rakefile
32
+ - VERSION
33
+ - bin/rails_templatizer
34
+ - lib/rails_templatizer.rb
35
+ - lib/rails_templatizer/version.rb
36
+ - rails_templatizer.gemspec
37
+ - recipes/app_template.rb
38
+ - recipes/application.rb
39
+ - recipes/authentication.rb
40
+ - recipes/autotest.rb
41
+ - recipes/capistrano.rb
42
+ - recipes/compass.rb
43
+ - recipes/factory_girl.rb
44
+ - recipes/faker.rb
45
+ - recipes/formtastic.rb
46
+ - recipes/friendly_id.rb
47
+ - recipes/git.rb
48
+ - recipes/haml_and_sass.rb
49
+ - recipes/jammit.rb
50
+ - recipes/jasmine.rb
51
+ - recipes/javascript.rb
52
+ - recipes/jquery.rb
53
+ - recipes/nifty_generators.rb
54
+ - recipes/rails3_generators.rb
55
+ - recipes/rspec.rb
56
+ - recipes/rvm.rb
57
+ - recipes/spork.rb
58
+ - recipes/welcome.rb
59
+ has_rdoc: true
60
+ homepage: http://bartels.ug
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options: []
65
+
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project: rails_templatizer
83
+ rubygems_version: 1.5.0
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Rails Templatizer summary
87
+ test_files: []
88
+