keybase-unofficial-local 0.0.3 → 0.0.4

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: '038fd64f38750e3e24ae832b1ad61110e3f9b712'
4
- data.tar.gz: 1e1aacdcc7fef1124030e2aa604759f679dcde4c
3
+ metadata.gz: f327e3aa87d69a7a7da0a1abe87d2d2169dc457e
4
+ data.tar.gz: 6142797174e330004eae98c225a56508e127a360
5
5
  SHA512:
6
- metadata.gz: b57ec4b89ba9ed4680d2d34f0d8a47b912a8b24ec41a1e9c5e5ba09bada173220e29e45144945f970e43031c883d694a3b4cb6f7f25a1abc09782a2bce2dcf12
7
- data.tar.gz: 852d7d45925c18f7ae5157c89f2cac8691edf630e111997a4f855f34b56d877bd6d8665b1d66d75c5372106e22eaced38ba536da664937ac168b38d7580e0130
6
+ metadata.gz: 3c11cc7aa703f8495a472cb86119ab44a4b010af47910bb440d051ee78b7b051721e749865c7908ea92bd569c3a2f3cc131829ed5e60640556f4b2a3bf762fa2
7
+ data.tar.gz: c3eb31d508d742a1fde970bd41df3ceb22c4e45bd5fcf6ee2b4b0e1540d00c181f9d421c8033e574258fa73eb40e671b36c5e5b7ea6fde25848023042b390a2b
@@ -14,7 +14,7 @@ module Keybase
14
14
  # The namespace for `keybase-unofficial-local`.
15
15
  module Local
16
16
  # The current version of `keybase-unofficial-local`.
17
- VERSION = "0.0.3"
17
+ VERSION = "0.0.4"
18
18
 
19
19
  extend Config
20
20
  end
@@ -1,11 +1,141 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "open3"
4
+ require "json"
5
+
3
6
  module Keybase
4
7
  module Local
5
8
  # Represents an interface to Keybase's teams.
6
- # @note This is a stub.
7
9
  module Team
8
- # stub
10
+ # The initial arguments to pass when executing Keybase for team management.
11
+ TEAM_EXEC_ARGS = %w[keybase team].freeze
12
+
13
+ # The pattern used to (partially) validate team names.
14
+ # @see https://github.com/keybase/client/blob/5aa02d1b351f0dfab050eb5ae22bffdf59f61d91/go/protocol/keybase1/extras.go#L1560
15
+ TEAM_PATTERN = /([a-zA-Z0-9][a-zA-Z0-9_]?)+/
16
+
17
+ class << self
18
+ # @param args [Array<String>] additional arguments to pass to `keybase team`
19
+ # @param payload [String, nil] input data to feed to the invocation
20
+ # @param json [Boolean] whether or not to parse `stdout` as JSON
21
+ # @return [Hash, Boolean, nil] the parsed JSON, or a true/false/nil result indicating
22
+ # command success
23
+ # @api private
24
+ def team_call(*args, payload: nil, json: false)
25
+ if json
26
+ response = Open3.popen3(*TEAM_EXEC_ARGS, *args) do |stdin, stdout, _, _|
27
+ stdin.write payload if payload
28
+ stdin.close # close after writing to let keybase know we're done
29
+ stdout.read
30
+ end
31
+
32
+ if response.empty?
33
+ {}
34
+ else
35
+ JSON.parse response
36
+ end
37
+ else
38
+ system(*TEAM_EXEC_ARGS, *args)
39
+ end
40
+ end
41
+
42
+ # Create a new Keybase team.
43
+ # @note This is a stub.
44
+ # @api private
45
+ def create(_team)
46
+ # stub
47
+ end
48
+
49
+ # Add a user to a Keybase team.
50
+ # @note This is a stub.
51
+ # @api private
52
+ def add_member(_team, _user, _role: :reader, _email: false)
53
+ # stub
54
+ end
55
+
56
+ # Remove a user from a Keybase team.
57
+ # @note This is a stub.
58
+ # @api private
59
+ def remove_member(_team, _user)
60
+ # stub
61
+ end
62
+
63
+ # Modify a user in a Keybase team.
64
+ # @note This is a stub.
65
+ # @api private
66
+ def edit_member(_team, _user, _role: :reader)
67
+ # stub
68
+ end
69
+
70
+ # List all teams currently belonged to.
71
+ # @param force_poll [Boolean] whether or not to force a poll of the server for all idents
72
+ # @return [Hash] a hash representation of all teams currently belonged to
73
+ def list_memberships(force_poll: false)
74
+ args = %w[list-memberships --json]
75
+ args << "--force-poll" if force_poll
76
+
77
+ team_call(*args, json: true)
78
+ end
79
+
80
+ # List all members of the given team.
81
+ # @param force_poll [Boolean] whether or not to force a poll of the server for all idents
82
+ # @return [Hash] a hash representation of all members of the given team
83
+ def list_members(team, force_poll: false)
84
+ args = %W[list-members #{team} --json]
85
+ args << "--force-poll" if force_poll
86
+
87
+ team_call(*args, json: true)
88
+ end
89
+
90
+ # Change the name of a Keybase team.
91
+ # @note This is a stub.
92
+ # @api private
93
+ def rename(_old_team, _new_team)
94
+ # stub
95
+ end
96
+
97
+ # Request access to a Keybase team.
98
+ # @note This is a stub.
99
+ # @api private
100
+ def request_access(_team)
101
+ # stub
102
+ end
103
+
104
+ # List requests to join Keybase teams.
105
+ # @note This is a stub.
106
+ # @api private
107
+ def list_requests
108
+ # stub
109
+ end
110
+
111
+ # Ignore a request to join a Keybase team.
112
+ # @note This is a stub.
113
+ # @api private
114
+ def ignore_request(_team, _user)
115
+ # stub
116
+ end
117
+
118
+ # Accept an email invitation to join a Keybase team.
119
+ # @note This is a stub.
120
+ # @api private
121
+ def accept_invite(_token)
122
+ # stub
123
+ end
124
+
125
+ # Leave a Keybase team.
126
+ # @note This is a stub.
127
+ # @api private
128
+ def leave(_team, _permanent: false)
129
+ # stub
130
+ end
131
+
132
+ # Delete a Keybase team.
133
+ # @note This is a stub.
134
+ # @api private
135
+ def delete(_team)
136
+ # stub
137
+ end
138
+ end
9
139
  end
10
140
  end
11
141
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keybase-unofficial-local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-20 00:00:00.000000000 Z
11
+ date: 2017-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: keybase-unofficial-core