Class: ExtForm::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ExtForm::Generators::InstallGenerator
- Defined in:
- lib/generators/ext_form/install_generator.rb
Instance Method Summary collapse
- #copy_assets ⇒ Object
- #copy_config ⇒ Object
- #copy_scaffold_template ⇒ Object
- #info_bootstrap ⇒ Object
- #show_readme ⇒ Object
Instance Method Details
#copy_assets ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/generators/ext_form/install_generator.rb', line 33 def copy_assets #bootstrap install if [:bootstrap] # I prefer if (file = 'app/assets/stylesheets/application.css') && File.exists?(file) # but it outputs a warning.... file = 'app/assets/stylesheets/application.css' if File.exists?(file) inject_into_file file, before: " *= require_tree .\n" do " *= require ext_form/application_bootstrap\n" end end file = 'app/assets/stylesheets/application.css.scss' if File.exists?(file) inject_into_file file, before: " *= require_tree .\n" do " *= require ext_form/application_bootstrap\n" end end file = 'app/assets/javascripts/application.js' if File.exists?(file) locale = [:locale] inject_into_file file, before: "//= require_tree .\n" do "//= require jquery_nested_form\n//= require bootstrap-datetimepicker\n//= require typeahead\n//= require select2\n//= require ext_form/application\n" end inject_into_file file, after: "//= require select2\n" do "//= require locales/bootstrap-datetimepicker.\#{locale}\n//= require select2_locale_\#{locale}\n" end if locale end # non bootstrap install, no more css and js. else file = 'app/assets/stylesheets/application.css' if File.exists?(file) inject_into_file file, before: " *= require_tree .\n" do " *= require ext_form/application\n" end end file = 'app/assets/stylesheets/application.css.scss' if File.exists?(file) inject_into_file file, before: " *= require_tree .\n" do " *= require ext_form/application\n" end end file = 'app/assets/javascripts/application.js' if File.exists?(file) inject_into_file file, before: "//= require_tree .\n" do "//= require jquery_nested_form\n//= require ext_form/application\n" end end end end |
#copy_config ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/ext_form/install_generator.rb', line 18 def copy_config template 'config/initializers/z_ext_form.rb' if [:bootstrap] template 'config/initializers/z_ext_form_bootstrap.rb' end directory 'config/locales' end |
#copy_scaffold_template ⇒ Object
28 29 30 31 |
# File 'lib/generators/ext_form/install_generator.rb', line 28 def copy_scaffold_template engine = [:template_engine] copy_file "_form.html.#{engine}", "lib/templates/#{engine}/scaffold/_form.html.#{engine}" end |
#info_bootstrap ⇒ Object
11 12 13 14 15 16 |
# File 'lib/generators/ext_form/install_generator.rb', line 11 def info_bootstrap return if .bootstrap? puts %q(ExtForm supports Twitter Bootstrap. If you want a configuration that is compatible it, then please re-run this generator with --bootstrap as an option.) end |
#show_readme ⇒ Object
106 107 108 109 110 |
# File 'lib/generators/ext_form/install_generator.rb', line 106 def show_readme if behavior == :invoke && .bootstrap? readme 'README' end end |