Class: Pod::Command::Blocklist
- Inherits:
-
Pod::Command
- Object
- Pod::Command
- Pod::Command::Blocklist
- Defined in:
- lib/cocoapods-blocklist/command/blocklist.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Blocklist
constructor
A new instance of Blocklist.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Blocklist
Returns a new instance of Blocklist.
32 33 34 35 36 37 |
# File 'lib/cocoapods-blocklist/command/blocklist.rb', line 32 def initialize(argv) @blocklist = argv.option('config') @warn = argv.flag?('warn') @lockfile_path = argv.shift_argument super end |
Class Method Details
.options ⇒ Object
25 26 27 28 29 30 |
# File 'lib/cocoapods-blocklist/command/blocklist.rb', line 25 def self. [ ['--config=CONFIG', 'Config file or URL for the blocklist'], ['--warn', 'Only warn about use of blocked pods'], ].concat(super) end |
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cocoapods-blocklist/command/blocklist.rb', line 47 def run open(@blocklist) do |f| @blocklist_file = JSON.parse(f.read) end warned = false failed_pods = {} @blocklist_file['pods'].each do |pod| name = pod['name'] if lockfile.pod_names.include? name version = Version.new(lockfile.version(name)) if Requirement.create(pod['versions']).satisfied_by?(version) UI.puts "[!] Validation error: Use of #{name} #{version} for reason: #{pod['reason']}".yellow failed_pods[name] = version warned = true end end end if !warned UI.puts "#{UI.path lockfile.defined_in_file.} passed blocklist validation".green else failed_pod_string = failed_pods.map { |name, version| "#{name} (#{version})"}.join(", ") unless @warn raise Informative.new("Failed blocklist validation due to use of #{failed_pod_string}") end end end |
#validate! ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/cocoapods-blocklist/command/blocklist.rb', line 39 def validate! super @lockfile = @lockfile_path ? Lockfile.from_file(Pathname(@lockfile_path)) : config.lockfile help! 'A lockfile is needed.' unless lockfile help! 'A blocklist file is needed.' unless @blocklist end |