Class: FrankensteinSinatra::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/frankenstein-sinatra/shell.rb

Class Method Summary collapse

Class Method Details

.clone(*args) ⇒ Object



16
17
18
19
# File 'lib/frankenstein-sinatra/shell.rb', line 16

def self.clone *args
  system "git clone #{git_path args.first}"
  system "cd #{args.first} && git remote add heroku #{git_path}"
end

.console(*args) ⇒ Object



29
30
31
# File 'lib/frankenstein-sinatra/shell.rb', line 29

def self.console *args
  system 'irb -r ./app.rb'
end

.deploy(*args) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/frankenstein-sinatra/shell.rb', line 21

def self.deploy *args
  setup unless set_up?
  system 'git add .'
  message = args.first || 'Deployed via Sinatra'
  system "git commit -a -m '#{message}'"
  system 'git push heroku master -q'
end

.git_path(*args) ⇒ Object



3
4
5
6
# File 'lib/frankenstein-sinatra/shell.rb', line 3

def self.git_path *args
  repo = args.first || project
  "[email protected]:#{repo}.git"
end

.help(*args) ⇒ Object



54
55
56
57
58
59
# File 'lib/frankenstein-sinatra/shell.rb', line 54

def self.help *args
  puts 'sinatra new {projectname} -----------> to generate a new project'
  puts 'sinatra server {optional: port} -----> to run the application server'
  puts 'sinatra console ---------------------> to run the application console'
  puts 'sinatra deploy {optional: message} --> to deploy your application'
end

.new(*args) ⇒ Object



12
13
14
# File 'lib/frankenstein-sinatra/shell.rb', line 12

def self.new *args
  FrankensteinSinatra::TemplateGenerator.new args.first
end

.project(*args) ⇒ Object



8
9
10
# File 'lib/frankenstein-sinatra/shell.rb', line 8

def self.project *args
  Dir.pwd.split('/').last.strip
end

.server(*args) ⇒ Object



33
34
35
36
# File 'lib/frankenstein-sinatra/shell.rb', line 33

def self.server *args
  port = args.first || '6937'
  system "shotgun -I config.ru -p #{port}"
end

.set_up?(*args) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/frankenstein-sinatra/shell.rb', line 50

def self.set_up? *args
  IO.readlines("./config.ru")[-1].index "#set"
end

.setup(*args) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/frankenstein-sinatra/shell.rb', line 38

def self.setup *args
  system "git init"
  system "heroku create" unless system "heroku create #{project}"
  system "heroku addons:add sendgrid:starter"
  system "heroku addons:add memcache"
  system "heroku addons:add custom_domains:basic"
  system "heroku addons:add zerigo_dns:basic"
  fingerprints = "\n#set up via Sinatra"
  File.open("config.ru", 'a+') {|f| f.write(fingerprints)}
  system "bundle install"
end