code_manifest 1.3.0 → 1.5.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: c1933fca25570b9db88c444401b2be9ebac5f75550959af0afdcfd0df1c94dd2
4
- data.tar.gz: a4372d5d3bc2ebbc1e0373636a23e5b974af6a24dc5f64f496a3794715f93809
3
+ metadata.gz: 57ebc00567f59f24c5be818a88ecb8d117175474290653d734a311d7718802de
4
+ data.tar.gz: b7a582abfe21b8f1eaf5beed11fe1244c43307d9e034c9a68da64ab4e9ff53b5
5
5
  SHA512:
6
- metadata.gz: c848fc474a9a5f59e3e4d55588d1781b2d4a1834314a4a0bf511779046ae7a020635f233e77502fb32f852d58af817fce07ccd3159b8bedc2d4f58f6543495cd
7
- data.tar.gz: 52ebaf7b9d59a2546112f9c5180f3add24cc7ae28c5022db26160a27ff0ee4e1f42c09f8ba49cafcaae733d730799d8215f82f8f4e9731fd06a5d95269e8692d
6
+ metadata.gz: 6793af62e46f89a33aed509ef44c9bccfd4e280ec483a1a39ec405d2145112ae8ff5531c7bd4e197f45e6b1973901182327eda7ea54f922930c172b63d21a083
7
+ data.tar.gz: 88387c161220a1142bbd69a8d6811fe8de84d8bdb8a7381db027c76f193e5461f34bdc5fda4b9b802e5d0fc3b7202329d015c942703236e5c0d386b14b2bb2eb
@@ -16,7 +16,13 @@ module CodeManifest
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)
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
@@ -27,11 +33,11 @@ module CodeManifest
27
33
  end
28
34
 
29
35
  def matches(paths)
30
- result_paths = paths.select do |path|
36
+ result_paths = Array(paths).select do |path|
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,29 +45,22 @@ 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
57
55
 
58
56
  def files_with_relative_path(files)
59
- files.map do |file|
60
- pathname = Pathname.new(file)
61
- next if pathname.directory?
57
+ prefix = File.join(CodeManifest.root, "/")
58
+
59
+ files.filter_map do |file|
60
+ next if File.directory?(file)
62
61
 
63
- pathname.relative_path_from(CodeManifest.root).to_s
64
- end.compact
62
+ file.delete_prefix(prefix)
63
+ end
65
64
  end
66
65
  end
67
66
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pathname'
4
-
5
3
  module CodeManifest
6
4
  class Rule
7
5
  attr_reader :exclude, :glob
@@ -26,10 +24,9 @@ module CodeManifest
26
24
  end
27
25
 
28
26
  def match?(file)
29
- file = Pathname.new(file)
30
- file = @root.join(file) unless file.absolute?
27
+ file = File.join(@root, file) unless File.absolute_path?(file)
31
28
 
32
- File.fnmatch?(glob, file.to_s, Manifest::GLOB_OPTIONS)
29
+ File.fnmatch?(glob, file, Manifest::GLOB_OPTIONS)
33
30
  end
34
31
  end
35
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CodeManifest
4
- VERSION = '1.3.0'
4
+ VERSION = '1.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_manifest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-21 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -41,7 +41,7 @@ licenses: []
41
41
  metadata:
42
42
  homepage_uri: https://github.com/rubyatscale/code_manifest
43
43
  source_code_uri: https://github.com/rubyatscale/code_manifest
44
- changelog_uri: https://github.com/rubyatscale/code_manifest/blob/main/releases
44
+ changelog_uri: https://github.com/rubyatscale/code_manifest/releases
45
45
  post_install_message:
46
46
  rdoc_options: []
47
47
  require_paths: