Class: Decko::Generators::Deck::DeckGenerator

Inherits:
Rails::Generators::AppBase
  • Object
show all
Includes:
DeckHelper, RailsOverrides
Defined in:
decko/lib/decko/generators/deck/deck_generator.rb,
decko/lib/decko/generators/deck/deck_generator/deck_helper.rb,
decko/lib/decko/generators/deck/deck_generator/interactive.rb,
decko/lib/decko/generators/deck/deck_generator/rails_overrides.rb

Overview

Create new Decks (Decko Applications)

Defined Under Namespace

Modules: DeckHelper, RailsOverrides Classes: Interactive

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



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

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

Instance Method Details

#configObject



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'decko/lib/decko/generators/deck/deck_generator.rb', line 68

def config
  inside "config" do
    erb_template "application.rb"
    erb_template "routes.rb"
    erb_template "environment.rb"
    erb_template "boot.rb"
    template "databases/#{options[:database]}.yml", "database.yml"
    template "cucumber.yml"
    template "storage.yml"
    template "initializers/cypress.rb" if platypus?
    template "puma.rb"
  end
end

#core_filesObject

Generator works its way through each public method below



51
52
53
54
55
# File 'decko/lib/decko/generators/deck/deck_generator.rb', line 51

def core_files
  erb_template "config.ru"
  erb_template "Gemfile"
  erb_template "Rakefile"
end

#dotfilesObject



61
62
63
64
65
66
# File 'decko/lib/decko/generators/deck/deck_generator.rb', line 61

def dotfiles
  copy_file "pryrc", ".pryrc"
  copy_file "gitignore", ".gitignore"
  template "rspec.erb", ".rspec"
  template "simplecov.rb.erb", ".simplecov"
end

#empty_dirsObject



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

def empty_dirs
  %w[mod log files tmp].each { |dirname| empty_directory_with_keep_file dirname }
end

#publicObject



82
83
84
85
86
87
# File 'decko/lib/decko/generators/deck/deck_generator.rb', line 82

def public
  inside "public" do
    template "robots.txt"
    inside("files") { template "htaccess", ".htaccess" }
  end
end

#scriptObject



93
94
95
96
# File 'decko/lib/decko/generators/deck/deck_generator.rb', line 93

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

#seed_dataObject



111
112
113
114
115
116
117
118
119
120
# File 'decko/lib/decko/generators/deck/deck_generator.rb', line 111

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

#specObject



98
99
100
101
102
103
104
105
106
107
# File 'decko/lib/decko/generators/deck/deck_generator.rb', line 98

def spec
  inside "spec" do
    if platypus?
      jasmine_yml :decko
    else
      jasmine_yml :deck
      template "spec_helper.rb"
    end
  end
end

#springObject



89
90
91
# File 'decko/lib/decko/generators/deck/deck_generator.rb', line 89

def spring
  inside("bin") { erb_template "spring" }
end