class LicensePageExtract::LicensePageExtract
Constants
- URI_CHOOSE_LICENSE_RAW
- URI_OPEN_SOURCE_ORG
Public Class Methods
getLicenseText(metadata = true, uri = "")
click to toggle source
# File lib/license_page_extract.rb, line 10 def self.getLicenseText(metadata = true, uri = "") if uri.include? URI_OPEN_SOURCE_ORG licensefile = uri.split('/')[-1].downcase + ".txt" uri = URI("#{URI_CHOOSE_LICENSE_RAW}#{licensefile}") license = Net::HTTP.get(uri) if !to_boolean(metadata) license = license.gsub(/---.*---/m,'') end puts "license was " + license return license end end
to_boolean(string)
click to toggle source
# File lib/license_page_extract.rb, line 23 def self.to_boolean(string) case string when /^(true|t|yes|y|1)$/i then true when /^(false|f|no|n|0)$/i then false else raise "Cannot convert to boolean: #{string}" end end