kbsecret 0.3.6 → 0.4.0

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: 84a1ecab08084cc71d8fb221a3a66984ca666e4b
4
- data.tar.gz: cb5712d9720862406333252f437cf690b56f3f59
3
+ metadata.gz: b92602206f1d3a9d5e7a6229c92de8483b90bc78
4
+ data.tar.gz: d8677ddd153af6bd8b045bb952035e6e3a2747cb
5
5
  SHA512:
6
- metadata.gz: 710f4ed51abb06d69d8287fd496b2e18545ca36c895d388bdba991faa87ffb57a511a6f582ea06ed0d5230e16ce5d8dfc18a4d4b4563a18c3f79ea701a3676ad
7
- data.tar.gz: 71e11b76e2f36dce94006e4b31bd421d712aa2101f6ec721030b32390feec0afb157be25194050bd2befecd48d4cfc61560cc483a95c18ace30ae0d0213b7bfb
6
+ metadata.gz: dd25e6557b8d4c087ba0768114a76db07bdfad421f90adbfbf17abb7a665131f2febae4e5767c7447512a5762533279b452841c93f0f0a2b89383acfa4966b61
7
+ data.tar.gz: df41aa140028171ebc7f10745af3e735390304b13fce9a7b249162fe32be6a29156e14e5a5f4894fda840ac63bb7c34e5068ed91aec7790a2b67e81bd82977d2
data/README.md CHANGED
@@ -60,11 +60,11 @@ default
60
60
  dev-team
61
61
 
62
62
  # add an environment record to the dev-team session
63
- $ kbsecret new environment API_KEY 0xBADBEEF -s dev-team
63
+ $ kbsecret new environment api-key API_KEY 0xBADBEEF -s dev-team
64
64
 
65
65
  # list all records under the dev-team session
66
66
  $ kbsecret list -s dev-team
67
- API_KEY
67
+ api-key
68
68
 
69
69
  # get all environment records in dev-team in an easy-to-source format
70
70
  $ kbsecret env -s dev-team --all
@@ -102,4 +102,3 @@ Please feel free to contribute completion scripts for other shells!
102
102
  ### TODO
103
103
 
104
104
  * zsh/fish completions
105
- * a TODO record type?
data/lib/kbsecret.rb CHANGED
@@ -11,7 +11,7 @@ require_relative "kbsecret/cli"
11
11
  # The primary namespace for kbsecret.
12
12
  module KBSecret
13
13
  # kbsecret's current version
14
- VERSION = "0.3.6"
14
+ VERSION = "0.4.0"
15
15
 
16
16
  # fail very early if the user doesn't have keybase and KBFS running
17
17
  raise Keybase::KeybaseNotRunningError unless Keybase.running?
@@ -18,11 +18,11 @@ module KBSecret
18
18
  # @api private
19
19
  DEFAULT_CONFIG = {
20
20
  mount: "/keybase",
21
-
21
+ session_root: "kbsecret",
22
22
  sessions: {
23
23
  default: {
24
24
  users: [Keybase.current_user],
25
- root: "kbsecret",
25
+ root: "default",
26
26
  },
27
27
  },
28
28
  }.freeze
@@ -81,5 +81,6 @@ module KBSecret
81
81
  end
82
82
 
83
83
  @config = DEFAULT_CONFIG.merge(user_config)
84
+ FileUtils.mkdir_p @config[:session_root]
84
85
  end
85
86
  end
@@ -8,12 +8,24 @@ module KBSecret
8
8
  # more useful records.
9
9
  # @abstract
10
10
  class Abstract
11
+ # @return [Session] the session associated with the record
11
12
  attr_accessor :session
13
+
14
+ # @return [Integer] the UNIX timestamp marking the record's last modification
12
15
  attr_reader :timestamp
16
+
17
+ # @return [Symbol] the record's label
13
18
  attr_reader :label
19
+
20
+ # @return [Symbol] the record's type
14
21
  attr_reader :type
22
+
23
+ # @return [Hash] the record's data
15
24
  attr_reader :data
16
25
 
26
+ # @return [String] the fully qualified path to the record in KBFS
27
+ attr_reader :path
28
+
17
29
  class << self
18
30
  # Add a field to the record's data.
19
31
  # @param field [Symbol] the new field's name
@@ -82,6 +94,7 @@ module KBSecret
82
94
  @label = label
83
95
  @type = self.class.type
84
96
  @data = {}
97
+ @path = File.join(session.directory, "#{label}.json")
85
98
  end
86
99
 
87
100
  # Fill in instance fields from a record's hash-representation.
@@ -93,14 +106,7 @@ module KBSecret
93
106
  @label = hsh[:label]
94
107
  @type = hsh[:type].to_sym
95
108
  @data = hsh[:data]
96
- end
97
-
98
- # The fully qualified path to the record's file.
99
- # @return [String] the path
100
- # @note If the record hasn't been synced to disk, this path may not
101
- # exist yet.
102
- def path
103
- File.join(session.directory, "#{label}.json")
109
+ @path = File.join(session.directory, "#{label}.json")
104
110
  end
105
111
 
106
112
  # Create a hash-representation of the current record.
@@ -90,21 +90,31 @@ module KBSecret
90
90
  FileUtils.rm_rf(directory)
91
91
  end
92
92
 
93
- private
94
-
93
+ # @return [Array<String>] the fully qualified paths of all records in the session
94
+ # @api private
95
95
  def record_paths
96
96
  Dir[File.join(directory, "*.json")]
97
97
  end
98
98
 
99
+ # Load all records associated with the session.
100
+ # @return [Array<Record::Abstract>] all records in the session
101
+ # @api private
99
102
  def load_records!
100
103
  record_paths.map do |path|
101
104
  Record.load_record! self, path
102
105
  end
103
106
  end
104
107
 
108
+ # @param rel [String, Symbol] the "root" of the session
109
+ # @param mkdir [Boolean] whether or not to make the session directory
110
+ # @return [String] the fully qualified path to the session
111
+ # @api private
105
112
  def rel_path(rel, mkdir: false)
113
+ # /keybase/private/[username]/kbsecret/[session]
106
114
  path = File.join(Config[:mount], "private",
107
- Keybase::U[config[:users]], rel)
115
+ Keybase::U[config[:users]],
116
+ Config[:session_root],
117
+ rel)
108
118
 
109
119
  FileUtils.mkdir_p path if mkdir
110
120
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kbsecret
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
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-06-06 00:00:00.000000000 Z
11
+ date: 2017-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: keybase-unofficial