Class: NeetoTranslateCli::PayloadBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/neeto_translate_cli/payload_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PayloadBuilder

Returns a new instance of PayloadBuilder.



9
10
11
12
13
# File 'lib/neeto_translate_cli/payload_builder.rb', line 9

def initialize(options)
  @options = options
  commit_id = git_commit_id
  @updated_keys = commit_id.empty? ? { frontend: [], backend: [] } : find_updated_keys(commit_id)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/neeto_translate_cli/payload_builder.rb', line 7

def options
  @options
end

#updated_keysObject (readonly)

Returns the value of attribute updated_keys.



7
8
9
# File 'lib/neeto_translate_cli/payload_builder.rb', line 7

def updated_keys
  @updated_keys
end

Instance Method Details

#no_new_changes?(payload) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/neeto_translate_cli/payload_builder.rb', line 28

def no_new_changes?(payload)
  payload[:frontend][:missing_keys].values.all?(&:empty?) && payload[:backend][:missing_keys].values.all?(&:empty?)
end

#process!Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/neeto_translate_cli/payload_builder.rb', line 15

def process!
  {
    frontend: { en: en_json_flattened, missing_keys: find_missing_keys_for(:frontend) },
    backend: { en: en_yml_flattened, missing_keys: find_missing_keys_for(:backend) },
    metadata: {
      repo: options[:repo],
      frontend: options[:frontend],
      backend: options[:backend],
      branch: options[:branch]
    }
  }
end