Class: Hanami::CLI::Generators::Context Private
- Inherits:
-
Object
- Object
- Hanami::CLI::Generators::Context
- Defined in:
- lib/hanami/cli/generators/context.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Method Summary collapse
- #bundled_assets? ⇒ Boolean private
- #bundled_views? ⇒ Boolean private
- #camelized_app_name ⇒ Object private
- #ctx ⇒ Object private
- #generate_assets? ⇒ Boolean private
- #hanami_assets_npm_package ⇒ Object private
- #hanami_gem(name) ⇒ Object private
- #hanami_gem_version(gem_name) ⇒ Object private
- #hanami_head? ⇒ Boolean private
- #humanized_app_name ⇒ Object private
-
#initialize(inflector, app, **options) ⇒ Context
constructor
private
A new instance of Context.
- #ruby_omit_hash_values? ⇒ Boolean private
- #underscored_app_name ⇒ Object private
Constructor Details
#initialize(inflector, app, **options) ⇒ Context
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Context.
15 16 17 18 19 |
# File 'lib/hanami/cli/generators/context.rb', line 15 def initialize(inflector, app, **) @inflector = inflector @app = app @options = end |
Instance Method Details
#bundled_assets? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 |
# File 'lib/hanami/cli/generators/context.rb', line 91 def bundled_assets? Hanami.bundled?("hanami-assets") end |
#bundled_views? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 |
# File 'lib/hanami/cli/generators/context.rb', line 85 def bundled_views? Hanami.bundled?("hanami-view") end |
#camelized_app_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/hanami/cli/generators/context.rb', line 55 def camelized_app_name inflector.camelize(app).gsub(/[^\p{Alnum}]/, "") end |
#ctx ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/hanami/cli/generators/context.rb', line 23 def ctx binding end |
#generate_assets? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 |
# File 'lib/hanami/cli/generators/context.rb', line 79 def generate_assets? !.fetch(:skip_assets, false) end |
#hanami_assets_npm_package ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 51 |
# File 'lib/hanami/cli/generators/context.rb', line 45 def hanami_assets_npm_package if hanami_head? %("hanami-assets": "hanami/assets-js#main") else %("hanami-assets": "#{Version.npm_package_requirement}") end end |
#hanami_gem(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 |
# File 'lib/hanami/cli/generators/context.rb', line 27 def hanami_gem(name) gem_name = name == "hanami" ? "hanami" : "hanami-#{name}" %(gem "#{gem_name}", #{hanami_gem_version(name)}) end |
#hanami_gem_version(gem_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 39 40 41 |
# File 'lib/hanami/cli/generators/context.rb', line 35 def hanami_gem_version(gem_name) if hanami_head? %(github: "hanami/#{gem_name}", branch: "main") else %("#{Version.gem_requirement}") end end |
#hanami_head? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 |
# File 'lib/hanami/cli/generators/context.rb', line 73 def hanami_head? .fetch(:head) end |
#humanized_app_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 |
# File 'lib/hanami/cli/generators/context.rb', line 67 def humanized_app_name inflector.humanize(app) end |
#ruby_omit_hash_values? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
99 100 101 |
# File 'lib/hanami/cli/generators/context.rb', line 99 def ruby_omit_hash_values? RUBY_VERSION >= "3.1" end |
#underscored_app_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/hanami/cli/generators/context.rb', line 61 def underscored_app_name inflector.underscore(app) end |