Sha256: 8d43dd2f4a88903d7983734fe9dd88e0d35180a7d678493a2de90f73315242c4
Contents?: true
Size: 737 Bytes
Versions: 5
Compression:
Stored size: 737 Bytes
Contents
# frozen_string_literal: true require "json" require "pathname" module ThemeCheck class JsonFile attr_reader :path def initialize(path, root) @path = Pathname(path) @root = Pathname(root) @loaded = false @content = nil @parser_error = nil end def relative_path @path.relative_path_from(@root) end def name relative_path.sub_ext('').to_s end def content load! @content end def parse_error load! @parser_error end private def load! return if @loaded @content = JSON.parse(File.read(@path)) rescue JSON::ParserError => e @parser_error = e ensure @loaded = true end end end
Version data entries
5 entries across 5 versions & 1 rubygems