phoenix_core 0.2.0.beta
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/README.md +3 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/noise.png +0 -0
- data/app/assets/javascripts/application.js +14 -0
- data/app/assets/stylesheets/application.css +8 -0
- data/app/assets/stylesheets/bootstrap.css +2467 -0
- data/app/assets/stylesheets/global.css +24 -0
- data/app/assets/stylesheets/landing.css +1 -0
- data/app/controllers/phoenix/base_controller.rb +5 -0
- data/app/controllers/phoenix/home_controller.rb +13 -0
- data/app/helpers/phoenix/base_helper.rb +4 -0
- data/app/mailers/phoenix/base_mailer.rb +10 -0
- data/app/models/phoenix/user.rb +8 -0
- data/app/views/phoenix/home/index.html.haml +13 -0
- data/app/views/phoenix/layouts/phoenix_core/application.html.erb +14 -0
- data/config/initializers/phoenix.rb +3 -0
- data/config/initializers/setup_mail.rb +19 -0
- data/config/initializers/simple_form.rb +93 -0
- data/config/locals/phoenix/en.yml +2 -0
- data/config/locals/simple_form/en.yml +23 -0
- data/config/locals/simple_form/zn-CN.yml +23 -0
- data/config/routes.rb +3 -0
- data/lib/generators/phoenix/app/app_generator.rb +209 -0
- data/lib/generators/phoenix/dummy/dummy_generator.rb +86 -0
- data/lib/generators/phoenix/dummy/templates/rails/Rakefile +7 -0
- data/lib/generators/phoenix/dummy/templates/rails/application.rb +14 -0
- data/lib/generators/phoenix/dummy/templates/rails/boot.rb +6 -0
- data/lib/generators/phoenix/dummy/templates/rails/mongoid.yml +0 -0
- data/lib/generators/phoenix/dummy/templates/rails/routes.rb +3 -0
- data/lib/generators/phoenix/extension/clash_keywords.yml +3 -0
- data/lib/generators/phoenix/extension/extension_generator.rb +137 -0
- data/lib/generators/phoenix/extension/templates/Gemfile +13 -0
- data/lib/generators/phoenix/extension/templates/README.md +21 -0
- data/lib/generators/phoenix/extension/templates/app/assets/javascripts/application.js +1 -0
- data/lib/generators/phoenix/extension/templates/app/assets/stylesheets/application.css +3 -0
- data/lib/generators/phoenix/extension/templates/app/controllers/phoenix/admin/plural_name_controller.rb +12 -0
- data/lib/generators/phoenix/extension/templates/app/controllers/phoenix/plural_name_controller.rb +32 -0
- data/lib/generators/phoenix/extension/templates/app/models/phoenix/plural_name/singular_name.rb +27 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_actions.html.erb +28 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_form.html.erb +68 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_plural_name.html.erb +2 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_records.html.erb +18 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_singular_name.html.erb +18 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_sortable_list.html.erb +7 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/edit.html.erb +1 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/index.html.erb +10 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/new.html.erb +1 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/plural_name/index.html.erb +11 -0
- data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/plural_name/show.html.erb +35 -0
- data/lib/generators/phoenix/extension/templates/config/locales/en.yml +5 -0
- data/lib/generators/phoenix/extension/templates/config/routes.rb +3 -0
- data/lib/generators/phoenix/extension/templates/extension.gemspec +28 -0
- data/lib/generators/phoenix/extension/templates/gitignore +10 -0
- data/lib/generators/phoenix/extension/templates/lib/generators/phoenix/plural_name_generator.rb +11 -0
- data/lib/generators/phoenix/extension/templates/lib/phoenix/plural_name.rb +25 -0
- data/lib/generators/phoenix/extension/templates/lib/phoenix/plural_name/engine.rb +29 -0
- data/lib/generators/phoenix/extension/templates/lib/phoenix_plural_name.rb +1 -0
- data/lib/generators/phoenix/extension/templates/lib/tasks/plural_name.rake +13 -0
- data/lib/generators/phoenix/extension/templates/phoenix_plural_name.gemspec +18 -0
- data/lib/generators/phoenix/extension/templates/spec/models/phoenix/singular_name_spec.rb +18 -0
- data/lib/generators/phoenix/extension/templates/spec/requests/phoenix/admin/plural_name_spec.rb +97 -0
- data/lib/generators/phoenix/extension/templates/spec/support/phoenix/factories.rb +7 -0
- data/lib/middleware/seo_assist.rb +0 -0
- data/lib/phoenix/core.rb +40 -0
- data/lib/phoenix/core/controller_helpers.rb +47 -0
- data/lib/phoenix/core/development_mail_interceptor.rb +10 -0
- data/lib/phoenix/core/engine.rb +10 -0
- data/lib/phoenix/core/ssl_requirement.rb +105 -0
- data/lib/phoenix/core/testing_support/common_rake.rb +25 -0
- data/lib/phoenix/core/testing_support/env.rb +2 -0
- data/lib/phoenix/engine.rb +65 -0
- data/lib/phoenix/version.rb +16 -0
- data/lib/phoenix_core.rb +3 -0
- data/lib/tasks/assets.rake +16 -0
- data/lib/tasks/phoenix.rake +2 -0
- metadata +252 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* global.css */
|
|
2
|
+
body {
|
|
3
|
+
background:#fff url(/assets/noise.png);
|
|
4
|
+
}
|
|
5
|
+
header {
|
|
6
|
+
background: #333;
|
|
7
|
+
height: 60px;
|
|
8
|
+
}
|
|
9
|
+
#body {
|
|
10
|
+
width: 980px;
|
|
11
|
+
margin: 0 auto;
|
|
12
|
+
}
|
|
13
|
+
footer {
|
|
14
|
+
border-top: 1px solid #ccc;
|
|
15
|
+
margin: 0 auto;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
#signup-form {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
#signin-form {
|
|
23
|
+
padding: 30px 0;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* landing.css */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Phoenix
|
|
2
|
+
class HomeController < BaseController
|
|
3
|
+
def index
|
|
4
|
+
#RubyProf.start
|
|
5
|
+
"hello world!"
|
|
6
|
+
#results = RubyProf.stop
|
|
7
|
+
|
|
8
|
+
#File.open "/home/lanvige/repos/profile-index.html", 'a' do |file|
|
|
9
|
+
# RubyProf::GraphHtmlPrinter.new(results).print(file)
|
|
10
|
+
#end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>PhoenixCore</title>
|
|
5
|
+
<%= stylesheet_link_tag "phoenix_core/application" %>
|
|
6
|
+
<%= javascript_include_tag "phoenix_core/application" %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# If you wish to intercept emails to go to a particuar email address
|
|
2
|
+
# ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
|
|
3
|
+
|
|
4
|
+
ActionMailer::Base.delivery_method = :smtp
|
|
5
|
+
|
|
6
|
+
Mail.register_interceptor(Phoenix::Core::DevelopmentMailInterceptor) if Rails.env.development?
|
|
7
|
+
|
|
8
|
+
# This assumes you're running your local development server on port 3000 via $ rails server
|
|
9
|
+
ActionMailer::Base.default_url_options = { :host => "localhost:3000" }
|
|
10
|
+
|
|
11
|
+
ActionMailer::Base.smtp_settings = {
|
|
12
|
+
:address => "smtp.gmail.com",
|
|
13
|
+
:port => 25,
|
|
14
|
+
:domain => "zhuke.me",
|
|
15
|
+
:authentication => :login,
|
|
16
|
+
:user_name => "zhuke.me@gmail.com",
|
|
17
|
+
:password => "zhuke.me001",
|
|
18
|
+
:tls => true
|
|
19
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Use this setup block to configure all options available in SimpleForm.
|
|
2
|
+
SimpleForm.setup do |config|
|
|
3
|
+
# Components used by the form builder to generate a complete input. You can remove
|
|
4
|
+
# any of them, change the order, or even add your own components to the stack.
|
|
5
|
+
# config.components = [ :placeholder, :label_input, :hint, :error ]
|
|
6
|
+
|
|
7
|
+
# Default tag used on hints.
|
|
8
|
+
# config.hint_tag = :span
|
|
9
|
+
|
|
10
|
+
# CSS class to add to all hint tags.
|
|
11
|
+
# config.hint_class = :hint
|
|
12
|
+
|
|
13
|
+
# CSS class used on errors.
|
|
14
|
+
# config.error_class = :error
|
|
15
|
+
|
|
16
|
+
# Default tag used on errors.
|
|
17
|
+
# config.error_tag = :span
|
|
18
|
+
|
|
19
|
+
# Method used to tidy up errors.
|
|
20
|
+
# config.error_method = :first
|
|
21
|
+
|
|
22
|
+
# Default tag used for error notification helper.
|
|
23
|
+
# config.error_notification_tag = :p
|
|
24
|
+
|
|
25
|
+
# CSS class to add for error notification helper.
|
|
26
|
+
# config.error_notification_class = :error_notification
|
|
27
|
+
|
|
28
|
+
# ID to add for error notification helper.
|
|
29
|
+
# config.error_notification_id = nil
|
|
30
|
+
|
|
31
|
+
# You can wrap all inputs in a pre-defined tag.
|
|
32
|
+
# config.wrapper_tag = :div
|
|
33
|
+
|
|
34
|
+
# CSS class to add to all wrapper tags.
|
|
35
|
+
# config.wrapper_class = :input
|
|
36
|
+
|
|
37
|
+
# CSS class to add to the wrapper if the field has errors.
|
|
38
|
+
# config.wrapper_error_class = :field_with_errors
|
|
39
|
+
|
|
40
|
+
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
|
41
|
+
# config.collection_wrapper_tag = nil
|
|
42
|
+
|
|
43
|
+
# You can wrap each item in a collection of radio/check boxes with a tag, defaulting to span.
|
|
44
|
+
# config.item_wrapper_tag = :span
|
|
45
|
+
|
|
46
|
+
# Series of attemps to detect a default label method for collection.
|
|
47
|
+
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
|
48
|
+
|
|
49
|
+
# Series of attemps to detect a default value method for collection.
|
|
50
|
+
# config.collection_value_methods = [ :id, :to_s ]
|
|
51
|
+
|
|
52
|
+
# How the label text should be generated altogether with the required text.
|
|
53
|
+
# config.label_text = lambda { |label, required| "#{required} #{label}" }
|
|
54
|
+
|
|
55
|
+
# You can define the class to use on all labels. Default is nil.
|
|
56
|
+
# config.label_class = nil
|
|
57
|
+
|
|
58
|
+
# You can define the class to use on all forms. Default is simple_form.
|
|
59
|
+
# config.form_class = :simple_form
|
|
60
|
+
|
|
61
|
+
# Whether attributes are required by default (or not). Default is true.
|
|
62
|
+
# config.required_by_default = true
|
|
63
|
+
|
|
64
|
+
# Tell browsers whether to use default HTML5 validations (novalidate option).
|
|
65
|
+
# Default is enabled.
|
|
66
|
+
# config.browser_validations = true
|
|
67
|
+
|
|
68
|
+
# Determines whether HTML5 types (:email, :url, :search, :tel) and attributes
|
|
69
|
+
# (e.g. required) are used or not. True by default.
|
|
70
|
+
# Having this on in non-HTML5 compliant sites can cause odd behavior in
|
|
71
|
+
# HTML5-aware browsers such as Chrome.
|
|
72
|
+
config.html5 = true
|
|
73
|
+
|
|
74
|
+
# Custom mappings for input types. This should be a hash containing a regexp
|
|
75
|
+
# to match as key, and the input type that will be used when the field name
|
|
76
|
+
# matches the regexp as value.
|
|
77
|
+
# config.input_mappings = { /count/ => :integer }
|
|
78
|
+
|
|
79
|
+
# Collection of methods to detect if a file type was given.
|
|
80
|
+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
|
81
|
+
|
|
82
|
+
# Default priority for time_zone inputs.
|
|
83
|
+
# config.time_zone_priority = nil
|
|
84
|
+
|
|
85
|
+
# Default priority for country inputs.
|
|
86
|
+
# config.country_priority = nil
|
|
87
|
+
|
|
88
|
+
# Default size for text inputs.
|
|
89
|
+
# config.default_input_size = 50
|
|
90
|
+
|
|
91
|
+
# When false, do not use translations for labels, hints or placeholders.
|
|
92
|
+
# config.translate = true
|
|
93
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
en:
|
|
2
|
+
simple_form:
|
|
3
|
+
"yes": 'Yes'
|
|
4
|
+
"no": 'No'
|
|
5
|
+
required:
|
|
6
|
+
text: 'required'
|
|
7
|
+
mark: '*'
|
|
8
|
+
# You can uncomment the line below if you need to overwrite the whole required html.
|
|
9
|
+
# When using html, text and mark won't be used.
|
|
10
|
+
# html: '<abbr title="required">*</abbr>'
|
|
11
|
+
error_notification:
|
|
12
|
+
default_message: "Some errors were found, please take a look:"
|
|
13
|
+
# Labels and hints examples
|
|
14
|
+
# labels:
|
|
15
|
+
# password: 'Password'
|
|
16
|
+
# user:
|
|
17
|
+
# new:
|
|
18
|
+
# email: 'E-mail para efetuar o sign in.'
|
|
19
|
+
# edit:
|
|
20
|
+
# email: 'E-mail.'
|
|
21
|
+
# hints:
|
|
22
|
+
# name: 'User name to sign in.'
|
|
23
|
+
# password: 'No special characters, please.'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
zh-CN:
|
|
2
|
+
simple_form:
|
|
3
|
+
"yes": 'Yes'
|
|
4
|
+
"no": 'No'
|
|
5
|
+
required:
|
|
6
|
+
text: 'required'
|
|
7
|
+
mark: '*'
|
|
8
|
+
# You can uncomment the line below if you need to overwrite the whole required html.
|
|
9
|
+
# When using html, text and mark won't be used.
|
|
10
|
+
# html: '<abbr title="required">*</abbr>'
|
|
11
|
+
error_notification:
|
|
12
|
+
default_message: "Some errors were found, please take a look:"
|
|
13
|
+
# Labels and hints examples
|
|
14
|
+
# labels:
|
|
15
|
+
# password: 'Password'
|
|
16
|
+
# user:
|
|
17
|
+
# new:
|
|
18
|
+
# email: 'E-mail para efetuar o sign in.'
|
|
19
|
+
# edit:
|
|
20
|
+
# email: 'E-mail.'
|
|
21
|
+
# hints:
|
|
22
|
+
# name: 'User name to sign in.'
|
|
23
|
+
# password: 'No special characters, please.'
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
|
3
|
+
require 'rails/version'
|
|
4
|
+
|
|
5
|
+
module Phoenix
|
|
6
|
+
class AppGenerator < Rails::Generators::AppBase
|
|
7
|
+
|
|
8
|
+
source_root Pathname.new(File.expand_path('../templates', __FILE__))
|
|
9
|
+
|
|
10
|
+
add_shared_options_for("Phoenix")
|
|
11
|
+
|
|
12
|
+
class_option :force, :type => :boolean, :aliases => ['-f'], :default => false,
|
|
13
|
+
:desc => "Force overwriting of directory"
|
|
14
|
+
|
|
15
|
+
class_option :gems, :type => :array, :aliases => ['-g'],
|
|
16
|
+
:desc => "Additional gems to install"
|
|
17
|
+
|
|
18
|
+
class_option :confirm, :type => :boolean, :aliases => ['-c'], :default => false,
|
|
19
|
+
:desc => "Confirm any prompts that require input"
|
|
20
|
+
|
|
21
|
+
class_option :testing, :type => :boolean, :aliases => ['-t'], :default => true,
|
|
22
|
+
:desc => "Automatically set up the project with phoenix-testing support"
|
|
23
|
+
|
|
24
|
+
class_option :trace, :type => :boolean, :default => false,
|
|
25
|
+
:desc => "Investigate any problems with the installer"
|
|
26
|
+
|
|
27
|
+
class_option :version, :type => :boolean, :default => false,
|
|
28
|
+
:desc => "Display the installed version of Phoenix Engine"
|
|
29
|
+
|
|
30
|
+
class_option :skip_db, :type => :boolean, :default => false,
|
|
31
|
+
:desc => "Skip database creation and migration tasks"
|
|
32
|
+
|
|
33
|
+
# Remove overridden or non-relevant class options
|
|
34
|
+
remove_class_option(:skip_test_unit, :skip_bundle, :skip_gemfile, :skip_active_record, :skip_sprockets)
|
|
35
|
+
|
|
36
|
+
TARGET_MAJOR_VERSION = 3
|
|
37
|
+
TARGET_MINOR_VERSION = 1
|
|
38
|
+
|
|
39
|
+
class << self
|
|
40
|
+
def reserved_app_names
|
|
41
|
+
@reserved_app_names ||= [
|
|
42
|
+
'phoenix',
|
|
43
|
+
'rails'
|
|
44
|
+
]
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def run!
|
|
49
|
+
self.destination_root = app_path
|
|
50
|
+
|
|
51
|
+
validate_options!
|
|
52
|
+
generate_rails!
|
|
53
|
+
prepare_gemfile!
|
|
54
|
+
run_bundle
|
|
55
|
+
|
|
56
|
+
rake('phoenix_core:install')
|
|
57
|
+
rake('phoenix_auth:install')
|
|
58
|
+
|
|
59
|
+
rake("db:migrate#{' --trace' if options[:trace]}")
|
|
60
|
+
|
|
61
|
+
puts "\n---------"
|
|
62
|
+
puts "Phoneinx successfully installed in '#{app_pathname}'!\n\n"
|
|
63
|
+
|
|
64
|
+
heroku_deploy! if options[:heroku]
|
|
65
|
+
|
|
66
|
+
note = ["\n=== ACTION REQUIRED ==="]
|
|
67
|
+
if options[:skip_db]
|
|
68
|
+
note << "Because you elected to skip database creation and migration in the installer"
|
|
69
|
+
note << "you will need to run the following tasks manually to maintain correct operation:"
|
|
70
|
+
note << "\ncd #{app_pathname}"
|
|
71
|
+
note << "bundle exec rake db:create"
|
|
72
|
+
note << "bundle exec rails generate phoenix:cms"
|
|
73
|
+
note << "bundle exec rake db:migrate"
|
|
74
|
+
note << "\n---------\n"
|
|
75
|
+
end
|
|
76
|
+
note << "Now you can launch your webserver using:"
|
|
77
|
+
note << "\ncd #{app_pathname}"
|
|
78
|
+
note << "rails server"
|
|
79
|
+
note << "\nThis will launch the built-in webserver at port 3000."
|
|
80
|
+
note << "You can now see your site running in your browser at http://localhost:3000"
|
|
81
|
+
|
|
82
|
+
if options[:heroku]
|
|
83
|
+
note << "\nIf you want files and images to work on heroku, you will need setup S3:"
|
|
84
|
+
note << "heroku config:add S3_BUCKET=XXXXXXXXX S3_KEY=XXXXXXXXX S3_SECRET=XXXXXXXXXX S3_REGION=XXXXXXXXXX"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
note << "\nThanks for installing Phoenix, enjoy creating your new application!"
|
|
88
|
+
note << "---------\n\n"
|
|
89
|
+
|
|
90
|
+
puts note.join("\n")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
protected
|
|
94
|
+
# Returns an instance of Pathname representing the required parameter app_path
|
|
95
|
+
def app_pathname
|
|
96
|
+
@app_pathname ||= Pathname.new(File.expand_path(app_path))
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def validate_options!
|
|
100
|
+
app_name = app_pathname.split.last.to_s
|
|
101
|
+
|
|
102
|
+
unless valid_rails_version?
|
|
103
|
+
puts "\nRails #{Rails::VERSION::STRING} is not supported by Phoenix #{Phoenix.version}, " \
|
|
104
|
+
"please use Rails #{TARGET_MAJOR_VERSION}.#{TARGET_MINOR_VERSION}.x instead."
|
|
105
|
+
exit(1)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
unless valid_app_name?(app_name)
|
|
109
|
+
puts "\nYou can't use '#{app_name}' as a name for your project, this is a reserved word that will cause conflicts."
|
|
110
|
+
puts "Please choose another name for your new project."
|
|
111
|
+
puts "\n"
|
|
112
|
+
exit(1)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
unless options[:force] || !app_pathname.directory?
|
|
116
|
+
puts "\nThe directory '#{app_pathname}' that you specified already exists."
|
|
117
|
+
puts "Use --force to overwrite an existing directory."
|
|
118
|
+
puts "\n"
|
|
119
|
+
exit(1)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if options[:heroku]
|
|
123
|
+
if options[:heroku].to_s.include?('_') or options[:heroku].to_s.length > 30
|
|
124
|
+
message = ["\nThe application name '#{options[:heroku]}' that you specified is invalid for Heroku."]
|
|
125
|
+
suggested_name = options[:heroku].dup.to_s
|
|
126
|
+
if suggested_name.include?('_')
|
|
127
|
+
message << "This is because it contains underscores which Heroku does not allow."
|
|
128
|
+
suggested_name.gsub!(/_/, '-')
|
|
129
|
+
end
|
|
130
|
+
if suggested_name.length > 30
|
|
131
|
+
message << "This is#{" also" unless suggested_name.nil?} because it is longer than 30 characters."
|
|
132
|
+
suggested_name = suggested_name[0..29]
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
if options[:force] || options[:confirm]
|
|
136
|
+
options[:heroku] = suggested_name
|
|
137
|
+
else
|
|
138
|
+
message << "Please choose another name like '#{suggested_name}'"
|
|
139
|
+
message << "Or use --confirm to automatically use '#{suggested_name}'"
|
|
140
|
+
message << "\n"
|
|
141
|
+
puts message.join("\n")
|
|
142
|
+
exit(1)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def generate_rails!
|
|
149
|
+
rails_options = options.dup
|
|
150
|
+
rails_options[:skip_test_unit] = true
|
|
151
|
+
rails_options[:skip_bundle] = true
|
|
152
|
+
|
|
153
|
+
Rails::Generators::AppGenerator.new([app_path], rails_options).invoke_all
|
|
154
|
+
|
|
155
|
+
if defined?(JRUBY_VERSION)
|
|
156
|
+
find_and_replace('Gemfile', /['|"]sqlite3['|"]/, "'activerecord-jdbcsqlite3-adapter'")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Remove rails from the Gemfile so that Phoenix can manage it
|
|
160
|
+
find_and_replace('Gemfile', %r{^gem 'rails'}, "# gem 'rails'")
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def prepare_gemfile!
|
|
164
|
+
if options[:testing]
|
|
165
|
+
gem 'phoenix_testing'
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
if options[:gems].present?
|
|
169
|
+
options[:gems].each do |g|
|
|
170
|
+
gem g
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
private
|
|
176
|
+
|
|
177
|
+
def find_and_replace(file, find, replace)
|
|
178
|
+
contents = app_pathname.join(file).read.gsub!(find, replace)
|
|
179
|
+
app_pathname.join(file).open("w") do |f|
|
|
180
|
+
f.puts contents
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def valid_rails_version?
|
|
185
|
+
Rails::VERSION::MAJOR >= TARGET_MAJOR_VERSION && Rails::VERSION::MINOR >= TARGET_MINOR_VERSION
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def valid_app_name?(app_name)
|
|
189
|
+
self.class.reserved_app_names.exclude?(app_name.downcase)
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Yes, this is really how you set exit_on_failure to true in Thor.
|
|
195
|
+
module Rails
|
|
196
|
+
module Generators
|
|
197
|
+
class AppBase
|
|
198
|
+
def self.exit_on_failure?
|
|
199
|
+
true
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
class AppGenerator
|
|
204
|
+
def self.exit_on_failure?
|
|
205
|
+
true
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
end
|