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_dry_monads? ⇒ Boolean private
- #bundled_views? ⇒ Boolean private
- #camelized_app_name ⇒ Object private
- #ctx ⇒ Object private
- #database_url ⇒ Object private
- #generate_assets? ⇒ Boolean private
- #generate_db? ⇒ Boolean private
- #generate_mysql? ⇒ Boolean private
- #generate_postgres? ⇒ Boolean private
- #generate_sqlite? ⇒ 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 = 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.
129 130 131 |
# File 'lib/hanami/cli/generators/context.rb', line 129 def bundled_assets? Hanami.bundled?("hanami-assets") end |
#bundled_dry_monads? ⇒ 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.
135 136 137 |
# File 'lib/hanami/cli/generators/context.rb', line 135 def bundled_dry_monads? Hanami.bundled?("dry-monads") 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.
123 124 125 |
# File 'lib/hanami/cli/generators/context.rb', line 123 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 |
#database_url ⇒ 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.
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/hanami/cli/generators/context.rb', line 109 def database_url if generate_sqlite? "sqlite://db/#{app}.sqlite" elsif generate_postgres? "postgres://localhost/#{app}" elsif generate_mysql? "mysql2://root@localhost/#{app}" else raise "Unknown database option: #{database_option}" end 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 |
#generate_db? ⇒ 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 generate_db? !.fetch(:skip_db, false) end |
#generate_mysql? ⇒ 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.
103 104 105 |
# File 'lib/hanami/cli/generators/context.rb', line 103 def generate_mysql? generate_db? && database_option == Commands::Gem::New::DATABASE_MYSQL end |
#generate_postgres? ⇒ 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.
97 98 99 |
# File 'lib/hanami/cli/generators/context.rb', line 97 def generate_postgres? generate_db? && database_option == Commands::Gem::New::DATABASE_POSTGRES end |
#generate_sqlite? ⇒ 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 generate_sqlite? generate_db? && database_option == Commands::Gem::New::DATABASE_SQLITE 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.
143 144 145 |
# File 'lib/hanami/cli/generators/context.rb', line 143 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 |