Module: DataKitten::PublishingFormats::CKAN
- Defined in:
- lib/data_kitten/publishing_formats/ckan.rb
Instance Method Summary collapse
- #contributors ⇒ Object
-
#data_title ⇒ Object
The human-readable title of the dataset.
-
#description ⇒ Object
A brief description of the dataset.
-
#distributions ⇒ Object
A list of distributions, referred to as
resources
by Datapackage. -
#identifier ⇒ Object
An identifier for the dataset.
-
#issued ⇒ Object
Date the dataset was released.
-
#keywords ⇒ Object
Keywords for the dataset.
-
#landing_page ⇒ Object
A web page which can be used to gain access to the dataset.
-
#language ⇒ Object
The language of the dataset.
-
#licenses ⇒ Object
A list of licenses.
- #maintainers ⇒ Object
-
#modified ⇒ Object
Date the dataset was modified.
-
#publishers ⇒ Object
A list of publishers.
-
#publishing_format ⇒ Symbol
The publishing format for the dataset.
-
#spatial ⇒ Object
Spatial coverage of the dataset.
-
#temporal ⇒ Object
The temporal coverage of the dataset.
-
#theme ⇒ Object
The main category of the dataset.
-
#update_frequency ⇒ Object
How frequently the data is updated.
Instance Method Details
#contributors ⇒ Object
130 131 132 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 130 def contributors extract_agent('author', 'author_email') end |
#data_title ⇒ Object
The human-readable title of the dataset.
69 70 71 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 69 def data_title .lookup("title") end |
#description ⇒ Object
A brief description of the dataset
76 77 78 79 80 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 76 def description .lookup("notes") || .lookup("description") rescue nil end |
#distributions ⇒ Object
A list of distributions, referred to as resources
by Datapackage.
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 151 def distributions distributions = [] .lookup("resources").each do |resource| distribution = { :title => resource["description"], :accessURL => landing_page, :downloadURL => resource["url"], :format => resource["format"], :mediaType => resource["mimetype"] || resource["content_type"], } distribution[:issued] = Date.parse(resource["created"]) rescue nil distribution[:modified] = Date.parse(resource["last_modified"] || resource["revision_timestamp"]) rescue nil distribution[:byteSize] = Integer(resource["size"]) rescue nil distributions << Distribution.new(self, ckan_resource: distribution) end return distributions rescue nil end |
#identifier ⇒ Object
An identifier for the dataset
85 86 87 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 85 def identifier .lookup("name") || @identifier end |
#issued ⇒ Object
Date the dataset was released
185 186 187 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 185 def issued Date.parse .lookup("metadata_created") rescue nil end |
#keywords ⇒ Object
Keywords for the dataset
101 102 103 104 105 106 107 108 109 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 101 def keywords keywords = [] .lookup("tags").each do |tag| keywords << tag end return keywords rescue [] end |
#landing_page ⇒ Object
A web page which can be used to gain access to the dataset
92 93 94 95 96 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 92 def landing_page .lookup("extras", "landing_page") || .lookup("url") || .lookup("ckan_url") end |
#language ⇒ Object
The language of the dataset
212 213 214 215 216 217 218 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 212 def language .lookup("language") || .lookup("metadata_language") || .lookup("extras", "metadata_language") || .lookup("extras", "language", 0) || .lookup("extras", "language") end |
#licenses ⇒ Object
A list of licenses.
137 138 139 140 141 142 143 144 145 146 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 137 def licenses id = .lookup("license_id") uri = .lookup("license_url") || .lookup("extras", "licence_url") name = .lookup("license_title") || .lookup("extras", "licence_url_title") if [id, uri, name].any? [License.new(:id => id, :uri => uri, :name => name)] else [] end end |
#maintainers ⇒ Object
126 127 128 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 126 def maintainers extract_agent('maintainer', 'maintainer_email') end |
#modified ⇒ Object
Date the dataset was modified
192 193 194 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 192 def modified Date.parse .lookup("metadata_modified") rescue nil end |
#publishers ⇒ Object
A list of publishers.
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 114 def publishers org = fetch_organization result = if org [org] elsif group_id = .lookup('groups', 0, 'id') [fetch_publisher(group_id)] else [] end result.compact end |
#publishing_format ⇒ Symbol
The publishing format for the dataset.
62 63 64 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 62 def publishing_format :ckan end |
#spatial ⇒ Object
Spatial coverage of the dataset
233 234 235 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 233 def spatial extract_spatial || extract_bbox end |
#temporal ⇒ Object
The temporal coverage of the dataset
199 200 201 202 203 204 205 206 207 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 199 def temporal from = .lookup("extras", "temporal_coverage-from") || .lookup("extras", "temporal-extent-begin") to = .lookup("extras", "temporal_coverage-to") || .lookup("extras", "temporal-extent-end") start_date = Date.parse from rescue nil end_date = Date.parse to rescue nil Temporal.new(:start => start_date, :end => end_date) end |
#theme ⇒ Object
The main category of the dataset
223 224 225 226 227 228 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 223 def theme .lookup("extras", "theme", 0) || .lookup("extras", "theme-primary") || .lookup("groups", 0, "name") || .lookup("groups", 0) end |
#update_frequency ⇒ Object
How frequently the data is updated.
174 175 176 177 178 179 180 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 174 def update_frequency .lookup("extras", "update_frequency") || .lookup("extras", "frequency-of-update") || .lookup("extras", "accrual_periodicity") rescue nil end |