Class: DeckoGenerator

Inherits:
Rails::Generators::AppBase
  • Object
show all
Defined in:
lib/decko/generators/decko/decko_generator.rb,
lib/decko/generators/decko/decko_generator/interactive.rb

Defined Under Namespace

Classes: Interactive

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



144
145
146
# File 'lib/decko/generators/decko/decko_generator.rb', line 144

def self.banner
  "decko new #{arguments.map(&:usage).join(' ')} [options]"
end

Instance Method Details

#configObject



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/decko/generators/decko/decko_generator.rb', line 91

def config
  empty_directory "config"

  inside "config" do
    template "application.rb"
    template "routes.erb", "routes.rb"
    template "environment.rb"
    template "boot.rb"
    template "databases/#{options[:database]}.yml", "database.yml"
    template "cucumber.yml" if options["core-dev"]
  end
end

#configruObject



83
84
85
# File 'lib/decko/generators/decko/decko_generator.rb', line 83

def configru
  template "config.ru"
end

#database_gemfile_entryObject



137
138
139
140
141
142
# File 'lib/decko/generators/decko/decko_generator.rb', line 137

def database_gemfile_entry
  return [] if options[:skip_active_record]
  gem_name, gem_version = gem_for_database
  msg = "Use #{options[:database]} as the database for Active Record"
  GemfileEntry.version gem_name, gem_version, msg
end

#dev_setupObject

should probably eventually use rails-like AppBuilder approach, but this is a first step.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/decko/generators/decko/decko_generator.rb', line 35

def dev_setup
  # TODO: rename or split, gem_path points to the source repo,
  # card and decko gems are subdirs
  @gemfile_gem_path = @gem_path = options["gem-path"]
  env_gem_path = ENV["DECKO_GEM_PATH"]
  if env_gem_path.present?
    @gemfile_gem_path = %q(#{ENV['DECKO_GEM_PATH']})
    @gem_path = env_gem_path
  end

  @include_jasmine_engine = false
  if options["core-dev"]
    core_dev_setup
    shared_dev_setup
  elsif options["mod-dev"]
    mod_dev_setup
    shared_dev_setup
  end
end

#filesObject



71
72
73
# File 'lib/decko/generators/decko/decko_generator.rb', line 71

def files
  empty_directory_with_keep_file "files"
end

#gemfileObject



79
80
81
# File 'lib/decko/generators/decko/decko_generator.rb', line 79

def gemfile
  template "Gemfile"
end

#gitignoreObject



87
88
89
# File 'lib/decko/generators/decko/decko_generator.rb', line 87

def gitignore
  copy_file "gitignore", ".gitignore"
end

#logObject



67
68
69
# File 'lib/decko/generators/decko/decko_generator.rb', line 67

def log
  empty_directory_with_keep_file "log"
end

#modObject

def readme

  copy_file "README", "README.rdoc"
end


63
64
65
# File 'lib/decko/generators/decko/decko_generator.rb', line 63

def mod
  empty_directory_with_keep_file "mod"
end

#publicObject



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/decko/generators/decko/decko_generator.rb', line 104

def public
  empty_directory "public"

  inside "public" do
    template "robots.txt"
    empty_directory "files"

    inside "files" do
      template "htaccess", ".htaccess"
    end
  end
end

#rakefileObject



55
56
57
# File 'lib/decko/generators/decko/decko_generator.rb', line 55

def rakefile
  template "Rakefile"
end

#scriptObject



117
118
119
120
121
122
# File 'lib/decko/generators/decko/decko_generator.rb', line 117

def script
  directory "script" do |content|
    "#{shebang}\n" + content
  end
  chmod "script", 0755 & ~File.umask, verbose: false
end

#seed_dataObject



126
127
128
129
130
131
132
133
134
135
# File 'lib/decko/generators/decko/decko_generator.rb', line 126

def seed_data
  if options["interactive"]
    Interactive.new(options, destination_root).run
  else
    puts "Now:
1. Run `cd #{File.basename(destination_root)}` to move your new deck directory
2. Run `decko seed` to seed your database (see db configuration in config/database.yml).
3. Run `decko server` to start your server"
  end
end

#tmpObject



75
76
77
# File 'lib/decko/generators/decko/decko_generator.rb', line 75

def tmp
  empty_directory "tmp"
end