Class: Lotus::Commands::Generate Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/commands/generate.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:

  • 0.3.0

Defined Under Namespace

Classes: Error

Constant Summary collapse

GENERATORS_NAMESPACE =

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:

  • 0.3.0

"Lotus::Generators::%s".freeze
APP_ARCHITECTURE =

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:

  • 0.3.0

'app'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, app_name, name, env, cli) ⇒ Generate

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 Generate.

Since:

  • 0.3.0



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lotus/commands/generate.rb', line 26

def initialize(type, app_name, name, env, cli)
  @cli      = cli
  @env      = env
  @name     = name
  @options  = env.to_options.merge(cli.options)

  sanitize_input(app_name, name)
  @type     = type

  @source   = Pathname.new(::File.dirname(__FILE__) + "/../generators/#{ @type }/").realpath
  @target   = Pathname.pwd.realpath

  @app      = Utils::String.new(@app_name).classify
end

Instance Attribute Details

#appObject (readonly)

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:

  • 0.3.0



22
23
24
# File 'lib/lotus/commands/generate.rb', line 22

def app
  @app
end

#app_nameObject (readonly)

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:

  • 0.3.0



22
23
24
# File 'lib/lotus/commands/generate.rb', line 22

def app_name
  @app_name
end

#cliObject (readonly)

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:

  • 0.3.0



22
23
24
# File 'lib/lotus/commands/generate.rb', line 22

def cli
  @cli
end

#envObject (readonly)

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:

  • 0.3.0



22
23
24
# File 'lib/lotus/commands/generate.rb', line 22

def env
  @env
end

#nameObject (readonly)

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:

  • 0.3.0



22
23
24
# File 'lib/lotus/commands/generate.rb', line 22

def name
  @name
end

#optionsObject (readonly)

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:

  • 0.3.0



22
23
24
# File 'lib/lotus/commands/generate.rb', line 22

def options
  @options
end

#sourceObject (readonly)

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:

  • 0.3.0



22
23
24
# File 'lib/lotus/commands/generate.rb', line 22

def source
  @source
end

#targetObject (readonly)

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:

  • 0.3.0



22
23
24
# File 'lib/lotus/commands/generate.rb', line 22

def target
  @target
end

Instance Method Details

#app_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:

  • 0.3.0



52
53
54
55
56
57
58
# File 'lib/lotus/commands/generate.rb', line 52

def app_root
  @app_root ||= begin
    result = Pathname.new(@options[:apps_path])
    result = result.join(@app_name) if @env.container?
    result
  end
end

#model_rootObject Also known as: core_root

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:

  • 0.3.1



68
69
70
71
# File 'lib/lotus/commands/generate.rb', line 68

def model_root
  @model_root ||= Pathname.new(['lib', ::File.basename(Dir.getwd)]
    .join(::File::SEPARATOR))
end

#spec_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:

  • 0.3.0



62
63
64
# File 'lib/lotus/commands/generate.rb', line 62

def spec_root
  @spec_root ||= Pathname.new('spec')
end

#startObject

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:

  • 0.3.0



43
44
45
46
47
48
# File 'lib/lotus/commands/generate.rb', line 43

def start
  generator.start
rescue Error => e
  puts e.message
  exit 1
end