ad_licenselint 1.1.0 → 1.2.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: 1d724417a61b9cdd45734e80b872bd17fcaeebb0764365bdb72324c90c4707c9
4
- data.tar.gz: b937d30a641e989a44449ca682bc14012d8557b6820d2e6cef9d9d3587381da3
3
+ metadata.gz: 23cdf653152204886e24a5a24af739c2e9a0747de02437f82ffb3474686a6e7d
4
+ data.tar.gz: b72c40f5409ad00ba77d9a1e99b86c51455c9081f0284395b107eeaa691ef2bc
5
5
  SHA512:
6
- metadata.gz: 66ad331fcf8166a73f4ffa825593db9034fa19676abd57684b385547ee482a945bbafed7f61b752f77ba44ce5fdbd9098294f4ab73bffeea8adc51749b67d2c9
7
- data.tar.gz: f3dc44e8915c811ffdc6d094d2dc54985e263e6d95e87bfdbe6f7d67616e112e5d12ad7528e1627af62f8541df3dccd4f253a267a301657a9f61cfa65a62302b
6
+ metadata.gz: '09cd7f80d92e31d5d164b748af551637389305f01e15f86beb6d9bc799df61ef9287b8e8e8136fea8d3737b2571eee0e9f0e9c612a92d31e9a522a15827ba189'
7
+ data.tar.gz: 9fef1fe60cc5241523c8dafa45d505dffe4ead2ce1beba0f506fbcbc422b481f26a4e87575fc7f6c625408c8baf2c4fb83626b8ab538c78daccf07e50d485b23
@@ -12,10 +12,6 @@ class LicenseEntry
12
12
  !pod_name.empty? && !license_name.empty?
13
13
  end
14
14
 
15
- def is_accepted
16
- ADLicenseLint::Constant::ACCEPTED_LICENSES.include?(license_name)
17
- end
18
-
19
15
  def copyright
20
16
  (/Copyright(.*)$/.match license_content)[0]
21
17
  end
@@ -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
- POD_SOURCE = Pod::Source.new("~/.cocoapods/repos/master")
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(&:is_accepted)
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
- set = POD_SOURCE.set(pod_name)
85
- return nil if set.highest_version.nil? # access to specification crashes if highest_version is nil
86
- set.specification.to_hash
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ad_licenselint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Felgines