Class: ActionText::Generators::InstallGenerator
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: 
          self,
           ::Rails::Generators::Base,
          Thor::Group | |
| Instance Chain: 
          self,
           ::Rails::Generators::Base,::Rails::Generators::Actions,
          Thor::Actions,
          Thor::Group | |
| Inherits: | Rails::Generators::Base 
 | 
| Defined in: | actiontext/lib/generators/action_text/install/install_generator.rb | 
Constant Summary
- 
    GEM_ROOT =
    
 # File 'actiontext/lib/generators/action_text/install/install_generator.rb', line 58"#{__dir__}/../../../.."
Class Method Summary
::Rails::Generators::Base - Inherited
| .base_root | Returns the base root for a common set of generators. | 
| .default_source_root | Returns the default source root for a given generator. | 
| .desc | Tries to get the description from a USAGE file one folder above the source root otherwise uses a default description. | 
| .hide! | Convenience method to hide this generator from the available ones when running rails generator command. | 
| .hook_for | Invoke a generator based on the value supplied by the user to the given option named “name”. | 
| .namespace | Convenience method to get the namespace from the class name. | 
| .remove_hook_for | Remove a previously added hook. | 
| .source_root | Returns the source root for this generator using default_source_root as default. | 
| .add_shebang_option! | Small macro to add ruby as an option to the generator with proper default value plus an instance helper method called shebang. | 
| .banner | Use Rails default banner. | 
| .base_name | Sets the base_name taking into account the current class namespace. | 
| .default_aliases_for_option | Returns default aliases for the option name given doing a lookup in Rails::Generators.aliases. | 
| .default_for_option | Returns default for the option name given doing a lookup in config. | 
| .default_generator_root, | |
| .default_value_for_option | Returns the default value for the option name given doing a lookup in Rails::Generators.options. | 
| .generator_name | Removes the namespaces and get the generator name. | 
| .usage_path | |
Instance Attribute Summary
::Rails::Generators::Base - Inherited
Instance Method Summary
- #append_dependencies_to_package_file
- #create_actiontext_files
- #create_migrations
- #install_javascript_dependencies
::Rails::Generators::Base - Inherited
| #extract_last_module | Takes in an array of nested modules and extracts the last module. | 
| #indent, | |
| #module_namespacing | Wrap block with namespace of current application if namespace exists and is not skipped. | 
| #namespace, #namespaced_path, #wrap_with_namespace | |
::Rails::Generators::Actions - Included
| #add_source | Add the given source to  | 
| #application | Alias for Rails::Generators::Actions#environment. | 
| #environment | Adds a line inside the Application class for  | 
| #gem | Adds an entry into  | 
| #gem_group | Wraps gem entries inside a group. | 
| #generate | Generate something using a generator from  | 
| #git | Run a command in git. | 
| #github, | |
| #initializer | Create a new initializer with the provided code (either in a block or a string). | 
| #lib | Create a new file in the  | 
| #rails_command | Runs the supplied rake task (invoked with ‘rails …’). | 
| #rake | Runs the supplied rake task (invoked with ‘rake …’). | 
| #rakefile | Create a new  | 
| #readme | Reads the given file at the source root and prints it in the console. | 
| #route | Make an entry in  | 
| #vendor | Create a new file in the  | 
| #execute_command | Runs the supplied command using either “rake …” or “rails …” based on the executor parameter provided. | 
| #extify | Add an extension to the given name based on the platform. | 
| #indentation | Indent the  | 
| #log | Define log for backwards compatibility. | 
| #optimize_indentation | Returns optimized string with indentation. | 
| #quote | Surround string with single quotes if there is no quotes. | 
| #with_indentation | Manage  | 
Instance Method Details
#append_dependencies_to_package_file
[ GitHub ]# File 'actiontext/lib/generators/action_text/install/install_generator.rb', line 19
def append_dependencies_to_package_file if (app_javascript_pack_path = Pathname.new("app/javascript/packs/application.js")).exist? js_dependencies.each_key do |dependency| line = %[require("#{dependency}")] unless app_javascript_pack_path.read.include? line say "Adding #{dependency} to #{app_javascript_pack_path}", :green append_to_file app_javascript_pack_path, "\n#{line}" end end else say <<~WARNING, :red WARNING: Action Text can't locate your JavaScript bundle to add its package dependencies. Add these lines to any bundles: require("trix") require("@rails/actiontext") Alternatively, install and setup the webpacker gem then rerun `bin/rails action_text:install` to have these dependencies added automatically. WARNING end end
#create_actiontext_files
[ GitHub ]# File 'actiontext/lib/generators/action_text/install/install_generator.rb', line 44
def create_actiontext_files template "actiontext.scss", "app/assets/stylesheets/actiontext.scss" copy_file "#{GEM_ROOT}/app/views/active_storage/blobs/_blob.html.erb", "app/views/active_storage/blobs/_blob.html.erb" end
#create_migrations
[ GitHub ]# File 'actiontext/lib/generators/action_text/install/install_generator.rb', line 51
def create_migrations rails_command "railties:install:migrations FROM=active_storage,action_text", inline: true end
#install_javascript_dependencies
[ GitHub ]# File 'actiontext/lib/generators/action_text/install/install_generator.rb', line 11
def install_javascript_dependencies rails_command "app:binstub:yarn", inline: true say "Installing JavaScript dependencies", :green run "#{Thor::Util.ruby_command} bin/yarn add #{js_dependencies.map { |name, version| "#{name}@#{version}" }.join(" ")}", abort_on_failure: true, capture: true end