Class: ShopifyCLI::Theme::Syncer::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_cli/theme/syncer/operation.rb

Constant Summary collapse

COLOR_BY_STATUS =
{
  error: :red,
  synced: :green,
  warning: :yellow,
  fixed: :cyan,
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx, method, file) ⇒ Operation

Returns a new instance of Operation.



16
17
18
19
20
# File 'lib/shopify_cli/theme/syncer/operation.rb', line 16

def initialize(ctx, method, file)
  @ctx = ctx
  @method = method
  @file = file
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



7
8
9
# File 'lib/shopify_cli/theme/syncer/operation.rb', line 7

def file
  @file
end

#methodObject

Returns the value of attribute method.



7
8
9
# File 'lib/shopify_cli/theme/syncer/operation.rb', line 7

def method
  @method
end

Instance Method Details

#as_error_messageObject



26
27
28
# File 'lib/shopify_cli/theme/syncer/operation.rb', line 26

def as_error_message
  as_message_with(status: :error)
end

#as_fix_messageObject



34
35
36
# File 'lib/shopify_cli/theme/syncer/operation.rb', line 34

def as_fix_message
  as_message_with(status: :fixed)
end

#as_synced_message(color: :green) ⇒ Object



30
31
32
# File 'lib/shopify_cli/theme/syncer/operation.rb', line 30

def as_synced_message(color: :green)
  as_message_with(status: :synced, color: color)
end

#file_pathObject



38
39
40
# File 'lib/shopify_cli/theme/syncer/operation.rb', line 38

def file_path
  file&.relative_path
end

#to_sObject



22
23
24
# File 'lib/shopify_cli/theme/syncer/operation.rb', line 22

def to_s
  "#{method} #{file_path}"
end