Commit c832f39b authored by Fabio Pelosin's avatar Fabio Pelosin

[Specification] Better support for heredocs.

parent 63c5e456
...@@ -501,15 +501,32 @@ Pod::Spec.new do |s| ...@@ -501,15 +501,32 @@ Pod::Spec.new do |s|
s.name = "#{data[:name]}" s.name = "#{data[:name]}"
s.version = "#{data[:version]}" s.version = "#{data[:version]}"
s.summary = "#{data[:summary]}" s.summary = "#{data[:summary]}"
# s.description = 'An optional longer description of #{data[:name]}.' # s.description = <<-DESC
# An optional longer description of #{data[:name]}
#
# * Markdonw format.
# * Don't worry about the indent, we strip it!
# DESC
s.homepage = "#{data[:homepage]}" s.homepage = "#{data[:homepage]}"
# Specify the license type. CocoaPods detects automatically the license file if it is named # Specify the license type. CocoaPods detects automatically the license file if it is named
# `LICENSE*', however if the name is different, specify it. # `LICENSE*.*', however if the name is different, specify it.
s.license = 'MIT (example)'
# s.license = { :type => 'MIT (example)', :file => 'FILE_LICENSE' }
#
# Only if no dedicated file is available include the full text of the license. # Only if no dedicated file is available include the full text of the license.
# #
s.license = 'MIT (example)' # s.license = {
# s.license = { :type => 'MIT', :file => 'LICENSE', :text => 'Permission is hereby granted ...' } # :type => 'MIT (example)',
# :text => <<-LICENSE
# Copyright (C) <year> <copyright holders>
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# ...
# LICENSE
# }
# Specify the authors of the library, with email addresses. You can often find # Specify the authors of the library, with email addresses. You can often find
# the email addresses of the authors by using the SCM log. E.g. $ git log # the email addresses of the authors by using the SCM log. E.g. $ git log
......
...@@ -189,15 +189,31 @@ module Pod ...@@ -189,15 +189,31 @@ module Pod
top_attr_accessor :summary top_attr_accessor :summary
top_attr_accessor :documentation top_attr_accessor :documentation
top_attr_accessor :requires_arc top_attr_accessor :requires_arc
top_attr_accessor :license, lambda { |l| ( l.kind_of? String ) ? { :type => l } : l }
top_attr_accessor :version, lambda { |v| Version.new(v) } top_attr_accessor :version, lambda { |v| Version.new(v) }
top_attr_accessor :license, lambda { |l| parse_license(l) }
top_attr_accessor :authors, lambda { |a| parse_authors(a) } top_attr_accessor :authors, lambda { |a| parse_authors(a) }
top_attr_reader :description, lambda {|instance, ivar| ivar || instance.summary } top_attr_reader :description, lambda { |instance, ivar| ivar || instance.summary }
top_attr_writer :description top_attr_writer :description, lambda { |d| strip_heredoc(d) }
alias_method :author=, :authors= alias_method :author=, :authors=
# Strips indentation in heredocs.
#
# @note Adapted from Ruby on Rails.
#
def self.strip_heredoc(string)
min_indent = string.scan(/^[ \t]*(?=\S)/).min
indent = min_indent ? min_indent.size : 0
string.gsub(/^[ \t]{#{indent}}/, '')
end
def self.parse_license(license)
license = ( license.kind_of? String ) ? { :type => license } : license
license[:text] = strip_heredoc(license[:text]) if license[:text]
license
end
def self.parse_authors(*names_and_email_addresses) def self.parse_authors(*names_and_email_addresses)
list = names_and_email_addresses.flatten list = names_and_email_addresses.flatten
unless list.first.is_a?(Hash) unless list.first.is_a?(Hash)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment