orange-ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/.gitignore +4 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +111 -0
  5. data/README.md +90 -0
  6. data/Rakefile +2 -0
  7. data/bin/orange +4 -0
  8. data/build.sh +11 -0
  9. data/cucumber.yml +2 -0
  10. data/features/default/ci.feature +12 -0
  11. data/features/default/configy.feature +14 -0
  12. data/features/default/core_extensions.feature +13 -0
  13. data/features/default/database.feature +12 -0
  14. data/features/default/ey_cloud.feature +20 -0
  15. data/features/default/factory_girl.feature +12 -0
  16. data/features/default/git.feature +18 -0
  17. data/features/default/hacks.feature +13 -0
  18. data/features/default/keypair.feature +14 -0
  19. data/features/step_definitions/custom_aruba_steps.rb +7 -0
  20. data/features/support/setup.rb +3 -0
  21. data/lib/orange/ruby/cli.rb +34 -0
  22. data/lib/orange/ruby/version.rb +5 -0
  23. data/lib/orange/ruby.rb +8 -0
  24. data/orange-ruby.gemspec +26 -0
  25. data/templates/default/ci.rb +44 -0
  26. data/templates/default/configy.rb +34 -0
  27. data/templates/default/core_extensions.rb +10 -0
  28. data/templates/default/cucumber.rb +3 -0
  29. data/templates/default/database.rb +3 -0
  30. data/templates/default/ey_cloud.rb +40 -0
  31. data/templates/default/factory_girl.rb +5 -0
  32. data/templates/default/gemfile.rb +37 -0
  33. data/templates/default/generator_defaults.rb +12 -0
  34. data/templates/default/git.rb +55 -0
  35. data/templates/default/hacks.rb +7 -0
  36. data/templates/default/hoptoad.rb +4 -0
  37. data/templates/default/keypair.rb +4 -0
  38. data/templates/default/layout.rb +16 -0
  39. data/templates/default/newrelic.rb +3 -0
  40. data/templates/default/preclean.rb +14 -0
  41. data/templates/default/public.rb +37 -0
  42. data/templates/default/rvm.rb +28 -0
  43. data/templates/default/template.rb +68 -0
  44. metadata +209 -0
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ree@orange
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in orange-ruby.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,111 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ orange-ruby (0.0.1)
5
+ rails (~> 3.0.3)
6
+ thor
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ abstract (1.0.0)
12
+ actionmailer (3.0.3)
13
+ actionpack (= 3.0.3)
14
+ mail (~> 2.2.9)
15
+ actionpack (3.0.3)
16
+ activemodel (= 3.0.3)
17
+ activesupport (= 3.0.3)
18
+ builder (~> 2.1.2)
19
+ erubis (~> 2.6.6)
20
+ i18n (~> 0.4)
21
+ rack (~> 1.2.1)
22
+ rack-mount (~> 0.6.13)
23
+ rack-test (~> 0.5.6)
24
+ tzinfo (~> 0.3.23)
25
+ activemodel (3.0.3)
26
+ activesupport (= 3.0.3)
27
+ builder (~> 2.1.2)
28
+ i18n (~> 0.4)
29
+ activerecord (3.0.3)
30
+ activemodel (= 3.0.3)
31
+ activesupport (= 3.0.3)
32
+ arel (~> 2.0.2)
33
+ tzinfo (~> 0.3.23)
34
+ activeresource (3.0.3)
35
+ activemodel (= 3.0.3)
36
+ activesupport (= 3.0.3)
37
+ activesupport (3.0.3)
38
+ arel (2.0.6)
39
+ aruba (0.2.8)
40
+ childprocess (~> 0.1.6)
41
+ cucumber (~> 0.10.0)
42
+ rspec (~> 2.3.0)
43
+ builder (2.1.2)
44
+ childprocess (0.1.6)
45
+ ffi (~> 0.6.3)
46
+ cucumber (0.10.0)
47
+ builder (>= 2.1.2)
48
+ diff-lcs (~> 1.1.2)
49
+ gherkin (~> 2.3.2)
50
+ json (~> 1.4.6)
51
+ term-ansicolor (~> 1.0.5)
52
+ diff-lcs (1.1.2)
53
+ erubis (2.6.6)
54
+ abstract (>= 1.0.0)
55
+ ffi (0.6.3)
56
+ rake (>= 0.8.7)
57
+ gherkin (2.3.3)
58
+ json (~> 1.4.6)
59
+ i18n (0.5.0)
60
+ json (1.4.6)
61
+ mail (2.2.13)
62
+ activesupport (>= 2.3.6)
63
+ i18n (>= 0.4.0)
64
+ mime-types (~> 1.16)
65
+ treetop (~> 1.4.8)
66
+ mime-types (1.16)
67
+ polyglot (0.3.1)
68
+ rack (1.2.1)
69
+ rack-mount (0.6.13)
70
+ rack (>= 1.0.0)
71
+ rack-test (0.5.6)
72
+ rack (>= 1.0)
73
+ rails (3.0.3)
74
+ actionmailer (= 3.0.3)
75
+ actionpack (= 3.0.3)
76
+ activerecord (= 3.0.3)
77
+ activeresource (= 3.0.3)
78
+ activesupport (= 3.0.3)
79
+ bundler (~> 1.0)
80
+ railties (= 3.0.3)
81
+ railties (3.0.3)
82
+ actionpack (= 3.0.3)
83
+ activesupport (= 3.0.3)
84
+ rake (>= 0.8.7)
85
+ thor (~> 0.14.4)
86
+ rake (0.8.7)
87
+ rspec (2.3.0)
88
+ rspec-core (~> 2.3.0)
89
+ rspec-expectations (~> 2.3.0)
90
+ rspec-mocks (~> 2.3.0)
91
+ rspec-core (2.3.1)
92
+ rspec-expectations (2.3.0)
93
+ diff-lcs (~> 1.1.2)
94
+ rspec-mocks (2.3.0)
95
+ term-ansicolor (1.0.5)
96
+ thor (0.14.6)
97
+ treetop (1.4.9)
98
+ polyglot (>= 0.3.1)
99
+ tzinfo (0.3.23)
100
+
101
+ PLATFORMS
102
+ ruby
103
+
104
+ DEPENDENCIES
105
+ aruba
106
+ bundler (~> 1.0.0)
107
+ cucumber
108
+ orange-ruby!
109
+ rails (~> 3.0.3)
110
+ rspec (~> 2.3.0)
111
+ thor
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+ Factory Labs - Rails 3 Templates
2
+ ================================
3
+
4
+ # Credits
5
+ Originally forked from https://github.com/leshill/rails3-app with additions from https://github.com/greendog99/greendog-rails-template - not a lot of resemblance to either one anymore, however.
6
+
7
+ Right now, only one template (default) exists - more will probably come along, however.
8
+
9
+ What's included in the default template?
10
+ ----
11
+
12
+ The TL;DR version: test:unit, shoulda, factory_girl, capybara, evergreen, haml, engineyard, mysql2, and formtastic. Read on for more details.
13
+
14
+ ### RVM
15
+ A new .rvmrc is created for the application, and set to be trusted automatically. We use REE for all of our production deployments because it's stable and blazing fast, to the rvmrc defaults to that interpreter. A new gemset is also created just for the new application.
16
+
17
+ ### Bundler
18
+ Bundler 1.0.7 is installed by default, and gems are cached into vendor by default.
19
+
20
+ ### Gems/Gemfile
21
+ We install a bunch of gems automatically. Here's the list:
22
+
23
+ ### General
24
+ * bundler (1.0.7)
25
+ * rails (3.0.3)
26
+ * thin (to speed up Cucumber/Capybara runs)
27
+ * mysql2
28
+ * haml-rails
29
+ * formtastic
30
+ * jammit (for asset packaging)
31
+ * configy (for application-wide configuration)
32
+ * newrelic_rpm
33
+ * rpm_contrib
34
+ * hoptoad_notifier
35
+
36
+ ### Development and Test
37
+ * annotate
38
+ * engineyard
39
+ * db-entropy
40
+ * ruby-debug
41
+ * rake-hooks
42
+ * factory_girl_generator
43
+ * evergreen
44
+ * fakeweb
45
+ * timecop
46
+ * shoulda
47
+ * mocha
48
+ * factory_girl_rails
49
+ * capybara
50
+ * database_cleaner
51
+ * cucumber-rails
52
+ * launchy
53
+
54
+ ## Public directory
55
+ We remove unnecessary files from public (favicon, robots.txt, rails.png, index.html), create a default robots.txt that excludes the admin, and replace Prototype with jQuery. In doing so, we download jQuery from the Google CDN to public/javascripts/jquery and register the jQuery files in Rails' defaults expansion.
56
+
57
+ ## Application stuff
58
+ A bunch of different things happen here:
59
+
60
+ * Rewrite the application layout to use Haml
61
+ * Add a Configy initializer and create a default application-wide config.yml
62
+ * Create an empty hacks.rb initializer for one-off patches
63
+ * Set up a mechanism for loading core extensions from lib/core_extensions
64
+ * Set up an empty test/factories.rb for factory_girl
65
+ * Run cucumber:install and set it up to use capybara and test::unit
66
+ * Set the generator defaults to exclude stylesheets and use shoulda, haml, factory_girl, cucumber, and no fixtures
67
+ * Set up some defaults for EY Cloud Chef, Newrelic, and Hoptoad (Not implemented yet)
68
+ * Create an SSH keypair and put it in the repo under config/keypair
69
+ * Create a default database.yml.example
70
+ * Set up a build.sh script for CI (Not implemented yet)
71
+
72
+ ## Git
73
+
74
+ * Create a .gitignore with some convenient defaults
75
+ * Create a git repo and add everything in an initial commit.
76
+ * Create a new Github repo and push to it (Not implemented yet)
77
+
78
+ Note on Patches/Pull Requests
79
+ -----------------------------
80
+
81
+ * Fork the project.
82
+ * Make your feature addition or bug fix.
83
+ * Commit, do not mess with rakefile, version, or history. (if you want to have
84
+ your own version, that is fine but bump version in a commit by itself we can
85
+ ignore when we pull)
86
+ * Send us a pull request. Bonus points for topic branches.
87
+
88
+ License
89
+ -------
90
+ Released as public domain. No guarantees, no warranties.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/orange ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
3
+ require 'orange/ruby/cli'
4
+ Orange::Ruby::CLI.start
data/build.sh ADDED
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+ # RVM
3
+ source ~/.profile
4
+ rvm use ree@orange-ruby --create
5
+
6
+ # Bundle
7
+ gem install bundler -v 1.0.0 --no-ri --no-rdoc && \
8
+ bundle install --deployment && \
9
+
10
+ # Tests
11
+ bundle exec cucumber
data/cucumber.yml ADDED
@@ -0,0 +1,2 @@
1
+ default: --format pretty features
2
+ wip: --tags=@wip features --format pretty
@@ -0,0 +1,12 @@
1
+ Feature:
2
+ In order to have the app tested consistently
3
+ As a user generating a new Rails app
4
+ I would like to have a build script set up for me
5
+
6
+ Background:
7
+ Given I set a generous command timeout
8
+
9
+ Scenario: The core extensions generator creates a build.sh
10
+ When I run "orange rails test_app"
11
+ And I cd to "test_app"
12
+ Then a file named "build.sh" should exist
@@ -0,0 +1,14 @@
1
+ Feature:
2
+ In order to easily configure application settings
3
+ As a user generating a new Rails app
4
+ I would like to have configy set up for me automatically
5
+
6
+ Background:
7
+ Given I set a generous command timeout
8
+
9
+ Scenario: The configy generator creates an initializer
10
+ When I run "orange rails test_app"
11
+ And I cd to "test_app"
12
+ Then the following files should exist:
13
+ | config/initializers/configy.rb |
14
+ | config/config.yml |
@@ -0,0 +1,13 @@
1
+ Feature:
2
+ In order to easily drop in core extensions
3
+ As a user generating a new Rails app
4
+ I would like to have a core extensions directory and initializer set up for me automatically
5
+
6
+ Background:
7
+ Given I set a generous command timeout
8
+
9
+ Scenario: The core extensions generator creates an initializer and a lib directory
10
+ When I run "orange rails test_app"
11
+ And I cd to "test_app"
12
+ Then a file named "config/initializers/core_extensions.rb" should exist
13
+ And a directory named "lib/core_extensions" should exist
@@ -0,0 +1,12 @@
1
+ Feature:
2
+ In order to easily configure application settings
3
+ As a user generating a new Rails app
4
+ I would like to have an example database.yml set up automatically
5
+
6
+ Background:
7
+ Given I set a generous command timeout
8
+
9
+ Scenario: The database generator creates a database.example.yml
10
+ When I run "orange rails test_app"
11
+ And I cd to "test_app"
12
+ Then a file named "config/database.example.yml" should exist
@@ -0,0 +1,20 @@
1
+ Feature:
2
+ In order to deploy the app on EY Cloud
3
+ As a user generating a new Rails app
4
+ I would like to have a cloud hooks and recipes set up for me
5
+
6
+ Background:
7
+ Given I set a generous command timeout
8
+
9
+ Scenario: The ey_cloud generator creates all the hooks files
10
+ When I run "orange rails test_app"
11
+ And I cd to "test_app"
12
+ Then the following files should exist:
13
+ | deploy/before_migrate.rb |
14
+ | deploy/after_migrate.rb |
15
+ | deploy/before_symlink.rb |
16
+ | deploy/after_symlink.rb |
17
+ | deploy/before_restart.rb |
18
+ | deploy/after_restart.rb |
19
+ And a directory named "cookbooks" should exist
20
+ And a directory named "tmp/recipes" should not exist
@@ -0,0 +1,12 @@
1
+ Feature:
2
+ In order to easily configure tests
3
+ As a user generating a new Rails app
4
+ I would like to have a blank factories.rb set up automatically
5
+
6
+ Background:
7
+ Given I set a generous command timeout
8
+
9
+ Scenario: The factory_girl generator creates factories.rb
10
+ When I run "orange rails test_app"
11
+ And I cd to "test_app"
12
+ Then a file named "test/factories.rb" should exist
@@ -0,0 +1,18 @@
1
+ Feature:
2
+ In order to get the app going quickly
3
+ As a user generating a new Rails app
4
+ I would like to have a git repo initialized for me
5
+
6
+ Background:
7
+ Given I set a generous command timeout
8
+
9
+ Scenario: The keypair generator creates a new RSA keypair
10
+ When I run "orange rails test_app"
11
+ And I cd to "test_app"
12
+ Then the following files should exist:
13
+ | log/.gitkeep |
14
+ | tmp/.gitkeep |
15
+ | .gitignore |
16
+ And a directory named ".git" should exist
17
+ When I run "git log"
18
+ Then the output should contain "Initial commit."
@@ -0,0 +1,13 @@
1
+ @wip
2
+ Feature:
3
+ In order to contain horrible hacks
4
+ As a user generating a new Rails app
5
+ I would like to have a place for hacks to live set up automatically
6
+
7
+ Background:
8
+ Given I set a generous command timeout
9
+
10
+ Scenario: The hacks generator creates an initializer
11
+ When I run "orange rails test_app"
12
+ And I cd to "test_app"
13
+ Then a file named "config/initializers/hacks.rb" should exist
@@ -0,0 +1,14 @@
1
+ Feature:
2
+ In order to deploy the app on EY Cloud
3
+ As a user generating a new Rails app
4
+ I would like to have a cloud keypair set up for me
5
+
6
+ Background:
7
+ Given I set a generous command timeout
8
+
9
+ Scenario: The keypair generator creates a new RSA keypair
10
+ When I run "orange rails test_app"
11
+ And I cd to "test_app"
12
+ Then the following files should exist:
13
+ | config/keypair/id_rsa |
14
+ | config/keypair/id_rsa.pub |
@@ -0,0 +1,7 @@
1
+ When /I set the command timeout to (\d+) seconds/ do |seconds|
2
+ @aruba_timeout_seconds = seconds.to_i
3
+ end
4
+
5
+ When /I set a generous command timeout/ do
6
+ When('I set the command timeout to 60 seconds')
7
+ end
@@ -0,0 +1,3 @@
1
+ require 'aruba/cucumber'
2
+ require 'fileutils'
3
+ require 'rspec/expectations'
@@ -0,0 +1,34 @@
1
+ require 'thor'
2
+ require 'thor/actions'
3
+
4
+ module Orange
5
+ module Ruby
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+ desc "rails [app]", "Create a new Rails 3 application from the default template"
10
+ long_desc "Orange will generate a new Rails 3 application for you based on on the Factory default template"
11
+
12
+ def rails(project)
13
+ exec(<<-COMMAND)
14
+ rails new #{project} \
15
+ --template=#{template}
16
+ COMMAND
17
+ end
18
+
19
+ desc "version", "Display information about this version of Orange"
20
+ def version
21
+ say "Orange v#{Orange::VERSION}"
22
+ say "Released under the MIT License. © 2010 Factory Design Labs"
23
+ end
24
+ map %w(-v --version) => :version
25
+
26
+ private
27
+
28
+ def template
29
+ File.expand_path(File.dirname(__FILE__) + "/../../../templates/default/template.rb")
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ module Orange
2
+ module Ruby
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../../lib') unless $:.include?(File.dirname(__FILE__) + '/../../lib')
2
+ require 'orange/ruby/version'
3
+ require 'orange/ruby/cli'
4
+
5
+ module Orange
6
+ module Ruby
7
+ end
8
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "orange/ruby/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "orange-ruby"
7
+ s.version = Orange::Ruby::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["F/ Interactive"]
10
+ s.email = ["jay.zeschin@factorylabs.com"]
11
+ s.homepage = "http://github.com/factorylabs/orange-ruby"
12
+ s.summary = %q{Rails 3 generators wrapped up in a nice tidy gem}
13
+ s.description = %q{Rails 3 generators wrapped up in a nice tidy gem}
14
+
15
+ s.add_dependency "thor"
16
+ s.add_dependency 'rails', '~> 3.0.3'
17
+ s.add_development_dependency "bundler", "~> 1.0.0"
18
+ s.add_development_dependency "cucumber"
19
+ s.add_development_dependency "aruba"
20
+ s.add_development_dependency "rspec", "~> 2.3.0"
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
+ s.require_paths = ["lib"]
26
+ end
@@ -0,0 +1,44 @@
1
+ # Configure CI
2
+ say "\n-- Configuring application for CI ...\n"
3
+
4
+ say "\n Creating build.sh ...\n"
5
+
6
+ file 'build.sh', <<-RUBY.gsub(/^ {2}/, '')
7
+ #!/bin/bash
8
+ # Autogenerated F/ build script. Tweak at will.
9
+ # RVM
10
+ source ~/.profile
11
+ rvm use ree@#{app_name} --create
12
+ export DISPLAY=:99
13
+
14
+ # Stop old XVFBs
15
+ start-stop-daemon --pidfile xvfb-x11vnc.pid --stop
16
+ start-stop-daemon --pidfile xvfb.pid --stop
17
+
18
+ # Start new XVFBs
19
+ start-stop-daemon --pidfile xvfb.pid --make-pidfile --exec /usr/bin/Xvfb --background --start -- -ac :99
20
+ start-stop-daemon --pidfile xvfb-x11vnc.pid --make-pidfile --exec /usr/bin/x11vnc --background --start -- -rfbport 5901 -display :99
21
+
22
+ # Bundle
23
+ gem install bundler -v 1.0.0 --no-ri --no-rdoc && \
24
+ bundle install --deployment && \
25
+
26
+ # DB Config
27
+ cp config/database.example.yml config/database.yml && \
28
+ bundle exec rake db:drop:all && \
29
+ bundle exec rake db:create:all && \
30
+ bundle exec rake db:migrate && \
31
+
32
+ # Tests
33
+ CUCUMBER_FORMAT=progress bundle exec rake && \
34
+ bundle exec evergreen run && \
35
+ bundle exec rake deploy:demo
36
+ BUILD_STATUS=$?
37
+
38
+ # Clean up XVFBs
39
+ start-stop-daemon --pidfile xvfb-x11vnc.pid --stop
40
+ start-stop-daemon --pidfile xvfb.pid --stop
41
+ exit $BUILD_STATUS
42
+ RUBY
43
+
44
+ run "chmod +x build.sh"
@@ -0,0 +1,34 @@
1
+ say "Setting up Configy ..."
2
+
3
+ initializer 'configy.rb', <<-RUBY.gsub(/^ {2}/, '')
4
+ # Use Configy (http://github.com/gvarela/configy) for application-wide configuration
5
+ # Load application-specific configuration from config/config.yml.
6
+ # Access the config params via ::Config
7
+ Configy.create(:config)
8
+ RUBY
9
+
10
+ file 'config/config.yml', <<-RUBY.gsub(/^ {2}/, '')
11
+ # Use Configy (http://github.com/gvarela/configy) for application-wide configuration settings
12
+ # These get loaded by config/initializers/configy.rb and can be accessed via ::Config
13
+
14
+ # Define settings for all environments here
15
+ common:
16
+
17
+ # For example:
18
+ # superuser: mfischer
19
+ # per_page: 20
20
+ # array_of_arrays:
21
+ # - [key, val]
22
+ # - [key2, val2]
23
+
24
+ # Define settings for specific environments here:
25
+
26
+ development:
27
+
28
+ test:
29
+
30
+ demo:
31
+
32
+ production:
33
+
34
+ RUBY
@@ -0,0 +1,10 @@
1
+ # Set up core extensions framework
2
+ say "Setting up core extensions ..."
3
+ empty_directory 'lib/core_extensions'
4
+ initializer 'core_extensions.rb', <<-RUBY.gsub(/^ {2}/, '')
5
+ # Long-lived core extensions and patches can go in lib/core_extensions. They will automatically be loaded here.
6
+ core_extension_files = Rails.root.join('lib','core_extensions','*.rb')
7
+ Dir.glob(core_extension_files).each do |path|
8
+ require path
9
+ end
10
+ RUBY
@@ -0,0 +1,3 @@
1
+ # Set up Cucumber
2
+ say "Setting up Cucumber ..."
3
+ run "#{@rvm} exec rails generate cucumber:install --testunit --capybara"
@@ -0,0 +1,3 @@
1
+ # Create example database.yml
2
+ say "Creating an example database.yml ... "
3
+ run "cp config/database.yml config/database.example.yml"
@@ -0,0 +1,40 @@
1
+ # Set up EY hooks files
2
+ say "Setting up EY Cloud deploy hooks ..."
3
+
4
+ empty_directory 'deploy'
5
+
6
+ file 'deploy/before_migrate.rb', <<-RUBY.gsub(/^ {2}/, '')
7
+ # EY Cloud Deploy - Pre-Migration Hooks
8
+ # See http://docs.engineyard.com/appcloud/guides/deployment/home#deploy-hooks for details
9
+ RUBY
10
+
11
+ file 'deploy/after_migrate.rb', <<-RUBY.gsub(/^ {2}/, '')
12
+ # EY Cloud Deploy - Post-Migration Hooks
13
+ # See http://docs.engineyard.com/appcloud/guides/deployment/home#deploy-hooks for details
14
+ RUBY
15
+
16
+ file 'deploy/before_symlink.rb', <<-RUBY.gsub(/^ {2}/, '')
17
+ # EY Cloud Deploy - Pre-Symlink Hooks
18
+ # See http://docs.engineyard.com/appcloud/guides/deployment/home#deploy-hooks for details
19
+ RUBY
20
+
21
+ file 'deploy/after_symlink.rb', <<-RUBY.gsub(/^ {2}/, '')
22
+ # EY Cloud Deploy - Post-Symlink Hooks
23
+ # See http://docs.engineyard.com/appcloud/guides/deployment/home#deploy-hooks for details
24
+ RUBY
25
+
26
+ file 'deploy/before_restart.rb', <<-RUBY.gsub(/^ {2}/, '')
27
+ # EY Cloud Deploy - Pre-Restart Hooks
28
+ # See http://docs.engineyard.com/appcloud/guides/deployment/home#deploy-hooks for details
29
+ RUBY
30
+
31
+ file 'deploy/after_restart.rb', <<-RUBY.gsub(/^ {2}/, '')
32
+ # EY Cloud Deploy - Post-Restart Hooks
33
+ # See http://docs.engineyard.com/appcloud/guides/deployment/home#deploy-hooks for details
34
+ RUBY
35
+
36
+ # Import cookbooks
37
+ say "Importing initial chef cookbooks ..."
38
+ run "git clone git@github.com:factorylabs/ey-cloud-recipes.git tmp/recipes"
39
+ run 'cp -R tmp/recipes/cookbooks cookbooks'
40
+ run 'rm -rf tmp/recipes'
@@ -0,0 +1,5 @@
1
+ # Set up factory_girl
2
+ log "\n Setting up Factory Girl ...\n"
3
+ file 'test/factories.rb', <<-RUBY.gsub(/^ {2}/, '')
4
+ # Put your factory_girl factories in here
5
+ RUBY
@@ -0,0 +1,37 @@
1
+ # Configure gems
2
+ say "\n-- Processing Gemfile ...\n"
3
+
4
+ ## Basic Gems
5
+ gem 'bundler', '1.0.7'
6
+ gem 'rails', '3.0.3'
7
+ gem 'thin', :require => false
8
+ gem 'mysql2'
9
+ gem 'haml-rails'
10
+ gem 'formtastic'
11
+ gem 'jammit'
12
+ gem 'configy'
13
+ gem 'newrelic_rpm', :require => false
14
+ gem 'rpm_contrib'
15
+ gem 'hoptoad_notifier'
16
+
17
+ ## Development gems
18
+ gem 'annotate'
19
+ gem 'engineyard', :require => false, :group => [ :development ]
20
+ gem 'db-entropy', :require => false
21
+ gem 'ruby-debug', :group => [ :development, :test ]
22
+ gem 'rake-hooks', :require => false, :group => [ :development ]
23
+ gem 'factory_girl_generator', :group => [ :development, :test]
24
+
25
+ ## Test Gems
26
+ gem 'evergreen', :require => 'evergreen/rails'
27
+
28
+ # This should not be required because it screws with webdriver. It gets explicitly required in test_helper.rb
29
+ gem 'fakeweb', :require => false, :group => [ :test ]
30
+ gem 'timecop', :group => [ :test ]
31
+ gem 'shoulda', :group => [ :test ]
32
+ gem 'mocha', :group => [ :test ]
33
+ gem 'factory_girl_rails', :group => [ :test ]
34
+ gem 'capybara', :group => [ :test ]
35
+ gem 'database_cleaner', :group => [ :test ]
36
+ gem 'cucumber-rails', :group => [ :test ]
37
+ gem 'launchy', :group => [ :test ]
@@ -0,0 +1,12 @@
1
+ # Set up generator defaults
2
+ log "\n Setting up generator defaults ...\n"
3
+ generators = <<-RUBY
4
+ config.generators do |g|
5
+ g.template_engine :haml
6
+ g.stylesheets false
7
+ g.test_framework :shoulda, :fixture => false
8
+ g.fixture_replacement :factory_girl
9
+ g.integration_tool :cucumber
10
+ end
11
+ RUBY
12
+ application generators
@@ -0,0 +1,55 @@
1
+ # Initialize Git repository
2
+ say "\n-- Initializing Git repository ...\n"
3
+
4
+ create_file "log/.gitkeep"
5
+ create_file "tmp/.gitkeep"
6
+
7
+ # Create a .gitignore file and a new local repository, commit everything
8
+ say "\n Creating .gitignore ...\n"
9
+ remove_file '.gitignore'
10
+
11
+ file '.gitignore', <<-CODE.gsub(/^ {2}/, '')
12
+ # System stuff
13
+ .DS_Store
14
+ .bundle
15
+ .idea
16
+ .rake_tasks
17
+ REVISION
18
+ vendor/bundle
19
+ .rake_tasks~
20
+ mkmf.log
21
+
22
+ # Local config files
23
+ config/database.yml
24
+ config/*.sphinx.conf
25
+ config/mongoid.yml
26
+
27
+ # Local DBs
28
+ db/sphinx
29
+ db/*.sqlite3
30
+
31
+ # Logs
32
+ log/*.log
33
+ log/*.pid
34
+
35
+ # Tempfiles
36
+ tmp/**/*
37
+ coverage
38
+ capybara*
39
+
40
+ # Assets
41
+ public/system
42
+ public/static
43
+ /assets
44
+ packages
45
+ CODE
46
+
47
+ # Do the initial commit
48
+ say "\n Creating the repo ...\n"
49
+
50
+ git :init
51
+ git :add => "."
52
+ git :commit => "-am 'Initial commit.'"
53
+
54
+ # Push to Github
55
+ # TODO: implement me
@@ -0,0 +1,7 @@
1
+ # Set up hacks initializer
2
+ log "\n Setting up hacks.rb ...\n"
3
+
4
+ initializer 'hacks.rb', <<-RUBY.gsub(/^ {2}/, '')
5
+ # Temporary patches, hacks, hotfixes, etc. go here.
6
+ # Gives them a predictable place to live
7
+ RUBY
@@ -0,0 +1,4 @@
1
+ # Set up Hoptoad
2
+ log "\n Setting up Hoptoad ...\n"
3
+ # TODO: How to pass the API key while keeping it private?
4
+ run "#{@rvm} exec rails generate hoptoad --api-key=XXXX"
@@ -0,0 +1,4 @@
1
+ # Build a keypair
2
+ log "\n Creating a repo keypair ...\n"
3
+ empty_directory 'config/keypair'
4
+ run 'echo "\n\n" | /usr/bin/ssh-keygen -q -t rsa -f config/keypair/id_rsa'
@@ -0,0 +1,16 @@
1
+ # Tweak app layout to use HAML
2
+ say "\n Converting application layout in HAML ...\n"
3
+ layout = <<-LAYOUT.gsub(/^ {2}/, '')
4
+ !!!
5
+ %html
6
+ %head
7
+ %title #{app_name.humanize}
8
+ = stylesheet_link_tag :all
9
+ = javascript_include_tag :defaults
10
+ = csrf_meta_tag
11
+ %body
12
+ = yield
13
+ LAYOUT
14
+
15
+ remove_file "app/views/layouts/application.html.erb"
16
+ create_file "app/views/layouts/application.html.haml", layout
@@ -0,0 +1,3 @@
1
+ # Set up Newrelic
2
+ say "\n Setting up Newrelic ...\n"
3
+ # TODO: Flesh this out. Also, how do we pass the key while still keeping it private?
@@ -0,0 +1,14 @@
1
+ say "Getting rid of files Rails provides that we don't use"
2
+
3
+ remove_file "README"
4
+ remove_file "public/index.html"
5
+ remove_file "public/images/rails.png"
6
+ remove_file "public/favicon.ico"
7
+
8
+ say "Creating a nicer default README"
9
+ create_file 'README.md', <<-FILE.gsub(/^ {2}/, '')
10
+ #{app_name.humanize}
11
+ ===========
12
+ * http://github.com/factorylabs/#{app_name}
13
+ * Application-specific documentation and notes go here.
14
+ FILE
@@ -0,0 +1,37 @@
1
+ # Tweak the Public directory
2
+ say "\n-- Processing public directory ...\n"
3
+
4
+ # Remove files we don't care about
5
+ say "\n Removing unnecessary files ...\n"
6
+ remove_file "public/index.html"
7
+ remove_file "public/favicon.ico"
8
+ remove_file "public/robots.txt"
9
+ remove_file "public/images/rails.png"
10
+
11
+ # Create a sane robots.txt
12
+ log "\n Creating a default robots.txt ...\n"
13
+ robots_txt = <<-ROBOTS.gsub(/^ {2}/, '')
14
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
15
+ #
16
+ User-Agent: *
17
+ Disallow: /admin
18
+
19
+ ROBOTS
20
+
21
+ create_file "public/robots.txt", robots_txt
22
+
23
+ # Remove Prototype
24
+ log "\n Removing Prototype ...\n"
25
+ remove_file "public/javascripts/controls.js"
26
+ remove_file "public/javascripts/dragdrop.js"
27
+ remove_file "public/javascripts/effects.js"
28
+ remove_file "public/javascripts/prototype.js"
29
+ remove_file "public/javascripts/rails.js"
30
+
31
+ # Add jQuery
32
+ log "\n Adding jQuery ...\n"
33
+ empty_directory 'public/javascripts/jquery'
34
+ get "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "public/javascripts/jquery/jquery.js"
35
+ get "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js", "public/javascripts/jquery/jquery-ui.js"
36
+ `curl http://github.com/rails/jquery-ujs/raw/master/src/rails.js -o public/javascripts/jquery/rails.js`
37
+ gsub_file 'config/application.rb', 'config.action_view.javascript_expansions[:defaults] = %w()', 'config.action_view.javascript_expansions[:defaults] = %w(jquery/jquery.js jquery/jquery-ui.js jquery/rails.js)'
@@ -0,0 +1,28 @@
1
+ # Configure RVM
2
+ say "\n-- Processing RVM ...\n"
3
+
4
+ ## Use REE and an app-specific gemset
5
+ desired_ruby = 'ree'
6
+ gemset_name = app_name
7
+
8
+ # Let us run shell commands inside our new gemset. Use this in other template partials.
9
+ @rvm = "rvm #{desired_ruby}@#{gemset_name}"
10
+
11
+ # Create .rvmrc
12
+ log "\n Creating default .rvmrc ...\n"
13
+ create_file ".rvmrc", @rvm
14
+
15
+ # Make the .rvmrc trusted
16
+ run "rvm rvmrc trust #{@app_path}"
17
+
18
+ # Since the gemset is likely empty, manually install bundler so it can install the rest
19
+ log "\n Install bundler ...\n"
20
+ run "#{@rvm} gem install bundler -v 1.0.7 --no-ri --no-rdoc"
21
+
22
+ # Install all other gems needed from Gemfile
23
+ log "\n Install Gemfile gems ...\n"
24
+ run "#{@rvm} exec bundle install"
25
+
26
+ # Cache bundled gems for deployment
27
+ log "\n Package Gemfile gems ...\n"
28
+ run "#{@rvm} exec bundle package"
@@ -0,0 +1,68 @@
1
+ # Basic Rails 3 Template
2
+ # ======================
3
+ # by F/ Interactive
4
+
5
+ say "\nF/ Interactive Rails 3 Template\n"
6
+ say "\nDetails at http://github.com/factorylabs/orange-ruby\n"
7
+
8
+ require 'net/http'
9
+ require 'net/https'
10
+
11
+ template_root = File.expand_path(File.join(File.dirname(__FILE__)))
12
+ source_paths << File.join(template_root, "files")
13
+
14
+ # Helpers - courtesy of Thoughtbot's Suspenders gem
15
+
16
+ def concat_file(source, destination)
17
+ contents = IO.read(find_in_source_paths(source))
18
+ append_file destination, contents
19
+ end
20
+
21
+ def replace_in_file(relative_path, find, replace)
22
+ path = File.join(destination_root, relative_path)
23
+ contents = IO.read(path)
24
+ unless contents.gsub!(find, replace)
25
+ raise "#{find.inspect} not found in #{relative_path}"
26
+ end
27
+ File.open(path, "w") { |file| file.write(contents) }
28
+ end
29
+
30
+ def download_file(uri_string, destination)
31
+ uri = URI.parse(uri_string)
32
+ http = Net::HTTP.new(uri.host, uri.port)
33
+ http.use_ssl = true if uri_string =~ /^https/
34
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
35
+ request = Net::HTTP::Get.new(uri.path)
36
+ contents = http.request(request).body
37
+ path = File.join(destination_root, destination)
38
+ File.open(path, "w") { |file| file.write(contents) }
39
+ end
40
+
41
+ # Main template
42
+ apply File.join(File.dirname(__FILE__),'preclean.rb')
43
+ apply File.join(File.dirname(__FILE__),'gemfile.rb')
44
+ apply File.join(File.dirname(__FILE__),'rvm.rb')
45
+ apply File.join(File.dirname(__FILE__),'public.rb')
46
+ apply File.join(File.dirname(__FILE__),'configy.rb')
47
+ apply File.join(File.dirname(__FILE__),'hacks.rb')
48
+ apply File.join(File.dirname(__FILE__),'core_extensions.rb')
49
+ apply File.join(File.dirname(__FILE__),'factory_girl.rb')
50
+ apply File.join(File.dirname(__FILE__),'cucumber.rb')
51
+ apply File.join(File.dirname(__FILE__),'generator_defaults.rb')
52
+ apply File.join(File.dirname(__FILE__),'newrelic.rb')
53
+ apply File.join(File.dirname(__FILE__),'hoptoad.rb')
54
+ apply File.join(File.dirname(__FILE__),'ey_cloud.rb')
55
+ apply File.join(File.dirname(__FILE__),'keypair.rb')
56
+ apply File.join(File.dirname(__FILE__),'database.rb')
57
+ apply File.join(File.dirname(__FILE__),'ci.rb')
58
+ apply File.join(File.dirname(__FILE__),'git.rb')
59
+
60
+ # Final housekeeping
61
+
62
+ docs = <<-DOCS
63
+ \nTemplate run is complete. Please run the following to complete the setup of #{app_name.humanize}:
64
+ - Add your API key to config/initializers/hoptoad.rb
65
+ - Import your config/newrelic.yml
66
+ DOCS
67
+
68
+ log docs
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: orange-ruby
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - F/ Interactive
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-27 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: thor
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rails
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 1
44
+ segments:
45
+ - 3
46
+ - 0
47
+ - 3
48
+ version: 3.0.3
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: bundler
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 23
60
+ segments:
61
+ - 1
62
+ - 0
63
+ - 0
64
+ version: 1.0.0
65
+ type: :development
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: cucumber
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ type: :development
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: aruba
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ type: :development
94
+ version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 2
106
+ - 3
107
+ - 0
108
+ version: 2.3.0
109
+ type: :development
110
+ version_requirements: *id006
111
+ description: Rails 3 generators wrapped up in a nice tidy gem
112
+ email:
113
+ - jay.zeschin@factorylabs.com
114
+ executables:
115
+ - orange
116
+ extensions: []
117
+
118
+ extra_rdoc_files: []
119
+
120
+ files:
121
+ - .gitignore
122
+ - .rvmrc
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - README.md
126
+ - Rakefile
127
+ - bin/orange
128
+ - build.sh
129
+ - cucumber.yml
130
+ - features/default/ci.feature
131
+ - features/default/configy.feature
132
+ - features/default/core_extensions.feature
133
+ - features/default/database.feature
134
+ - features/default/ey_cloud.feature
135
+ - features/default/factory_girl.feature
136
+ - features/default/git.feature
137
+ - features/default/hacks.feature
138
+ - features/default/keypair.feature
139
+ - features/step_definitions/custom_aruba_steps.rb
140
+ - features/support/setup.rb
141
+ - lib/orange/ruby.rb
142
+ - lib/orange/ruby/cli.rb
143
+ - lib/orange/ruby/version.rb
144
+ - orange-ruby.gemspec
145
+ - templates/default/ci.rb
146
+ - templates/default/configy.rb
147
+ - templates/default/core_extensions.rb
148
+ - templates/default/cucumber.rb
149
+ - templates/default/database.rb
150
+ - templates/default/ey_cloud.rb
151
+ - templates/default/factory_girl.rb
152
+ - templates/default/gemfile.rb
153
+ - templates/default/generator_defaults.rb
154
+ - templates/default/git.rb
155
+ - templates/default/hacks.rb
156
+ - templates/default/hoptoad.rb
157
+ - templates/default/keypair.rb
158
+ - templates/default/layout.rb
159
+ - templates/default/newrelic.rb
160
+ - templates/default/preclean.rb
161
+ - templates/default/public.rb
162
+ - templates/default/rvm.rb
163
+ - templates/default/template.rb
164
+ has_rdoc: true
165
+ homepage: http://github.com/factorylabs/orange-ruby
166
+ licenses: []
167
+
168
+ post_install_message:
169
+ rdoc_options: []
170
+
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ none: false
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ hash: 3
179
+ segments:
180
+ - 0
181
+ version: "0"
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ none: false
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ hash: 3
188
+ segments:
189
+ - 0
190
+ version: "0"
191
+ requirements: []
192
+
193
+ rubyforge_project:
194
+ rubygems_version: 1.3.7
195
+ signing_key:
196
+ specification_version: 3
197
+ summary: Rails 3 generators wrapped up in a nice tidy gem
198
+ test_files:
199
+ - features/default/ci.feature
200
+ - features/default/configy.feature
201
+ - features/default/core_extensions.feature
202
+ - features/default/database.feature
203
+ - features/default/ey_cloud.feature
204
+ - features/default/factory_girl.feature
205
+ - features/default/git.feature
206
+ - features/default/hacks.feature
207
+ - features/default/keypair.feature
208
+ - features/step_definitions/custom_aruba_steps.rb
209
+ - features/support/setup.rb