Module: Filesortd

Included in:
Script
Defined in:
lib/filesortd.rb,
lib/filesortd/cli.rb,
lib/filesortd/cond.rb,
lib/filesortd/afile.rb,
lib/filesortd/folder.rb,
lib/filesortd/matcher.rb,
lib/filesortd/version.rb,
lib/filesortd/callback.rb

Defined Under Namespace

Classes: Afile, AlwaysTrueMatcher, BasenameMatcher, CLI, Callback, Matcher, Script, SpotlightMatcher, XattrMatcher

Constant Summary collapse

VERSION =
"0.2.0"

Instance Method Summary collapse

Instance Method Details

#folders(*paths, &block) ⇒ Object Also known as: folder



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/filesortd/folder.rb', line 14

def folders(*paths, &block)
  paths = select_existing paths
  unless paths == []
    callback = Docile.dsl_eval(Callback.new, &block)
    cb = Proc.new do |modified, added, removed|
      puts "Processing files: #{added}"
      callback.call added
    end
    l = Listen.to(*paths).latency(0.5).change(&cb)
    l.start(false)
    @listeners << l
  end
end

#os(s, &block) ⇒ Object



2
3
4
5
6
# File 'lib/filesortd/cond.rb', line 2

def os(s, &block)
  if s == current_os
    block.call
  end
end

#select_existing(paths) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/filesortd/folder.rb', line 6

def select_existing(paths)
  paths.select do |path|
    e = File.exists? path
    puts "Folder does not exist: #{path}" unless e
    e
  end
end