Skip to content

Instantly share code, notes, and snippets.

@talum
Last active June 2, 2018 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talum/02e16d46d7ec73f96589f5f938c02c7b to your computer and use it in GitHub Desktop.
Save talum/02e16d46d7ec73f96589f5f938c02c7b to your computer and use it in GitHub Desktop.
Assignments on Learn.co
class DeployCodeChallenge
attr_reader :git_source_url, :deployable_task, :deployer, :assignees, :errors
attr_accessor :deployed_repo_url
def initialize(git_source_url:, deployable_task:, deployer:, assignees:)
@git_source_url = git_source_url
@deployable_task = deployable_task
@deployer = to_deploying_user(deployer)
@assignees = to_github_collaborators(assignees)
@errors = []
end
def execute
Dir.mktmpdir do |working_dir|
deployer.clone(git_source_url, deployable_task, working_dir)
deployer.create_remote_repo(deployable_task)
deployer.push(deployable_task, working_dir)
self.deployed_repo_url = deployer.destination_repo_url(deployable_task.challenge_name)
deployer.add_assignees_as_collaborators(deployable_task, assignees)
deployer.accept_invitations(deployable_task, assignees)
end
end
private
def to_deploying_user(user)
CodeChallengeDeployingUser.new_from_user(user, self)
end
def to_github_collaborators(assignees)
assignees.map{|a| to_github_collaborator(a)}
end
def to_github_collaborator(assignee)
GithubCollaborator.new_from_user(assignee)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment