Module: DataKitten::PublishingFormats::CKAN
- Defined in:
- lib/data_kitten/publishing_formats/ckan.rb
Instance Method Summary collapse
- #base_uri ⇒ Object
- #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
resourcesby 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
#base_uri ⇒ Object
246 247 248 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 246 def base_uri DataKitten::PublishingFormats::CKAN.get_base(self.uri) end |
#contributors ⇒ Object
139 140 141 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 139 def contributors extract_agent('author', 'author_email') end |
#data_title ⇒ Object
The human-readable title of the dataset.
78 79 80 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 78 def data_title .lookup("title") end |
#description ⇒ Object
A brief description of the dataset
85 86 87 88 89 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 85 def description .lookup("notes") || .lookup("description") rescue nil end |
#distributions ⇒ Object
A list of distributions, referred to as resources by Datapackage.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 160 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
94 95 96 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 94 def identifier .lookup("name") || @identifier end |
#issued ⇒ Object
Date the dataset was released
194 195 196 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 194 def issued Date.parse .lookup("metadata_created") rescue nil end |
#keywords ⇒ Object
Keywords for the dataset
110 111 112 113 114 115 116 117 118 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 110 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
101 102 103 104 105 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 101 def landing_page .lookup("extras", "landing_page") || .lookup("url") || .lookup("ckan_url") end |
#language ⇒ Object
The language of the dataset
221 222 223 224 225 226 227 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 221 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.
146 147 148 149 150 151 152 153 154 155 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 146 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
135 136 137 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 135 def maintainers extract_agent('maintainer', 'maintainer_email') end |
#modified ⇒ Object
Date the dataset was modified
201 202 203 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 201 def modified Date.parse .lookup("metadata_modified") rescue nil end |
#publishers ⇒ Object
A list of publishers.
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 123 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.
71 72 73 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 71 def publishing_format :ckan end |
#spatial ⇒ Object
Spatial coverage of the dataset
242 243 244 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 242 def spatial extract_spatial || extract_bbox end |
#temporal ⇒ Object
The temporal coverage of the dataset
208 209 210 211 212 213 214 215 216 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 208 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
232 233 234 235 236 237 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 232 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.
183 184 185 186 187 188 189 |
# File 'lib/data_kitten/publishing_formats/ckan.rb', line 183 def update_frequency .lookup("extras", "update_frequency") || .lookup("extras", "frequency-of-update") || .lookup("extras", "accrual_periodicity") rescue nil end |