Class: Boa::Commands

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/boa/commands.rb

Constant Summary collapse

BASE_FILES =

initialize VIPER hierarchy

{
  'AppDelegate.h'     => 'Classes',
  'AppDelegate.m'     => 'Classes',
  'AppDependencies.h' => 'Classes',
  'AppDependencies.m' => 'Classes'
}
PROJECT_FILES =
{
  'RootWireframe.h'   => 'Classes/Common/Wireframe',
  'RootWireframe.m'   => 'Classes/Common/Wireframe'
}
CONFIG_FILE =

configuration

'.boa.yml'

Instance Method Summary collapse

Instance Method Details

#configureObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/boa/commands.rb', line 65

def configure
  return YAML.load_file(CONFIG_FILE) if File.exists? CONFIG_FILE

  config = {
    project: ask('Project name:'),
    author:  ask('Author:')
  }

  File.open(CONFIG_FILE, 'w') do |f|
    f.write config.to_yaml
  end

  config
end

#initObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/boa/commands.rb', line 28

def init
  config = invoke(:configure, [])

  # Classes
  empty_directory 'Classes'

  # Classes/Common
  empty_directory 'Classes/Common'
  empty_directory 'Classes/Common/Categories'
  empty_directory 'Classes/Common/Model'
  empty_directory 'Classes/Common/Store'
  empty_directory 'Classes/Common/Utils'
  empty_directory 'Classes/Common/Wireframe'

  # Classes/Modules
  empty_directory 'Classes/Modules'

  # Add config
  @project = config[:project]
  @author  = config[:author]
  @date    = Time.now.strftime('%d/%m/%y')

  # Generate files
  BASE_FILES.each do |file_name, folder|
    template "templates/#{file_name}", "#{folder}/#{@project}#{file_name}"
  end

  PROJECT_FILES.each do |file_name, folder|
    template "templates/#{file_name}", "#{folder}/#{file_name}"
  end
end