Class: WagnGenerator
- Inherits:
-
Rails::Generators::AppBase
- Object
- Rails::Generators::AppBase
- WagnGenerator
- Defined in:
- lib/wagn/generators/wagn/wagn_generator.rb,
lib/wagn/generators/wagn/wagn_generator/interactive.rb
Defined Under Namespace
Classes: Interactive
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #configru ⇒ Object
- #database_gemfile_entry ⇒ Object
-
#dev_setup ⇒ Object
should probably eventually use rails-like AppBuilder approach, but this is a first step.
- #files ⇒ Object
- #gemfile ⇒ Object
- #gitignore ⇒ Object
- #log ⇒ Object
-
#mod ⇒ Object
def readme copy_file “README”, “README.rdoc” end.
- #public ⇒ Object
- #rakefile ⇒ Object
- #script ⇒ Object
- #seed_data ⇒ Object
- #tmp ⇒ Object
Class Method Details
.banner ⇒ Object
153 154 155 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 153 def self. "wagn new #{arguments.map(&:usage).join(' ')} [options]" end |
Instance Method Details
#config ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 93 def config empty_directory "config" inside "config" do template "application.rb" template "routes.erb", "routes.rb" template "environment.rb" template "boot.rb" template "databases/#{[:database]}.yml", "database.yml" template "cucumber.yml" if ["core-dev"] end end |
#configru ⇒ Object
85 86 87 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 85 def configru template "config.ru" end |
#database_gemfile_entry ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 138 def database_gemfile_entry return [] if [:skip_active_record] gem_name, gem_version = gem_for_database if gem_name == "mysql2" # && Gem.loaded_specs['rails'].version < Gem::Version.new('4.2.5') # Rails update from 4.2.4 to 4.2.5 didn't help. # Current mysql2 gem (0.4.1) is still causing trouble. # Maybe with the next Rails release? # Could also be that ruby 1.9.3 is the problem. gem_version = "0.3.20" end msg = "Use #{[:database]} as the database for Active Record" GemfileEntry.version gem_name, gem_version, msg end |
#dev_setup ⇒ Object
should probably eventually use rails-like AppBuilder approach, but this is a first step.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 37 def dev_setup # TODO: rename or split, gem_path points to the source repo, # card and wagn gems are subdirs @gemfile_gem_path = @gem_path = ["gem-path"] env_gem_path = ENV["WAGN_GEM_PATH"] if env_gem_path.present? @gemfile_gem_path = %q(#{ENV['WAGN_GEM_PATH']}) @gem_path = env_gem_path end @include_jasmine_engine = false if ["core-dev"] core_dev_setup shared_dev_setup elsif ["mod-dev"] mod_dev_setup shared_dev_setup end end |
#files ⇒ Object
73 74 75 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 73 def files empty_directory_with_keep_file "files" end |
#gemfile ⇒ Object
81 82 83 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 81 def gemfile template "Gemfile" end |
#gitignore ⇒ Object
89 90 91 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 89 def gitignore copy_file "gitignore", ".gitignore" end |
#log ⇒ Object
69 70 71 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 69 def log empty_directory_with_keep_file "log" end |
#mod ⇒ Object
def readme
copy_file "README", "README.rdoc"
end
65 66 67 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 65 def mod empty_directory_with_keep_file "mod" end |
#public ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 106 def public empty_directory "public" inside "public" do template "robots.txt" empty_directory "files" inside "files" do template "htaccess", ".htaccess" end end end |
#rakefile ⇒ Object
57 58 59 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 57 def rakefile template "Rakefile" end |
#script ⇒ Object
119 120 121 122 123 124 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 119 def script directory "script" do |content| "#{shebang}\n" + content end chmod "script", 0755 & ~File.umask, verbose: false end |
#seed_data ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 128 def seed_data if ["interactive"] Interactive.new(, destination_root).run else puts "Now: 1. Run `wagn seed` to seed your database (see db configuration in config/database.yml). 2. Run `wagn server` to start your server" end end |
#tmp ⇒ Object
77 78 79 |
# File 'lib/wagn/generators/wagn/wagn_generator.rb', line 77 def tmp empty_directory "tmp" end |