Sha256: 6c00af8e477922f0edd7fba51e418512ffbd76108d0e6cdb632aa57355be01e2

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

class Licensee
  class Licenses
    class << self

      # Returns an array of Licensee::License instances
      def list
        @licenses ||= begin
          licenses = []
          keys.each { |key| licenses.push License.new(key) }
          licenses
        end
      end

      # Given a license key, attempt to return a matching Licensee::License instance
      def find(key)
        list.find { |l| l.key.downcase == key.downcase }
      end

      # Path to vendored licenses
      def base
        @base ||= File.expand_path "../../vendor/choosealicense.com/_licenses", File.dirname(__FILE__)
      end

      private

      # Returns a list of potential license keys, as vendored
      def keys
        @keys ||= begin
          keyes = Dir.entries(base)
          keyes.map! { |l| File.basename(l, ".txt").downcase }
          keyes.reject! { |l| l =~ /^\./ || l.nil? }
          keyes
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
licensee-4.0.0 lib/licensee/licenses.rb