rails_wizard 0.1.0

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.
Files changed (45) hide show
  1. data/README.markdown +95 -0
  2. data/bin/rails_wizard +7 -0
  3. data/lib/rails_wizard.rb +10 -0
  4. data/lib/rails_wizard/command.rb +78 -0
  5. data/lib/rails_wizard/config.rb +86 -0
  6. data/lib/rails_wizard/recipe.rb +106 -0
  7. data/lib/rails_wizard/recipes.rb +38 -0
  8. data/lib/rails_wizard/template.rb +57 -0
  9. data/recipes/activerecord.rb +37 -0
  10. data/recipes/capybara.rb +34 -0
  11. data/recipes/cucumber.rb +16 -0
  12. data/recipes/devise.rb +23 -0
  13. data/recipes/git.rb +15 -0
  14. data/recipes/haml.rb +11 -0
  15. data/recipes/heroku.rb +58 -0
  16. data/recipes/hoptoad.rb +31 -0
  17. data/recipes/jammit.rb +43 -0
  18. data/recipes/jquery.rb +23 -0
  19. data/recipes/less.rb +12 -0
  20. data/recipes/mongo_mapper.rb +18 -0
  21. data/recipes/mongohq.rb +59 -0
  22. data/recipes/mongoid.rb +18 -0
  23. data/recipes/mootools.rb +23 -0
  24. data/recipes/omniauth.rb +15 -0
  25. data/recipes/prototype.rb +11 -0
  26. data/recipes/redis.rb +11 -0
  27. data/recipes/rightjs.rb +17 -0
  28. data/recipes/rspec.rb +21 -0
  29. data/recipes/sass.rb +13 -0
  30. data/recipes/sequel.rb +13 -0
  31. data/recipes/slim.rb +11 -0
  32. data/recipes/test_unit.rb +11 -0
  33. data/spec/rails_wizard/config_spec.rb +99 -0
  34. data/spec/rails_wizard/recipe_spec.rb +103 -0
  35. data/spec/rails_wizard/recipes/sanity_spec.rb +30 -0
  36. data/spec/rails_wizard/recipes_spec.rb +24 -0
  37. data/spec/rails_wizard/template_spec.rb +48 -0
  38. data/spec/spec_helper.rb +11 -0
  39. data/spec/support/rails_directory.rb +17 -0
  40. data/spec/support/template_runner.rb +28 -0
  41. data/templates/helpers.erb +44 -0
  42. data/templates/layout.erb +42 -0
  43. data/templates/recipe.erb +9 -0
  44. data/version.rb +3 -0
  45. metadata +139 -0
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+ require 'rspec'
4
+
5
+ Dir[File.dirname(__FILE__) + '/support/*'].each{|path| require path}
6
+
7
+ require 'rails_wizard'
8
+
9
+ RSpec.configure do |config|
10
+
11
+ end
@@ -0,0 +1,17 @@
1
+ class RailsDirectory
2
+ def initialize(path)
3
+ @path = path
4
+ end
5
+
6
+ def file_path(path)
7
+ File.join(@path, path)
8
+ end
9
+
10
+ def has_file?(path)
11
+ File.exist?(file_path(path))
12
+ end
13
+
14
+ def [](path)
15
+ File.open(file_path(path)).read
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ class TemplateRunner
2
+ attr_reader :template, :config, :app_name, :dir, :rails_dir, :output
3
+ def initialize(template, config)
4
+ @template = template
5
+ @config = config
6
+ end
7
+
8
+ def run(app_name = 'rails_app')
9
+ @app_name = app_name
10
+ @dir = Dir.mktmpdir
11
+ @rails_dir = File.join(@dir, @app_name)
12
+ Dir.chrdir(@dir) do
13
+ template_file = File.open 'template.rb', 'w'
14
+ template_file.write
15
+ template_file.close
16
+ @output = `rails new #{@app_name} -m template.rb`
17
+ end
18
+ @output
19
+ end
20
+
21
+ def rails
22
+ RailsDirectory.new(@rails_dir)
23
+ end
24
+
25
+ def clean
26
+ FileUtils.remove_entry_secure @dir
27
+ end
28
+ end
@@ -0,0 +1,44 @@
1
+ def recipes; @recipes end
2
+ def recipe?(name); @recipes.include?(name) end
3
+
4
+ def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end
5
+ def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
6
+ def say_wizard(text); say_custom(@current_recipe || 'wizard', text) end
7
+
8
+ def ask_wizard(question)
9
+ ask "\033[1m\033[30m\033[46m" + (@current_recipe || "prompt").rjust(10) + "\033[0m\033[36m" + " #{question}\033[0m"
10
+ end
11
+
12
+ def yes_wizard?(question)
13
+ answer = ask_wizard(question + " \033[33m(y/n)\033[0m")
14
+ case answer.downcase
15
+ when "yes", "y"
16
+ true
17
+ when "no", "n"
18
+ false
19
+ else
20
+ yes_wizard?(question)
21
+ end
22
+ end
23
+
24
+ def no_wizard?(question); !yes_wizard?(question) end
25
+
26
+ def multiple_choice(question, choices)
27
+ say_custom('question', question)
28
+ values = {}
29
+ choices.each_with_index do |choice,i|
30
+ values[(i + 1).to_s] = choice[1]
31
+ say_custom (i + 1).to_s + ')', choice[0]
32
+ end
33
+ answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer)
34
+ values[answer]
35
+ end
36
+
37
+ @current_recipe = nil
38
+
39
+ @after_blocks = []
40
+ def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
41
+ @after_everything_blocks = []
42
+ def after_everything(&block); @after_everything_blocks << [@current_recipe, block]; end
43
+ @before_configs = {}
44
+ def before_config(&block); @before_configs[@current_recipe] = block; end
@@ -0,0 +1,42 @@
1
+ # >---------------------------------------------------------------------------<
2
+ #
3
+ # _____ _ _ __ ___ _
4
+ # | __ \ (_) | \ \ / (_) | |
5
+ # | |__) |__ _ _| |___\ \ /\ / / _ ______ _ _ __ __| |
6
+ # | _ // _` | | / __|\ \/ \/ / | |_ / _` | '__/ _` |
7
+ # | | \ \ (_| | | \__ \ \ /\ / | |/ / (_| | | | (_| |
8
+ # |_| \_\__,_|_|_|___/ \/ \/ |_/___\__,_|_| \__,_|
9
+ #
10
+ # This template was generated by RailsWizard, the amazing and awesome Rails
11
+ # application template builder. Get started at http://railswizard.org
12
+ #
13
+ # >---------------------------------------------------------------------------<
14
+
15
+ # >----------------------------[ Initial Setup ]------------------------------<
16
+
17
+ initializer 'generators.rb', <<-RUBY
18
+ Rails.application.config.generators do |g|
19
+ end
20
+ RUBY
21
+
22
+ @recipes = <%= resolve_recipes.map(&:key).inspect %>
23
+
24
+ <%= render "helpers" %>
25
+
26
+ <% resolve_recipes.each do |recipe| %>
27
+ <%= render 'recipe', recipe.get_binding %>
28
+ <% end %>
29
+
30
+ <% if custom_code? %># >-----------------------------[ Custom Code ]-------------------------------<
31
+
32
+ <%= custom_code %><% end %>
33
+
34
+ @current_recipe = nil
35
+
36
+ # >-----------------------------[ Run Bundler ]-------------------------------<
37
+
38
+ say_wizard "Running Bundler install. This will take a while."
39
+ run 'bundle install'
40
+ say_wizard "Running after Bundler callbacks."
41
+ @after_blocks.each{|b| @current_recipe = b[0]; b[1].call}
42
+ @after_everything_blocks.each{|b| @current_recipe = b[0]; b[1].call}
@@ -0,0 +1,9 @@
1
+ # ><%= "[ #{name} ]".center(75,'-') %><
2
+
3
+ @current_recipe = "<%= key %>"
4
+ @before_configs["<%= key %>"].call if @before_configs["<%= key %>"]
5
+ say_recipe '<%= name %>'
6
+
7
+ <%= config.compile if config %>
8
+
9
+ <%= template %>
data/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module RailsWizard
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_wizard
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Michael Bleigh
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-15 00:00:00 -05:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: i18n
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 3.0.0
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 2.5.0
47
+ type: :development
48
+ version_requirements: *id003
49
+ description: Quickly and easily create Rails application templates featuring dozens of popular libraries.
50
+ email:
51
+ - michael@intridea.com
52
+ executables:
53
+ - rails_wizard
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - lib/rails_wizard/command.rb
60
+ - lib/rails_wizard/config.rb
61
+ - lib/rails_wizard/recipe.rb
62
+ - lib/rails_wizard/recipes.rb
63
+ - lib/rails_wizard/template.rb
64
+ - lib/rails_wizard.rb
65
+ - recipes/activerecord.rb
66
+ - recipes/capybara.rb
67
+ - recipes/cucumber.rb
68
+ - recipes/devise.rb
69
+ - recipes/git.rb
70
+ - recipes/haml.rb
71
+ - recipes/heroku.rb
72
+ - recipes/hoptoad.rb
73
+ - recipes/jammit.rb
74
+ - recipes/jquery.rb
75
+ - recipes/less.rb
76
+ - recipes/mongo_mapper.rb
77
+ - recipes/mongohq.rb
78
+ - recipes/mongoid.rb
79
+ - recipes/mootools.rb
80
+ - recipes/omniauth.rb
81
+ - recipes/prototype.rb
82
+ - recipes/redis.rb
83
+ - recipes/rightjs.rb
84
+ - recipes/rspec.rb
85
+ - recipes/sass.rb
86
+ - recipes/sequel.rb
87
+ - recipes/slim.rb
88
+ - recipes/test_unit.rb
89
+ - README.markdown
90
+ - version.rb
91
+ - templates/helpers.erb
92
+ - templates/layout.erb
93
+ - templates/recipe.erb
94
+ - spec/rails_wizard/config_spec.rb
95
+ - spec/rails_wizard/recipe_spec.rb
96
+ - spec/rails_wizard/recipes/sanity_spec.rb
97
+ - spec/rails_wizard/recipes_spec.rb
98
+ - spec/rails_wizard/template_spec.rb
99
+ - spec/spec_helper.rb
100
+ - spec/support/rails_directory.rb
101
+ - spec/support/template_runner.rb
102
+ - bin/rails_wizard
103
+ has_rdoc: true
104
+ homepage: http://railswizard.org/
105
+ licenses: []
106
+
107
+ post_install_message:
108
+ rdoc_options: []
109
+
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: "0"
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ requirements: []
125
+
126
+ rubyforge_project: rails_wizard
127
+ rubygems_version: 1.5.0
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: A tool for quickly generating Rails application templates.
131
+ test_files:
132
+ - spec/rails_wizard/config_spec.rb
133
+ - spec/rails_wizard/recipe_spec.rb
134
+ - spec/rails_wizard/recipes/sanity_spec.rb
135
+ - spec/rails_wizard/recipes_spec.rb
136
+ - spec/rails_wizard/template_spec.rb
137
+ - spec/spec_helper.rb
138
+ - spec/support/rails_directory.rb
139
+ - spec/support/template_runner.rb