Class: Hanami::CLI::Generators::Context Private

Inherits:
Object
  • Object
show all
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.

Since:

  • 2.0.0

Direct Known Subclasses

App::SliceContext

Instance Method Summary collapse

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.

Since:

  • 2.0.0



15
16
17
18
19
# File 'lib/hanami/cli/generators/context.rb', line 15

def initialize(inflector, app, **options)
  @inflector = inflector
  @app = app
  @options = 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.

Returns:

  • (Boolean)

Since:

  • 2.1.0



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.

Returns:

  • (Boolean)

Since:

  • 2.1.0



85
86
87
# File 'lib/hanami/cli/generators/context.rb', line 85

def bundled_views?
  Hanami.bundled?("hanami-view")
end

#camelized_app_nameObject

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.

Since:

  • 2.0.0



55
56
57
# File 'lib/hanami/cli/generators/context.rb', line 55

def camelized_app_name
  inflector.camelize(app).gsub(/[^\p{Alnum}]/, "")
end

#ctxObject

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.

Since:

  • 2.0.0



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.

Returns:

  • (Boolean)

Since:

  • 2.1.0



79
80
81
# File 'lib/hanami/cli/generators/context.rb', line 79

def generate_assets?
  !options.fetch(:skip_assets, false)
end

#hanami_assets_npm_packageObject

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.

Since:

  • 2.1.0



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.

Since:

  • 2.0.0



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.

Since:

  • 2.0.0



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.

Returns:

  • (Boolean)

Since:

  • 2.1.0



73
74
75
# File 'lib/hanami/cli/generators/context.rb', line 73

def hanami_head?
  options.fetch(:head)
end

#humanized_app_nameObject

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.

Since:

  • 2.1.0



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_nameObject

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.

Since:

  • 2.0.0



61
62
63
# File 'lib/hanami/cli/generators/context.rb', line 61

def underscored_app_name
  inflector.underscore(app)
end