Sha256: ff46d30dfdfc25976386d33055c64991736459ff071219d184d0d4a77f848734
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require "json" require "pathname" module ThemeCheck class JsonFile def initialize(relative_path, storage) @relative_path = relative_path @storage = storage @loaded = false @content = nil @parser_error = nil end def path @storage.path(@relative_path) end def relative_path @relative_pathname ||= Pathname.new(@relative_path) end def source @source ||= @storage.read(@relative_path) end def content load! @content end def parse_error load! @parser_error end def name relative_path.sub_ext('').to_s end def json? true end def liquid? false end def ==(other) other.is_a?(JsonFile) && relative_path == other.relative_path end alias_method :eql?, :== private def load! return if @loaded @content = JSON.parse(source) rescue JSON::ParserError => e @parser_error = e ensure @loaded = true end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
theme-check-1.0.0 | lib/theme_check/json_file.rb |
theme-check-0.10.2 | lib/theme_check/json_file.rb |
theme-check-0.10.1 | lib/theme_check/json_file.rb |