Class: JekyllData::Reader
- Inherits:
-
Jekyll::Reader
- Object
- Jekyll::Reader
- JekyllData::Reader
- Defined in:
- lib/jekyll-data/reader.rb
Instance Method Summary collapse
-
#initialize(site) ⇒ Reader
constructor
A new instance of Reader.
-
#read ⇒ Object
Read data files within theme-gem.
-
#read_theme_data ⇒ Object
Read data files within a theme gem and add them to internal data.
Constructor Details
#initialize(site) ⇒ Reader
Returns a new instance of Reader.
7 8 9 10 11 12 13 14 |
# File 'lib/jekyll-data/reader.rb', line 7 def initialize(site) @site = site @theme = site.theme if @theme.data_path @theme_data_files = Dir[File.join(@theme.data_path, "**", "*.{yaml,yml,json,csv,tsv}")] end end |
Instance Method Details
#read ⇒ Object
Read data files within theme-gem.
Returns nothing.
19 20 21 22 |
# File 'lib/jekyll-data/reader.rb', line 19 def read super read_theme_data end |
#read_theme_data ⇒ Object
Read data files within a theme gem and add them to internal data
Returns a hash appended with new data
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jekyll-data/reader.rb', line 27 def read_theme_data if @theme.data_path # # show contents of "<theme>/_data/" dir being read while degugging. inspect_theme_data theme_data = ThemeDataReader.new(site).read(site.config["data_dir"]) @site.data = Jekyll::Utils.deep_merge_hashes(theme_data, @site.data) # # show contents of merged site.data hash while debugging with # additional --show-data switch. inspect_merged_hash if site.config["show-data"] && site.config["verbose"] end end |