Class: Guard::RoGuard

Inherits:
Guard
  • Object
show all
Defined in:
lib/ro_support/ro_guard.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.def_meth(meth, &blk) ⇒ Object



7
8
9
10
11
# File 'lib/ro_support/ro_guard.rb', line 7

def self.def_meth(meth, &blk)
  define_singleton_method meth, &blk
  define_method meth, &blk
  Pry::Command.send :define_method, meth, &blk
end

Instance Method Details

#handle(file, &blk) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/ro_support/ro_guard.rb', line 48

def handle(file, &blk)
  #puts "Handling #{paths.flatten}"
  r = paths.flatten.grep /#{file}$/
  unless r.empty?
    blk.call
  end
end

#notify(msg) ⇒ Object



43
44
45
46
# File 'lib/ro_support/ro_guard.rb', line 43

def notify(msg)
  puts msg
  Notifier.notify msg
end

#pathsObject



37
38
39
40
41
# File 'lib/ro_support/ro_guard.rb', line 37

def paths
  @paths.flatten! if @paths.respond_to?(:flatten!)
  @paths.uniq! if @paths.respond_to?(:uniq!)
  @paths ||= []
end

#run_on_modifications(paths) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/ro_support/ro_guard.rb', line 28

def run_on_modifications(paths)
  @paths = paths
  handle('Guardfile') do
    bash "bundle exec guard"
  end

  bash "rake install"
end

#startObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/ro_support/ro_guard.rb', line 17

def start
  commands = Pry::CommandSet.new do
    block_command "install" do |*args|
      system "rake install"
      output.out "nimabi"
    end
  end

  Pry::Commands.import commands
end