package_cloud 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7a98fd9d7b7a723d627d7debdadb8d3f25a45c9
4
- data.tar.gz: ba564108283c4275fbcd93cf77fc0895f7aabf05
3
+ metadata.gz: da547c1bb5a039ffd16b0bd2ae9a7ed9bfcc595d
4
+ data.tar.gz: 05322c214d17a1dfdff07efdf98f796a1c025b70
5
5
  SHA512:
6
- metadata.gz: 59de8e032d120b7e7a32639fec9b6aefc844ad1245fc8182d555082ac02e7605bcb997132fbf0fd2fd29768058c59ae94e1431eed9221c0f05a8a795c3d70a6f
7
- data.tar.gz: 1f93ef3313671e992cbca983557ca46d6b2b91e9e4f43ac2c16260d3fb8da29ce65f66597811f79be89b1a52bf3108a6a3ef082707d1a9bfd54c4884e87d85ea
6
+ metadata.gz: fa498f5144a3ed889a914dbbca47c9c141270f49c54b053cef0a3c89e21819bcd8aa224d7de3e3183e71963cbf14ba0b9929e8b6818be4d554e7c8841d738bda
7
+ data.tar.gz: 6044ec9e49b5d7afb6c44eb74e8084f2c99ca4fdf99cf55f1d831c7beaecffb271411ccdcc9fc14eca6ee4d83837db7ccb790dc826167a525f11f81cbec56f8e
@@ -6,6 +6,7 @@ module PackageCloud
6
6
  autoload :Distro, "package_cloud/cli/distro"
7
7
  autoload :Entry, "package_cloud/cli/entry"
8
8
  autoload :MasterToken, "package_cloud/cli/master_token"
9
+ autoload :ReadToken, "package_cloud/cli/read_token"
9
10
  autoload :Repository, "package_cloud/cli/repository"
10
11
 
11
12
  class Base < Thor
@@ -10,6 +10,9 @@ module PackageCloud
10
10
  desc "master_token SUBCMD ...ARGS", "manage master tokens"
11
11
  subcommand "master_token", MasterToken
12
12
 
13
+ desc "read_token SUBCMD ...ARGS", "manage read tokens"
14
+ subcommand "read_token", ReadToken
15
+
13
16
  desc "yank user/repo[/distro/version] package_name",
14
17
  "yank package from user/repo [in dist/version]"
15
18
  def yank(repo_desc, package_name)
@@ -15,8 +15,7 @@ module PackageCloud
15
15
  puts " #{token.name} (#{token.value})"
16
16
  puts " read tokens:"
17
17
  token.read_tokens.each do |read_token|
18
- puts " #{read_token.name}"
19
- puts " #{read_token.value}"
18
+ puts " { id: #{read_token.id}, name: #{read_token.name}, value: #{read_token.value} }"
20
19
  puts
21
20
  end
22
21
  puts "" unless i == tokens.length - 1
@@ -0,0 +1,39 @@
1
+ module PackageCloud
2
+ module CLI
3
+ class ReadToken < Base
4
+ desc "destroy user/repository mastertoken/readtoken",
5
+ "revokes read token associated to a master token"
6
+ def destroy(repo_name, master_and_read_token)
7
+ print "Looking for repository at #{repo_name}... "
8
+ repo = client.repository(repo_name)
9
+
10
+ given_master_token, given_read_token = master_and_read_token.split("/")
11
+
12
+ if given_master_token.nil? || given_read_token.nil?
13
+ print "invalid master token and/or read token!\n".red
14
+ exit(127)
15
+ end
16
+
17
+ master_token = repo.master_tokens.detect { |t| t.name == given_master_token }
18
+
19
+ if master_token.nil?
20
+ print "couldn't find master token named #{given_master_token}\n".red
21
+ exit(127)
22
+ end
23
+
24
+ read_token = master_token.read_tokens.detect { |t| t.name == given_read_token }
25
+
26
+ if read_token.nil?
27
+ print "couldn't find read token named #{given_read_token} for #{given_master_token}\n".red
28
+ exit(127)
29
+ end
30
+
31
+ master_token_path = master_token.paths["self"]
32
+
33
+ read_token.destroy(master_token_path, read_token.id)
34
+
35
+ print "success!\n"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -7,7 +7,7 @@ module PackageCloud
7
7
 
8
8
  def read_tokens
9
9
  @attrs["read_tokens"].map do |read_token|
10
- ReadToken.new(read_token)
10
+ ReadToken.new(@config, read_token)
11
11
  end
12
12
  end
13
13
 
@@ -1,7 +1,14 @@
1
1
  module PackageCloud
2
2
  class ReadToken < Object
3
- def initialize(attrs)
3
+ def initialize(config, attrs)
4
+ @config = config
4
5
  @attrs = attrs
5
6
  end
7
+
8
+ def destroy(master_token_path, read_token_id)
9
+ base_url = @config.base_url
10
+ url = "#{base_url}#{master_token_path}/read_tokens/#{read_token_id}"
11
+ RestClient.delete(url)
12
+ end
6
13
  end
7
14
  end
@@ -1,7 +1,7 @@
1
1
  module PackageCloud
2
2
  MAJOR_VERSION = "0"
3
3
  MINOR_VERSION = "2"
4
- PATCH_VERSION = "12"
4
+ PATCH_VERSION = "13"
5
5
 
6
6
  VERSION = [MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION].join(".")
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: package_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Damato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-26 00:00:00.000000000 Z
11
+ date: 2014-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -128,6 +128,7 @@ files:
128
128
  - lib/package_cloud/cli/distro.rb
129
129
  - lib/package_cloud/cli/entry.rb
130
130
  - lib/package_cloud/cli/master_token.rb
131
+ - lib/package_cloud/cli/read_token.rb
131
132
  - lib/package_cloud/cli/repository.rb
132
133
  - lib/package_cloud/client.rb
133
134
  - lib/package_cloud/config_file.rb