Class: CocoaPodsAcknowledgements::PlistGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods_acknowledgements/plist_generator.rb

Direct Known Subclasses

SettingsPlistGenerator

Class Method Summary collapse

Class Method Details

.file_accessor(spec, platform, sandbox) ⇒ Object

———————————————————————–#



44
45
46
47
48
49
50
# File 'lib/cocoapods_acknowledgements/plist_generator.rb', line 44

def file_accessor(spec, platform, sandbox)
  pod_root = sandbox.pod_dir(spec.name)
  if pod_root.exist?
    path_list = Pod::Sandbox::PathList.new(pod_root)
    Pod::Sandbox::FileAccessor.new(path_list, spec.consumer(platform))
  end
end

.generate(target_description, sandbox, excluded) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cocoapods_acknowledgements/plist_generator.rb', line 11

def generate(target_description, sandbox, excluded)
  root_specs = target_description.specs.map(&:root).uniq.reject { |spec| excluded.include?(spec.name) }

  return nil if root_specs.empty?

   = []
  root_specs.each do |spec|
    pod_root = sandbox.pod_dir(spec.name)
    platform = Pod::Platform.new(target_description.platform_name)
    file_accessor = file_accessor(spec, platform, sandbox)
    license_text = license_text(spec, file_accessor)

     = {
      "name" => spec.name,
      "version" => spec.version,
      "authors" => spec.authors,
      "socialMediaURL" => spec.social_media_url,
      "summary" => spec.summary,
      "description" => parse_markdown(spec.description),
      "licenseType" => spec.license[:type],
      "licenseText" => license_text,
      "homepage" => spec.homepage,
    }
     << 
  end

   = {}
  ["specs"] = 
  
end

.license_text(spec, file_accessor) ⇒ String, Nil

Returns the text of the license for the given spec.

Parameters:

  • spec (Specification)

    the specification for which license is needed.

Returns:

  • (String)

    The text of the license.

  • (Nil)

    If not license text could be found.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cocoapods_acknowledgements/plist_generator.rb', line 60

def license_text(spec, file_accessor)
  return nil unless spec.license
  text = spec.license[:text]
  unless text
    if file_accessor
      if license_file = file_accessor.license
        if license_file.exist?
          text = IO.read(license_file)
        else
          UI.warn "Unable to read the license file `#{license_file }` " \
            "for the spec `#{spec}`"
        end
      end
    end
  end
  text
end

.markdown_parserObject



7
8
9
# File 'lib/cocoapods_acknowledgements/plist_generator.rb', line 7

def markdown_parser
  @markdown_parser ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML)
end

.parse_markdown(text) ⇒ Object



78
79
80
81
# File 'lib/cocoapods_acknowledgements/plist_generator.rb', line 78

def parse_markdown(text)
  return nil unless text
  markdown_parser.render(text)
end