Class: CocoaPodsAcknowledgements::AddOns::Acknowledgement
- Inherits:
-
Object
- Object
- CocoaPodsAcknowledgements::AddOns::Acknowledgement
- Defined in:
- lib/cocoapods_acknowledgements/addons/acknowledgement.rb
Instance Attribute Summary collapse
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
-
#initialize(file) ⇒ Acknowledgement
constructor
A new instance of Acknowledgement.
- #license_text(podspec, directory) ⇒ String, Nil
- #metadata_plist_item ⇒ Hash, Nil
- #settings_plist_item ⇒ Hash, Nil
Constructor Details
#initialize(file) ⇒ Acknowledgement
Returns a new instance of Acknowledgement.
10 11 12 13 14 15 16 |
# File 'lib/cocoapods_acknowledgements/addons/acknowledgement.rb', line 10 def initialize(file) path = Pathname(file). if file directory = path.dirname @spec = Pod::Specification.from_file(file) if path.exist? @license_text = license_text(@spec, directory) end |
Instance Attribute Details
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
6 7 8 |
# File 'lib/cocoapods_acknowledgements/addons/acknowledgement.rb', line 6 def spec @spec end |
Instance Method Details
#license_text(podspec, directory) ⇒ String, Nil
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cocoapods_acknowledgements/addons/acknowledgement.rb', line 24 def license_text(podspec, directory) return nil unless podspec text = podspec.license[:text] if text.nil? license_file = podspec.license[:file] || "LICENSE" license_path = directory + license_file return nil unless license_path.exist? text = File.read(license_path) end text end |
#metadata_plist_item ⇒ Hash, Nil
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cocoapods_acknowledgements/addons/acknowledgement.rb', line 41 def return nil unless @spec and @license_text { name: @spec.name, version: @spec.version.to_s, authors: Hash[@spec..map { |k, v| [k, v || ""] }], socialMediaURL: @spec. || "", summary: @spec.summary, licenseType: @spec.license[:type], licenseText: @license_text, homepage: @spec.homepage } end |
#settings_plist_item ⇒ Hash, Nil
58 59 60 61 62 63 64 65 |
# File 'lib/cocoapods_acknowledgements/addons/acknowledgement.rb', line 58 def settings_plist_item return nil unless @spec and @license_text { Title: @spec.name, Type: "PSGroupSpecifier", FooterText: @license_text } end |