Class: DTK::Client::Operation::Module::PushDtkn::ConvertSource

Inherits:
Object
  • Object
show all
Defined in:
lib/client/operation/module/push_dtkn/convert_source.rb,
lib/client/operation/module/push_dtkn/convert_source/service_info.rb,
lib/client/operation/module/push_dtkn/convert_source/component_info.rb

Direct Known Subclasses

ComponentInfo, ServiceInfo

Defined Under Namespace

Classes: ComponentInfo, ServiceInfo

Class Method Summary collapse

Class Method Details

.transform_and_commit(remote_module_info, parent) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/client/operation/module/push_dtkn/convert_source.rb', line 33

def self.transform_and_commit(remote_module_info, parent)
  target_repo_dir      = parent.target_repo_dir
  parsed_common_module = parent.base_dsl_file_obj.parse_content(:common_module)
  current_branch         = Operation::ClientModuleDir::GitRepo.current_branch(:path => target_repo_dir).data(:branch)

  if service_info = remote_module_info.data(:service_info)
    transform_service_info(target_repo_dir, parent, service_info, parsed_common_module, current_branch)
  end

  if component_info = remote_module_info.data(:component_info)
    transform_component_info(target_repo_dir, parent, component_info, parsed_common_module, current_branch)
  end
end

.transform_component_info(target_repo_dir, parent, component_info, parsed_common_module, current_branch) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/client/operation/module/push_dtkn/convert_source.rb', line 67

def self.transform_component_info(target_repo_dir, parent, component_info, parsed_common_module, current_branch)
  transform_helper                   = ServiceAndComponentInfo::TransformTo.new(target_repo_dir, parent.module_ref, parent.version, parsed_common_module)
  component_file_path__content_array = ComponentInfo.transform_info(transform_helper, component_info['remote_repo_url'], parent)
  component_info_remote              = "remotes/dtkn-component-info/master"

  create_and_checkout_branch?(current_branch, target_repo_dir, component_info_remote) do |repo|
    # find deleted files from master branch and delete them in component info cached branch ("remotes/dtkn-component-info/master")
    delete_diffs(repo, component_info_remote, current_branch, target_repo_dir)

    component_file_path__content_array.each { |file| Operation::ClientModuleDir.create_file_with_content("#{file_path(target_repo_dir, file)}", file[:content]) }
    commit_and_push_to_remote(repo, target_repo_dir, "master", "dtkn-component-info")
  end
end

.transform_info(transform_helper, remote_repo_url, parent) ⇒ Object



47
48
49
# File 'lib/client/operation/module/push_dtkn/convert_source.rb', line 47

def self.transform_info(transform_helper, remote_repo_url, parent)
  new(transform_helper, info_type, remote_repo_url, parent).transform_info
end

.transform_service_info(target_repo_dir, parent, service_info, parsed_common_module, current_branch) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/client/operation/module/push_dtkn/convert_source.rb', line 51

def self.transform_service_info(target_repo_dir, parent, service_info, parsed_common_module, current_branch)
  transform_helper = ServiceAndComponentInfo::TransformTo.new(target_repo_dir, parent.module_ref, parent.version, parsed_common_module)
  service_file_path__content_array = ServiceInfo.transform_info(transform_helper, service_info['remote_repo_url'], parent)

  create_and_checkout_branch?(current_branch, target_repo_dir, "remotes/dtkn/master") do |repo|
    FileUtils.mkdir_p("#{target_repo_dir}/assemblies") unless File.exists?("#{target_repo_dir}/assemblies")

    args = [transform_helper, ServiceInfo.info_type, service_info['remote_repo_url'], parent]
    service_file_path__content_array.each { |file| Operation::ClientModuleDir.create_file_with_content("#{service_file_path(target_repo_dir, file, *args)}", file[:content]) }

    delete_assemblies?(service_file_path__content_array, target_repo_dir)

    commit_and_push_to_remote(repo, target_repo_dir, "master", "dtkn")
  end
end