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



135
136
137
# File 'lib/decko/generators/decko/decko_generator.rb', line 135

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

Instance Method Details

#configObject



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/decko/generators/decko/decko_generator.rb', line 81

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"]
    template "initializers/cypress_on_rails.rb" if options["core-dev"]
  end
end

#configruObject



73
74
75
# File 'lib/decko/generators/decko/decko_generator.rb', line 73

def configru
  template "config.ru"
end

#database_gemfile_entryObject



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

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
# File 'lib/decko/generators/decko/decko_generator.rb', line 35

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

#filesObject



61
62
63
# File 'lib/decko/generators/decko/decko_generator.rb', line 61

def files
  empty_directory_with_keep_file "files"
end

#gemfileObject



69
70
71
# File 'lib/decko/generators/decko/decko_generator.rb', line 69

def gemfile
  template "Gemfile"
end

#gitignoreObject



77
78
79
# File 'lib/decko/generators/decko/decko_generator.rb', line 77

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

#logObject



57
58
59
# File 'lib/decko/generators/decko/decko_generator.rb', line 57

def log
  empty_directory_with_keep_file "log"
end

#modObject

def readme

  copy_file "README", "README.rdoc"
end


53
54
55
# File 'lib/decko/generators/decko/decko_generator.rb', line 53

def mod
  empty_directory_with_keep_file "mod"
end

#publicObject



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/decko/generators/decko/decko_generator.rb', line 95

def public
  empty_directory "public"

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

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

#rakefileObject



45
46
47
# File 'lib/decko/generators/decko/decko_generator.rb', line 45

def rakefile
  template "Rakefile"
end

#scriptObject



108
109
110
111
112
113
# File 'lib/decko/generators/decko/decko_generator.rb', line 108

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

#seed_dataObject



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

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



65
66
67
# File 'lib/decko/generators/decko/decko_generator.rb', line 65

def tmp
  empty_directory "tmp"
end