Module: DataKitten::PublishingFormats::Datapackage
- Defined in:
- lib/data_kitten/publishing_formats/datapackage.rb
Overview
Datapackage metadata format module. Automatically mixed into Dataset for datasets that include a datapackage.json
.
Instance Method Summary collapse
-
#change_history ⇒ Array
A history of changes to the Dataset.
-
#contributors ⇒ Object
A list of contributors.
-
#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. -
#keywords ⇒ Object
Keywords for the dataset.
-
#licenses ⇒ Object
A list of licenses.
-
#maintainers ⇒ Object
A list of maintainers.
-
#modified ⇒ Object
Date the dataset was modified.
-
#publishers ⇒ Object
A list of publishers.
-
#publishing_format ⇒ Symbol
The publishing format for the dataset.
- #rights ⇒ Object
-
#sources ⇒ Object
Where the data is sourced from.
Instance Method Details
#change_history ⇒ Array
A history of changes to the Dataset.
If Dataset#source is :git
, this is the git changelog for the actual distribution files, rather then the full unfiltered log.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 131 def change_history @change_history ||= begin if origin == :git # Get a log for each file in the local repo logs = distributions.map do |file| if file.path log = repository.log.path(file.path) # Convert to list of commits log.map{|commit| commit} else [] end end # combine all logs, make unique, and re-sort in date order logs.flatten.uniq.sort_by{|x| x.committer.date}.reverse else [] end end end |
#contributors ⇒ Object
A list of contributors.
75 76 77 78 79 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 75 def contributors package.contributors.map do |x| Agent.new(:name => x['name'], :uri => x['web'], :email => x['email']) end end |
#data_title ⇒ Object
The human-readable title of the dataset.
91 92 93 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 91 def data_title package.title || package.name end |
#description ⇒ Object
A brief description of the dataset
98 99 100 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 98 def description package.description end |
#distributions ⇒ Object
A list of distributions, referred to as resources
by Datapackage.
84 85 86 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 84 def distributions package.resources.map { |resource| Distribution.new(self, datapackage_resource: resource) } end |
#keywords ⇒ Object
Keywords for the dataset
105 106 107 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 105 def keywords package.keywords end |
#licenses ⇒ Object
A list of licenses.
58 59 60 61 62 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 58 def licenses package.licenses.map do |x| License.new(:id => x['id'], :uri => x['url'], :name => x['name']) end end |
#maintainers ⇒ Object
A list of maintainers.
40 41 42 43 44 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 40 def maintainers package.maintainers.map do |x| Agent.new(:name => x['name'], :uri => x['web'], :email => x['email']) end end |
#modified ⇒ Object
Date the dataset was modified
119 120 121 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 119 def modified package.last_modified end |
#publishers ⇒ Object
A list of publishers.
49 50 51 52 53 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 49 def publishers package.publisher.map do |x| Agent.new(:name => x['name'], :uri => x['web'], :email => x['email']) end end |
#publishing_format ⇒ Symbol
The publishing format for the dataset.
33 34 35 |
# File 'lib/data_kitten/publishing_formats/datapackage.rb', line 33 def publishing_format :datapackage end |