Class: Zine::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/zine/watcher.rb

Overview

Watch files for changes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(posts_and_headlines, build_directory, source_directory) ⇒ Watcher

Returns a new instance of Watcher.



12
13
14
15
16
17
18
19
# File 'lib/zine/watcher.rb', line 12

def initialize(posts_and_headlines, build_directory, source_directory)
  @posts_and_headlines = posts_and_headlines
  @build_directory = File.join Dir.pwd, build_directory
  @source_directory = File.join Dir.pwd, source_directory
  @upload_array = []
  @delete_array = []
  @listener_array = []
end

Instance Attribute Details

#delete_arrayObject (readonly)

Returns the value of attribute delete_array.



9
10
11
# File 'lib/zine/watcher.rb', line 9

def delete_array
  @delete_array
end

#listener_arrayObject

Returns the value of attribute listener_array.



10
11
12
# File 'lib/zine/watcher.rb', line 10

def listener_array
  @listener_array
end

#upload_arrayObject (readonly)

Returns the value of attribute upload_array.



9
10
11
# File 'lib/zine/watcher.rb', line 9

def upload_array
  @upload_array
end

Instance Method Details

#notice(file_name) ⇒ Object



21
22
23
# File 'lib/zine/watcher.rb', line 21

def notice(file_name)
  @upload_array << file_name
end

#startObject

Build a delete list & an upload list for SSH from changes in build, & rebuild & reload on changes in source



27
28
29
30
# File 'lib/zine/watcher.rb', line 27

def start
  watch_build_dir
  watch_source_dir
end