Class: DataKitten::License
- Inherits:
-
Object
- Object
- DataKitten::License
- Defined in:
- lib/data_kitten/license.rb
Overview
A license for a Dataset or Distribution
Constant Summary collapse
- LICENSES =
{ /opendatacommons.org.*\/by(\/|$)/ => "odc-by", /opendatacommons.org.*\/odbl(\/|$)/ => "odc-odbl", /opendatacommons.org.*\/pddl(\/|$)/ => "odc-pddl", /opendefinition.org.*\/odc-by(\/|$)/ => "odc-by", /opendefinition.org.*\/odc-pddl(\/|$)/ => "odc-pddl", /opendefinition.org.*\/cc-zero(\/|$)/ => "cc-zero", /opendefinition.org.*\/cc-by(\/|$)/ => "cc-by", /opendefinition.org.*\/cc-by-sa(\/|$)/ => "cc-by-sa", /opendefinition.org.*\/gfdl(\/|$)/ => "gfdl", /creativecommons.org.*\/zero(\/|$)/ => "cc-zero", /creativecommons.org.*\/by-sa(\/|$)/ => "cc-by-sa", /creativecommons.org.*\/by(\/|$)/ => "cc-by", /(data|nationalarchives).gov.uk.*\/open-government-licence(\/|$)/ => "ogl-uk", /usa.gov\/publicdomain(\/|$)/ => "us-pd" }
Instance Attribute Summary collapse
-
#abbr ⇒ String
The license abbreviation.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is ⇒ String
A short ID that identifies the license.
-
#name ⇒ String
The human name of the license.
-
#type ⇒ String
The type of information this license applies to.
-
#uri ⇒ String
The URI for the license text.
Instance Method Summary collapse
- #get_license_abbr(uri) ⇒ Object
-
#initialize(options) ⇒ License
constructor
Create a new License object.
Constructor Details
#initialize(options) ⇒ License
Create a new License object.
51 52 53 54 55 56 57 |
# File 'lib/data_kitten/license.rb', line 51 def initialize() @id = [:id] @name = [:name] @uri = [:uri] @type = [:type] @abbr = get_license_abbr(@uri) if @uri end |
Instance Attribute Details
#abbr ⇒ String
Returns the license abbreviation.
42 43 44 |
# File 'lib/data_kitten/license.rb', line 42 def abbr @abbr end |
#id ⇒ Object
Returns the value of attribute id.
26 27 28 |
# File 'lib/data_kitten/license.rb', line 26 def id @id end |
#is ⇒ String
Returns a short ID that identifies the license.
26 |
# File 'lib/data_kitten/license.rb', line 26 attr_accessor :id |
#name ⇒ String
Returns the human name of the license.
30 31 32 |
# File 'lib/data_kitten/license.rb', line 30 def name @name end |
#type ⇒ String
Returns the type of information this license applies to. Could be :data
or :content
.
38 39 40 |
# File 'lib/data_kitten/license.rb', line 38 def type @type end |
#uri ⇒ String
Returns the URI for the license text.
34 35 36 |
# File 'lib/data_kitten/license.rb', line 34 def uri @uri end |
Instance Method Details
#get_license_abbr(uri) ⇒ Object
59 60 61 62 |
# File 'lib/data_kitten/license.rb', line 59 def get_license_abbr(uri) license = LICENSES.find { |regex, abbr| uri =~ regex } license.last if license end |