Class: Clearsight::Middleman

Inherits:
Object
  • Object
show all
Includes:
Methadone::CLILogging, Methadone::SH
Defined in:
lib/clearsight/middleman.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Middleman

Returns a new instance of Middleman.



8
9
10
# File 'lib/clearsight/middleman.rb', line 8

def initialize(args)
  @args = args
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



6
7
8
# File 'lib/clearsight/middleman.rb', line 6

def args
  @args
end

Instance Method Details

#cloneObject



28
29
30
31
32
# File 'lib/clearsight/middleman.rb', line 28

def clone
  print "Cloning ClearSight middleman template..."
  sh "git clone [email protected]:clearsightstudio/middleman-template.git ~/.middleman/clearsight"
  puts "done."
end

#create(project) ⇒ Object



40
41
42
43
44
45
# File 'lib/clearsight/middleman.rb', line 40

def create(project)
  setup
  print "Setting up new middleman project..."
  sh "middleman init -T=clearsight #{project}"
  puts "done."
end

#passObject



20
21
22
# File 'lib/clearsight/middleman.rb', line 20

def pass
  sh "middleman #{@args.join(' ')}"
end

#runObject



12
13
14
15
16
17
18
# File 'lib/clearsight/middleman.rb', line 12

def run
  if @args.first == "new"
    create @args[1]
  else
    pass
  end
end

#setupObject



24
25
26
# File 'lib/clearsight/middleman.rb', line 24

def setup
  File.exist?("#{ENV['HOME']}/.middleman/clearsight") ? update : clone
end

#updateObject



34
35
36
37
38
# File 'lib/clearsight/middleman.rb', line 34

def update
  print "Updating ClearSight middleman template..."
  sh "cd ~/.middleman/clearsight && git pull && cd -"
  puts "done."
end