relevance_rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in relevance_rails.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ Relevance Rails
2
+ ==============
3
+
4
+ Yo dawg, I heard you like automation, so I automated your automation so you can autopilot while you autopilot!
5
+
6
+ Rails 3 projects with every fiddly bit convened rather than configured. Includes
7
+
8
+ * HAML and SCSS
9
+ * RSpec 2 with Relevance config niceties
10
+ * Factory Girl
11
+ * Mocha configured for mocking
12
+ * Capistrano deploy recipes
13
+ * A VM deployment target under provision
14
+
15
+ Getting Started
16
+ ---------------
17
+
18
+ ````sh
19
+ gem install relevance_rails
20
+ relevance_rails new <your new project>
21
+ ````
22
+
23
+ Caveats
24
+ -------
25
+
26
+ Only supports REE 1.8.7, Rails 3.1 and MySQL right now.
27
+
28
+ Improvements
29
+ ------------
30
+
31
+ Fork, do your work, and issue a pull request.
32
+
33
+ Issues
34
+ ------
35
+
36
+ Open a github issue and I'll look at it next Friday.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by RubyGems.
4
+ #
5
+ # The application 'railties' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'rubygems'
10
+
11
+ version = ">= 0"
12
+
13
+ if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
14
+ version = $1
15
+ ARGV.shift
16
+ end
17
+
18
+ require 'relevance_rails/template_injector'
19
+
20
+ gem 'railties', version
21
+ load Gem.bin_path('railties', 'rails', version)
@@ -0,0 +1,129 @@
1
+ class RelevanceFileGenerator < Rails::Generators::NamedBase
2
+
3
+ desc "This generator creates a number of default Rails files."
4
+
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ def copy_gemfile
8
+ copy_file "Gemfile", "Gemfile"
9
+ end
10
+
11
+ def create_readme_markdown
12
+ create_file "README.markdown", <<-README
13
+ # #{name}
14
+
15
+ ## Getting Started
16
+
17
+ gem install bundler
18
+ # TODO other setup commands here
19
+ README
20
+ end
21
+
22
+ def create_application_layout
23
+ create_file 'app/views/layouts/application.html.haml', <<-LAYOUT
24
+ !!!
25
+ %html
26
+ %head
27
+ %title #{name}
28
+ = stylesheet_link_tag :application
29
+ = javascript_include_tag :application
30
+ = csrf_meta_tag
31
+ %body
32
+ = yield
33
+ LAYOUT
34
+ end
35
+
36
+ def create_rvmrc
37
+ create_file ".rvmrc", "rvm use ree-1.8.7-2012.02@#{name}"
38
+ end
39
+
40
+ def create_rspec
41
+ create_file '.rspec', '--colour'
42
+ end
43
+
44
+ def copy_spec_helper
45
+ copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
46
+ end
47
+
48
+ def copy_capfile
49
+ copy_file 'Capfile', 'Capfile'
50
+ end
51
+
52
+ def create_deploy
53
+ create_file 'config/deploy.rb', <<-CAP_CONFIG
54
+ require 'bundler/capistrano'
55
+
56
+ set :application, "#{name}"
57
+ set :repository, "."
58
+ set :deploy_via, :copy
59
+
60
+ set :scm, :git
61
+
62
+ set :deploy_to, "/var/www/apps/\#{application}"
63
+ default_run_options[:pty] = true
64
+ set :ssh_options, { :paranoid => false, :forward_agent => true }
65
+
66
+ set :copy_exclude, '.git/*'
67
+
68
+ set :stages, %w(vagrant)
69
+ set :default_stage, 'vagrant'
70
+
71
+ after "deploy:setup", "deploy:copy_shared_db_config"
72
+ after "deploy:create_symlink", "deploy:symlink_shared_db_config"
73
+
74
+ Dir['config/deploy/recipes/*.rb'].sort.each { |f| eval(File.read(f)) }
75
+ CAP_CONFIG
76
+ end
77
+
78
+ def create_database_example_yml
79
+ create_file 'config/database.example.yml', <<-DATABASE_CONFIG
80
+ development:
81
+ adapter: mysql2
82
+ encoding: utf8
83
+ database: #{name}_development
84
+
85
+ # Warning: The database defined as "test" will be erased and
86
+ # re-generated from your development database when you run "rake".
87
+ # Do not set this db to the same as development or production.
88
+ test:
89
+ adapter: mysql2
90
+ encoding: utf8
91
+ database: #{name}_test
92
+
93
+ production:
94
+ adapter: mysql2
95
+ encoding: utf8
96
+ database: #{name}_production
97
+ DATABASE_CONFIG
98
+ end
99
+
100
+ def create_authorized_key_data_bag
101
+ authorized_keys = `ssh-add -L`.split("\n")
102
+ authorized_keys.map! {|key| "\"#{key}\""}
103
+ create_file 'authorized_keys.json', <<-AUTHORIZED_KEYS
104
+ {
105
+ "id":"authorized_keys",
106
+ "keys": [
107
+ #{authorized_keys.join(",\n")}
108
+ ]
109
+ }
110
+ AUTHORIZED_KEYS
111
+ end
112
+
113
+ def copy_deploy_recipes
114
+ copy_file 'recipes_deploy.rb', 'config/deploy/recipes/deploy.rb'
115
+ end
116
+
117
+ def copy_vagrant_stage
118
+ copy_file 'vagrant.rb', 'config/deploy/vagrant.rb'
119
+ end
120
+
121
+ def fix_session_store
122
+ gsub_file 'config/initializers/session_store.rb', 'key:', ':key =>'
123
+ end
124
+
125
+ def fix_wrap_parameters
126
+ gsub_file 'config/initializers/wrap_parameters.rb', 'format:', ':format =>'
127
+ end
128
+
129
+ end
@@ -0,0 +1,7 @@
1
+ require 'capistrano/ext/multistage'
2
+ load 'deploy'
3
+ load 'deploy/assets'
4
+
5
+ Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
6
+
7
+ load 'config/deploy' # remove this line to skip loading any of the default tasks
@@ -0,0 +1,35 @@
1
+ source :rubygems
2
+
3
+ gem 'rails', '3.1.1'
4
+ gem 'haml', '3.1.3'
5
+ gem 'configatron', '2.8.3'
6
+ gem 'airbrake', '~> 3.0.4'
7
+ gem 'factory_girl_rails', '1.2.0'
8
+ gem 'jquery-rails', '1.0.14'
9
+ gem 'therubyracer'
10
+ gem 'mysql2', '~> 0.3.11'
11
+
12
+ # Gems used only for assets and not required
13
+ # in production environments by default.
14
+ group "assets" do
15
+ gem 'sass-rails', '~> 3.1.4'
16
+ gem 'coffee-rails', '~> 3.1.1'
17
+ gem 'uglifier', '>= 1.0.3'
18
+ end
19
+
20
+ group "development" do
21
+ gem 'pry'
22
+ end
23
+
24
+ group "development", "test" do
25
+ gem 'capybara', '~> 1.1.1'
26
+ gem 'selenium-webdriver', '~> 2.5.0'
27
+ gem 'rspec-rails', '~> 2.6.0'
28
+ gem 'mocha', '~> 0.9.12'
29
+ gem 'guard-rspec', '~> 0.5.0', :require => false
30
+ gem 'growl', '~> 1.0.3', :require => false
31
+ gem 'rb-fsevent', '~> 0.4.2', :require => false
32
+ gem 'capistrano', '~> 2.11.2'
33
+ gem 'capistrano-ext', '1.2.1', :require => nil
34
+ gem 'capistrano_colors'
35
+ end
@@ -0,0 +1,17 @@
1
+ namespace :deploy do
2
+ task :start do ; end
3
+ task :stop do ; end
4
+ task :restart, :roles => :app, :except => { :no_release => true } do
5
+ run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
6
+ end
7
+
8
+ task :copy_shared_db_config do
9
+ run "mkdir -p #{shared_path}/config"
10
+ example_config_contents = File.read('config/database.example.yml')
11
+ put(example_config_contents, "#{shared_path}/config/database.yml", :via => :scp)
12
+ end
13
+
14
+ task :symlink_shared_db_config do
15
+ run "ln -nfs #{shared_path}/config/database.yml #{current_path}/config/database.yml"
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+ require File.expand_path("../../config/environment", __FILE__)
3
+ require 'rspec/rails'
4
+
5
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
6
+
7
+ RSpec.configure do |config|
8
+ config.mock_with :mocha
9
+ config.filter_run :focused => true
10
+ config.run_all_when_everything_filtered = true
11
+ config.alias_example_to :fit, :focused => true
12
+ config.alias_example_to :xit, :disabled => true
13
+ config.color_enabled = true
14
+ end
@@ -0,0 +1,5 @@
1
+ set :user, 'deploy'
2
+
3
+ role :web, "172.25.5.5"
4
+ role :app, "172.25.5.5"
5
+ role :db, "172.25.5.5", :primary => true
@@ -0,0 +1,5 @@
1
+ require "relevance_rails/version"
2
+
3
+ module RelevantRails
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,38 @@
1
+ RVM_RUBY = "ree-1.8.7-2012.02"
2
+ RVM_GEMSET = app_name
3
+
4
+ def rvm_run(command, config = {})
5
+ run ". ~/.rvm/scripts/rvm && rvm use #{RVM_RUBY}@#{RVM_GEMSET} && #{command}", config
6
+ end
7
+
8
+ run 'rm README.rdoc'
9
+ run 'rm doc/README_FOR_APP'
10
+ run 'rm public/index.html'
11
+ run 'rm public/favicon.ico'
12
+ run 'rm -rf test'
13
+ run 'rm Gemfile'
14
+ run 'rm app/assets/images/rails.png'
15
+ run 'rm app/views/layouts/application.html.erb'
16
+
17
+ generate(:relevance_file, app_name)
18
+
19
+ rvm_run "rvm use #{RVM_RUBY}@#{RVM_GEMSET} --create"
20
+ rvm_run "gem install bundler"
21
+ rvm_run "bundle install"
22
+
23
+ git :init
24
+ append_file ".gitignore", "config/database.yml\n"
25
+ run 'cp config/database.example.yml config/database.yml'
26
+ git :add => "."
27
+ git :commit => "-a -m 'Initial commit'"
28
+
29
+ git :remote => 'add -f elzar git://github.com/relevance/elzar.git'
30
+ git :merge => '-s ours --no-commit elzar/master'
31
+ git :"read-tree" => '--prefix=provision/ -u elzar/master'
32
+ gsub_file 'provision/Vagrantfile', /config\.vm\.host_name(\s+)= .*$/, "config.vm.host_name\\1= '#{app_name.gsub('_','-')}.local'"
33
+ gsub_file 'provision/roles/rails.rb', /:rails_app => \{$(\s+):name => .*$(\s+)\}/,":rails_app => {\\1:name => '#{app_name}'\\2}"
34
+ run 'mv authorized_keys.json provision/data_bags/deploy/authorized_keys.json'
35
+ git :add => 'provision/data_bags/deploy/authorized_keys.json'
36
+ git :add => 'provision/Vagrantfile'
37
+ git :add => 'provision/roles/rails.rb'
38
+ git :commit => '-m "Merge Elzar as our provision subdirectory"'
@@ -0,0 +1,5 @@
1
+ template = File.join(File.dirname(__FILE__), "relevance_rails_template.rb")
2
+ unless ARGV.any? =~ /^-d$/ then
3
+ ARGV << '-m'
4
+ ARGV << template
5
+ end
@@ -0,0 +1,3 @@
1
+ module RelevanceRails
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "relevance_rails/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "relevance_rails"
7
+ s.version = RelevanceRails::VERSION
8
+ s.authors = ["Alex Redington"]
9
+ s.email = ["alex.redington@thinkrelevance.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Rails 3 Relevance style, with all infrastructure bits automated away.}
12
+ s.description = %q{A Rails 3 wrapper which forces template use and includes a plethora of generators for standard Relevance bits.}
13
+
14
+ s.rubyforge_project = "relevance_rails"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.bindir = 'bin'
22
+ s.executables = ['relevance_rails']
23
+
24
+ # specify any dependencies here; for example:
25
+ # s.add_development_dependency "rspec"
26
+ s.add_runtime_dependency "rails", "~> 3.1"
27
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: relevance_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex Redington
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &2151903760 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2151903760
25
+ description: A Rails 3 wrapper which forces template use and includes a plethora of
26
+ generators for standard Relevance bits.
27
+ email:
28
+ - alex.redington@thinkrelevance.com
29
+ executables:
30
+ - relevance_rails
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - Gemfile
36
+ - README.md
37
+ - Rakefile
38
+ - bin/relevance_rails
39
+ - lib/generators/relevance_file/relevance_file_generator.rb
40
+ - lib/generators/relevance_file/templates/Capfile
41
+ - lib/generators/relevance_file/templates/Gemfile
42
+ - lib/generators/relevance_file/templates/recipes_deploy.rb
43
+ - lib/generators/relevance_file/templates/spec_helper.rb
44
+ - lib/generators/relevance_file/templates/vagrant.rb
45
+ - lib/relevance_rails.rb
46
+ - lib/relevance_rails/relevance_rails_template.rb
47
+ - lib/relevance_rails/template_injector.rb
48
+ - lib/relevance_rails/version.rb
49
+ - relevance_rails.gemspec
50
+ homepage: ''
51
+ licenses: []
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project: relevance_rails
70
+ rubygems_version: 1.8.15
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Rails 3 Relevance style, with all infrastructure bits automated away.
74
+ test_files: []