package_cloud 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,13 +11,43 @@ module PackageCloud
11
11
  subcommand "master_token", MasterToken
12
12
 
13
13
 
14
- desc "push user/repo[/distro/version] /path/to/package",
15
- "push package to repository (in distro/version if required)"
16
- def push(repo, package_file)
14
+ desc "push user/repo[/distro/version] /path/to/packages",
15
+ "push package(s) to repository (in distro/version if required)"
16
+ def push(repo, package_file, *package_files)
17
17
  ARGV.clear # otherwise gets explodes
18
+ package_files << package_file
19
+
20
+ exts = package_files.map { |f| f.split(".").last }.uniq
21
+
22
+ if package_files.length > 1 && exts.length > 1
23
+ abort("You can't push multiple packages of different types at the same time.\nFor example, use *.deb to push all your debs at once.".red)
24
+ end
25
+
26
+ invalid_packages = package_files.select do |f|
27
+ !["gem", "deb", "rpm"].include?(f.split(".").last)
28
+ end
29
+
30
+ if invalid_packages.any?
31
+ message = "I don't know how to push these packages:\n\n".red
32
+ invalid_packages.each do |p|
33
+ message << " #{p}\n"
34
+ end
35
+ message << "\npackage_cloud only supports debs, gems, and rpms.".red
36
+ abort(message)
37
+ end
38
+
39
+ if exts.first == "gem" && package_files.length > 1
40
+ answer = get_valid("Are you sure you want to push #{package_files.length} packages? (y/n)") do |s|
41
+ s == "y" || s == "n"
42
+ end
43
+
44
+ if answer != "y"
45
+ puts "Aborting...".red
46
+ end
47
+ end
18
48
 
19
49
  validator = Validator.new(client)
20
- dist_id = validator.distribution_id(repo, package_file)
50
+ dist_id = validator.distribution_id(repo, package_files, exts.first)
21
51
 
22
52
  # strip os/dist
23
53
  repo = repo.split("/")[0..1].join("/")
@@ -25,9 +55,27 @@ module PackageCloud
25
55
  print "Looking for repository at #{repo}... "
26
56
  repo = client.repository(repo)
27
57
  print "success!\n"
28
- print "Pushing #{package_file}... "
29
- repo.create_package(package_file, dist_id)
58
+ package_files.each do |f|
59
+ print "Pushing #{f}... "
60
+ repo.create_package(f, dist_id)
61
+ end
30
62
  end
63
+
64
+ private
65
+ def get_valid(prompt)
66
+ selection = ""
67
+ times = 0
68
+ until yield(selection)
69
+ if times > 0
70
+ puts "#{selection} is not a valid selection."
71
+ end
72
+ print "#{prompt}: "
73
+ selection = ::Kernel.gets.chomp
74
+ times += 1
75
+ end
76
+
77
+ selection
78
+ end
31
79
  end
32
80
  end
33
81
  end
@@ -4,9 +4,7 @@ module PackageCloud
4
4
  @client = client
5
5
  end
6
6
 
7
- def distribution_id(repo, filename)
8
- package_type = filename.split(".").last
9
-
7
+ def distribution_id(repo, filenames, package_type)
10
8
  if distributions[package_type]
11
9
  _,_,dist_sel,ver_sel = repo.split("/")
12
10
 
@@ -20,15 +18,15 @@ module PackageCloud
20
18
  ver["id"]
21
19
  else
22
20
  puts "#{ver_sel} isn't a valid version of #{dist["display_name"]}\n\n"
23
- select_dist(repo, filename, package_type)
21
+ select_dist(repo, filenames, package_type)
24
22
  end
25
23
  else
26
24
  puts "#{dist_sel} isn't a valid operating system.\n\n"
27
- select_dist(repo, filename, package_type)
25
+ select_dist(repo, filenames, package_type)
28
26
  end
29
27
  else
30
28
  puts "#{package_type} packages require an operating system and version to be selected.\n\n"
31
- select_dist(repo, filename, package_type)
29
+ select_dist(repo, filenames, package_type)
32
30
  end
33
31
  else
34
32
  nil
@@ -63,7 +61,7 @@ module PackageCloud
63
61
  selection
64
62
  end
65
63
 
66
- def select_dist(repo, filename, package_type)
64
+ def select_dist(repo, filenames, package_type)
67
65
  puts "If you don't see your OS or version here, send us an email at support@packagecloud.io:\n\n"
68
66
  distros = distributions[package_type]
69
67
  distros.each_with_index do |dist, index|
@@ -81,7 +79,11 @@ module PackageCloud
81
79
  repo = repo.split("/")[0..1].join("/")
82
80
  os_shortcut = "#{distro["index_name"]}/#{version["index_name"]}"
83
81
  shortcut = "#{repo}/#{os_shortcut}"
84
- puts "\nPush #{filename} to #{shortcut}? "
82
+ if filenames.length > 1
83
+ puts "\nPush #{filenames.length} packages to #{shortcut}? "
84
+ else
85
+ puts "\nPush #{filenames.first} to #{shortcut}? "
86
+ end
85
87
  answer = get_valid("(y/n)") { |sel| sel == "y" || sel == "n" }
86
88
 
87
89
  if answer == "y"
@@ -1,7 +1,7 @@
1
1
  module PackageCloud
2
2
  MAJOR_VERSION = "0"
3
3
  MINOR_VERSION = "2"
4
- PATCH_VERSION = "0"
4
+ PATCH_VERSION = "1"
5
5
 
6
6
  VERSION = [MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION].join(".")
7
7
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: package_cloud
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Golick
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2014-04-14 00:00:00 Z
13
+ date: 2014-04-16 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor