Class: PackageCloud::CLI::Repository

Inherits:
Base
  • Object
show all
Defined in:
lib/package_cloud/cli/repository.rb

Instance Method Summary collapse

Instance Method Details

#create(repo_name) ⇒ Object


7
8
9
10
11
12
13
14
15
16
# File 'lib/package_cloud/cli/repository.rb', line 7

def create(repo_name)
  config.read_or_create
  client = Client.new(config)

  print "Looking for repository at #{repo_name}... "
  repo = client.create_repo(repo_name, options[:private])
  print "success!\n".color(:green)
  puts "Your repository has been created at:"
  puts "    #{repo["url"]}"
end

#install(repo, package_type) ⇒ Object


37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/package_cloud/cli/repository.rb', line 37

def install(repo, package_type)
  if Process.uid != 0 && package_type != "gem"
    abort("You have to run install as root.".color(:red))
  end

  print "Locating repository at #{repo}... "
  repo = client.repository(repo)
  print "success!\n"
  script = repo.install_script(package_type)
  pid = fork { exec("/bin/bash", script.path) }
  Process.waitpid(pid)
  script.unlink
end

#listObject


20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/package_cloud/cli/repository.rb', line 20

def list
  repos = client.repositories
  if repos.length == 0
    puts "You have no repositories at the moment. Create one!"
  else
    puts "Your repositories:"
    puts ""
    repos.each_with_index do |repo, i|
      puts "  #{repo.fqname} (#{repo.private_human})"
      puts "  last push: #{repo.last_push_human} | packages: #{repo.package_count_human}"
      puts "" unless i == repos.length - 1
    end
  end
end