Class: RailsAppGenerator::Context
- Inherits:
-
Object
- Object
- RailsAppGenerator::Context
- Defined in:
- lib/rails_app_generator/context.rb
Overview
Context stores the template folder and options
Instance Attribute Summary collapse
-
#addon_template_path ⇒ Object
readonly
Returns the value of attribute addon_template_path.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rails_override_template_path ⇒ Object
readonly
Returns the value of attribute rails_override_template_path.
-
#rails_template_path ⇒ Object
readonly
Returns the value of attribute rails_template_path.
Instance Method Summary collapse
- #addons ⇒ Object
- #debug ⇒ Object
-
#default_addons ⇒ Object
Skippable parts of the default Rails generator, e.g.
-
#initialize(rails_template_path, rails_override_template_path, addon_template_path, options = {}) ⇒ Context
constructor
Build a context object from the given arguments to be passed around within Rails Generator and AddOns.
Constructor Details
#initialize(rails_template_path, rails_override_template_path, addon_template_path, options = {}) ⇒ Context
Build a context object from the given arguments to be passed around within Rails Generator and AddOns.
18 19 20 21 22 23 24 |
# File 'lib/rails_app_generator/context.rb', line 18 def initialize(rails_template_path, rails_override_template_path, addon_template_path, = {}) @rails_template_path = rails_template_path @rails_override_template_path = rails_override_template_path @addon_template_path = addon_template_path @options = end |
Instance Attribute Details
#addon_template_path ⇒ Object (readonly)
Returns the value of attribute addon_template_path.
8 9 10 |
# File 'lib/rails_app_generator/context.rb', line 8 def addon_template_path @addon_template_path end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/rails_app_generator/context.rb', line 10 def @options end |
#rails_override_template_path ⇒ Object (readonly)
Returns the value of attribute rails_override_template_path.
7 8 9 |
# File 'lib/rails_app_generator/context.rb', line 7 def rails_override_template_path @rails_override_template_path end |
#rails_template_path ⇒ Object (readonly)
Returns the value of attribute rails_template_path.
6 7 8 |
# File 'lib/rails_app_generator/context.rb', line 6 def rails_template_path @rails_template_path end |
Instance Method Details
#addons ⇒ Object
26 27 28 29 30 |
# File 'lib/rails_app_generator/context.rb', line 26 def addons AddOns.constants.select { |klass| AddOns.const_get(klass).is_a?(Class) }.map { |klass| AddOns.const_get(klass) } .map(&:to_s) # .map(&:name) only works in Ruby 3.0+ .map(&:underscore) end |
#debug ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/rails_app_generator/context.rb', line 39 def debug kv('rails_template_path', rails_template_path) kv('rails_override_template_path', rails_override_template_path) kv('addon_template_path', addon_template_path) debug_default_addons debug_addons end |
#default_addons ⇒ Object
Skippable parts of the default Rails generator, e.g. active_record, active_job…
33 34 35 36 37 |
# File 'lib/rails_app_generator/context.rb', line 33 def default_addons = addons.map { |option| "skip_#{option}".to_sym } = RailsAppGenerator::AppGenerator..keys.grep(/skip_/) ( - ).map { |option| option.to_s.delete_prefix('skip_').to_sym } end |