Class: Exo::Generator

Inherits:
Object
  • Object
show all
Defined in:
app/services/exo/generator.rb

Constant Summary collapse

APP_FOLDER_EXCLUDED =
['assets', 'helpers']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slug, options = nil) ⇒ Generator

Returns a new instance of Generator.



8
9
10
11
# File 'app/services/exo/generator.rb', line 8

def initialize slug, options=nil
  self.slug = slug
  self.options = options || {}
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'app/services/exo/generator.rb', line 6

def options
  @options
end

#slugObject

Returns the value of attribute slug.



6
7
8
# File 'app/services/exo/generator.rb', line 6

def slug
  @slug
end

Instance Method Details

#generates_configObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/services/exo/generator.rb', line 13

def generates_config
  exo_config_path = File.join root_path, 'config', 'exo', "#{slug}.yml"

  dir = File.dirname exo_config_path
  FileUtils.mkdir_p dir unless File.directory? dir
  unless File.exists?(exo_config_path)
    puts " + #{exo_config_path}"
    yaml = {
      'theme'         => slug,
      'main_host'     => "#{slug}.com",
      'hosts'         => nil,
      'contributors'  => nil,
      'resources'     => nil,
      'routes'        => nil
    }.to_yaml
    File.open(exo_config_path, 'w') {|f| f.write yaml }
  end
end

#generates_foldersObject



32
33
34
35
36
37
# File 'app/services/exo/generator.rb', line 32

def generates_folders
  app_folder = File.join root_path, 'app'

  generates_slug_subfolder_of app_folder
  generates_slug_subfolder_of File.join app_folder, 'assets'
end