-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move data sets into a dedicated directory
I want site and _site to be a similar shape. The leading-underscore YAML files are not intended to have a 1:1 relationship with a generated file. I think that's my major mental model. I want there to be a 1:1 relationship between a "source" in `site` and a "target" in `_site`. We'll see.
- Loading branch information
Showing
8 changed files
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
class DataSet | ||
attr_reader :path | ||
|
||
def self.gather(dir) | ||
Dir | ||
.glob("#{dir}/*") | ||
.reject { |path| File.directory?(path) } | ||
.map { |path| new(path) } | ||
end | ||
|
||
def initialize(path) | ||
@path = path | ||
end | ||
|
||
def data | ||
YAML.safe_load( | ||
File.read(path), | ||
permitted_classes: [Date, PinboardBookmark, Symbol] | ||
) | ||
@data ||= | ||
YAML.safe_load( | ||
File.read(path), | ||
permitted_classes: [Date, PinboardBookmark, Symbol] | ||
) | ||
end | ||
|
||
def name | ||
path.delete_prefix(Build.source_dir).delete_prefix("/_").delete(".yml") | ||
end | ||
|
||
def hydrate | ||
self | ||
end | ||
|
||
def write | ||
self | ||
extname = File.extname(path) | ||
File.basename(path, extname) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters