Class: Filesortd::XattrMatcher
- Inherits:
-
Object
- Object
- Filesortd::XattrMatcher
- Defined in:
- lib/filesortd/matcher.rb
Instance Method Summary collapse
-
#initialize(xattr, &matcher) ⇒ XattrMatcher
constructor
A new instance of XattrMatcher.
- #match(path) ⇒ Object
Constructor Details
#initialize(xattr, &matcher) ⇒ XattrMatcher
Returns a new instance of XattrMatcher.
23 24 25 26 27 |
# File 'lib/filesortd/matcher.rb', line 23 def initialize(xattr, &matcher) require "osx/plist" @xattr = xattr @matcher = matcher end |
Instance Method Details
#match(path) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/filesortd/matcher.rb', line 29 def match(path) return false unless `xattr -l #{path.shellescape}`.include? @xattr str = [`xattr -px #{@xattr.shellescape} #{path.shellescape}`.gsub("\n", "").gsub(" ", "")].pack("H*") pl = OSX::PropertyList.load(str) @matcher.call(pl, path) end |