Class: SinatraBasic

Inherits:
Generator show all
Defined in:
lib/generators/sinatra_basic.rb

Instance Method Summary collapse

Methods inherited from Generator

#initialize, #make_dir, #make_file, #pre_install

Constructor Details

This class inherits a constructor from Generator

Instance Method Details

#post_installObject



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

def post_install
  puts `cd #{@base} && git init && bundle`
end

#runObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/sinatra_basic.rb', line 4

def run
  make_file("Gemfile") {
    "source 'http://rubygems.org'\ngem 'sinatra'"
  }
  make_file("app.rb") {
%Q|
require 'sinatra'

get '/' do
erb :index
end
|
  }

  make_file("config.ru") {
    "require './app'\nrun Sinatra::Application"
  }
  make_file("README.md")

  make_dir("public")
  make_dir("public/css")
  make_dir("public/js")
  make_dir("views")
  make_file("views/layout.erb") {
%Q|<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<%= yield %>
</body>
</html> |
  }
  make_file("views/index.erb") { "Hello World" }
  make_file("public/css/style.css")
end