class Shard::CLI::Fork

Attributes

ref[R]
#

Declarations #

#

Public Class Methods

new(shard_line) click to toggle source
#

Constructor #

#
# File lib/shard/cli/fork.rb, line 19
def initialize(shard_line)
  @ref = Shard::Ref(shard_line)
end
run(shard_line) click to toggle source
#

Class Methods #

#
# File lib/shard/cli/fork.rb, line 29
def self.run(shard_line)
  new(shard_line).run
end

Public Instance Methods

run() click to toggle source
#

Instance Methods #

#
# File lib/shard/cli/fork.rb, line 39
def run
  if ref.nil?
    puts "That is not a valid shard reference."
    return
  end

  if Shard::Credentials.saved? && Shard::Credentials.valid?
    fork_shard
  else
    puts "You are not currently logged into Github."
    Shard::CLI::Config.run

    if Shard::Credentials.saved?
      run
    end
  end
end

Private Instance Methods

fork_shard() click to toggle source
# File lib/shard/cli/fork.rb, line 59
def fork_shard
  lister = Shard::Lister.new(ref.user)
  shard  = lister.shards[ref.name]

  if shard
    puts "Forking #{ ref.user }/#{ ref.name }..."
    Shard.api.fork_gist(shard.id)
  else
    puts "That is not a valid shard reference."
  end
end