Class: PlatformosCheck::LiquidFile
- Inherits:
-
AppFile
- Object
- AppFile
- PlatformosCheck::LiquidFile
show all
- Defined in:
- lib/platformos_check/liquid_file.rb
Instance Attribute Summary
Attributes inherited from AppFile
#storage, #version
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from AppFile
#==, #build_name, #dir_names, #dir_prefix, #graphql?, #initialize, #module_name, #module_original_file?, #module_original_file_path, #module_overwrite_file?, #module_overwrite_file_path, #module_prefix, #name, #path, #relative_path, #remove_extension, #source, #translation?, #yaml?
Class Method Details
.parse(source) ⇒ Object
78
79
80
81
82
83
84
85
86
|
# File 'lib/platformos_check/liquid_file.rb', line 78
def self.parse(source)
Tags.register_tags!
Liquid::Template.parse(
source,
line_numbers: true,
error_mode: :warn,
disable_liquid_c_nodes: true
)
end
|
Instance Method Details
30
31
32
|
# File 'lib/platformos_check/liquid_file.rb', line 30
def form?
false
end
|
#layout? ⇒ Boolean
38
39
40
|
# File 'lib/platformos_check/liquid_file.rb', line 38
def layout?
false
end
|
#liquid? ⇒ Boolean
14
15
16
|
# File 'lib/platformos_check/liquid_file.rb', line 14
def liquid?
true
end
|
#migration? ⇒ Boolean
22
23
24
|
# File 'lib/platformos_check/liquid_file.rb', line 22
def migration?
false
end
|
#notification? ⇒ Boolean
18
19
20
|
# File 'lib/platformos_check/liquid_file.rb', line 18
def notification?
false
end
|
#page? ⇒ Boolean
26
27
28
|
# File 'lib/platformos_check/liquid_file.rb', line 26
def page?
false
end
|
#parse ⇒ Object
66
67
68
|
# File 'lib/platformos_check/liquid_file.rb', line 66
def parse
@ast ||= self.class.parse(source)
end
|
#partial? ⇒ Boolean
34
35
36
|
# File 'lib/platformos_check/liquid_file.rb', line 34
def partial?
false
end
|
#rewriter ⇒ Object
42
43
44
|
# File 'lib/platformos_check/liquid_file.rb', line 42
def rewriter
@rewriter ||= AppFileRewriter.new(@relative_path, source)
end
|
#root ⇒ Object
74
75
76
|
# File 'lib/platformos_check/liquid_file.rb', line 74
def root
parse.root
end
|
#source_excerpt(line) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/platformos_check/liquid_file.rb', line 46
def source_excerpt(line)
original_lines = source.split("\n")
original_lines[bounded(0, line - 1, original_lines.size - 1)].strip
rescue StandardError => e
PlatformosCheck.bug(<<~EOS)
Exception while running `source_excerpt(#{line})`:
```
#{e.class}: #{e.message}
#{e.backtrace.join("\n ")}
```
path: #{path}
source:
```
#{source}
```
EOS
end
|
#warnings ⇒ Object
70
71
72
|
# File 'lib/platformos_check/liquid_file.rb', line 70
def warnings
parse&.warnings
end
|
#write ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/platformos_check/liquid_file.rb', line 5
def write
content = rewriter.to_s
return unless source != content
@storage.write(@relative_path, content.gsub("\n", @eol))
@source = content
@rewriter = nil
end
|