code_manifest 1.4.0 → 1.6.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
  SHA256:
3
- metadata.gz: 85dc605af26d3707bb98d61bf27ff898bb8582c5a11220b3b5d54bf17fc1f824
4
- data.tar.gz: 856aa8f8a5e703e076aedfa4c4676245e6786eaa7ad834f967bfa8864b00ecee
3
+ metadata.gz: 211b0ae49d5f5dce85d9f53d13c20c27e6d1cb00a57a6a74dc7ac2a2382531e7
4
+ data.tar.gz: 112bd81d18216f690854b91959fcd0b8751f1920c0c91a6f4f04e7d1a6966456
5
5
  SHA512:
6
- metadata.gz: d36a050c65f13dac20af4a540007ad8ef5c8c396492c93a51541bcdffee3ec8413ce0e78d8b62e2c9c821f7a073817bad96f380058c4f5c2f02cc507c60269b0
7
- data.tar.gz: 597149b71d2a7514989de7843e75621124b15e883a7d5e8bb62e935b3a834f514fedb2cf00f78b13fcfa86790efa6c1e8dd428dd0f50ddbd92c12ead27a8c560
6
+ metadata.gz: 91c7488e0b6f981f86b7abd43528c5c6f042092f8fa5ae48719aa4ebb8a2185c5119e638b48d7b07f716a77391da126bdbd152288b1a930d03dc9d60117067a4
7
+ data.tar.gz: 4c95aaa6414587ff839299847a3e583808fb98538ba378a0b90aae29660362082cbfc5912f6dad70d3a594d37f6aadb5fd7ee7dc351faa0b6dd992df9c92d999
@@ -11,12 +11,18 @@ module CodeManifest
11
11
 
12
12
  def initialize(patterns)
13
13
  @rules ||= Array(patterns).map do |pattern|
14
- Rule.new(CodeManifest.root, pattern)
14
+ Rule.new(pattern)
15
15
  end
16
16
  end
17
17
 
18
18
  def files
19
- @files ||= (inclusion_files - exclusion_files).sort!.freeze
19
+ @files ||= begin
20
+ inclusion_files = Dir.glob(inclusion_rules.map(&:glob), GLOB_OPTIONS, base: CodeManifest.root)
21
+ inclusion_files.delete_if do |file|
22
+ exclusion_rules.any? { |rule| rule.match?(file) }
23
+ end
24
+ files_with_relative_path(inclusion_files).sort!.freeze
25
+ end
20
26
  end
21
27
 
22
28
  def digest
@@ -31,7 +37,7 @@ module CodeManifest
31
37
  inclusion_rules.any? { |rule| rule.match?(path) }
32
38
  end
33
39
  result_paths.reject! do |path|
34
- exclusion_files.any? { |rule| rule.match?(path) }
40
+ exclusion_rules.any? { |rule| rule.match?(path) }
35
41
  end
36
42
 
37
43
  result_paths.sort!
@@ -39,18 +45,10 @@ module CodeManifest
39
45
 
40
46
  private
41
47
 
42
- def inclusion_files
43
- @inclusion_files ||= files_with_relative_path(Dir.glob(inclusion_rules.map(&:glob), GLOB_OPTIONS))
44
- end
45
-
46
48
  def inclusion_rules
47
49
  @inclusion_rules ||= rules.reject(&:exclude)
48
50
  end
49
51
 
50
- def exclusion_files
51
- @exclusion_files ||= files_with_relative_path(Dir.glob(exclusion_rules.map(&:glob), GLOB_OPTIONS))
52
- end
53
-
54
52
  def exclusion_rules
55
53
  @exclusion_rules ||= rules.select(&:exclude)
56
54
  end
@@ -4,27 +4,27 @@ module CodeManifest
4
4
  class Rule
5
5
  attr_reader :exclude, :glob
6
6
 
7
- def initialize(root, pattern)
8
- @root = root
7
+ def initialize(pattern)
9
8
  @exclude = false
10
- @glob = @root
9
+ @glob = pattern
11
10
 
12
- if pattern.start_with?('!')
11
+ if glob.start_with?("!")
13
12
  @exclude = true
14
- pattern = pattern[1..-1]
13
+ @glob = glob.delete_prefix("!")
15
14
  end
16
15
 
17
- if pattern.start_with?('/')
18
- pattern = pattern[1..-1]
16
+ if File.absolute_path?(glob)
17
+ @glob = glob.delete_prefix(File::SEPARATOR)
19
18
  else
20
- @glob = @glob.join('**')
19
+ @glob = File.join("**", glob)
21
20
  end
22
-
23
- @glob = @glob.join(pattern).to_s
24
21
  end
25
22
 
26
23
  def match?(file)
27
- file = File.join(@root, file) unless File.absolute_path?(file)
24
+ if File.absolute_path?(file)
25
+ prefix = File.join(CodeManifest.root, "/")
26
+ file = file.delete_prefix(prefix)
27
+ end
28
28
 
29
29
  File.fnmatch?(glob, file, Manifest::GLOB_OPTIONS)
30
30
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CodeManifest
4
- VERSION = '1.4.0'
4
+ VERSION = '1.6.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_manifest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers