eldarscrolls 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/.gitignore +8 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +6 -0
  4. data/ChangeLog.md +63 -0
  5. data/Gemfile +3 -0
  6. data/Guardfile +18 -0
  7. data/MIT_LICENSE +20 -0
  8. data/README.md +157 -0
  9. data/Rakefile +78 -0
  10. data/bin/eldar +7 -0
  11. data/bin/eldarscrolls +7 -0
  12. data/eldarscrolls.gemspec +32 -0
  13. data/features/step_definitions/common_steps.rb +211 -0
  14. data/features/support/common.rb +51 -0
  15. data/features/support/env.rb +18 -0
  16. data/lib/eldarscrolls.rb +10 -0
  17. data/lib/eldarscrolls/command.rb +85 -0
  18. data/lib/eldarscrolls/config.rb +86 -0
  19. data/lib/eldarscrolls/scroll.rb +106 -0
  20. data/lib/eldarscrolls/scrolls.rb +38 -0
  21. data/lib/eldarscrolls/template.rb +67 -0
  22. data/lib/rails/generators/.DS_Store +0 -0
  23. data/lib/rails/generators/run_template/USAGE +13 -0
  24. data/lib/rails/generators/run_template/run_template_generator.rb +13 -0
  25. data/sample.rb +74 -0
  26. data/scrolls/active_admin.rb +19 -0
  27. data/scrolls/capybara.rb +34 -0
  28. data/scrolls/cucumber.rb +21 -0
  29. data/scrolls/delayed_job.rb +94 -0
  30. data/scrolls/env_yaml.rb +53 -0
  31. data/scrolls/eycloud.rb +72 -0
  32. data/scrolls/eycloud_recipes_on_deploy.rb +20 -0
  33. data/scrolls/git.rb +17 -0
  34. data/scrolls/github.rb +38 -0
  35. data/scrolls/guard.rb +75 -0
  36. data/scrolls/jquery.rb +11 -0
  37. data/scrolls/mysql.rb +51 -0
  38. data/scrolls/passenger.rb +11 -0
  39. data/scrolls/postgresql.rb +54 -0
  40. data/scrolls/prototype.rb +21 -0
  41. data/scrolls/puma.rb +11 -0
  42. data/scrolls/rails_basics.rb +54 -0
  43. data/scrolls/redis.rb +19 -0
  44. data/scrolls/resque.rb +59 -0
  45. data/scrolls/rspec.rb +21 -0
  46. data/scrolls/simple_form.rb +19 -0
  47. data/scrolls/split.rb +35 -0
  48. data/scrolls/spork.rb +19 -0
  49. data/scrolls/sqlite3.rb +10 -0
  50. data/scrolls/test_unit.rb +11 -0
  51. data/scrolls/thin.rb +10 -0
  52. data/scrolls/twitter_bootstrap.rb +41 -0
  53. data/scrolls/unicorn.rb +10 -0
  54. data/scrolls/zzz/activerecord.rb +69 -0
  55. data/scrolls/zzz/cancan.rb +16 -0
  56. data/scrolls/zzz/carrierwave.rb +42 -0
  57. data/scrolls/zzz/carrierwave_direct.rb +13 -0
  58. data/scrolls/zzz/cartographer.rb +33 -0
  59. data/scrolls/zzz/devise.rb +52 -0
  60. data/scrolls/zzz/devise_invitable.rb +23 -0
  61. data/scrolls/zzz/event_calendar.rb +12 -0
  62. data/scrolls/zzz/factory_girl.rb +38 -0
  63. data/scrolls/zzz/ffaker.rb +22 -0
  64. data/scrolls/zzz/fixture_builder.rb +35 -0
  65. data/scrolls/zzz/forgery.rb +15 -0
  66. data/scrolls/zzz/haml.rb +11 -0
  67. data/scrolls/zzz/heroku.rb +58 -0
  68. data/scrolls/zzz/hoptoad.rb +34 -0
  69. data/scrolls/zzz/inherited_resources.rb +12 -0
  70. data/scrolls/zzz/intercom.rb +35 -0
  71. data/scrolls/zzz/jammit.rb +43 -0
  72. data/scrolls/zzz/jasmine.rb +12 -0
  73. data/scrolls/zzz/mini_magick.rb +13 -0
  74. data/scrolls/zzz/mongo_mapper.rb +20 -0
  75. data/scrolls/zzz/mongohq.rb +61 -0
  76. data/scrolls/zzz/mongoid.rb +20 -0
  77. data/scrolls/zzz/mootools.rb +23 -0
  78. data/scrolls/zzz/newrelic.rb +11 -0
  79. data/scrolls/zzz/nifty_generators.rb +21 -0
  80. data/scrolls/zzz/oa_oauth.rb +12 -0
  81. data/scrolls/zzz/omniauth.rb +55 -0
  82. data/scrolls/zzz/paper_trail.rb +17 -0
  83. data/scrolls/zzz/pow.rb +12 -0
  84. data/scrolls/zzz/rails_admin.rb +22 -0
  85. data/scrolls/zzz/rails_dev_tweaks.rb +10 -0
  86. data/scrolls/zzz/rails_erd.rb +9 -0
  87. data/scrolls/zzz/rails_footnotes.rb +14 -0
  88. data/scrolls/zzz/ransack.rb +32 -0
  89. data/scrolls/zzz/rmagick.rb +13 -0
  90. data/scrolls/zzz/sass.rb +13 -0
  91. data/scrolls/zzz/sequel.rb +13 -0
  92. data/scrolls/zzz/settingslogic.rb +43 -0
  93. data/scrolls/zzz/shoulda_matchers.rb +11 -0
  94. data/scrolls/zzz/sidekiq.rb +23 -0
  95. data/scrolls/zzz/slim.rb +11 -0
  96. data/scrolls/zzz/thinking_sphinx.rb +14 -0
  97. data/scrolls/zzz/vanity.rb +35 -0
  98. data/spec/eldarscrolls/config_spec.rb +99 -0
  99. data/spec/eldarscrolls/scroll_spec.rb +103 -0
  100. data/spec/eldarscrolls/scrolls/sanity_spec.rb +30 -0
  101. data/spec/eldarscrolls/scrolls_spec.rb +24 -0
  102. data/spec/eldarscrolls/template_spec.rb +57 -0
  103. data/spec/spec_helper.rb +11 -0
  104. data/spec/support/rails_directory.rb +17 -0
  105. data/spec/support/template_runner.rb +28 -0
  106. data/templates/helpers.erb +45 -0
  107. data/templates/layout.erb +43 -0
  108. data/templates/new_scroll.erb +28 -0
  109. data/templates/scroll.erb +10 -0
  110. data/version.rb +3 -0
  111. metadata +299 -0
@@ -0,0 +1,13 @@
1
+ Description:
2
+ Apply an application template to an existing application
3
+
4
+ Application templates are traditionally used for new applications. Such as:
5
+
6
+ rails new myapp -m /path/to/template.rb
7
+
8
+ This generator allows the templates to be reused/reapplied to this existing application.
9
+
10
+ Example:
11
+ rails g run_template /path/to/template.rb
12
+ rails g run_template https://mycompany.com/template.rb
13
+
@@ -0,0 +1,13 @@
1
+ class RunTemplateGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ argument :template_path, :desc => "Path to an application template"
5
+
6
+ def apply_template
7
+ path = template_path
8
+ unless path =~ /^https?:\/\//
9
+ path = File.expand_path(path, Dir.pwd)
10
+ end
11
+ apply path
12
+ end
13
+ end
@@ -0,0 +1,74 @@
1
+ # >---------------------------------------------------------------------------<
2
+ #
3
+ # ______ __ ____ ____
4
+ # / __/ /__/ /__ _____ / __/__________ / / /__
5
+ # / _// / _ / _ `/ __/ _\ \/ __/ __/ _ \/ / (_-<
6
+ # /___/_/\_,_/\_,_/_/ /___/\__/_/ \___/_/_/___/
7
+ #
8
+ #
9
+ # This template was generated by Eldar Scrolls, the amazing and awesome Rails
10
+ # application template builder. Get started at http://eldarscrolls.org
11
+ #
12
+ # ___________________________________________________________________________
13
+ # |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
14
+ # | | |
15
+ # | Name: | b9755a02fbf7886df8b2 |
16
+ # | URL: | http://railswizard.local/b9755a02fbf7886df8b2.rb |
17
+ # | Updated: | March 12, 2011 at 21:47PM |
18
+ # | | |
19
+ # |\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\|
20
+ # ---------------------------------------------------------------------------
21
+
22
+ # >----------------------------[ Initial Setup ]------------------------------<
23
+
24
+ initializer 'generators.rb', <<-RUBY
25
+ Rails.application.config.generators do |g|
26
+ end
27
+ RUBY
28
+
29
+ scrolls = ["activerecord", "devise", "prototype"]
30
+
31
+ def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end
32
+ def say_scroll(name); say "\033[1m\033[36m" + "scroll".rjust(10) + "\033[0m" + " Running #{name} scroll..." end
33
+ def say_wizard(text); say_custom('wizard', text) end
34
+ def ask_wizard(question)
35
+ ask "\033[1m\033[30m\033[46m" + "prompt".rjust(10) + "\033[0m\033[36m" + " #{question}\033[0m"
36
+ end
37
+ def yes_wizard?(question)
38
+ answer = ask_wizard(question + " \033[33m(y/n)\033[0m")
39
+ case answer.downcase
40
+ when "yes", "y"
41
+ true
42
+ when "no", "n"
43
+ false
44
+ else
45
+ yes_wizard?(question)
46
+ end
47
+ end
48
+ def no_wizard?(question); !yes_wizard?(question) end
49
+ def multiple_choice(question, choices)
50
+ say_custom('question', question)
51
+ values = {}
52
+ choices.each_with_index do |choice,i|
53
+ values[(i + 1).to_s] = choice[1]
54
+ say_custom (i + 1).to_s + '.', choice[0]
55
+ end
56
+ answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer)
57
+ values[answer]
58
+ end
59
+
60
+ @after_blocks = []
61
+ def after_bundler(&block); @after_blocks << block; end
62
+
63
+
64
+ say_wizard ask_wizard("What do you want to know?")
65
+ say_wizard yes_wizard?("Is there a god?")
66
+ say_wizard multiple_choice("What do you like?", [["Puppies","puppies"],["Kitties","kitties"]])
67
+
68
+ # >-----------------------------[ Run Bundler ]-------------------------------<
69
+
70
+ say_wizard "Running Bundler install. This will take a while."
71
+ run 'bundle install'
72
+ say_wizard "Running after Bundler callbacks."
73
+ @after_blocks.each{|b| b.call}
74
+
@@ -0,0 +1,19 @@
1
+ #unless scrolls.include? 'sass-rails'
2
+ # gem 'sass-rails'
3
+ #end
4
+ gem 'activeadmin'
5
+
6
+ after_everything do
7
+ generate "active_admin:install"
8
+ end
9
+
10
+ __END__
11
+
12
+ name: Active Admin
13
+ description: "The administration framework for Ruby on Rails applications"
14
+ author: jonochang
15
+ website: http://activeadmin.info/
16
+
17
+ exclusive: administration
18
+ category: administration
19
+ tags: [administration]
@@ -0,0 +1,34 @@
1
+ gem 'capybara', :group => [:development, :test]
2
+
3
+ after_bundler do
4
+ create_file "spec/support/capybara.rb", <<-RUBY
5
+ require 'capybara/rails'
6
+ require 'capybara/rspec'
7
+ RUBY
8
+
9
+ create_file "spec/requests/home_spec.rb", <<-RUBY
10
+ require 'spec_helper'
11
+
12
+ describe 'visiting the homepage' do
13
+ before do
14
+ visit '/'
15
+ end
16
+
17
+ it 'should have a body' do
18
+ page.should have_css('body')
19
+ end
20
+ end
21
+ RUBY
22
+ end
23
+
24
+ __END__
25
+
26
+ name: Capybara
27
+ description: "Use the Capybara acceptance testing libraries with RSpec."
28
+ author: mbleigh
29
+
30
+ requires: [rspec]
31
+ run_after: [rspec]
32
+ exclusive: acceptance_testing
33
+ category: testing
34
+ tags: [acceptance]
@@ -0,0 +1,21 @@
1
+ gem_group :test do
2
+ gem 'cucumber-rails', :require => false # https://github.com/cucumber/cucumber-rails/issues/202
3
+ gem 'capybara'
4
+ gem 'database_cleaner'
5
+ end
6
+
7
+
8
+ after_bundler do
9
+ rake "db:create"
10
+ generate "cucumber:install --capybara#{' --rspec' if scrolls.include?('rspec')}#{' -D' unless scrolls.include?('activerecord')}"
11
+ end
12
+
13
+ __END__
14
+
15
+ name: Cucumber
16
+ description: "Use Cucumber for integration testing with Capybara."
17
+ author: mbleigh
18
+
19
+ exclusive: acceptance_testing
20
+ category: testing
21
+ tags: [acceptance]
@@ -0,0 +1,94 @@
1
+ gem 'delayed_job_active_record'
2
+ gem 'delayed_job_admin'
3
+
4
+ if config["admin"]
5
+ inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
6
+ <<-RUBY
7
+
8
+ def delayed_job_admin_authentication
9
+ # authentication_logic_goes_here
10
+ true
11
+ end
12
+
13
+ RUBY
14
+ end
15
+
16
+ create_file "readmes/delayed_job_admin.md", <<-MD
17
+ # Delayed Job Admin README
18
+
19
+ Delayed Job Admin console is available at [/delayed_job_admin](http://localhost:3000/delayed_job_admin).
20
+
21
+ ```
22
+ open http://localhost:3000/delayed_job_admin
23
+ ```
24
+
25
+ ## Steps to complete
26
+
27
+ ### Authentication
28
+
29
+ By default, there is no authentication or authorization protecting access to `/delayed_job_admin`.
30
+
31
+ Please go to `app/controllers/application_controller.rb` and edit the following method:
32
+
33
+ ```ruby
34
+ def delayed_job_admin_authentication
35
+ # authentication_logic_goes_here
36
+ true
37
+ end
38
+ ```
39
+
40
+ For example, if you are using the Devise gem and have an Admin model:
41
+
42
+ ```ruby
43
+ def delayed_job_admin_authentication
44
+ authenticate_admin!
45
+ end
46
+ ```
47
+
48
+ MD
49
+ end
50
+
51
+ if scroll? "eycloud_recipes_on_deploy"
52
+ gem 'eycloud-recipe-delayed_job', :group => :eycloud
53
+ end
54
+
55
+
56
+ after_bundler do
57
+ generate 'delayed_job'
58
+
59
+ if scroll? "eycloud_recipes_on_deploy"
60
+ say_wizard 'Installing deploy hooks to restart delayed_job after deploys'
61
+ run "touch deploy/before_restart.rb"
62
+ append_file "deploy/before_restart.rb", <<-RUBY
63
+ on_app_servers_and_utilities do
64
+ node[:applications].each do |app_name, data|
65
+ sudo 'echo "sleep 20 && monit -g dj_\#{app_name} restart all" | at now'
66
+ end
67
+ end
68
+ RUBY
69
+
70
+ append_file "deploy/cookbooks/main/recipes/default.rb", "\nrequire_recipe 'delayed_job'\n"
71
+ end
72
+ end
73
+
74
+ after_everything do
75
+ say_custom "readme", "Delayed Job Admin"
76
+ run %q{cat "readmes/delayed_job_admin.md"}
77
+ end
78
+
79
+ __END__
80
+
81
+ name: Delayed Job
82
+ description: Use Delayed Job to handle background jobs
83
+ author: drnic
84
+
85
+ exclusive: worker
86
+ category: worker
87
+ tags: [worker,background-tasks]
88
+
89
+ run_after: [eycloud_recipes_on_deploy]
90
+
91
+ config:
92
+ - admin:
93
+ type: boolean
94
+ prompt: "Install simple admin interface to Delayed Job?"
@@ -0,0 +1,53 @@
1
+
2
+
3
+ say_wizard "Generating config/env.yaml..."
4
+
5
+ append_file "config/application.rb", <<-RUBY
6
+
7
+ require 'env_yaml'
8
+ RUBY
9
+
10
+ create_file "lib/env_yaml.rb", <<-RUBY
11
+ require 'yaml'
12
+ begin
13
+ env_yaml = YAML.load_file(File.dirname(__FILE__) + '/../config/env.yml')
14
+ if env_hash = env_yaml[ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development']
15
+ env_hash.each_pair do |k,v|
16
+ ENV[k] = v.to_s
17
+ end
18
+ end
19
+ rescue StandardError => e
20
+ end
21
+
22
+ RUBY
23
+
24
+ create_file "config/env.yml", <<-YAML
25
+ defaults: &defaults
26
+ ENV_YAML: true
27
+
28
+ development:
29
+ <<: *defaults
30
+
31
+ test:
32
+ <<: *defaults
33
+
34
+ production:
35
+ <<: *defaults
36
+ YAML
37
+
38
+ def env(k,v,rack_env='development')
39
+ inject_into_file "config/env.yml", :after => "#{rack_env}:\n <<: *defaults" do
40
+ <<-YAML
41
+ #{k}: #{v.inspect}
42
+ YAML
43
+ end
44
+ end
45
+
46
+ __END__
47
+
48
+ name: EnvYAML
49
+ description: "Allows you to set environment variables in a YAML file at config/env.yaml"
50
+ author: mbleigh
51
+
52
+ category: other
53
+ tags: [utilities, configuration]
@@ -0,0 +1,72 @@
1
+ @name = File.basename(File.expand_path("."))
2
+
3
+ gem_group :development do
4
+ gem 'ey_cli'
5
+ gem 'engineyard'
6
+ end
7
+
8
+ gem 'ey_config' # for partner services
9
+
10
+ required_dbs = %w[mysql postgresql]
11
+ required_app_servers = %w[unicorn trinidad passenger puma thin]
12
+
13
+ selected_db = required_dbs.find {|db| scroll? db }
14
+ unless selected_db
15
+ say_custom "eycloud", "Please include a DB choice from: #{required_dbs.join ", "}"
16
+ exit_now = true
17
+ end
18
+
19
+ selected_app_server = required_app_servers.find {|app| scroll? app }
20
+ unless selected_app_server
21
+ say_custom "eycloud", "Please include an App Server choice from: #{required_app_servers.join ", "}"
22
+ exit_now = true
23
+ end
24
+
25
+ exit 1 if exit_now
26
+
27
+ after_everything do
28
+ @git_url ||= `git config remote.origin.url`.strip
29
+ if @git_url.size == 0
30
+ say_custom "eycloud", "Skipping... no git URI discovered"
31
+ else
32
+ run "ey login"
33
+
34
+ if @mysql_stack
35
+ say_custom "eycloud", "Using mysql #{@mysql_stack}"
36
+ elsif @postgresql_stack
37
+ say_custom "eycloud", "Using postgresql #{@postgresql_stack}"
38
+ end
39
+
40
+ framework_env = multiple_choice "Which framework environment?", [%w[Production production], %w[Staging staging]]
41
+
42
+ # TODO check for app name first
43
+ app_name = (@repo_name && @repo_name.size > 0) ? @repo_name : @name
44
+ say_custom "eycloud", "Checking for availability of #{app_name}"
45
+ @app_names ||= `ey_cli apps | grep "-" | sed "s/.* //"`.split(/\n/)
46
+ while @app_names.include?(app_name)
47
+ app_name = ask_wizard "Application #{app_name} is already taken; what"
48
+ end
49
+
50
+ name = File.basename(".")
51
+ command = "ey_cli create_app --name #{app_name} --type rails3 "
52
+ command += "--git #{@git_url} "
53
+ command += "--framework_env #{framework_env} "
54
+ command += "--env_name #{@name}_#{framework_env} "
55
+ command += "--stack #{selected_app_server} "
56
+ command += "--solo"
57
+ run command
58
+
59
+ end
60
+ end
61
+
62
+ __END__
63
+
64
+ name: Engine Yard Cloud
65
+ description: The Most Powerful Ruby Cloud
66
+ author: drnic
67
+
68
+ category: deployment
69
+ exclusive: deployment
70
+
71
+ requires: [github, eycloud_recipes_on_deploy]
72
+ run_after: [github, eycloud_recipes_on_deploy]
@@ -0,0 +1,20 @@
1
+ gem "engineyard-recipes", :group => [:development]
2
+
3
+ after_bundler do
4
+ say_custom "eycloud", "Setting up deploy hooks..."
5
+ run "bundle exec ey-recipes init --on-deploy --chef"
6
+ run "bundle update"
7
+ end
8
+
9
+
10
+ __END__
11
+
12
+ name: Recipes on Deploy
13
+ description: Run Engine Yard Cloud recipes during deployment instead of independently.
14
+ author: drnic
15
+ website: https://github.com/engineyard/engineyard-recipes
16
+
17
+ requires: [eycloud]
18
+ run_before: [eycloud]
19
+ category: deployment
20
+ tags: [background, worker]
@@ -0,0 +1,17 @@
1
+ after_everything do
2
+ git :init
3
+ git :add => '.'
4
+ git :commit => '-m "Initial import."'
5
+ end
6
+
7
+ __END__
8
+
9
+ name: Git
10
+ description: "Provides basic Git setup for the Rails app and commits the initial repository."
11
+ author: mbleigh
12
+
13
+ exclusive: scm
14
+ category: deployment
15
+
16
+ run_before: [git, eycloud, heroku]
17
+