Class: CocoaPodsAcknowledgements::AddOns::PodsPlistModifier
- Inherits:
-
Object
- Object
- CocoaPodsAcknowledgements::AddOns::PodsPlistModifier
- Defined in:
- lib/cocoapods_acknowledgements/addons/modifiers/pods_plist_modifier.rb
Instance Method Summary collapse
-
#add(plist_metadata, excluded_names) ⇒ Object
Adds acknowledgements to the CocoaPods generated plist and markdown files except the excluded ones.
-
#initialize(target, sandbox) ⇒ PodsPlistModifier
constructor
A modifier to update:.
-
#markdown ⇒ String
The acknowledgement texts at Pods/Target Support Files/Pods-#app_name/Pods-#app_name-acknowledgements.markdown.
-
#plist ⇒ CFPropertyList::List
The acknowledgement plist at Pods/Target Support Files/Pods-#app_name/Pods-#app_name-acknowledgements.plist.
-
#settings_plist ⇒ CFPropertyList::List
The acknowledgement plist in the app Settings.bundle.
Constructor Details
#initialize(target, sandbox) ⇒ PodsPlistModifier
A modifier to update:
-
Pods/Target Support Files/Pods-#app_name/Pods-#app_name-acknowledgements.plist|markdown
-
settings_bundle/#app_name-settings-metadata.plist“
17 18 19 20 21 22 23 24 25 |
# File 'lib/cocoapods_acknowledgements/addons/modifiers/pods_plist_modifier.rb', line 17 def initialize(target, sandbox) @markdown_path = sandbox.target_support_files_root + target.cocoapods_target_label + "#{target.cocoapods_target_label}-acknowledgements.markdown" @plist_path = sandbox.target_support_files_root + target.cocoapods_target_label + "#{target.cocoapods_target_label}-acknowledgements.plist" project = Xcodeproj::Project.open(target.user_project_path) file = project.files.find { |f| f.path =~ /Settings\.bundle$/ } settings_bundle = file&.real_path @settings_plist = settings_bundle + "#{target.cocoapods_target_label}-settings-metadata.plist" if settings_bundle&.exist? end |
Instance Method Details
#add(plist_metadata, excluded_names) ⇒ Object
Adds acknowledgements to the CocoaPods generated plist and markdown files except the excluded ones.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cocoapods_acknowledgements/addons/modifiers/pods_plist_modifier.rb', line 53 def add(, excluded_names) = [*] excluded_names = [*excluded_names] return if .empty? plist = (, excluded_names) [@plist_path, @settings_plist].each do |path| next unless path&.writable? Pod::UI.puts "Saving #{path}".green plist.save(path, CFPropertyList::List::FORMAT_XML) end File.write @markdown_path, markdown_text_with(plist) end |
#markdown ⇒ String
Returns the acknowledgement texts at Pods/Target Support Files/Pods-#app_name/Pods-#app_name-acknowledgements.markdown.
29 30 31 32 |
# File 'lib/cocoapods_acknowledgements/addons/modifiers/pods_plist_modifier.rb', line 29 def markdown return nil unless @markdown_path&.readable? File.read @markdown_path end |
#plist ⇒ CFPropertyList::List
Returns the acknowledgement plist at Pods/Target Support Files/Pods-#app_name/Pods-#app_name-acknowledgements.plist.
36 37 38 39 |
# File 'lib/cocoapods_acknowledgements/addons/modifiers/pods_plist_modifier.rb', line 36 def plist return nil unless @plist_path&.readable? CFPropertyList::List.new(file: @plist_path) end |
#settings_plist ⇒ CFPropertyList::List
Returns the acknowledgement plist in the app Settings.bundle.
43 44 45 46 |
# File 'lib/cocoapods_acknowledgements/addons/modifiers/pods_plist_modifier.rb', line 43 def settings_plist return nil unless @settings_plist&.readable? CFPropertyList::List.new(file: @settings_plist) end |