Class: RosettAi::Config::CompileResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/rosett_ai/config/compile_result.rb

Overview

Structured result from compiling a single scope file.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCompileResult

Returns a new instance of CompileResult.



21
22
23
24
# File 'lib/rosett_ai/config/compile_result.rb', line 21

def initialize(**)
  super
  self.warnings ||= []
end

Instance Attribute Details

#diffObject (readonly)

Unified diff string (for simulate mode)



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rosett_ai/config/compile_result.rb', line 17

CompileResult = Struct.new(
  :scope, :source_path, :target_path, :json_data,
  :warnings, :action, :diff
) do
  def initialize(**)
    super
    self.warnings ||= []
  end

  # @return [Boolean] true if action is :created, :updated, or :unchanged
  def success?
    [:created, :updated, :unchanged].include?(action)
  end

  # @return [Boolean] true if action is :created or :updated
  def changed?
    [:created, :updated].include?(action)
  end
end

#scopeObject (readonly)

The scope name (managed, user, project, local)



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rosett_ai/config/compile_result.rb', line 17

CompileResult = Struct.new(
  :scope, :source_path, :target_path, :json_data,
  :warnings, :action, :diff
) do
  def initialize(**)
    super
    self.warnings ||= []
  end

  # @return [Boolean] true if action is :created, :updated, or :unchanged
  def success?
    [:created, :updated, :unchanged].include?(action)
  end

  # @return [Boolean] true if action is :created or :updated
  def changed?
    [:created, :updated].include?(action)
  end
end

#warningsObject (readonly)

Advisory messages (version mismatch, missing env vars, etc.)



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rosett_ai/config/compile_result.rb', line 17

CompileResult = Struct.new(
  :scope, :source_path, :target_path, :json_data,
  :warnings, :action, :diff
) do
  def initialize(**)
    super
    self.warnings ||= []
  end

  # @return [Boolean] true if action is :created, :updated, or :unchanged
  def success?
    [:created, :updated, :unchanged].include?(action)
  end

  # @return [Boolean] true if action is :created or :updated
  def changed?
    [:created, :updated].include?(action)
  end
end

Instance Method Details

#action=(value) ⇒ Object

One of :created, :updated, :unchanged, :skipped



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rosett_ai/config/compile_result.rb', line 17

CompileResult = Struct.new(
  :scope, :source_path, :target_path, :json_data,
  :warnings, :action, :diff
) do
  def initialize(**)
    super
    self.warnings ||= []
  end

  # @return [Boolean] true if action is :created, :updated, or :unchanged
  def success?
    [:created, :updated, :unchanged].include?(action)
  end

  # @return [Boolean] true if action is :created or :updated
  def changed?
    [:created, :updated].include?(action)
  end
end

#changed?Boolean

Returns true if action is :created or :updated.

Returns:

  • (Boolean)

    true if action is :created or :updated



32
33
34
# File 'lib/rosett_ai/config/compile_result.rb', line 32

def changed?
  [:created, :updated].include?(action)
end

#json_data=(value) ⇒ Object

The compiled JSON data (before serialization)



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rosett_ai/config/compile_result.rb', line 17

CompileResult = Struct.new(
  :scope, :source_path, :target_path, :json_data,
  :warnings, :action, :diff
) do
  def initialize(**)
    super
    self.warnings ||= []
  end

  # @return [Boolean] true if action is :created, :updated, or :unchanged
  def success?
    [:created, :updated, :unchanged].include?(action)
  end

  # @return [Boolean] true if action is :created or :updated
  def changed?
    [:created, :updated].include?(action)
  end
end

#source_path=(value) ⇒ Object

Path to the source YAML file



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rosett_ai/config/compile_result.rb', line 17

CompileResult = Struct.new(
  :scope, :source_path, :target_path, :json_data,
  :warnings, :action, :diff
) do
  def initialize(**)
    super
    self.warnings ||= []
  end

  # @return [Boolean] true if action is :created, :updated, or :unchanged
  def success?
    [:created, :updated, :unchanged].include?(action)
  end

  # @return [Boolean] true if action is :created or :updated
  def changed?
    [:created, :updated].include?(action)
  end
end

#success?Boolean

Returns true if action is :created, :updated, or :unchanged.

Returns:

  • (Boolean)

    true if action is :created, :updated, or :unchanged



27
28
29
# File 'lib/rosett_ai/config/compile_result.rb', line 27

def success?
  [:created, :updated, :unchanged].include?(action)
end

#target_path=(value) ⇒ Object

Path to the target JSON file



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rosett_ai/config/compile_result.rb', line 17

CompileResult = Struct.new(
  :scope, :source_path, :target_path, :json_data,
  :warnings, :action, :diff
) do
  def initialize(**)
    super
    self.warnings ||= []
  end

  # @return [Boolean] true if action is :created, :updated, or :unchanged
  def success?
    [:created, :updated, :unchanged].include?(action)
  end

  # @return [Boolean] true if action is :created or :updated
  def changed?
    [:created, :updated].include?(action)
  end
end