file_scanner 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28d079722f80fd8d08f242cea61b0994d6b2bb35
4
- data.tar.gz: 0713446d2aa7ce967b7005aa96dcead35c3ea4e7
3
+ metadata.gz: 478c7732cd0abb2981102eefe125cd22b9a20817
4
+ data.tar.gz: 3e2b952a497d05a4922391e9cbcb8ece65547878
5
5
  SHA512:
6
- metadata.gz: df069987cf734fe0ec58b7c857fd24524179fcac86ac5b7ab8663548bdfb6b28ad366c8182e2ed75b01c7c00735d928ebc30352b5d49e70bb509b2fa49a8fe89
7
- data.tar.gz: 8dd06c2d10ae10c60a437b574431e7eb439845c1175b4e95b09370f755bfccf76dd91773001981a4950b906d98b92f02f437b6c2dbe975b613842f85cd776638
6
+ metadata.gz: 1dc2e81cec24ffde8024dc70b72afe8f4f749fbc911d2da201ec2129221852f66b98054ecc3e9767c32e7c75526bc7822018ce2bfaf9810ab4847d144c8093a5
7
+ data.tar.gz: 80083baacc776549ecbe1575256459eba93bff72935b55428652ee42e8706d9e95b9a2dfd826f274dc29b685c4ffde6d90f1208e399f6bff013e2f4ca0904327
data/README.md CHANGED
@@ -11,6 +11,7 @@
11
11
  * [Enumerator](#enumerator)
12
12
  * [Block](#block)
13
13
  * [Mode](#mode)
14
+ * [Check](#check)
14
15
  * [Logger](#logger)
15
16
 
16
17
  ## Scope
@@ -81,9 +82,18 @@ end
81
82
 
82
83
  #### Mode
83
84
  By default the worker will select paths by applying any of the matching filters: this is it, it suffice just one of the specified filters to be true to grab the path.
84
- In case you want restrict paths selection by all matching filters, just specify it:
85
+ In case you want restrict paths selection by all matching filters, just specify the `all` option:
85
86
  ```ruby
86
87
  worker = FileScanner::Worker.new(loader: loader, filters: filters, all: true)
88
+ worker.call # will filter by applying all? predicate
89
+ ```
90
+
91
+ #### Check
92
+ By default the worker will scan for both directories and files.
93
+ In case you want restrict paths selection by files only, just specify the `check` option:
94
+ ```ruby
95
+ worker = FileScanner::Worker.new(loader: loader, filters: filters, check: true)
96
+ worker.call # will skip directories
87
97
  ```
88
98
 
89
99
  #### Logger
@@ -1,3 +1,3 @@
1
1
  module FileScanner
2
- VERSION = "3.0.1"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -14,11 +14,13 @@ module FileScanner
14
14
  filters: Filters::defaults,
15
15
  slice: SLICE,
16
16
  all: false,
17
+ check: false,
17
18
  logger: Logger.new(nil))
18
19
  @path = File.expand_path(path)
19
20
  @filters = filters
20
21
  @slice = slice.to_i
21
22
  @mode = mode(all)
23
+ @check = check
22
24
  @logger = logger
23
25
  end
24
26
 
@@ -36,6 +38,11 @@ module FileScanner
36
38
  all ? ALL : ANY
37
39
  end
38
40
 
41
+ private def valid?(file)
42
+ return true unless @check
43
+ FileTest.file?(file)
44
+ end
45
+
39
46
  private def filter(file)
40
47
  @filters.send(@mode) do |filter|
41
48
  @logger.debug { "filtering by \e[33m#{@mode}\e[0m with \e[33m#{filter}\e[0m on #{File.basename(file)}" }
@@ -48,7 +55,7 @@ module FileScanner
48
55
  end
49
56
 
50
57
  private def filtered
51
- paths.lazy.select { |file| filter(file) }
58
+ paths.lazy.select { |file| valid?(file) && filter(file) }
52
59
  end
53
60
 
54
61
  private def slices
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_scanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - costajob