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



21
22
23
# File 'lib/aetherg/aetherg.rb', line 21

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

Instance Method Details

#create_appObject



36
37
38
39
# File 'lib/aetherg/aetherg.rb', line 36

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



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

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



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

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



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

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



26
27
28
29
30
31
32
33
34
# File 'lib/aetherg/aetherg.rb', line 26

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



52
53
54
# File 'lib/aetherg/aetherg.rb', line 52

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

#create_gitignoreObject



78
79
80
# File 'lib/aetherg/aetherg.rb', line 78

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

#create_gitkeepObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/aetherg/aetherg.rb', line 101

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
end

#create_initializersObject



82
83
84
85
86
# File 'lib/aetherg/aetherg.rb', line 82

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



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

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

#create_readmeObject



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

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

#create_redis_config_and_initializerObject



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

def create_redis_config_and_initializer
  if @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



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

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

#create_settings_configObject



73
74
75
76
# File 'lib/aetherg/aetherg.rb', line 73

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



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

def create_views_layout
  unless @no_views
    template "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



14
15
16
17
18
19
# File 'lib/aetherg/aetherg.rb', line 14

def setup
  @name = @app_path = name.filename
  options.each do |key, value|
    instance_variable_set "@#{key.to_s}".to_sym, value
  end
end