bibliothecary 7.1.3 → 7.1.4

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: 363f07f35de59f9e70b69e78e25c47a16eaaeb88399db593af9fa8907f9057b4
4
- data.tar.gz: e960f21a1d5df9dbe686efce3dd0968e08b60f24b20767fc861a344704e9f3f9
3
+ metadata.gz: 139600bf079b4cc07ba891b319f14dd7ec7af7622bcd5b87ef93b70e21191e58
4
+ data.tar.gz: 1b0162957be9078ffb00d6c2f1ff2d2654e7aad74853bb7f06e3c81be50ca950
5
5
  SHA512:
6
- metadata.gz: c4758b79d123881d8ead04bc325f2121388e216edffebfceadd2dae1183d8cb04999b205055d29a3b509ffee640e534dce9701a71fb97812d573a3bee0357297
7
- data.tar.gz: 753f4495fb06a20dd2e77a41520c9db05b44442f94b261df5c2871454110636ca58efb22ccfecfb1922da8f5510e0edd6e3d5ec9384cf48494325c7489c90757
6
+ metadata.gz: ef6071d7672fc07be61cac936b10f694675758ca4ed2d9dfdf9cd77c440f1538771cccc528f1b4d2486fe8e6621eff96ae7825c69b97b957140302e3d7fa01f9
7
+ data.tar.gz: 3797470015e7d7f2da4b6603ece7e327083bb10d5b77f4bb2c8adc139f35fe0a5c1e90ef1d8cc36aba83a5ca77144f6433a98d85e8164dee8a3a38dc23fa9450
@@ -42,6 +42,22 @@ module Bibliothecary
42
42
  Bibliothecary::Parsers.constants.map{|c| Bibliothecary::Parsers.const_get(c) }.sort_by{|c| c.to_s.downcase }
43
43
  end
44
44
 
45
+ def load_file_info_list_from_contents(file_path_contents_hash)
46
+ # Parses an array of format [{file_path: "", contents: ""},] to match
47
+ # on both filename matches, and one content_match patterns.
48
+ file_list = []
49
+
50
+ file_path_contents_hash.each do |file|
51
+ info = FileInfo.new(nil, file[:file_path], file[:contents])
52
+
53
+ next if ignored_files.include?(info.relative_path)
54
+
55
+ add_files_to_list(file_list, info)
56
+ end
57
+
58
+ file_list
59
+ end
60
+
45
61
  def load_file_info_list_from_paths(paths)
46
62
  file_list = []
47
63
 
@@ -50,12 +66,7 @@ module Bibliothecary
50
66
 
51
67
  next if ignored_files.include?(info.relative_path)
52
68
 
53
- applicable_package_managers(info).each do |package_manager|
54
- file = info.dup
55
- file.package_manager = package_manager
56
-
57
- file_list.push(file)
58
- end
69
+ add_files_to_list(file_list, info)
59
70
  end
60
71
 
61
72
  file_list
@@ -71,12 +82,7 @@ module Bibliothecary
71
82
  next unless FileTest.file?(subpath)
72
83
  next if ignored_files.include?(info.relative_path)
73
84
 
74
- applicable_package_managers(info).each do |package_manager|
75
- file = info.dup
76
- file.package_manager = package_manager
77
-
78
- file_list.push(file)
79
- end
85
+ add_files_to_list(file_list, info)
80
86
  end
81
87
 
82
88
  file_list
@@ -90,6 +96,10 @@ module Bibliothecary
90
96
  RelatedFilesInfo.create_from_file_infos(load_file_info_list_from_paths(paths).reject { |info| info.package_manager.nil? })
91
97
  end
92
98
 
99
+ def find_manifests_from_contents(file_path_contents_hash)
100
+ RelatedFilesInfo.create_from_file_infos(load_file_info_list_from_contents(file_path_contents_hash).reject { |info| info.package_manager.nil? })
101
+ end
102
+
93
103
  def analyse_file(file_path, contents)
94
104
  package_managers.select { |pm| pm.match?(file_path, contents) }.map do |pm|
95
105
  pm.analyse_contents(file_path, contents)
@@ -124,5 +134,16 @@ module Bibliothecary
124
134
  def ignored_files
125
135
  @configuration.ignored_files
126
136
  end
137
+
138
+ private
139
+
140
+ def add_files_to_list(file_list, info)
141
+ applicable_package_managers(info).each do |package_manager|
142
+ file = info.dup
143
+ file.package_manager = package_manager
144
+
145
+ file_list.push(file)
146
+ end
147
+ end
127
148
  end
128
149
  end
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "7.1.3"
2
+ VERSION = "7.1.4"
3
3
  end
data/lib/bibliothecary.rb CHANGED
@@ -34,6 +34,10 @@ module Bibliothecary
34
34
  runner.load_file_info_list_from_paths(paths)
35
35
  end
36
36
 
37
+ def self.load_file_info_list_from_contents(file_path_contents_hash)
38
+ runner.load_file_info_list_from_contents(file_path_contents_hash)
39
+ end
40
+
37
41
  def self.analyse_file(file_path, contents)
38
42
  runner.analyse_file(file_path, contents)
39
43
  end
@@ -54,6 +58,10 @@ module Bibliothecary
54
58
  runner.find_manifests_from_paths(paths)
55
59
  end
56
60
 
61
+ def self.find_manifests_from_contents(file_path_contents_hash)
62
+ runner.find_manifests_from_contents(file_path_contents_hash)
63
+ end
64
+
57
65
  def self.ignored_dirs
58
66
  configuration.ignored_dirs
59
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibliothecary
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.3
4
+ version: 7.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-23 00:00:00.000000000 Z
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb