module Jekyll::Favicon::StaticFile::Mutable
Create static file based on a source file
Public Instance Methods
mtime()
click to toggle source
overrides Jekyll::StaticFile method
Calls superclass method
# File lib/jekyll/favicon/static_file/mutable.rb, line 28 def mtime return super if File.file? path end
mutable?()
click to toggle source
Calls superclass method
# File lib/jekyll/favicon/static_file/mutable.rb, line 12 def mutable? mutation.any? || super end
mutation()
click to toggle source
# File lib/jekyll/favicon/static_file/mutable.rb, line 16 def mutation refers = case @extname when ".xml" mutation_refers.select { |refer| refer.key? "browserconfig" } else mutation_refers.collect { |refer| refer["webmanifest"] } .compact end patch(Utils.merge(*refers) || {}) end
Private Instance Methods
copy_file(dest_path)
click to toggle source
overrides Jekyll::StaticFile method
# File lib/jekyll/favicon/static_file/mutable.rb, line 35 def copy_file(dest_path) # return unless mutable? # return super(dest_path) unless mutation.any? File.write dest_path, mutated_content end
mutable()
click to toggle source
# File lib/jekyll/favicon/static_file/mutable.rb, line 61 def mutable return unless File.file? path content = File.read path case File.extname path when ".xml" then REXML::Document.new content else JSON.parse content end end
mutated_content()
click to toggle source
# File lib/jekyll/favicon/static_file/mutable.rb, line 42 def mutated_content case @extname when ".json", ".webmanifest", ".manifest" then mutated_content_json when ".xml" then mutated_content_xml end end
mutated_content_json()
click to toggle source
# File lib/jekyll/favicon/static_file/mutable.rb, line 49 def mutated_content_json mutated = Jekyll::Utils.deep_merge_hashes (mutable || {}), mutation JSON.pretty_generate mutated end
mutated_content_xml()
click to toggle source
# File lib/jekyll/favicon/static_file/mutable.rb, line 54 def mutated_content_xml mutated = Utils.mutate_element (mutable || REXML::Document.new), mutation output = +"" mutated.write output output end
mutation_refers()
click to toggle source
# File lib/jekyll/favicon/static_file/mutable.rb, line 71 def mutation_refers site.static_files .select { |static_file| static_file.is_a? StaticFile } .select(&:referenceable?) .collect(&:refer) .flatten end