Class: DataKitten::Dataset
- Inherits:
-
Object
- Object
- DataKitten::Dataset
- Includes:
- Hosts, Origins, PublishingFormats
- Defined in:
- lib/data_kitten/dataset.rb
Overview
Represents a single dataset from some origin (see dcat:Dataset for relevant vocabulary).
Designed to be created with a URI to the dataset, and then to work out metadata from there.
Currently supports Datasets hosted in Git (and optionally on GitHub), and which use the Datapackage metadata format.
Instance Attribute Summary collapse
-
#access_url ⇒ String
The URL that gives access to the dataset.
-
#identifier ⇒ String
A unique identifier of the dataset.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
- #source ⇒ Object
Instance Method Summary collapse
- #base_uri ⇒ Object
-
#change_history ⇒ Array
A history of changes to the Dataset.
-
#contributor_agreement_url ⇒ String
The URL of the contributor license agreement.
-
#contributors ⇒ Array<Agent>
A list of contributors.
-
#crowdsourced? ⇒ Boolean
Has the data been crowdsourced?.
-
#data_title ⇒ String
The human-readable title of the dataset.
-
#description ⇒ String
A brief description of the dataset.
-
#distributions ⇒ Array<Distribution>
(also: #files, #resources)
A list of distributions.
-
#documentation_url ⇒ String
Human-readable documentation for the dataset.
-
#host ⇒ Symbol
Where the dataset is hosted.
-
#initialize(url_or_options, base_url = nil) ⇒ Dataset
constructor
Create a new Dataset object.
-
#issued ⇒ Date
(also: #release_date)
Date the dataset was released.
-
#keywords ⇒ Array<string>
Keywords for the dataset.
-
#landing_page ⇒ String
A web page that can be used to gain access to the dataset, its distributions and/or additional information.
-
#language ⇒ String
The language of the dataset.
-
#licenses ⇒ Array<License>
A list of licenses.
-
#maintainers ⇒ Array<Agent>
A list of maintainers.
-
#modified ⇒ Date
Date the dataset was last modified.
-
#origin ⇒ Symbol
The origin type of the dataset.
-
#publishers ⇒ Array<Agent>
A list of publishers.
-
#publishing_format ⇒ Symbol
The publishing format for the dataset.
-
#release_type ⇒ Symbol
What type of dataset is this? Options are:
:web_service
for API-accessible data, or:one_off
for downloadable data dumps. -
#rights ⇒ Object<Rights>
The rights statment for the data.
-
#sources ⇒ Array<Source>
Where the data is sourced from.
-
#spatial ⇒ GeoJSON Geometry
Spatial coverage of the dataset.
-
#supported? ⇒ Boolean
Can metadata be loaded for this Dataset?.
-
#temporal ⇒ Object<Temporal>
The temporal coverage of the dataset.
-
#theme ⇒ String
The main category the dataset belongs to.
-
#time_sensitive? ⇒ Boolean
Is the information time-sensitive?.
-
#update_frequency ⇒ String
How frequently the data is updated.
- #uri ⇒ Object
- #url ⇒ Object
Constructor Details
#new(url) ⇒ Dataset #new(options) ⇒ Dataset
Create a new Dataset object
The class will attempt to auto-load metadata from this URL.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/data_kitten/dataset.rb', line 43 def initialize(, base_url=nil) url = case when Hash base_url ||= [:base_url] [:access_url] else end @access_url = DataKitten::Fetcher.wrap(url) @base_uri = URI(base_url) if base_url detect_origin detect_host detect_publishing_format end |
Instance Attribute Details
#access_url ⇒ String
Returns the URL that gives access to the dataset.
30 31 32 |
# File 'lib/data_kitten/dataset.rb', line 30 def access_url @access_url end |
#identifier ⇒ String
A unique identifier of the dataset.
107 108 109 |
# File 'lib/data_kitten/dataset.rb', line 107 def identifier @identifier end |
#metadata ⇒ Object
Returns the value of attribute metadata.
290 291 292 |
# File 'lib/data_kitten/dataset.rb', line 290 def @metadata end |
#source ⇒ Object
71 72 73 |
# File 'lib/data_kitten/dataset.rb', line 71 def source @source ||= @access_url.as_json if @access_url.ok? end |
Instance Method Details
#base_uri ⇒ Object
63 64 65 |
# File 'lib/data_kitten/dataset.rb', line 63 def base_uri @base_uri || uri.merge("/") end |
#change_history ⇒ Array
A history of changes to the Dataset
279 280 281 |
# File 'lib/data_kitten/dataset.rb', line 279 def change_history [] end |
#contributor_agreement_url ⇒ String
The URL of the contributor license agreement
256 257 258 |
# File 'lib/data_kitten/dataset.rb', line 256 def contributor_agreement_url nil end |
#contributors ⇒ Array<Agent>
A list of contributors
228 229 230 |
# File 'lib/data_kitten/dataset.rb', line 228 def contributors [] end |
#crowdsourced? ⇒ Boolean
Has the data been crowdsourced?
249 250 251 |
# File 'lib/data_kitten/dataset.rb', line 249 def crowdsourced? false end |
#data_title ⇒ String
The human-readable title of the dataset.
112 113 114 |
# File 'lib/data_kitten/dataset.rb', line 112 def data_title nil end |
#description ⇒ String
A brief description of the dataset
119 120 121 |
# File 'lib/data_kitten/dataset.rb', line 119 def description nil end |
#distributions ⇒ Array<Distribution> Also known as: files, resources
A list of distributions. Has aliases for popular alternative vocabularies.
263 264 265 |
# File 'lib/data_kitten/dataset.rb', line 263 def distributions [] end |
#documentation_url ⇒ String
Human-readable documentation for the dataset.
133 134 135 |
# File 'lib/data_kitten/dataset.rb', line 133 def documentation_url nil end |
#host ⇒ Symbol
Where the dataset is hosted.
99 100 101 |
# File 'lib/data_kitten/dataset.rb', line 99 def host nil end |
#issued ⇒ Date Also known as: release_date
Date the dataset was released
148 149 150 |
# File 'lib/data_kitten/dataset.rb', line 148 def issued nil end |
#keywords ⇒ Array<string>
Keywords for the dataset
126 127 128 |
# File 'lib/data_kitten/dataset.rb', line 126 def keywords [] end |
#landing_page ⇒ String
A web page that can be used to gain access to the dataset, its distributions and/or additional information.
163 164 165 |
# File 'lib/data_kitten/dataset.rb', line 163 def landing_page nil end |
#language ⇒ String
The language of the dataset.
235 236 237 |
# File 'lib/data_kitten/dataset.rb', line 235 def language nil end |
#licenses ⇒ Array<License>
A list of licenses
214 215 216 |
# File 'lib/data_kitten/dataset.rb', line 214 def licenses [] end |
#maintainers ⇒ Array<Agent>
A list of maintainers
200 201 202 |
# File 'lib/data_kitten/dataset.rb', line 200 def maintainers [] end |
#modified ⇒ Date
Date the dataset was last modified
156 157 158 |
# File 'lib/data_kitten/dataset.rb', line 156 def modified nil end |
#origin ⇒ Symbol
The origin type of the dataset.
90 91 92 |
# File 'lib/data_kitten/dataset.rb', line 90 def origin nil end |
#publishers ⇒ Array<Agent>
A list of publishers
207 208 209 |
# File 'lib/data_kitten/dataset.rb', line 207 def publishers [] end |
#publishing_format ⇒ Symbol
The publishing format for the dataset.
193 194 195 |
# File 'lib/data_kitten/dataset.rb', line 193 def publishing_format nil end |
#release_type ⇒ Symbol
What type of dataset is this? Options are: :web_service
for API-accessible data, or :one_off
for downloadable data dumps.
141 142 143 |
# File 'lib/data_kitten/dataset.rb', line 141 def release_type false end |
#rights ⇒ Object<Rights>
The rights statment for the data
221 222 223 |
# File 'lib/data_kitten/dataset.rb', line 221 def rights nil end |
#sources ⇒ Array<Source>
Where the data is sourced from
177 178 179 |
# File 'lib/data_kitten/dataset.rb', line 177 def sources [] end |
#spatial ⇒ GeoJSON Geometry
Spatial coverage of the dataset
286 287 288 |
# File 'lib/data_kitten/dataset.rb', line 286 def spatial nil end |
#supported? ⇒ Boolean
Can metadata be loaded for this Dataset?
81 82 83 |
# File 'lib/data_kitten/dataset.rb', line 81 def supported? !(origin.nil? || publishing_format.nil?) end |
#temporal ⇒ Object<Temporal>
The temporal coverage of the dataset
170 171 172 |
# File 'lib/data_kitten/dataset.rb', line 170 def temporal nil end |
#theme ⇒ String
The main category the dataset belongs to.
242 243 244 |
# File 'lib/data_kitten/dataset.rb', line 242 def theme nil end |
#time_sensitive? ⇒ Boolean
Is the information time-sensitive?
184 185 186 |
# File 'lib/data_kitten/dataset.rb', line 184 def time_sensitive? false end |
#update_frequency ⇒ String
How frequently the data is updated.
272 273 274 |
# File 'lib/data_kitten/dataset.rb', line 272 def update_frequency nil end |
#uri ⇒ Object
59 60 61 |
# File 'lib/data_kitten/dataset.rb', line 59 def uri URI(@access_url.to_s) end |
#url ⇒ Object
67 68 69 |
# File 'lib/data_kitten/dataset.rb', line 67 def url @access_url.to_s end |