Class: LazyFork::LazyForker

Inherits:
Object
  • Object
show all
Defined in:
lib/lazy_fork.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ LazyForker

Returns a new instance of LazyForker.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/lazy_fork.rb', line 7

def initialize(options)
  @options = options

  # tell the user they're being a lazy fork
  puts "You lazy forker..."

  unless Dir.exist?(LAZY_FORK_HOME)
    puts "Creating #{LAZY_FORK_HOME}..."
    Dir.mkdir LAZY_FORK_HOME
  end

  authenticate_client
end

Instance Method Details

#forkObject



21
22
23
# File 'lib/lazy_fork.rb', line 21

def fork
  clone_repo(fork_repo(get_repo(ARGV.first)), ARGV.last)
end

#fork?(repo) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/lazy_fork.rb', line 25

def fork?(repo)
  @client.repository(repo)[:fork]
end

#source(repo) ⇒ Object



29
30
31
32
# File 'lib/lazy_fork.rb', line 29

def source(repo)
  source_slug = @client.repository(repo)[:source][:full_name]
  Octokit::Repository.new(source_slug)
end