Class: ThemeCheck::JsonFile

Inherits:
Object
  • Object
show all
Defined in:
lib/theme_check/json_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(relative_path, storage) ⇒ JsonFile

Returns a new instance of JsonFile.



7
8
9
10
11
12
13
# File 'lib/theme_check/json_file.rb', line 7

def initialize(relative_path, storage)
  @relative_path = relative_path
  @storage = storage
  @loaded = false
  @content = nil
  @parser_error = nil
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



49
50
51
# File 'lib/theme_check/json_file.rb', line 49

def ==(other)
  other.is_a?(JsonFile) && relative_path == other.relative_path
end

#contentObject



27
28
29
30
# File 'lib/theme_check/json_file.rb', line 27

def content
  load!
  @content
end

#json?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/theme_check/json_file.rb', line 41

def json?
  true
end

#liquid?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/theme_check/json_file.rb', line 45

def liquid?
  false
end

#nameObject



37
38
39
# File 'lib/theme_check/json_file.rb', line 37

def name
  relative_path.sub_ext('').to_s
end

#parse_errorObject



32
33
34
35
# File 'lib/theme_check/json_file.rb', line 32

def parse_error
  load!
  @parser_error
end

#pathObject



15
16
17
# File 'lib/theme_check/json_file.rb', line 15

def path
  @storage.path(@relative_path)
end

#relative_pathObject



19
20
21
# File 'lib/theme_check/json_file.rb', line 19

def relative_path
  @relative_pathname ||= Pathname.new(@relative_path)
end

#sourceObject



23
24
25
# File 'lib/theme_check/json_file.rb', line 23

def source
  @source ||= @storage.read(@relative_path)
end