Sha256: 4a0a4a8325bed5f8b2fe4df339859a76f4471549a08db6ba26822fa491046b50

Contents?: true

Size: 930 Bytes

Versions: 118

Compression:

Stored size: 930 Bytes

Contents

require 'json'
require 'hash-joiner'
require 'open-uri'

module Jekyll_Get
  class Generator < Jekyll::Generator
    safe true
    priority :highest

    def generate(site)
      config = site.config['jekyll_get']
      if !config
        return
      end
      if !config.kind_of?(Array)
        config = [config]
      end
      config.each do |d|
        begin
          target = site.data[d['data']]
          source = JSON.load(open(d['json']))
          if target
            HashJoiner.deep_merge target, source
          else
            site.data[d['data']] = source
          end
          if d['cache']
            data_source = (site.config['data_source'] || '_data')
            path = "#{data_source}/#{d['data']}.json"
            open(path, 'wb') do |file|
              file << JSON.generate(site.data[d['data']])
            end
          end
        rescue
          next
        end
      end
    end
  end
end

Version data entries

118 entries across 118 versions & 1 rubygems

Version Path
jumbo-jekyll-theme-1.4.3.34 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.33 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.32 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.30 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.29 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.28 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.27 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.26 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.25 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.24 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.23 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.22 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.21 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.20 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.19 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.18 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.17 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.16 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.15 _plugins/jekyll_get.rb
jumbo-jekyll-theme-1.4.3.14 _plugins/jekyll_get.rb