Class: Sincli::Generators::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/sincli/generators/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Application

Returns a new instance of Application.



6
7
8
9
10
# File 'lib/sincli/generators/application.rb', line 6

def initialize(name, options)
  @name = name
  @options = options
  @options.delete(:db) if @options[:no_database]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/sincli/generators/application.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/sincli/generators/application.rb', line 4

def options
  @options
end

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sincli/generators/application.rb', line 12

def create
  create_root_dir
  create_root_files
  create_config
  create_app_dir
  create_views
  create_assets
  create_models_and_controllers
  Dir.chdir('..')
  Executions.new(name, options).execute
end

#create_app_dirObject



38
39
40
41
# File 'lib/sincli/generators/application.rb', line 38

def create_app_dir
  Dir.mkdir 'app'
  Dir.chdir 'app'
end

#create_assetsObject



49
50
51
52
53
# File 'lib/sincli/generators/application.rb', line 49

def create_assets
  return if options[:api_only]

  Assets.new(name, options).generate
end

#create_configObject



28
29
30
# File 'lib/sincli/generators/application.rb', line 28

def create_config
  Config.new(name, options).generate
end

#create_models_and_controllersObject



55
56
57
# File 'lib/sincli/generators/application.rb', line 55

def create_models_and_controllers
  ModelsAndControllers.new(name, options).generate
end

#create_root_dirObject



32
33
34
35
36
# File 'lib/sincli/generators/application.rb', line 32

def create_root_dir
  dir_name = name.dash_case
  dir = Dir.mkdir(dir_name)
  Dir.chdir(dir_name)
end

#create_root_filesObject



24
25
26
# File 'lib/sincli/generators/application.rb', line 24

def create_root_files
  RootFiles.new(name, options).generate
end

#create_viewsObject



43
44
45
46
47
# File 'lib/sincli/generators/application.rb', line 43

def create_views
  return if options[:api_only]

  Views.new(name, options).generate
end