Class: ThemeCheck::AssetFile
Instance Attribute Summary
Attributes inherited from ThemeFile
#storage, #version
Instance Method Summary
collapse
Methods inherited from ThemeFile
#==, #json?, #liquid?, #path, #relative_path, #source
Constructor Details
#initialize(relative_path, storage) ⇒ AssetFile
Returns a new instance of AssetFile.
6
7
8
9
10
|
# File 'lib/theme_check/asset_file.rb', line 6
def initialize(relative_path, storage)
super
@loaded = false
@content = nil
end
|
Instance Method Details
#gzipped_size ⇒ Object
25
26
27
|
# File 'lib/theme_check/asset_file.rb', line 25
def gzipped_size
@gzipped_size ||= Zlib.gzip(source).bytesize
end
|
#name ⇒ Object
29
30
31
|
# File 'lib/theme_check/asset_file.rb', line 29
def name
relative_path.to_s
end
|
#rewriter ⇒ Object
12
13
14
|
# File 'lib/theme_check/asset_file.rb', line 12
def rewriter
@rewriter ||= ThemeFileRewriter.new(@relative_path, source)
end
|
#write ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/theme_check/asset_file.rb', line 16
def write
content = rewriter.to_s
if source != content
@storage.write(@relative_path, content.gsub("\n", @eol))
@source = content
@rewriter = nil
end
end
|