Class: Snfn::Generator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



22
23
24
# File 'lib/snfn.rb', line 22

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

Instance Method Details

#create_appObject



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

def create_app
  template "app.rb", File.join(@app_path, "#{@name}.rb")
end

#create_configObject



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

def create_config
  template "config.ru", File.join(@app_path, "config.ru")
end

#create_database_initializerObject



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

def create_database_initializer
  template("config/initializers/database.rb", File.join(@app_path, "config/initializers/database.rb")) unless @no_database
end

#create_db_configObject



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

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

#create_empty_directoriesObject

Create empty directories



27
28
29
30
31
# File 'lib/snfn.rb', line 27

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

#create_gemfileObject



51
52
53
# File 'lib/snfn.rb', line 51

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

#create_lib_gitkeepObject



87
88
89
# File 'lib/snfn.rb', line 87

def create_lib_gitkeep
  create_file File.join(@app_path, "lib", ".gitkeep")
end

#create_procfileObject



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

def create_procfile
  copy_file("Procfile", File.join(@app_path, "Procfile")) unless @no_heroku
end

#create_public_directoryObject



33
34
35
36
37
# File 'lib/snfn.rb', line 33

def create_public_directory
  %w{public/css public/js public/img}.each do |dir|
    directory dir, File.join(@app_path, dir)
  end
end

#create_rakefileObject



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

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

#create_readmeObject



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

def create_readme
  copy_file "README.mdown", File.join(@app_path, "README.mdown")
end

#create_redis_configObject



79
80
81
# File 'lib/snfn.rb', line 79

def create_redis_config
  copy_file("config/redis.yml", File.join(@app_path, "config/redis.yml")) if @redis
end

#create_redis_initializerObject



83
84
85
# File 'lib/snfn.rb', line 83

def create_redis_initializer
  template("config/initializers/redis.rb", File.join(@app_path, "config/initializers/redis.rb")) if @redis
end

#create_server_configObject



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

def create_server_config
  template "config/unicorn.rb", File.join(@app_path, "config/unicorn.rb")
end

#create_view_directoryObject



39
40
41
# File 'lib/snfn.rb', line 39

def create_view_directory
  directory "views", File.join(@app_path, "views")
end

#setupObject

Creates instance variables from options passed to snfn.



15
16
17
18
19
20
# File 'lib/snfn.rb', line 15

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