Class: Grapethor::New

Inherits:
Thor::Group
  • Object
show all
Includes:
Utils, Thor::Actions
Defined in:
lib/grapethor/generators/new.rb

Constant Summary

Constants included from Utils

Utils::ATTRS_MAP, Utils::CONFIG_FILENAME, Utils::TEST_FRAMEWORK_DIRNAME

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

Returns the value of attribute app_copyright


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_copyright
  @app_copyright
end

#app_dbObject (readonly)

Returns the value of attribute app_db


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_db
  @app_db
end

#app_licenseObject (readonly)

Returns the value of attribute app_license


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_license
  @app_license
end

#app_nameObject (readonly)

Returns the value of attribute app_name


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_name
  @app_name
end

#app_ormObject (readonly)

Returns the value of attribute app_orm


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_orm
  @app_orm
end

#app_pathObject (readonly)

Returns the value of attribute app_path


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_path
  @app_path
end

#app_prefixObject (readonly)

Returns the value of attribute app_prefix


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_prefix
  @app_prefix
end

#app_rubyObject (readonly)

Returns the value of attribute app_ruby


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_ruby
  @app_ruby
end

#app_serverObject (readonly)

Returns the value of attribute app_server


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_server
  @app_server
end

#app_test_frameworkObject (readonly)

Returns the value of attribute app_test_framework


8
9
10
# File 'lib/grapethor/generators/new.rb', line 8

def app_test_framework
  @app_test_framework
end

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/grapethor/generators/new.rb', line 22

def self.exit_on_failure?
  true
end

.source_rootObject


27
28
29
# File 'lib/grapethor/generators/new.rb', line 27

def self.source_root
  File.join(__dir__, '..')
end

Instance Method Details

#create_newObject


110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/grapethor/generators/new.rb', line 110

def create_new
  report("Creating new application...") do
    directory 'templates/new', File.join(app_path, app_name)
    chmod File.join(app_path, app_name, 'bin', 'console'), 0755
    chmod File.join(app_path, app_name, 'bin', 'setup'), 0755
    chmod File.join(app_path, app_name, 'bin', 'server'), 0755

    directory "templates/#{app_db}", "#{app_path}/#{app_name}"

    directory "templates/#{app_test_framework}", "#{app_path}/#{app_name}"

    directory "templates/docker", "#{app_path}/#{app_name}" if app_docker?

    directory "templates/license/#{app_license}", "#{app_path}/#{app_name}"

    directory "templates/swagger", "#{app_path}/#{app_name}" if app_swagger?
  end
end

#parse_args_and_optsObject


94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/grapethor/generators/new.rb', line 94

def parse_args_and_opts
  @app_name           = name
  @app_path           = options[:path]
  @app_prefix         = options[:prefix]
  @app_server         = options[:server]
  @app_test_framework = options[:test]
  @app_db             = options[:db]
  @app_orm            = options[:orm]
  @app_docker         = options[:docker]
  @app_license        = options[:license]
  @app_copyright      = options[:copyright] || "Author of #{app_name}"
  @app_ruby           = options[:ruby]
  @app_swagger        = options[:swagger]
end