Class: DTK::Client::Operation::Module::Install::CommonModule

Inherits:
DTK::Client::Operation::Module::Install show all
Defined in:
lib/client/operation/module/install/common_module.rb

Constant Summary collapse

BaseRoute =
'modules'

Constants inherited from DTK::Client::Operation::Module

MODULE_LOCK, OPERATIONS

Constants inherited from DTK::Client::Operation

TYPES

Class Method Summary collapse

Methods inherited from DTK::Client::Operation::Module::Install

execute, #install

Methods included from DTK::Client::Operation::ModuleServiceCommon::ClassMixin

#method_missing, #respond_to?

Methods included from Auxiliary

#hash_to_yaml, #snake_form, #snake_to_camel_case, #yaml_to_hash

Class Method Details

.install(module_ref, file_obj, opts = {}) ⇒ Object

opts can have keys:

:has_remote_repo


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/client/operation/module/install/common_module.rb', line 25

def self.install(module_ref, file_obj, opts = {})
  common_post_body = PostBody.new(
    :module_name => module_ref.module_name,
    :namespace   => module_ref.namespace,
    :version?    => module_ref.version
  )

  create_post_body = common_post_body.merge(:has_remote_repo? => opts[:has_remote_repo]) 
  response = rest_post("#{BaseRoute}/create_empty_module", create_post_body)

  branch    = response.required(:branch, :name)
  repo_url  = response.required(:repo, :url)

  repo_dir = file_obj.parent_dir # repo dir is directory that directly holds the base file object file_obj
  git_response = ClientModuleDir::GitRepo.fetch_merge_and_push(:repo_dir => repo_dir, :repo_url => repo_url, :branch => branch)
  commit_sha     = git_response.data(:head_sha)
  rest_post("#{BaseRoute}/update_from_repo", common_post_body.merge(:commit_sha => commit_sha, :initial_update => true))
end