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/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.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pod/command/ack_filter.rb', line 19 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
15 16 17 |
# File 'lib/pod/command/ack_filter.rb', line 15 def self.filter(args, &block) self.new(args, &block).run end |
.options ⇒ Object
11 12 13 |
# File 'lib/pod/command/ack_filter.rb', line 11 def self. [['--output=FILENAME', 'Output filtered acknowledgements to FILENAME']] end |
Instance Method Details
#output_filename ⇒ Object
38 39 40 |
# File 'lib/pod/command/ack_filter.rb', line 38 def output_filename @filename || 'Acknowledgements.plist' end |
#run ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pod/command/ack_filter.rb', line 42 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
33 34 35 36 |
# File 'lib/pod/command/ack_filter.rb', line 33 def validate! super help! 'Specify filtering pattern' if !@pattern && !@filter_block end |