Class: Pod::Command::AckFilter
- Inherits:
-
Pod::Command
- Object
- Pod::Command
- Pod::Command::AckFilter
- Defined in:
- lib/pod/command/ack_filter.rb
Constant Summary collapse
- ACKNOWLEDGEMENTS_FILE =
'Pods/Target Support Files/Pods/Pods-acknowledgements.plist'
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv, &block) ⇒ AckFilter
constructor
A new instance of AckFilter.
- #output_filename ⇒ Object
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv, &block) ⇒ AckFilter
Returns a new instance of AckFilter.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/pod/command/ack_filter.rb', line 22 def initialize(argv, &block) if argv.kind_of?(CLAide::ARGV) @pattern = Regexp.new(argv.shift_argument) unless argv.empty? @filename = argv.option('output') super else if argv[:pattern] @pattern = argv[:pattern].kind_of?(Regexp) ? argv[:pattern] : Regexp.new(argv[:pattern]) end @filename = argv[:output] @filter_block = block end end |
Class Method Details
.filter(args, &block) ⇒ Object
18 19 20 |
# File 'lib/pod/command/ack_filter.rb', line 18 def self.filter(args, &block) self.new(args, &block).run end |
.options ⇒ Object
14 15 16 |
# File 'lib/pod/command/ack_filter.rb', line 14 def self. [['--output=FILENAME', 'Output filtered acknowledgements to FILENAME']] end |
Instance Method Details
#output_filename ⇒ Object
41 42 43 |
# File 'lib/pod/command/ack_filter.rb', line 41 def output_filename @filename || 'Acknowledgements.plist' end |
#run ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pod/command/ack_filter.rb', line 45 def run plist = CFPropertyList::List.new(file: ACKNOWLEDGEMENTS_FILE) specs = plist.value.value['PreferenceSpecifiers'] specs.value.reject! do |spec| if @filter_block @filter_block.call(spec.value['FooterText'].value) else spec.value['FooterText'].value =~ @pattern end end plist.save(output_filename, CFPropertyList::List::FORMAT_XML) end |
#validate! ⇒ Object
36 37 38 39 |
# File 'lib/pod/command/ack_filter.rb', line 36 def validate! super help! 'Specify filtering pattern' if !@pattern && !@filter_block end |