Module: Hanami::CLI::Commands::Project Private

Defined in:
lib/hanami/cli/commands/project.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0

Constant Summary collapse

MIGRATION_TIMESTAMP_FORMAT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0

"%Y%m%d%H%M%S".freeze
MIGRATION_FILENAME_PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0

"%{timestamp}_%{name}".freeze

Class Method Summary collapse

Class Method Details

.action(context) ⇒ 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:

  • 1.1.0



253
254
255
# File 'lib/hanami/cli/commands/project.rb', line 253

def self.action(context)
  root.join("apps", context.app, "controllers", context.controller, "#{context.action}.rb")
end

.action_spec(context) ⇒ 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:

  • 1.1.0



329
330
331
# File 'lib/hanami/cli/commands/project.rb', line 329

def self.action_spec(context)
  root.join("spec", context.app, "controllers", context.controller, "#{context.action}_spec.rb")
end

.app(context) ⇒ 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:

  • 1.1.0



377
378
379
# File 'lib/hanami/cli/commands/project.rb', line 377

def self.app(context)
  root.join("apps", context.app)
end

.app?(context) ⇒ 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:

  • 1.1.0



383
384
385
# File 'lib/hanami/cli/commands/project.rb', line 383

def self.app?(context)
  apps.include?(context.app)
end

.app_application(context) ⇒ 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:

  • 1.1.0



193
194
195
# File 'lib/hanami/cli/commands/project.rb', line 193

def self.app_application(context)
  root.join("apps", context.app, "application.rb")
end

.app_favicon(context) ⇒ 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:

  • 1.1.0



223
224
225
# File 'lib/hanami/cli/commands/project.rb', line 223

def self.app_favicon(context)
  root.join("apps", context.app, "assets", "favicon.ico")
end

.app_layout(context) ⇒ 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:

  • 1.1.0



211
212
213
# File 'lib/hanami/cli/commands/project.rb', line 211

def self.app_layout(context)
  root.join("apps", context.app, "views", "application_layout.rb")
end

.app_layout_spec(context) ⇒ 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:

  • 1.1.0



317
318
319
# File 'lib/hanami/cli/commands/project.rb', line 317

def self.app_layout_spec(context)
  root.join("spec", context.app, "views", "application_layout_spec.rb")
end

.app_routes(context) ⇒ 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:

  • 1.1.0



205
206
207
# File 'lib/hanami/cli/commands/project.rb', line 205

def self.app_routes(context)
  root.join("apps", context.app, "config", "routes.rb")
end

.app_sessions_secretObject

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:

  • 1.1.0



199
200
201
# File 'lib/hanami/cli/commands/project.rb', line 199

def self.app_sessions_secret
  SecureRandom.hex(32)
end

.app_spec(context) ⇒ 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:

  • 1.1.0



313
314
315
# File 'lib/hanami/cli/commands/project.rb', line 313

def self.app_spec(context)
  root.join("spec", context.app)
end

.app_template(context) ⇒ 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:

  • 1.1.0



217
218
219
# File 'lib/hanami/cli/commands/project.rb', line 217

def self.app_template(context)
  root.join("apps", context.app, "templates", "application.html.#{context.template}")
end

.appsObject

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:

  • 1.1.0



389
390
391
# File 'lib/hanami/cli/commands/project.rb', line 389

def self.apps
  Dir.glob(root.join("apps", "*")).map { |app| File.basename(app) }
end

.assets_manifestObject

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:

  • 1.1.0



173
174
175
# File 'lib/hanami/cli/commands/project.rb', line 173

def self.assets_manifest(*)
  root.join("public", "assets.json")
end

.bootObject

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:

  • 1.1.0



57
58
59
# File 'lib/hanami/cli/commands/project.rb', line 57

def self.boot(*)
  root.join("config", "boot.rb")
end

.capybaraObject

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:

  • 1.1.0



371
372
373
# File 'lib/hanami/cli/commands/project.rb', line 371

def self.capybara(*)
  root.join("spec", "support", "capybara.rb")
end

.config_ruObject

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:

  • 1.1.0



45
46
47
# File 'lib/hanami/cli/commands/project.rb', line 45

def self.config_ru(*)
  root.join("config.ru")
end

.controllers(context) ⇒ 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:

  • 1.1.0



229
230
231
# File 'lib/hanami/cli/commands/project.rb', line 229

def self.controllers(context)
  root.join("apps", context.app, "controllers")
end

.controllers_spec(context) ⇒ 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:

  • 1.1.0



323
324
325
# File 'lib/hanami/cli/commands/project.rb', line 323

def self.controllers_spec(context)
  root.join("spec", context.app, "controllers")
end

.dbObject

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:

  • 1.1.0



75
76
77
# File 'lib/hanami/cli/commands/project.rb', line 75

def self.db(*)
  root.join("db")
end

.db_schemaObject

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:

  • 1.1.0



81
82
83
# File 'lib/hanami/cli/commands/project.rb', line 81

def self.db_schema(*)
  root.join("db", "schema.sql")
end

.dotrspecObject

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:

  • 1.1.0



347
348
349
# File 'lib/hanami/cli/commands/project.rb', line 347

def self.dotrspec(*)
  root.join(".rspec")
end

.entities(context) ⇒ 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:

  • 1.1.0



143
144
145
# File 'lib/hanami/cli/commands/project.rb', line 143

def self.entities(context)
  root.join("lib", context.options.fetch(:project), "entities")
end

.entities_spec(context) ⇒ 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:

  • 1.1.0



277
278
279
# File 'lib/hanami/cli/commands/project.rb', line 277

def self.entities_spec(context)
  root.join("spec", context.options.fetch(:project), "entities")
end

.entity(context) ⇒ 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:

  • 1.1.0



149
150
151
# File 'lib/hanami/cli/commands/project.rb', line 149

def self.entity(context)
  root.join("lib", context.options.fetch(:project), "entities", "#{context.model}.rb")
end

.entity_spec(context) ⇒ 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:

  • 1.1.0



283
284
285
# File 'lib/hanami/cli/commands/project.rb', line 283

def self.entity_spec(context)
  root.join("spec", context.options.fetch(:project), "entities", "#{context.model}_spec.rb")
end

.env(environment) ⇒ 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:

  • 1.1.0



69
70
71
# File 'lib/hanami/cli/commands/project.rb', line 69

def self.env(*, environment)
  root.join(".env.#{environment}")
end

.environmentObject

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:

  • 1.1.0



51
52
53
# File 'lib/hanami/cli/commands/project.rb', line 51

def self.environment(*)
  root.join("config", "environment.rb")
end

.features_helperObject

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:

  • 1.1.0



359
360
361
# File 'lib/hanami/cli/commands/project.rb', line 359

def self.features_helper(*)
  root.join("spec", "features_helper.rb")
end

.features_spec(context) ⇒ 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:

  • 1.1.0



341
342
343
# File 'lib/hanami/cli/commands/project.rb', line 341

def self.features_spec(context)
  root.join("spec", context.app, "features")
end

.find_migration(context) ⇒ 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:

  • 1.1.0



107
108
109
# File 'lib/hanami/cli/commands/project.rb', line 107

def self.find_migration(context)
  list(root.join("db", "migrations", "*_#{context.migration}.rb")).first
end

.gemfileObject

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:

  • 1.1.0



21
22
23
# File 'lib/hanami/cli/commands/project.rb', line 21

def self.gemfile(*)
  root.join("Gemfile")
end

.gitignoreObject

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:

  • 1.1.0



39
40
41
# File 'lib/hanami/cli/commands/project.rb', line 39

def self.gitignore(*)
  root.join(".gitignore")
end

.hanamircObject

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:

  • 1.1.0



33
34
35
# File 'lib/hanami/cli/commands/project.rb', line 33

def self.hanamirc(*)
  root.join(".hanamirc")
end

.images(context) ⇒ 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:

  • 1.1.0



235
236
237
# File 'lib/hanami/cli/commands/project.rb', line 235

def self.images(context)
  root.join("apps", context.app, "assets", "images")
end

.initializersObject

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:

  • 1.1.0



63
64
65
# File 'lib/hanami/cli/commands/project.rb', line 63

def self.initializers(*)
  root.join("config", "initializers")
end

.javascripts(context) ⇒ 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:

  • 1.1.0



241
242
243
# File 'lib/hanami/cli/commands/project.rb', line 241

def self.javascripts(context)
  root.join("apps", context.app, "assets", "javascripts")
end

.keep(path) ⇒ 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:

  • 1.1.0



395
396
397
# File 'lib/hanami/cli/commands/project.rb', line 395

def self.keep(path)
  root.join(path, ".gitkeep")
end

.list(pattern) ⇒ 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:

  • 1.1.0



401
402
403
# File 'lib/hanami/cli/commands/project.rb', line 401

def self.list(pattern)
  Hanami::Utils::FileList[pattern]
end

.mailer(context) ⇒ 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:

  • 1.1.0



131
132
133
# File 'lib/hanami/cli/commands/project.rb', line 131

def self.mailer(context)
  root.join("lib", context.options.fetch(:project), "mailers", "#{context.mailer}.rb")
end

.mailer_spec(context) ⇒ 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:

  • 1.1.0



307
308
309
# File 'lib/hanami/cli/commands/project.rb', line 307

def self.mailer_spec(context)
  root.join("spec", context.options.fetch(:project), "mailers", "#{context.mailer}_spec.rb")
end

.mailer_template(context, format) ⇒ 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:

  • 1.1.0



187
188
189
# File 'lib/hanami/cli/commands/project.rb', line 187

def self.mailer_template(context, format)
  root.join("lib", context.options.fetch(:project), "mailers", "templates", "#{context.mailer}.#{format}.#{context.options.fetch(:template)}")
end

.mailer_templates(context) ⇒ 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:

  • 1.1.0



137
138
139
# File 'lib/hanami/cli/commands/project.rb', line 137

def self.mailer_templates(context)
  list root.join("lib", context.options.fetch(:project), "mailers", "templates", "#{context.mailer}.*.*")
end

.mailers(context) ⇒ 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:

  • 1.1.0



119
120
121
# File 'lib/hanami/cli/commands/project.rb', line 119

def self.mailers(context)
  root.join("lib", context.options.fetch(:project), "mailers")
end

.mailers_spec(context) ⇒ 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:

  • 1.1.0



301
302
303
# File 'lib/hanami/cli/commands/project.rb', line 301

def self.mailers_spec(context)
  root.join("spec", context.options.fetch(:project), "mailers")
end

.mailers_templates(context) ⇒ 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:

  • 1.1.0



125
126
127
# File 'lib/hanami/cli/commands/project.rb', line 125

def self.mailers_templates(context)
  root.join("lib", context.options.fetch(:project), "mailers", "templates")
end

.migration(context) ⇒ 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:

  • 1.1.0



93
94
95
96
97
# File 'lib/hanami/cli/commands/project.rb', line 93

def self.migration(context)
  filename = MIGRATION_FILENAME_PATTERN % { timestamp: migration_timestamp, name: context.migration }

  root.join("db", "migrations", "#{filename}.rb")
end

.migration_timestampObject

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:

  • 1.1.0



101
102
103
# File 'lib/hanami/cli/commands/project.rb', line 101

def self.migration_timestamp
  Time.now.utc.strftime(MIGRATION_TIMESTAMP_FORMAT)
end

.migrationsObject

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:

  • 1.1.0



87
88
89
# File 'lib/hanami/cli/commands/project.rb', line 87

def self.migrations(*)
  root.join("db", "migrations")
end

.project(context) ⇒ 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:

  • 1.1.0



113
114
115
# File 'lib/hanami/cli/commands/project.rb', line 113

def self.project(context)
  root.join("lib", "#{context.options.fetch(:project)}.rb")
end

.public_app_assets(context) ⇒ 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:

  • 1.1.0



179
180
181
182
183
# File 'lib/hanami/cli/commands/project.rb', line 179

def self.public_app_assets(context)
  # FIXME: extract this URL to path conversion into Hanami::Utils
  assets_directory = context.base_url.sub(/\A\//, "").split("/")
  root.join("public", "assets", *assets_directory)
end

.public_directoryObject

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:

  • 1.1.0



167
168
169
# File 'lib/hanami/cli/commands/project.rb', line 167

def self.public_directory(*)
  root.join("public")
end

.rakefileObject

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:

  • 1.1.0



27
28
29
# File 'lib/hanami/cli/commands/project.rb', line 27

def self.rakefile(*)
  root.join("Rakefile")
end

.readmeObject

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:

  • 1.1.0



15
16
17
# File 'lib/hanami/cli/commands/project.rb', line 15

def self.readme(*)
  root.join("README.md")
end

.repositories(context) ⇒ 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:

  • 1.1.0



155
156
157
# File 'lib/hanami/cli/commands/project.rb', line 155

def self.repositories(context)
  root.join("lib", context.options.fetch(:project), "repositories")
end

.repositories_spec(context) ⇒ 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:

  • 1.1.0



289
290
291
# File 'lib/hanami/cli/commands/project.rb', line 289

def self.repositories_spec(context)
  root.join("spec", context.options.fetch(:project), "repositories")
end

.repository(context) ⇒ 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:

  • 1.1.0



161
162
163
# File 'lib/hanami/cli/commands/project.rb', line 161

def self.repository(context)
  root.join("lib", context.options.fetch(:project), "repositories", "#{context.model}_repository.rb")
end

.repository_spec(context) ⇒ 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:

  • 1.1.0



295
296
297
# File 'lib/hanami/cli/commands/project.rb', line 295

def self.repository_spec(context)
  root.join("spec", context.options.fetch(:project), "repositories", "#{context.model}_repository_spec.rb")
end

.rootObject

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:

  • 1.1.0



407
408
409
# File 'lib/hanami/cli/commands/project.rb', line 407

def self.root
  File
end

.spec_helperObject

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:

  • 1.1.0



353
354
355
# File 'lib/hanami/cli/commands/project.rb', line 353

def self.spec_helper(*)
  root.join("spec", "spec_helper.rb")
end

.stylesheets(context) ⇒ 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:

  • 1.1.0



247
248
249
# File 'lib/hanami/cli/commands/project.rb', line 247

def self.stylesheets(context)
  root.join("apps", context.app, "assets", "stylesheets")
end

.support_specObject

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:

  • 1.1.0



365
366
367
# File 'lib/hanami/cli/commands/project.rb', line 365

def self.support_spec(*)
  root.join("spec", "support")
end

.template(context) ⇒ 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:

  • 1.1.0



265
266
267
# File 'lib/hanami/cli/commands/project.rb', line 265

def self.template(context)
  root.join("apps", context.app, "templates", context.controller, "#{context.action}.html.#{context.options.fetch(:template)}")
end

.templates(context) ⇒ 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:

  • 1.1.0



271
272
273
# File 'lib/hanami/cli/commands/project.rb', line 271

def self.templates(context)
  list root.join("apps", context.app, "templates", context.controller, "#{context.action}.*.*")
end

.view(context) ⇒ 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:

  • 1.1.0



259
260
261
# File 'lib/hanami/cli/commands/project.rb', line 259

def self.view(context)
  root.join("apps", context.app, "views", context.controller, "#{context.action}.rb")
end

.view_spec(context) ⇒ 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:

  • 1.1.0



335
336
337
# File 'lib/hanami/cli/commands/project.rb', line 335

def self.view_spec(context)
  root.join("spec", context.app, "views", context.controller, "#{context.action}_spec.rb")
end