thyone_creator 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/bin/thyone +7 -0
  2. data/lib/rails_wizard/command.rb +116 -0
  3. data/lib/rails_wizard/config.rb +88 -0
  4. data/lib/rails_wizard/recipe.rb +106 -0
  5. data/lib/rails_wizard/recipes.rb +38 -0
  6. data/lib/rails_wizard/template.rb +73 -0
  7. data/lib/rails_wizard.rb +10 -0
  8. data/recipes/action_mailer.rb +123 -0
  9. data/recipes/active_admin.rb +44 -0
  10. data/recipes/activerecord.rb +37 -0
  11. data/recipes/add_user.rb +129 -0
  12. data/recipes/airbrake.rb +34 -0
  13. data/recipes/backbone.rb +23 -0
  14. data/recipes/capybara.rb +34 -0
  15. data/recipes/cleanup.rb +40 -0
  16. data/recipes/cloudfiles.rb +36 -0
  17. data/recipes/compass.rb +46 -0
  18. data/recipes/compass_960.rb +48 -0
  19. data/recipes/cucumber.rb +75 -0
  20. data/recipes/datamapper.rb +111 -0
  21. data/recipes/devise.rb +114 -0
  22. data/recipes/extras.rb +80 -0
  23. data/recipes/git.rb +40 -0
  24. data/recipes/guard.rb +99 -0
  25. data/recipes/haml.rb +23 -0
  26. data/recipes/heroku.rb +62 -0
  27. data/recipes/home_page.rb +58 -0
  28. data/recipes/home_page_users.rb +47 -0
  29. data/recipes/html5.rb +153 -0
  30. data/recipes/inherited_resources.rb +23 -0
  31. data/recipes/less.rb +12 -0
  32. data/recipes/mongohq.rb +59 -0
  33. data/recipes/mongoid.rb +39 -0
  34. data/recipes/mongolab.rb +59 -0
  35. data/recipes/omniauth.rb +192 -0
  36. data/recipes/omniauth_email.rb +82 -0
  37. data/recipes/paperclip.rb +79 -0
  38. data/recipes/rails_admin.rb +21 -0
  39. data/recipes/redis.rb +23 -0
  40. data/recipes/responders.rb +10 -0
  41. data/recipes/resque.rb +25 -0
  42. data/recipes/rspec.rb +133 -0
  43. data/recipes/sass.rb +25 -0
  44. data/recipes/seed_database.rb +76 -0
  45. data/recipes/settingslogic.rb +43 -0
  46. data/recipes/simple_form.rb +54 -0
  47. data/recipes/slim.rb +46 -0
  48. data/recipes/static_page.rb +43 -0
  49. data/recipes/subdomains.rb +121 -0
  50. data/recipes/users_page.rb +165 -0
  51. data/spec/rails_wizard/config_spec.rb +108 -0
  52. data/spec/rails_wizard/recipe_spec.rb +81 -0
  53. data/spec/rails_wizard/recipes/sanity_spec.rb +30 -0
  54. data/spec/rails_wizard/recipes_spec.rb +24 -0
  55. data/spec/rails_wizard/template_spec.rb +78 -0
  56. data/spec/spec_helper.rb +11 -0
  57. data/spec/support/rails_directory.rb +17 -0
  58. data/spec/support/template_runner.rb +28 -0
  59. data/templates/helpers.erb +45 -0
  60. data/templates/layout.erb +83 -0
  61. data/templates/recipe.erb +10 -0
  62. data/version.rb +3 -0
  63. metadata +251 -0
data/bin/thyone ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.dirname(__FILE__) + '/../lib'
3
+
4
+ require 'rubygems'
5
+ require 'rails_wizard/command'
6
+
7
+ RailsWizard::Command.start
@@ -0,0 +1,116 @@
1
+ require 'rails_wizard'
2
+ require 'thor'
3
+
4
+ module RailsWizard
5
+ class Command < Thor
6
+ include Thor::Actions
7
+ desc "new APP_NAME", "create a new Rails app"
8
+ method_option :recipes, :type => :array, :aliases => "-r"
9
+ method_option :defaults, :type => :string, :aliases => "-d"
10
+ def new(name)
11
+ recipes, defaults = load_defaults
12
+ recipes = ask_for_recipes(recipes)
13
+ run_template(name, recipes, defaults, nil)
14
+ end
15
+
16
+ desc "template TEMPLATE_FILE", "create a new Rails template"
17
+ method_option :recipes, :type => :array, :aliases => "-r"
18
+ method_option :defaults, :type => :string, :aliases => "-d"
19
+ def template(template_name)
20
+ recipes, defaults = load_defaults
21
+ recipes = ask_for_recipes(recipes)
22
+ run_template(nil, recipes, defaults, template_name)
23
+ end
24
+
25
+ desc "list [CATEGORY]", "list available recipes (optionally by category)"
26
+ def list(category = nil)
27
+ if category
28
+ recipes = RailsWizard::Recipes.for(category).map{|r| RailsWizard::Recipe.from_mongo(r) }
29
+ else
30
+ recipes = RailsWizard::Recipes.list_classes
31
+ end
32
+
33
+ recipes.each do |recipe|
34
+ puts recipe.key.ljust(15) + "# #{recipe.description}"
35
+ end
36
+ end
37
+
38
+ no_tasks do
39
+ def cyan; "\033[36m" end
40
+ def clear; "\033[0m" end
41
+ def bold; "\033[1m" end
42
+ def red; "\033[31m" end
43
+ def green; "\033[32m" end
44
+ def yellow; "\033[33m" end
45
+
46
+ def load_defaults
47
+ # Load defaults from a file; if a file specifies recipes, they'll be run *before*
48
+ # any on the command line (or prompted for)..
49
+ defaults = if options[:defaults]
50
+ File.open(options[:defaults]) {|f| YAML.load(f) }
51
+ else
52
+ {}
53
+ end
54
+ recipes = defaults.delete('recipes') { [] }
55
+ [recipes, defaults]
56
+ end
57
+
58
+ def print_recipes(recipes)
59
+ puts
60
+ puts "#{bold}#{cyan}Available Recipes#{clear}:"
61
+ RailsWizard::Recipes.categories.each do |category|
62
+ puts "#{bold}#{cyan}#{category}#{clear}: " +RailsWizard::Recipes.for(category).collect {|recipe|
63
+ recipes.include?(recipe) ? "#{green}#{bold}#{recipe}#{clear}" : recipe
64
+ }.join(', ')
65
+ end
66
+ puts
67
+ end
68
+
69
+ def ask_for_recipes(recipes)
70
+ if options[:recipes]
71
+ return recipes + options[:recipes]
72
+ end
73
+ while recipe = ask("#{print_recipes(recipes)}#{bold}Which recipe would you like to add? #{clear}#{yellow}(blank to finish)#{clear}")
74
+ if recipe == ''
75
+ break
76
+ elsif recipes.include?(recipe)
77
+ recipes -= [recipe]
78
+ elsif RailsWizard::Recipes.list.include?(recipe)
79
+ recipes << recipe
80
+ else
81
+ puts
82
+ puts "> #{red}Invalid recipe, please try again.#{clear}"
83
+ end
84
+ end
85
+ recipes
86
+ end
87
+
88
+ #pass in name if you want to create a rails app
89
+ #pass in file_name if you want to create a template
90
+ def run_template(name, recipes, defaults, file_name=nil)
91
+ puts
92
+ puts
93
+ puts "#{bold}Generating#{name ? " and Running" : ''} Template..."
94
+ puts
95
+
96
+ if file_name
97
+ file = File.new(file_name,'w')
98
+ else
99
+ file = Tempfile.new('template')
100
+ end
101
+ template = RailsWizard::Template.new(recipes, defaults)
102
+ file.write template.compile
103
+ file.close
104
+ if name
105
+ system "rails new #{name} -m #{file.path} #{template.args.join(' ')}"
106
+ else
107
+ puts "install with the command:"
108
+ puts
109
+ puts "rails new <APP_NAME> -m #{file.path} #{template.args.join(' ')}"
110
+ end
111
+ ensure
112
+ file.unlink unless file_name
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,88 @@
1
+ require 'active_support/ordered_hash'
2
+
3
+ module RailsWizard
4
+ class Config
5
+ attr_reader :questions, :defaults
6
+
7
+ def initialize(schema, defaults=nil)
8
+ @questions = ActiveSupport::OrderedHash.new
9
+ @defaults = defaults
10
+ schema.each do |hash|
11
+ key = hash.keys.first
12
+ details = hash.values.first
13
+
14
+ kind = details['type']
15
+ raise ArgumentError, "Unrecognized question type, must be one of #{QUESTION_TYPES.keys.join(', ')}" unless QUESTION_TYPES.keys.include?(kind)
16
+ @questions[key] = QUESTION_TYPES[kind].new(details)
17
+ end
18
+ end
19
+
20
+ def compile(values = {})
21
+ result = []
22
+ values.merge!(defaults) if defaults
23
+ result << "config = #{values.inspect}"
24
+ @questions.each_pair do |key, question|
25
+ result << "config['#{key}'] = #{question.compile} unless config.key?('#{key}')"
26
+ end
27
+ result.join("\n")
28
+ end
29
+
30
+ class Prompt
31
+ attr_reader :prompt, :details
32
+ def initialize(details)
33
+ @details = details
34
+ @prompt = details['prompt']
35
+ end
36
+
37
+ def compile
38
+ "#{question} if #{conditions}"
39
+ end
40
+
41
+ def question
42
+ "ask_wizard(#{prompt.inspect})"
43
+ end
44
+
45
+ def conditions
46
+ [config_conditions, recipe_conditions].join(' && ')
47
+ end
48
+
49
+ def config_conditions
50
+ if details['if']
51
+ "config['#{details['if']}']"
52
+ elsif details['unless']
53
+ "!config['#{details['unless']}']"
54
+ else
55
+ 'true'
56
+ end
57
+ end
58
+
59
+ def recipe_conditions
60
+ if details['if_recipe']
61
+ "recipe?('#{details['if_recipe']}')"
62
+ elsif details['unless_recipe']
63
+ "!recipe?('#{details['unless_recipe']}')"
64
+ else
65
+ 'true'
66
+ end
67
+ end
68
+ end
69
+
70
+ class TrueFalse < Prompt
71
+ def question
72
+ "yes_wizard?(#{prompt.inspect})"
73
+ end
74
+ end
75
+
76
+ class MultipleChoice < Prompt
77
+ def question
78
+ "multiple_choice(#{prompt.inspect}, #{@details['choices'].inspect})"
79
+ end
80
+ end
81
+
82
+ QUESTION_TYPES = {
83
+ 'boolean' => TrueFalse,
84
+ 'string' => Prompt,
85
+ 'multiple_choice' => MultipleChoice
86
+ }
87
+ end
88
+ end
@@ -0,0 +1,106 @@
1
+ require 'rails_wizard/config'
2
+
3
+ require 'active_support/inflector'
4
+ require 'yaml'
5
+ require 'erb'
6
+
7
+ module RailsWizard
8
+ class Recipe
9
+ extend Comparable
10
+
11
+ def self.<=>(another)
12
+ return -1 if another.run_after.include?(self.key) || self.run_before.include?(another.key)
13
+ return 1 if another.run_before.include?(self.key) || self.run_after.include?(another.key)
14
+ self.key <=> another.key
15
+ end
16
+
17
+ ATTRIBUTES = %w(key args category name description template config exclusive tags run_before run_after requires defaults)
18
+ DEFAULT_ATTRIBUTES = {
19
+ :category => 'other',
20
+ :args => [],
21
+ :tags => [],
22
+ :run_after => [],
23
+ :run_before => [],
24
+ :requires => []
25
+ }
26
+
27
+ def self.generate(key, template_or_file, attributes = {})
28
+ if template_or_file.respond_to?(:read)
29
+ file = template_or_file.read
30
+ parts = file.split(/^__END__$/)
31
+ raise ArgumentError, "The recipe file must have YAML matter after an __END__" unless parts.size == 2
32
+ template = parts.first.strip
33
+ attributes = YAML.load(parts.last).inject({}) do |h,(k,v)|
34
+ h[k.to_sym] = v
35
+ h
36
+ end.merge!(attributes)
37
+ else
38
+ template = template_or_file
39
+ end
40
+
41
+ recipe_class = Class.new(RailsWizard::Recipe)
42
+ recipe_class.attributes = attributes
43
+ recipe_class.template = template
44
+ recipe_class.key = key
45
+
46
+ recipe_class
47
+ end
48
+
49
+ ATTRIBUTES.each do |setter|
50
+ class_eval <<-RUBY
51
+ def self.#{setter}
52
+ attributes[:#{setter}]
53
+ end
54
+
55
+ def self.#{setter}=(val)
56
+ attributes[:#{setter}] = val
57
+ end
58
+
59
+ def #{setter}
60
+ self.class.#{setter}
61
+ end
62
+ RUBY
63
+ end
64
+
65
+ # The attributes hash containing any set values for
66
+ def self.attributes
67
+ @attributes ||= DEFAULT_ATTRIBUTES.dup
68
+ end
69
+
70
+ def self.attributes=(hash)
71
+ attributes.merge! hash
72
+ end
73
+
74
+ def self.config
75
+ return nil unless attributes[:config]
76
+ RailsWizard::Config.new(attributes[:config], attributes[:defaults])
77
+ end
78
+
79
+ def attributes
80
+ self.class.attributes
81
+ end
82
+
83
+ def self.compile
84
+ "# >#{"[ #{name} ]".center(75,'-')}<\n\n# #{description}\nsay_recipe '#{name}'\n\n#{template}\n"
85
+ end
86
+ def compile; self.class.compile end
87
+
88
+ def self.to_mongo(value)
89
+ case value
90
+ when Class
91
+ value.key
92
+ when String
93
+ value
94
+ end
95
+ end
96
+
97
+ def self.from_mongo(key)
98
+ return key if key.respond_to?(:superclass) && key.superclass == RailsWizard::Recipe
99
+ RailsWizard::Recipes[key]
100
+ end
101
+
102
+ def self.get_binding
103
+ binding
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,38 @@
1
+ module RailsWizard
2
+ module Recipes
3
+ @@categories = {}
4
+ @@list = {}
5
+
6
+ def self.add(recipe)
7
+ RailsWizard::Recipes.const_set ActiveSupport::Inflector.camelize(recipe.key), recipe
8
+ @@list[recipe.key] = recipe
9
+ (@@categories[recipe.category.to_s] ||= []) << recipe.key
10
+ @@categories[recipe.category.to_s].uniq!
11
+ recipe
12
+ end
13
+
14
+ def self.[](key)
15
+ @@list[key.to_s]
16
+ end
17
+
18
+ def self.list
19
+ @@list.keys.sort
20
+ end
21
+
22
+ def self.list_classes
23
+ @@list.values.sort_by{|c| c.key}
24
+ end
25
+
26
+ def self.categories
27
+ @@categories.keys.sort
28
+ end
29
+
30
+ def self.for(category)
31
+ (@@categories[category.to_s] || []).sort
32
+ end
33
+
34
+ def self.remove_from_category(category, recipe)
35
+ (@@categories[category.to_s] ||= []).delete(recipe.key)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,73 @@
1
+ module RailsWizard
2
+ class Template
3
+ attr_reader :recipes, :defaults
4
+
5
+ def initialize(recipes, defaults={})
6
+ @recipes = recipes.map{|r| RailsWizard::Recipe.from_mongo(r)}
7
+ @defaults = defaults
8
+ end
9
+
10
+ def self.template_root
11
+ File.dirname(__FILE__) + '/../../templates'
12
+ end
13
+
14
+ def self.render(template_name, binding = nil)
15
+ erb = ERB.new(File.open(template_root + '/' + template_name + '.erb').read)
16
+ erb.result(binding)
17
+ end
18
+ def render(template_name, binding = nil); self.class.render(template_name, binding) end
19
+
20
+
21
+ # Sort the recipes list taking 'run_after' directives into account.
22
+ def resolve_recipes
23
+ @resolve_recipes ||= begin
24
+ list = recipes_with_dependencies
25
+
26
+ for i in 0...list.size
27
+ after_keys = list[i+1..-1].map { |r| r.key }
28
+
29
+ if (list[i].run_after & after_keys).any?
30
+ list.push list.slice!(i)
31
+ redo
32
+ end
33
+ end
34
+
35
+ list.each {|recipe| recipe.defaults = defaults[recipe.key] }
36
+ list
37
+ end
38
+ end
39
+
40
+ def recipe_classes
41
+ @recipe_classes ||= recipes.map{|r| RailsWizard::Recipe.from_mongo(r)}
42
+ end
43
+
44
+ def recipes_with_dependencies
45
+ @recipes_with_dependencies ||= recipe_classes
46
+
47
+ added_more = false
48
+ for recipe in recipe_classes
49
+ recipe.requires.each do |requirement|
50
+ requirement = RailsWizard::Recipe.from_mongo(requirement)
51
+ count = @recipes_with_dependencies.size
52
+ (@recipes_with_dependencies << requirement).uniq!
53
+ unless @recipes_with_dependencies.size == count
54
+ added_more = true
55
+ end
56
+ end
57
+ end
58
+
59
+ added_more ? recipes_with_dependencies : @recipes_with_dependencies
60
+ end
61
+
62
+ def compile
63
+ render 'layout', binding
64
+ end
65
+
66
+ def args
67
+ recipes.map(&:args).uniq
68
+ end
69
+
70
+ def custom_code?; false end
71
+ def custom_code; nil end
72
+ end
73
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails_wizard/recipes'
2
+ require 'rails_wizard/recipe'
3
+ require 'rails_wizard/config'
4
+ require 'rails_wizard/template'
5
+
6
+ Dir[File.dirname(__FILE__) + '/../recipes/*.rb'].each do |path|
7
+ key = File.basename(path, '.rb')
8
+ recipe = RailsWizard::Recipe.generate(key, File.open(path))
9
+ RailsWizard::Recipes.add(recipe)
10
+ end
@@ -0,0 +1,123 @@
1
+ # Application template recipe for the rails_apps_composer. Check for a newer version here:
2
+ # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/action_mailer.rb
3
+
4
+ case config['mailer']
5
+ when 'smtp'
6
+ recipes << 'smtp'
7
+ when 'gmail'
8
+ recipes << 'gmail'
9
+ when 'sendgrid'
10
+ gem 'sendgrid'
11
+ recipes << 'sendgrid'
12
+ when 'mandrill'
13
+ gem 'hominid'
14
+ recipes << 'mandrill'
15
+ end
16
+
17
+ after_bundler do
18
+ ### modifying environment configuration files for ActionMailer
19
+ say_wizard "ActionMailer recipe running 'after bundler'"
20
+ ### development environment
21
+ gsub_file 'config/environments/development.rb', /# Don't care if the mailer can't send/, '# ActionMailer Config'
22
+ gsub_file 'config/environments/development.rb', /config.action_mailer.raise_delivery_errors = false/ do
23
+ <<-RUBY
24
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
25
+ config.action_mailer.delivery_method = :smtp
26
+ # change to true to allow email to be sent during development
27
+ config.action_mailer.perform_deliveries = false
28
+ config.action_mailer.raise_delivery_errors = true
29
+ config.action_mailer.default :charset => "utf-8"
30
+ RUBY
31
+ end
32
+ ### test environment
33
+ inject_into_file 'config/environments/test.rb', :before => "\nend" do
34
+ <<-RUBY
35
+ \n
36
+ # ActionMailer Config
37
+ config.action_mailer.default_url_options = { :host => 'example.com' }
38
+ RUBY
39
+ end
40
+ ### production environment
41
+ gsub_file 'config/environments/production.rb', /config.active_support.deprecation = :notify/ do
42
+ <<-RUBY
43
+ config.active_support.deprecation = :notify
44
+
45
+ config.action_mailer.default_url_options = { :host => 'example.com' }
46
+ # ActionMailer Config
47
+ # Setup for production - deliveries, no errors raised
48
+ config.action_mailer.delivery_method = :smtp
49
+ config.action_mailer.perform_deliveries = true
50
+ config.action_mailer.raise_delivery_errors = false
51
+ config.action_mailer.default :charset => "utf-8"
52
+ RUBY
53
+ end
54
+
55
+ ### modifying environment configuration files to send email using a GMail account
56
+ if recipes.include? 'gmail'
57
+ gmail_configuration_text = <<-TEXT
58
+ \n
59
+ config.action_mailer.smtp_settings = {
60
+ address: "smtp.gmail.com",
61
+ port: 587,
62
+ domain: "example.com",
63
+ authentication: "plain",
64
+ enable_starttls_auto: true,
65
+ user_name: ENV["GMAIL_USERNAME"],
66
+ password: ENV["GMAIL_PASSWORD"]
67
+ }
68
+ TEXT
69
+ say_wizard gmail_configuration_text
70
+ inject_into_file 'config/environments/development.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
71
+ inject_into_file 'config/environments/production.rb', gmail_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
72
+ end
73
+
74
+ ### modifying environment configuration files to send email using a SendGrid account
75
+ if recipes.include? 'sendgrid'
76
+ sendgrid_configuration_text = <<-TEXT
77
+ \n
78
+ config.action_mailer.smtp_settings = {
79
+ address: "smtp.sendgrid.net",
80
+ port: 25,
81
+ domain: "example.com",
82
+ authentication: "plain",
83
+ user_name: ENV["SENDGRID_USERNAME"],
84
+ password: ENV["SENDGRID_PASSWORD"]
85
+ }
86
+ TEXT
87
+ say_wizard gmail_configuration_text
88
+ inject_into_file 'config/environments/development.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
89
+ inject_into_file 'config/environments/production.rb', sendgrid_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
90
+ end
91
+
92
+ ### modifying environment configuration files to send email using a Mandrill account
93
+ if recipes.include? 'mandrill'
94
+ mandrill_configuration_text = <<-TEXT
95
+ \n
96
+ config.action_mailer.smtp_settings = {
97
+ :address => "smtp.mandrillapp.com",
98
+ :port => 25,
99
+ :user_name => ENV["MANDRILL_USERNAME"],
100
+ :password => ENV["MANDRILL_API_KEY"]
101
+ }
102
+ TEXT
103
+ say_wizard gmail_configuration_text
104
+ inject_into_file 'config/environments/development.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
105
+ inject_into_file 'config/environments/production.rb', mandrill_configuration_text, :after => 'config.action_mailer.default :charset => "utf-8"'
106
+ end
107
+
108
+ end
109
+
110
+ __END__
111
+
112
+ name: ActionMailer
113
+ description: "Configure ActionMailer for email."
114
+ author: RailsApps
115
+
116
+ category: other
117
+ tags: [utilities, configuration]
118
+
119
+ config:
120
+ - mailer:
121
+ type: multiple_choice
122
+ prompt: "How will you send email?"
123
+ choices: [["SMTP account", smtp], ["Gmail account", gmail], ["SendGrid account", sendgrid], ["Mandrill by MailChimp account", mandrill]]
@@ -0,0 +1,44 @@
1
+ if recipes.include? 'mongoid'
2
+ gem 'formtastic', "~> 2.1.1"
3
+ gem 'activeadmin-mongoid'
4
+ else
5
+ gem 'activeadmin'
6
+ end
7
+ gem "meta_search", '>= 1.1.0.pre'
8
+ # sass-rails is also required but is by default in rails
9
+
10
+
11
+ after_bundler do
12
+ case config['user_model']
13
+ when 'default'
14
+ generate 'active_admin:install'
15
+ when ''
16
+ generate 'active_admin:install'
17
+ when 'skip'
18
+ generate 'active_admin:install --skip-users'
19
+ else
20
+ generate "active_admin:install #{config['user_model']}"
21
+ end
22
+
23
+ if config['i18n']
24
+ get "https://raw.github.com/gregbell/active_admin/master/lib/active_admin/locales/zh_cn.yml", "config/locales/active_admin.zh-CN.yml"
25
+ gsub_file "config/locales/active_admin.zh-CN.yml", /zh_cn/, "zh-CN"
26
+ end
27
+ end
28
+
29
+ __END__
30
+
31
+ name: ActiveAdmin
32
+ description: "Install Active Admin to build an administration zone data in your application"
33
+ author: systho
34
+
35
+ category: other
36
+
37
+ config:
38
+ - user_model:
39
+ type: string
40
+ prompt: "What model will you use for admin users ? type 'skip' to skip this step (default is AdminUser)"
41
+ - i18n:
42
+ type: boolean
43
+ prompt: "Would you want to set active admin to zh-CN locale?"
44
+
@@ -0,0 +1,37 @@
1
+ if config['database']
2
+ say_wizard "Configuring '#{config['database']}' database settings..."
3
+ old_gem = gem_for_database
4
+ @options = @options.dup.merge(:database => config['database'])
5
+ gsub_file 'Gemfile', "gem '#{old_gem}'", "gem '#{gem_for_database}'"
6
+ template "config/databases/#{@options[:database]}.yml", "config/database.yml.new"
7
+ run 'mv config/database.yml.new config/database.yml'
8
+ end
9
+
10
+ after_bundler do
11
+ rake "db:create:all" if config['auto_create']
12
+ end
13
+
14
+ __END__
15
+
16
+ name: ActiveRecord
17
+ description: "Use the default ActiveRecord database store."
18
+ author: mbleigh
19
+
20
+ exclusive: orm
21
+ category: persistence
22
+ tags: [sql, defaults, orm]
23
+
24
+ config:
25
+ - database:
26
+ type: multiple_choice
27
+ prompt: "Which database are you using?"
28
+ choices:
29
+ - ["MySQL", mysql]
30
+ - ["Oracle", oracle]
31
+ - ["PostgreSQL", postgresql]
32
+ - ["SQLite", sqlite3]
33
+ - ["Frontbase", frontbase]
34
+ - ["IBM DB", ibm_db]
35
+ - auto_create:
36
+ type: boolean
37
+ prompt: "Automatically create database with default configuration?"