class Umwelt::Command::Clone

Public Class Methods

new(path: '.umwelt') click to toggle source
# File lib/umwelt/command/clone.rb, line 7
def initialize(path: '.umwelt')
  @path = path
  @written_paths = {}
end

Public Instance Methods

call(user_project: '/') click to toggle source
# File lib/umwelt/command/clone.rb, line 12
def call(user_project: '/')
  user_name, project_name = user_project.split('/')

  project = get_project(
    project_name: project_name, user_name: user_name
  )
  store_project!(project)

  history = get_history(project.project_id)
  store_history!(history)
  get_episodes(history)
end

Private Instance Methods

episode_exist?(phase_id) click to toggle source
# File lib/umwelt/command/clone.rb, line 36
def episode_exist?(phase_id)
  Umwelt::Episode::File::Restore
    .new(path: @path)
    .call(phase_id)
    .success?
end
get_episode(phase_id) click to toggle source
# File lib/umwelt/command/clone.rb, line 51
def get_episode(phase_id)
  prove(Umwelt::Episode::Get.new.call(phase_id)).episode
end
get_episodes(history) click to toggle source
# File lib/umwelt/command/clone.rb, line 27
def get_episodes(history)
  history.phases.map do |phase|
    next if episode_exist? phase.id

    episode = get_episode(phase.id)
    store_episode!(phase.id, episode)
  end
end
get_history(project_id) click to toggle source
# File lib/umwelt/command/clone.rb, line 61
def get_history(project_id)
  prove(Umwelt::History::Get.new.call(project_id)).history
end
get_project(user_project) click to toggle source
# File lib/umwelt/command/clone.rb, line 71
def get_project(user_project)
  prove(Umwelt::Project::Get.new.call(user_project)).project
end
store_episode!(id, episode) click to toggle source
# File lib/umwelt/command/clone.rb, line 43
def store_episode!(id, episode)
  @written_paths.merge! prove(
    Umwelt::Episode::File::Store
    .new(path: @path)
    .call(id, episode)
  ).written_paths
end
store_history!(history) click to toggle source
# File lib/umwelt/command/clone.rb, line 55
def store_history!(history)
  @written_paths.merge! prove(
    Umwelt::History::File::Store.new(path: @path).call(history)
  ).written_paths
end
store_project!(project) click to toggle source
# File lib/umwelt/command/clone.rb, line 65
def store_project!(project)
  @written_paths.merge! prove(
    Umwelt::Project::File::Store.new(path: @path).call(project)
  ).written_paths
end