Class: Aetherg::Generator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/aetherg/aetherg.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



28
29
30
# File 'lib/aetherg/aetherg.rb', line 28

def self.source_root
  File.expand_path(File.join(File.dirname(__FILE__), "..", "templates"))
end

Instance Method Details

#create_appObject



43
44
45
46
# File 'lib/aetherg/aetherg.rb', line 43

def create_app
  template "application.rb", File.join(@app_path, "application.rb")
  template "app/routes/welcome.rb", File.join(@app_path, "/app/routes/welcome.rb")
end

#create_assets_configObject



102
103
104
105
106
# File 'lib/aetherg/aetherg.rb', line 102

def create_assets_config
  unless @no_views
    template("config/initializers/assets.rb", File.join(@app_path, "config/initializers/assets.rb"))
  end
end

#create_config_with_bootObject



54
55
56
57
# File 'lib/aetherg/aetherg.rb', line 54

def create_config_with_boot
  template "config.ru", File.join(@app_path, "config.ru")
  template "boot.rb", File.join(@app_path, "boot.rb")
end

#create_db_configObject



75
76
77
78
# File 'lib/aetherg/aetherg.rb', line 75

def create_db_config
  template("config/database.yml", File.join(@app_path, "config/database.example.yml")) unless @no_database
  template("config/database.yml", File.join(@app_path, "config/database.yml")) unless @no_database
end

#create_empty_directoriesObject

Create empty directories



33
34
35
36
37
38
39
40
41
# File 'lib/aetherg/aetherg.rb', line 33

def create_empty_directories
  %w{app/models app/helpers app/routes config/initializers db/migrate lib log tmp}.each do |dir|
    empty_directory File.join(@app_path, dir)
  end

  %w{app/assets app/assets/images app/assets/javascripts app/assets/stylesheets app/assets/fonts app/views app/views/layouts public}.each do |dir|
    empty_directory File.join(@app_path, dir)
  end unless @no_views
end

#create_gemfileObject



59
60
61
# File 'lib/aetherg/aetherg.rb', line 59

def create_gemfile
  template "Gemfile", File.join(@app_path, "Gemfile")
end

#create_gitignoreObject



85
86
87
# File 'lib/aetherg/aetherg.rb', line 85

def create_gitignore
  copy_file "gitignore", File.join(@app_path, ".gitignore")
end

#create_gitkeepObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/aetherg/aetherg.rb', line 108

def create_gitkeep
  create_file File.join(@app_path, "app", "assets", "images", ".keep") unless @no_views
  create_file File.join(@app_path, "app", "assets", "stylesheets", ".keep") unless @no_views
  create_file File.join(@app_path, "app", "assets", "javascripts", ".keep") unless @no_views
  create_file File.join(@app_path, "app", "assets", "fonts", ".keep") unless @no_views
  create_file File.join(@app_path, "app", "models", ".keep")
  create_file File.join(@app_path, "app", "routes", ".keep")
  create_file File.join(@app_path, "log", ".keep")
  create_file File.join(@app_path, "tmp", ".keep")
  create_file File.join(@app_path, "app", "views", ".keep") unless @no_views
  create_file File.join(@app_path, "lib", ".keep")
  create_file File.join(@app_path, "db", "migrate", ".keep")
  create_file File.join(@app_path, "public", ".keep") unless @no_views
  create_file File.join(@app_path, "public", "favicon.ico") unless @no_views
end

#create_initializersObject



89
90
91
92
93
# File 'lib/aetherg/aetherg.rb', line 89

def create_initializers
  template("config/initializers/connection.rb", File.join(@app_path, "config/initializers/connection.rb")) unless @no_database
  template("config/initializers/environment.rb", File.join(@app_path, "config/initializers/environment.rb"))
  template("config/initializer.rb", File.join(@app_path, "config/initializer.rb"))
end

#create_rakefileObject



63
64
65
# File 'lib/aetherg/aetherg.rb', line 63

def create_rakefile
  template "Rakefile", File.join(@app_path, "Rakefile")
end

#create_readmeObject



67
68
69
# File 'lib/aetherg/aetherg.rb', line 67

def create_readme
  template "README.md", File.join(@app_path, "README.md")
end

#create_redis_config_and_initializerObject



95
96
97
98
99
100
# File 'lib/aetherg/aetherg.rb', line 95

def create_redis_config_and_initializer
  unless @no_redis
    copy_file("config/redis.yml", File.join(@app_path, "config/redis.yml"))
    template("config/initializers/redis.rb", File.join(@app_path, "config/initializers/redis.rb"))
  end
end

#create_server_configObject



71
72
73
# File 'lib/aetherg/aetherg.rb', line 71

def create_server_config
  copy_file "config/puma.rb", File.join(@app_path, "config/puma.example.rb")
end

#create_settings_configObject



80
81
82
83
# File 'lib/aetherg/aetherg.rb', line 80

def create_settings_config
  template("config/settings.yml", File.join(@app_path, "config/settings.example.yml"))
  template("config/settings.yml", File.join(@app_path, "config/settings.yml"))
end

#create_views_layoutObject



48
49
50
51
52
# File 'lib/aetherg/aetherg.rb', line 48

def create_views_layout
  unless @no_views
    copy_file "app/views/layouts/application.erb", File.join(@app_path, "/app/views/layouts/application.erb")
  end
end

#setupObject

Creates instance variables from options passed to Aether



17
18
19
20
21
22
23
24
25
26
# File 'lib/aetherg/aetherg.rb', line 17

def setup
  @name = @app_path = name.filename
  # options.each do |key, value|
  #   instance_variable_set "@#{key.to_s}".to_sym, value
  # end
  @database = options[:database]
  options[:no_database]? @no_database = true : @no_database = false
  options[:no_redis]? @no_redis = true : @no_redis = false
  options[:no_views]? @no_views = true : @no_views = false
end