Class: Guard::Mochanode

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/mocha-node.rb

Constant Summary collapse

GEM_NAME =
"mocha-node"

Class Method Summary collapse

Class Method Details

.init(name) ⇒ Object

Guardfile template needed inside guard gem



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/guard/mocha-node.rb', line 10

def self.init(name)
  if ::Guard::Dsl.guardfile_include?(GEM_NAME)
    ::Guard::UI.info "Guardfile already includes #{GEM_NAME} guard"
  else
    content = File.read('Guardfile')
    guard   = File.read("#{::Guard.locate_guard(GEM_NAME)}/lib/guard/mocha_node/templates/Guardfile")
    File.open('Guardfile', 'wb') do |f|
      f.puts(content)
      f.puts("")
      f.puts(guard)
    end
    ::Guard::UI.info "#{name} guard added to Guardfile, feel free to edit it"
  end
end