Class: Guard::Sync

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/sync.rb

Instance Method Summary collapse

Constructor Details

#initialize(watchers = [], options = {}) ⇒ Sync

Returns a new instance of Sync.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/guard/sync.rb', line 6

def initialize(watchers = [], options = {})
  super
  @options = {
    :all_on_start => false,
    :archive => false,
    :recursive => true,
    :compress => true,
    :permissions => true,
    :delete => false,
    :src => '.',
    :verbose => false,
    :quiet => true
  }.merge options
  update
end

Instance Method Details

#run_allObject



26
27
28
29
30
# File 'lib/guard/sync.rb', line 26

def run_all
  # UI.info "Guard::Sync is running" if @opts
  UI.info "#{@action}d #{@options[:include]}"
  `#{@command}` if @opts
end

#run_on_additions(paths) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/guard/sync.rb', line 32

def run_on_additions paths
  @action = "create"
  @options[:exclude] = '*'
  @options[:include] = paths.to_s[1..-2]
  @options[:delete] = false
  update
  run_all
end

#run_on_removals(paths) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/guard/sync.rb', line 41

def run_on_removals paths
  @action = "remove"
  @options[:exclude] = '*'
  @options[:include] = paths.to_s[1..-2]
  @options[:delete] = true
  update
  run_all
end

#startObject



22
23
24
# File 'lib/guard/sync.rb', line 22

def start
  run_all if @options[:all_on_start]
end