Sha256: c5ffe4c64bd87db434d11bdecb3fc16595e64875f345c7ad38ac0af24d39950f
Contents?: true
Size: 1.23 KB
Versions: 5
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true require "pathname" module ThemeCheck class Theme DEFAULT_LOCALE_REGEXP = %r{^locales/(.*)\.default$} attr_reader :root def initialize(root) @root = Pathname.new(root) end def liquid @liquid ||= @root.glob("**/*.liquid").map { |path| Template.new(path, @root) } end def json @json ||= @root.glob("**/*.json").map { |path| JsonFile.new(path, @root) } end def default_locale_json return @default_locale_json if defined?(@default_locale_json) @default_locale_json = json.find do |json_file| json_file.name.match?(DEFAULT_LOCALE_REGEXP) end end def default_locale if default_locale_json default_locale_json.name[DEFAULT_LOCALE_REGEXP, 1] else "en" end end def all @all ||= json + liquid end def [](name) all.find { |t| t.name == name } end def templates liquid.select(&:template?) end def sections liquid.select(&:section?) end def snippets liquid.select(&:snippet?) end def directories @directories ||= @root.glob('*').select { |f| File.directory?(f) }.map { |f| f.relative_path_from(@root) } end end end
Version data entries
5 entries across 5 versions & 1 rubygems