Module: Sevgi::Showcase::Dark Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Applies dark-theme color mappings to showcase source files.
Instance Method Summary collapse
-
#apply(source, mapping) ⇒ String
private
Applies a color mapping to source text.
-
#apply_file(source, target, mapping) ⇒ String
private
Applies a color mapping to a source file and preserves its mode.
Instance Method Details
#apply(source, mapping) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Applies a color mapping to source text.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sevgi/showcase/dark.rb', line 15 def apply(source, mapping) applied = Hash.new(0) content = replace_quoted(source, mapping, applied) content = replace_percent_words(content, mapping, applied) missing = mapping.keys.reject { applied[it].positive? } ArgumentError.("Unapplied dark mapping(s): #{missing.join(", ")}") unless missing.empty? content end |
#apply_file(source, target, mapping) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Applies a color mapping to a source file and preserves its mode.
32 33 34 35 36 37 |
# File 'lib/sevgi/showcase/dark.rb', line 32 def apply_file(source, target, mapping) target.tap do File.write(target, apply(File.read(source), mapping)) File.chmod(File.stat(source).mode & 0o777, target) end end |