Class: BooticCli::Themes::UpdatedTheme
- Inherits:
-
Object
- Object
- BooticCli::Themes::UpdatedTheme
- Defined in:
- lib/bootic_cli/themes/updated_theme.rb
Overview
given :source and :target themes, UpdatedTheme computes assets and templates with more recent versions in :source
Defined Under Namespace
Classes: TemplateWithDiff
Instance Method Summary collapse
- #assets ⇒ Object
-
#initialize(source:, target:) ⇒ UpdatedTheme
constructor
A new instance of UpdatedTheme.
- #templates ⇒ Object
Constructor Details
#initialize(source:, target:) ⇒ UpdatedTheme
Returns a new instance of UpdatedTheme.
11 12 13 |
# File 'lib/bootic_cli/themes/updated_theme.rb', line 11 def initialize(source:, target:) @source, @target = source, target end |
Instance Method Details
#assets ⇒ Object
27 28 29 30 31 |
# File 'lib/bootic_cli/themes/updated_theme.rb', line 27 def assets @assets ||= map_pair(source.assets, target.assets) do |a, b| [more_recent?(a, b), a] end end |
#templates ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bootic_cli/themes/updated_theme.rb', line 15 def templates @templates ||= map_pair(source.templates, target.templates) do |a, b| diff = Diffy::Diff.new(normalize_endings(b.body), normalize_endings(a.body), context: 1) if more_recent?(a, b) && !diff.to_s.empty? c = TemplateWithDiff.new(a.file_name, a.body, a.updated_on, diff) [true, c] else [false, nil] end end end |