fynd 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +4 -2
 - data/lib/fynd/criteria.rb +2 -2
 - data/lib/fynd/tests.rb +13 -13
 - data/lib/fynd/version.rb +1 -1
 - metadata +3 -3
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,6 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Fynd
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            I found GNU find to be slow, so I made it slower.
         
     | 
| 
      
 3 
     | 
    
         
            +
            I found GNU find to be slow, so I made it slower by rewriting it in Ruby.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Fynd is heavily inspired by the, uh... find command, I guess.
         
     | 
| 
       4 
6 
     | 
    
         | 
| 
       5 
7 
     | 
    
         
             
            ## Is it any good?
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
         @@ -23,7 +25,7 @@ find("/var/log").iname("system").type(:file).files 
     | 
|
| 
       23 
25 
     | 
    
         
             
            => ["/var/log/system.log", "/var/log/system.log.0.bz2", "/var/log/system.log.1.bz2", "/var/log/system.log.2.bz2", "/var/log/system.log.3.bz2", "/var/log/system.log.4.bz2", "/var/log/system.log.5.bz2", "/var/log/system.log.6.bz2", "/var/log/system.log.7.bz2"]
         
     | 
| 
       24 
26 
     | 
    
         
             
            ```
         
     | 
| 
       25 
27 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
            You can  
     | 
| 
      
 28 
     | 
    
         
            +
            You can even pass the files to a block.
         
     | 
| 
       27 
29 
     | 
    
         | 
| 
       28 
30 
     | 
    
         
             
            ```ruby
         
     | 
| 
       29 
31 
     | 
    
         
             
            require 'fynd'
         
     | 
    
        data/lib/fynd/criteria.rb
    CHANGED
    
    | 
         @@ -22,10 +22,10 @@ module Fynd 
     | 
|
| 
       22 
22 
     | 
    
         
             
                  # For every path...
         
     | 
| 
       23 
23 
     | 
    
         
             
                  paths.each do |path|
         
     | 
| 
       24 
24 
     | 
    
         
             
                    # Pull out all directories
         
     | 
| 
       25 
     | 
    
         
            -
                    # dirs = Dir.glob(File.expand_path(path)).select { |f| File. 
     | 
| 
      
 25 
     | 
    
         
            +
                    # dirs = Dir.glob(File.expand_path(path)).select { |f| File.lstat(f).directory? }
         
     | 
| 
       26 
26 
     | 
    
         
             
                    # Shove all found files into the collection
         
     | 
| 
       27 
27 
     | 
    
         
             
                    # @sieve.collection << Dir.glob(File.expand_path(path))
         
     | 
| 
       28 
     | 
    
         
            -
                    @sieve.collection << Find.find(path).to_a
         
     | 
| 
      
 28 
     | 
    
         
            +
                    @sieve.collection << Find.find(File.expand_path(path)).to_a
         
     | 
| 
       29 
29 
     | 
    
         
             
                  end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
                  # Flatten it and strip out non-unique files
         
     | 
    
        data/lib/fynd/tests.rb
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ module Fynd::Tests 
     | 
|
| 
       18 
18 
     | 
    
         
             
              # effect, the access time of the file it points to is always used.
         
     | 
| 
       19 
19 
     | 
    
         
             
              def anewer(other)
         
     | 
| 
       20 
20 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       21 
     | 
    
         
            -
                  File. 
     | 
| 
      
 21 
     | 
    
         
            +
                  File.lstat(file).atime > File.lstat(other).atime
         
     | 
| 
       22 
22 
     | 
    
         
             
                end
         
     | 
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
         @@ -32,7 +32,7 @@ module Fynd::Tests 
     | 
|
| 
       32 
32 
     | 
    
         
             
                time = Time.now    
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       35 
     | 
    
         
            -
                  atime = File. 
     | 
| 
      
 35 
     | 
    
         
            +
                  atime = File.lstat(file).atime
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                  case comparer
         
     | 
| 
       38 
38 
     | 
    
         
             
                  when '+'
         
     | 
| 
         @@ -60,7 +60,7 @@ module Fynd::Tests 
     | 
|
| 
       60 
60 
     | 
    
         
             
              # points to is always used.
         
     | 
| 
       61 
61 
     | 
    
         
             
              def cnewer(other)
         
     | 
| 
       62 
62 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       63 
     | 
    
         
            -
                  File. 
     | 
| 
      
 63 
     | 
    
         
            +
                  File.lstat(file).ctime > File.lstat(other).ctime
         
     | 
| 
       64 
64 
     | 
    
         
             
                end
         
     | 
| 
       65 
65 
     | 
    
         
             
              end
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
         @@ -73,7 +73,7 @@ module Fynd::Tests 
     | 
|
| 
       73 
73 
     | 
    
         
             
              # File is empty and is either a regular file or a directory.
         
     | 
| 
       74 
74 
     | 
    
         
             
              def empty
         
     | 
| 
       75 
75 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       76 
     | 
    
         
            -
                  File. 
     | 
| 
      
 76 
     | 
    
         
            +
                  File.lstat(file).zero?
         
     | 
| 
       77 
77 
     | 
    
         
             
                end
         
     | 
| 
       78 
78 
     | 
    
         
             
              end
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
         @@ -89,14 +89,14 @@ module Fynd::Tests 
     | 
|
| 
       89 
89 
     | 
    
         
             
              # File's numeric group ID is n.
         
     | 
| 
       90 
90 
     | 
    
         
             
              def gid(n)
         
     | 
| 
       91 
91 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       92 
     | 
    
         
            -
                  File. 
     | 
| 
      
 92 
     | 
    
         
            +
                  File.lstat(file).gid == n.to_i
         
     | 
| 
       93 
93 
     | 
    
         
             
                end
         
     | 
| 
       94 
94 
     | 
    
         
             
              end
         
     | 
| 
       95 
95 
     | 
    
         | 
| 
       96 
96 
     | 
    
         
             
              # File belongs to group gname (numeric group ID allowed).
         
     | 
| 
       97 
97 
     | 
    
         
             
              def group(name)
         
     | 
| 
       98 
98 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       99 
     | 
    
         
            -
                  gid = File. 
     | 
| 
      
 99 
     | 
    
         
            +
                  gid = File.lstat(file).gid
         
     | 
| 
       100 
100 
     | 
    
         
             
                  Etc.getgrgid(gid).name == name
         
     | 
| 
       101 
101 
     | 
    
         
             
                end
         
     | 
| 
       102 
102 
     | 
    
         
             
              end
         
     | 
| 
         @@ -124,7 +124,7 @@ module Fynd::Tests 
     | 
|
| 
       124 
124 
     | 
    
         
             
              # -samefile test instead.
         
     | 
| 
       125 
125 
     | 
    
         
             
              def inum(n)
         
     | 
| 
       126 
126 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       127 
     | 
    
         
            -
                  File. 
     | 
| 
      
 127 
     | 
    
         
            +
                  File.lstat(file).ino == n.to_i
         
     | 
| 
       128 
128 
     | 
    
         
             
                end
         
     | 
| 
       129 
129 
     | 
    
         
             
              end
         
     | 
| 
       130 
130 
     | 
    
         | 
| 
         @@ -184,7 +184,7 @@ module Fynd::Tests 
     | 
|
| 
       184 
184 
     | 
    
         
             
              # No user corresponds to file's numeric user ID.
         
     | 
| 
       185 
185 
     | 
    
         
             
              def nouser
         
     | 
| 
       186 
186 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       187 
     | 
    
         
            -
                  uid = File. 
     | 
| 
      
 187 
     | 
    
         
            +
                  uid = File.lstat(file).uid
         
     | 
| 
       188 
188 
     | 
    
         
             
                  begin
         
     | 
| 
       189 
189 
     | 
    
         
             
                    Etc.getpwuid(uid)
         
     | 
| 
       190 
190 
     | 
    
         
             
                    false
         
     | 
| 
         @@ -197,7 +197,7 @@ module Fynd::Tests 
     | 
|
| 
       197 
197 
     | 
    
         
             
              # No group corresponds to file's numeric group ID.
         
     | 
| 
       198 
198 
     | 
    
         
             
              def nogroup
         
     | 
| 
       199 
199 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       200 
     | 
    
         
            -
                  gid = File. 
     | 
| 
      
 200 
     | 
    
         
            +
                  gid = File.lstat(file).gid
         
     | 
| 
       201 
201 
     | 
    
         
             
                  begin
         
     | 
| 
       202 
202 
     | 
    
         
             
                    Etc.getgrgid(gid)
         
     | 
| 
       203 
203 
     | 
    
         
             
                    false
         
     | 
| 
         @@ -302,9 +302,9 @@ module Fynd::Tests 
     | 
|
| 
       302 
302 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       303 
303 
     | 
    
         
             
                  case c.to_s
         
     | 
| 
       304 
304 
     | 
    
         
             
                  when 'f', 'file'
         
     | 
| 
       305 
     | 
    
         
            -
                    File. 
     | 
| 
      
 305 
     | 
    
         
            +
                    File.lstat(file).file?
         
     | 
| 
       306 
306 
     | 
    
         
             
                  when 'd', 'dir', 'directory'
         
     | 
| 
       307 
     | 
    
         
            -
                    File. 
     | 
| 
      
 307 
     | 
    
         
            +
                    File.lstat(file).directory?
         
     | 
| 
       308 
308 
     | 
    
         
             
                  else
         
     | 
| 
       309 
309 
     | 
    
         
             
                    false
         
     | 
| 
       310 
310 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -314,7 +314,7 @@ module Fynd::Tests 
     | 
|
| 
       314 
314 
     | 
    
         
             
              # File's numeric user ID is n.
         
     | 
| 
       315 
315 
     | 
    
         
             
              def uid(n)
         
     | 
| 
       316 
316 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       317 
     | 
    
         
            -
                  File. 
     | 
| 
      
 317 
     | 
    
         
            +
                  File.lstat(file).uid == n.to_i
         
     | 
| 
       318 
318 
     | 
    
         
             
                end
         
     | 
| 
       319 
319 
     | 
    
         
             
              end
         
     | 
| 
       320 
320 
     | 
    
         | 
| 
         @@ -325,7 +325,7 @@ module Fynd::Tests 
     | 
|
| 
       325 
325 
     | 
    
         
             
              # File is owned by user uname (numeric user ID allowed).
         
     | 
| 
       326 
326 
     | 
    
         
             
              def user(name)
         
     | 
| 
       327 
327 
     | 
    
         
             
                files.select! do |file|
         
     | 
| 
       328 
     | 
    
         
            -
                  uid = File. 
     | 
| 
      
 328 
     | 
    
         
            +
                  uid = File.lstat(file).uid.to_i
         
     | 
| 
       329 
329 
     | 
    
         
             
                  Etc.getpwuid(uid).name == name
         
     | 
| 
       330 
330 
     | 
    
         
             
                end
         
     | 
| 
       331 
331 
     | 
    
         
             
              end
         
     | 
    
        data/lib/fynd/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: fynd
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -64,7 +64,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       64 
64 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       65 
65 
     | 
    
         
             
                  segments:
         
     | 
| 
       66 
66 
     | 
    
         
             
                  - 0
         
     | 
| 
       67 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 67 
     | 
    
         
            +
                  hash: 4151080051906730584
         
     | 
| 
       68 
68 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       69 
69 
     | 
    
         
             
              none: false
         
     | 
| 
       70 
70 
     | 
    
         
             
              requirements:
         
     | 
| 
         @@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       73 
73 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       74 
74 
     | 
    
         
             
                  segments:
         
     | 
| 
       75 
75 
     | 
    
         
             
                  - 0
         
     | 
| 
       76 
     | 
    
         
            -
                  hash:  
     | 
| 
      
 76 
     | 
    
         
            +
                  hash: 4151080051906730584
         
     | 
| 
       77 
77 
     | 
    
         
             
            requirements: []
         
     | 
| 
       78 
78 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       79 
79 
     | 
    
         
             
            rubygems_version: 1.8.24
         
     |