-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Html rendering #47
base: master
Are you sure you want to change the base?
Html rendering #47
Changes from 17 commits
d7789e2
eb1543e
e5bc6aa
9a8d14b
bef1e1c
a455178
694d867
d3ee536
947f4ca
3b7c780
b6e79fa
78ecf99
c6cdf19
e571bb6
b002205
a35e4ad
4742148
de284c3
02dc5fa
7ca1b48
5b18d4d
0dc1721
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module CocoaPodsAcknowledgements | ||
module Auxiliaries | ||
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 | ||
|
||
# Returns the text of the license for the given spec. | ||
# | ||
# @param [Specification] spec | ||
# the specification for which license is needed. | ||
# | ||
# @return [String] The text of the license. | ||
# @return [Nil] If not license text could be found. | ||
# | ||
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 | ||
Pod::UI.warn "Unable to read the license file `#{license_file }` " \ | ||
"for the spec `#{spec}`" | ||
end | ||
end | ||
end | ||
end | ||
text | ||
end | ||
end | ||
end | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'cocoapods_acknowledgements/auxiliaries' | ||
module CocoaPodsAcknowledgements | ||
class Generator | ||
class << self | ||
include Auxiliaries | ||
|
||
def generate_specs(target_description, sandbox, excluded, root_specs) | ||
[] | ||
end | ||
|
||
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? | ||
generate_specs(target_description, sandbox, excluded, root_specs) | ||
end | ||
end | ||
end | ||
end | ||
|
||
module CocoaPodsAcknowledgements | ||
class Generator | ||
class SpecObject | ||
attr_accessor :name, :version, :authors, :socialMedialURL, :summary, | ||
:description, :licenseType, :licenseText, :homepage | ||
def initialize(options) | ||
@name = options["name"] | ||
@version = options["version"] | ||
@authors = options["authors"] | ||
@socialMediaURL = options["socialMediaURL"] | ||
@summary = options["summary"] | ||
@description = options["description"] | ||
@licenseType = options["licenseType"] | ||
@licenseText = options["licenseText"] | ||
@homepage = options["homepage"] | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'cocoapods_acknowledgements/markdown_parser' | ||
require 'cocoapods_acknowledgements/generator' | ||
|
||
module CocoaPodsAcknowledgements | ||
class HTMLGenerator < PlistGenerator | ||
class << self | ||
def generate_specs(target_description, sandbox, excluded, root_specs) | ||
metadata = super | ||
specs = metadata["specs"] | ||
metadata["specs"] = specs.map do |spec| | ||
Generator::SpecObject.new(spec) | ||
end | ||
metadata["header"] = header | ||
metadata["footer"] = footer | ||
metadata | ||
end | ||
|
||
def header | ||
'Acknowledgements' | ||
end | ||
|
||
def footer | ||
'Generated by CocoaPods - https://cocoapods.org' | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'redcarpet' | ||
|
||
module CocoaPodsAcknowledgements | ||
class MarkdownParser | ||
class << self | ||
def markdown_parser | ||
@markdown_parser ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @krin-san How to retrieve There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I mistyped – it's named plugin 'cocoapods-acknowledgements', :settings_bundle => true We can use plugin 'cocoapods-acknowledgements', :html_render_options => {:no_links => false, :link_attributes => {"link" => "#C0C0C0", "vlink" => "#808080", "alink" => "#FF0000"}} Just need to figure out how to pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @krin-san We can extend def generate_specs(target_description, sandbox, excluded, root_specs, options = {})
[]
end
def generate(target_description, sandbox, excluded, options = {})
root_specs = target_description.specs.map(&:root).uniq.reject {|spec| excluded.include?(spec.name)}
return nil if root_specs.empty?
generate_specs(target_description, sandbox, excluded, root_specs)
end I don't see any better option here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a Ruby developer actually 😄. Whichever option allowing to define |
||
end | ||
|
||
def parse_markdown(text) | ||
return nil unless text | ||
markdown_parser.render(text) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,34 @@ | ||
require 'redcarpet' | ||
require 'cocoapods_acknowledgements/markdown_parser' | ||
require 'cocoapods_acknowledgements/generator' | ||
|
||
module CocoaPodsAcknowledgements | ||
class PlistGenerator | ||
class PlistGenerator < Generator | ||
class << self | ||
|
||
def markdown_parser | ||
@markdown_parser ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML) | ||
end | ||
|
||
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? | ||
|
||
def generate_specs(target_description, sandbox, excluded, root_specs) | ||
specs_metadata = [] | ||
root_specs.each do |spec| | ||
specs = root_specs.map 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) | ||
|
||
spec_metadata = { | ||
metadata = { | ||
"name" => spec.name, | ||
"version" => spec.version, | ||
"authors" => spec.authors, | ||
"socialMediaURL" => spec.social_media_url, | ||
"summary" => spec.summary, | ||
"description" => parse_markdown(spec.description), | ||
"description" => MarkdownParser.parse_markdown(spec.description), | ||
"licenseType" => spec.license[:type], | ||
"licenseText" => license_text, | ||
"homepage" => spec.homepage, | ||
} | ||
specs_metadata << spec_metadata | ||
end | ||
|
||
specs_metadata += specs | ||
metadata = {} | ||
metadata["specs"] = specs_metadata | ||
metadata | ||
end | ||
|
||
#-----------------------------------------------------------------------# | ||
|
||
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 | ||
|
||
# Returns the text of the license for the given spec. | ||
# | ||
# @param [Specification] spec | ||
# the specification for which license is needed. | ||
# | ||
# @return [String] The text of the license. | ||
# @return [Nil] If not license text could be found. | ||
# | ||
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 | ||
Pod::UI.warn "Unable to read the license file `#{license_file }` " \ | ||
"for the spec `#{spec}`" | ||
end | ||
end | ||
end | ||
end | ||
text | ||
end | ||
|
||
def parse_markdown(text) | ||
return nil unless text | ||
markdown_parser.render(text) | ||
end | ||
|
||
#-----------------------------------------------------------------------# | ||
|
||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing newlines missing in all these files, everything should also be using 2 spaces for indentation