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
- #any? ⇒ Boolean
- #assets ⇒ Object
-
#initialize(source:, target:, force_update: false) ⇒ UpdatedTheme
constructor
A new instance of UpdatedTheme.
- #templates ⇒ Object
Constructor Details
#initialize(source:, target:, force_update: false) ⇒ UpdatedTheme
Returns a new instance of UpdatedTheme.
20 21 22 23 24 25 |
# File 'lib/bootic_cli/themes/updated_theme.rb', line 20 def initialize(source:, target:, force_update: false) @source, @target = source, target # when doing a pull or push, we don't care if the other end has a more recent version # we only do that when syncing changes, in which case force_update should be false @force_update = force_update end |
Instance Method Details
#any? ⇒ Boolean
27 28 29 |
# File 'lib/bootic_cli/themes/updated_theme.rb', line 27 def any? templates.any? # || assets.any? end |
#assets ⇒ Object
44 45 46 47 48 |
# File 'lib/bootic_cli/themes/updated_theme.rb', line 44 def assets @assets ||= map_pair(source.assets, target.assets) do |a, b| [should_update?(a, b), a] end end |
#templates ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bootic_cli/themes/updated_theme.rb', line 31 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 !diff.to_s.empty? && should_update?(a, b) c = TemplateWithDiff.new(a.file_name, a.body, a.updated_on, diff) [true, c] else [false, nil] end end end |