ad_licenselint 1.1.0 → 1.2.0
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.
- checksums.yaml +4 -4
- data/lib/ad_licenselint/license_entry.rb +0 -4
- data/lib/ad_licenselint/runner.rb +30 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23cdf653152204886e24a5a24af739c2e9a0747de02437f82ffb3474686a6e7d
|
4
|
+
data.tar.gz: b72c40f5409ad00ba77d9a1e99b86c51455c9081f0284395b107eeaa691ef2bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09cd7f80d92e31d5d164b748af551637389305f01e15f86beb6d9bc799df61ef9287b8e8e8136fea8d3737b2571eee0e9f0e9c612a92d31e9a522a15827ba189'
|
7
|
+
data.tar.gz: 9fef1fe60cc5241523c8dafa45d505dffe4ead2ce1beba0f506fbcbc422b481f26a4e87575fc7f6c625408c8baf2c4fb83626b8ab538c78daccf07e50d485b23
|
@@ -1,9 +1,14 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module ADLicenseLint
|
2
4
|
|
3
5
|
class Runner
|
4
6
|
attr_accessor :options, :path
|
5
7
|
|
6
|
-
|
8
|
+
POD_SOURCES = ["trunk", "master"]
|
9
|
+
.map { |source| File.join(ENV["HOME"], ".cocoapods/repos", source) }
|
10
|
+
.select { |path| File.exist? path }
|
11
|
+
.map { |path| Pod::Source.new path }
|
7
12
|
|
8
13
|
def initialize(options = nil)
|
9
14
|
if options.nil?
|
@@ -20,7 +25,7 @@ module ADLicenseLint
|
|
20
25
|
plist_files = Dir[acknowledgements_plist_path] # one plist for each target
|
21
26
|
json_contents = plist_files.map { |plist_file| acknowledgement_json(plist_file) }
|
22
27
|
entries = all_entries(json_contents)
|
23
|
-
warning_entries = entries.reject
|
28
|
+
warning_entries = entries.reject { |entry| accepted? entry }
|
24
29
|
displayed_entries = options[:all] ? entries : warning_entries
|
25
30
|
|
26
31
|
Report.new(displayed_entries)
|
@@ -81,9 +86,13 @@ module ADLicenseLint
|
|
81
86
|
end
|
82
87
|
|
83
88
|
def pod_specification(pod_name)
|
84
|
-
|
85
|
-
|
86
|
-
|
89
|
+
POD_SOURCES
|
90
|
+
.map { |source| source.set(pod_name) }
|
91
|
+
.filter { |set| !set.highest_version.nil? } # access to specification crashes if highest_version is nil
|
92
|
+
.sort_by(&:highest_version)
|
93
|
+
.reverse # highest version first
|
94
|
+
.map { |set| set.specification.to_hash }
|
95
|
+
.first
|
87
96
|
end
|
88
97
|
|
89
98
|
def pod_names_from_podfile
|
@@ -101,8 +110,24 @@ module ADLicenseLint
|
|
101
110
|
File.join(@path, 'Pods', 'Target\ Support\ Files')
|
102
111
|
end
|
103
112
|
|
113
|
+
def config_path
|
114
|
+
File.join(@path, ".ad_licenselint.yml")
|
115
|
+
end
|
116
|
+
|
104
117
|
def acknowledgements_plist_path
|
105
118
|
File.join(target_support_path, "Pods-*/*acknowledgements.plist")
|
106
119
|
end
|
120
|
+
|
121
|
+
def accepted?(entry)
|
122
|
+
ADLicenseLint::Constant::ACCEPTED_LICENSES.include?(entry.license_name) || allowlist.include?(entry.pod_name)
|
123
|
+
end
|
124
|
+
|
125
|
+
def config_file
|
126
|
+
@config ||= (File.exist?(config_path) ? YAML.load(File.read(config_path)) : {})
|
127
|
+
end
|
128
|
+
|
129
|
+
def allowlist
|
130
|
+
config_file["allow"] || []
|
131
|
+
end
|
107
132
|
end
|
108
133
|
end
|