kbsecret 0.2.2 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f2ba5bfa023b12c86f64fd86b7bada8daf6f219
4
- data.tar.gz: c403e756af14fe31813700aefa67c46a05dceb04
3
+ metadata.gz: 726c2a148f51589eeef719b170d7f5102532b0f1
4
+ data.tar.gz: 2500fec63f6f4a1f843197fc2e5e69be64232723
5
5
  SHA512:
6
- metadata.gz: 7cc451a8a3f419514238d52994aae8c7c91dc044195b2e9562131dcd5976425f362e202fda6d914c00a84742f019149c618097d17a6412201dd6bd4d70ab9c8a
7
- data.tar.gz: fa75fb703cb27f820b8e154ad22372d2dce821240ea3f7575808e5a5a349fe8cae9289ec068d836cefa586261a0fe95bbdf060dc8683b8c11fc5aea38d94f4b5
6
+ metadata.gz: cec6a334486cf1286c2a11e4192b834a477c4472535192a1ecaf136dc54068fd64d3bae22e90340e5463580d2202a5a4fb2a9d5cff103a21165a9bba015673d1
7
+ data.tar.gz: 0acfe368d0e5891a58d905917885980449cd38f9c9d87b0c634d16f2b4b019140d63d152c5f22a052aebbe0837b86c19c3f49c5924ec90869460649ef428edc9
data/bin/kbsecret CHANGED
@@ -1,14 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
 
5
- BUILTIN_CMDS = [
6
- "help",
7
- "version",
8
- "commands",
9
- "types",
10
- "conf",
11
- ].freeze
6
+ BUILTIN_CMDS = %w[help version commands types conf].freeze
12
7
 
13
8
  EXT_PATHS = ENV["PATH"].split(File::PATH_SEPARATOR).map do |path|
14
9
  Dir[File.join(path, "kbsecret-*")]
@@ -18,13 +13,24 @@ EXT_CMDS = EXT_PATHS.map do |c|
18
13
  File.basename(c, File.extname(c)).sub!("kbsecret-", "")
19
14
  end.freeze
20
15
 
21
- ALIASES = Hash.new { |_, k| k }.update({
16
+ ALIASES = Hash.new { |_, k| k }.update(
22
17
  "--help" => "help",
23
- "-h" => "help",
24
- }).freeze
18
+ "-h" => "help"
19
+ ).freeze
25
20
 
26
21
  ALL_CMDS = (ALIASES.keys + BUILTIN_CMDS + EXT_CMDS).freeze
27
22
 
23
+ KBSECRET_HELP = <<~EOS
24
+ Usage:
25
+ kbsecret <command> <args ...>
26
+
27
+ Available commands:
28
+ #{ALL_CMDS.join(", ")}
29
+
30
+ More more information about a particular command, try:
31
+ kbsecret help <command>
32
+ EOS
33
+
28
34
  def external?(cmd)
29
35
  EXT_CMDS.include?(cmd)
30
36
  end
@@ -49,24 +55,13 @@ end
49
55
  def help(*args)
50
56
  command = normalize args.shift
51
57
  if command.nil?
52
- puts <<~EOS
53
- Usage:
54
- kbsecret <command> <args ...>
55
-
56
- Available commands:
57
- #{ALL_CMDS.join(", ")}
58
-
59
- More more information about a particular command, try:
60
- kbsecret help <command>
61
- EOS
58
+ puts KBSECRET_HELP
59
+ elsif builtin? command
60
+ send "#{command}_help"
62
61
  else
63
- if builtin? command
64
- send "#{command}_help"
65
- else
66
- # XXX: this probably doesn't make sense, since not every user command
67
- # will implement --help.
68
- system expand(command), "--help"
69
- end
62
+ # XXX: this probably doesn't make sense, since not every user command
63
+ # will implement --help.
64
+ system expand(command), "--help"
70
65
  end
71
66
  end
72
67
 
@@ -83,7 +78,7 @@ def help_help
83
78
  EOS
84
79
  end
85
80
 
86
- def version(*args)
81
+ def version(*_args)
87
82
  puts <<~EOS
88
83
  kbsecret version #{KBSecret::VERSION}.
89
84
  EOS
@@ -98,7 +93,7 @@ def version_help
98
93
  EOS
99
94
  end
100
95
 
101
- def commands
96
+ def commands(*_args)
102
97
  puts ALL_CMDS.join("\n")
103
98
  end
104
99
 
@@ -111,7 +106,7 @@ def commands_help
111
106
  EOS
112
107
  end
113
108
 
114
- def types
109
+ def types(*_args)
115
110
  puts KBSecret::Record.record_types.join("\n")
116
111
  end
117
112
 
@@ -124,7 +119,7 @@ def types_help
124
119
  EOS
125
120
  end
126
121
 
127
- def conf
122
+ def conf(*_args)
128
123
  abort("You need to set $EDITOR!") unless ENV["EDITOR"]
129
124
  Process.spawn("#{ENV["EDITOR"]} #{KBSecret::Config::CONFIG_FILE}")
130
125
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -12,6 +13,8 @@ opts = Slop.parse suppress_errors: true do |o|
12
13
  EOS
13
14
 
14
15
  o.string "-s", "--session", "the session name", default: :default
16
+ o.bool "-x", "--terse", "output in field:value format"
17
+ o.bool "-i", "--ifs", "separate terse pairs with this string", default: ":"
15
18
 
16
19
  o.on "-h", "--help" do
17
20
  puts o
@@ -19,7 +22,7 @@ opts = Slop.parse suppress_errors: true do |o|
19
22
  end
20
23
 
21
24
  o.on "--introspect-flags" do
22
- puts o.options.flat_map { |o| o.flags }.join "\n"
25
+ puts o.options.flat_map(&:flags).join "\n"
23
26
  exit
24
27
  end
25
28
  end
@@ -40,4 +43,8 @@ abort("Fatal: No such record.") unless record
40
43
  field_values = record.class.data_fields.map { |f| record.send f }
41
44
  field_pairs = record.class.data_fields.zip(field_values)
42
45
 
43
- puts field_pairs.map { |f, v| "#{f}: #{v}" }.join "\n"
46
+ if opts.terse?
47
+ puts field_pairs.map { |f, v| "#{f}#{opts[:ifs]}#{v}" }.join "\n"
48
+ else
49
+ puts field_pairs.map { |f, v| "#{f}: #{v}" }.join "\n"
50
+ end
data/bin/kbsecret-env CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -25,7 +26,7 @@ opts = Slop.parse suppress_errors: true do |o|
25
26
  end
26
27
 
27
28
  o.on "--introspect-flags" do
28
- puts o.options.flat_map { |o| o.flags }.join "\n"
29
+ puts o.options.flat_map(&:flags).join "\n"
29
30
  exit
30
31
  end
31
32
  end
data/bin/kbsecret-list CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -21,7 +22,7 @@ opts = Slop.parse suppress_errors: true do |o|
21
22
  end
22
23
 
23
24
  o.on "--introspect-flags" do
24
- puts o.options.flat_map { |o| o.flags }.join "\n"
25
+ puts o.options.flat_map(&:flags).join "\n"
25
26
  exit
26
27
  end
27
28
  end
@@ -46,4 +47,3 @@ records.each do |record|
46
47
 
47
48
  puts line
48
49
  end
49
-
data/bin/kbsecret-login CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -16,7 +17,7 @@ opts = Slop.parse suppress_errors: true do |o|
16
17
  EOS
17
18
 
18
19
  o.bool "-a", "--all", "retrieve all login records, not just listed ones"
19
- o.bool "-t", "--terse", "output in label:username:password format"
20
+ o.bool "-x", "--terse", "output in label:username:password format"
20
21
  o.string "-i", "--ifs", "separate terse fields with this string", default: ":"
21
22
  o.string "-s", "--session", "the session name", default: :default
22
23
 
@@ -26,7 +27,7 @@ opts = Slop.parse suppress_errors: true do |o|
26
27
  end
27
28
 
28
29
  o.on "--introspect-flags" do
29
- puts o.options.flat_map { |o| o.flags }.join "\n"
30
+ puts o.options.flat_map(&:flags).join "\n"
30
31
  exit
31
32
  end
32
33
  end
data/bin/kbsecret-new CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -33,7 +34,7 @@ opts = Slop.parse suppress_errors: true do |o|
33
34
  end
34
35
 
35
36
  o.on "--introspect-flags" do
36
- puts o.options.flat_map { |o| o.flags }.join "\n"
37
+ puts o.options.flat_map(&:flags).join "\n"
37
38
  exit
38
39
  end
39
40
  end
@@ -74,9 +75,8 @@ else
74
75
  fields = opts.args
75
76
  end
76
77
 
77
-
78
78
  begin
79
79
  session.add_record(type, label, *fields)
80
80
  rescue => e
81
- abort "Fatal: #{e.to_s}."
81
+ abort "Fatal: #{e}."
82
82
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "keybase"
4
5
  require "kbsecret"
@@ -26,7 +27,7 @@ opts = Slop.parse suppress_errors: true do |o|
26
27
  end
27
28
 
28
29
  o.on "--introspect-flags" do
29
- puts o.options.flat_map { |o| o.flags }.join "\n"
30
+ puts o.options.flat_map(&:flags).join "\n"
30
31
  exit
31
32
  end
32
33
  end
data/bin/kbsecret-pass CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -25,7 +26,7 @@ opts = Slop.parse suppress_errors: true do |o|
25
26
  end
26
27
 
27
28
  o.on "--introspect-flags" do
28
- puts o.options.flat_map { |o| o.flags }.join "\n"
29
+ puts o.options.flat_map(&:flags).join "\n"
29
30
  exit
30
31
  end
31
32
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -22,16 +23,14 @@ opts = Slop.parse suppress_errors: true do |o|
22
23
  end
23
24
 
24
25
  o.on "--introspect-flags" do
25
- puts o.options.flat_map { |o| o.flags }.join "\n"
26
+ puts o.options.flat_map(&:flags).join "\n"
26
27
  exit
27
28
  end
28
29
  end
29
30
 
30
31
  sess_name = opts[:session]
31
32
 
32
- unless ENV["EDITOR"]
33
- abort "Fatal: $EDITOR is not set."
34
- end
33
+ abort "Fatal: $EDITOR is not set." unless ENV["EDITOR"]
35
34
 
36
35
  unless KBSecret::Config.session? sess_name
37
36
  abort "Fatal: Unknown session: '#{sess_name}'."
@@ -39,7 +38,7 @@ end
39
38
 
40
39
  session = KBSecret::Session.new label: sess_name
41
40
  label = opts.args.shift
42
- record = session.records.find { |r| r.label == label}
41
+ record = session.records.find { |r| r.label == label }
43
42
 
44
43
  if record
45
44
  Process.spawn("#{ENV["EDITOR"]} #{record.path}")
data/bin/kbsecret-rm CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -23,7 +24,7 @@ opts = Slop.parse suppress_errors: true do |o|
23
24
  end
24
25
 
25
26
  o.on "--introspect-flags" do
26
- puts o.options.flat_map { |o| o.flags }.join "\n"
27
+ puts o.options.flat_map(&:flags).join "\n"
27
28
  exit
28
29
  end
29
30
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -23,7 +24,7 @@ opts = Slop.parse suppress_errors: true do |o|
23
24
  end
24
25
 
25
26
  o.on "--introspect-flags" do
26
- puts o.options.flat_map { |o| o.flags }.join "\n"
27
+ puts o.options.flat_map(&:flags).join "\n"
27
28
  exit
28
29
  end
29
30
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -20,7 +21,7 @@ opts = Slop.parse suppress_errors: true do |o|
20
21
  end
21
22
 
22
23
  o.on "--introspect-flags" do
23
- puts o.options.flat_map { |o| o.flags }.join "\n"
24
+ puts o.options.flat_map(&:flags).join "\n"
24
25
  exit
25
26
  end
26
27
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -23,7 +24,7 @@ opts = Slop.parse suppress_errors: true do |o|
23
24
  end
24
25
 
25
26
  o.on "--introspect-flags" do
26
- puts o.options.flat_map { |o| o.flags }.join "\n"
27
+ puts o.options.flat_map(&:flags).join "\n"
27
28
  exit
28
29
  end
29
30
  end
data/bin/kbsecret-todo CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "kbsecret"
4
5
  require "slop"
@@ -24,8 +25,8 @@ opts = Slop.parse suppress_errors: true do |o|
24
25
  end
25
26
 
26
27
  o.on "--introspect-flags" do
27
- subcmds = ["start", "suspend", "complete"]
28
- comp = o.options.flat_map { |o| o.flags } + subcmds
28
+ subcmds = %w[start suspend complete]
29
+ comp = o.options.flat_map(&:flags) + subcmds
29
30
  puts comp.join "\n"
30
31
  exit
31
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "yaml"
2
4
  require "fileutils"
3
5
 
@@ -21,27 +23,27 @@ module KBSecret
21
23
  default: {
22
24
  users: [Keybase.current_user],
23
25
  root: "kbsecret",
24
- }
25
- }
26
+ },
27
+ },
26
28
  }.freeze
27
29
 
28
30
  # Retrieve a configured value.
29
31
  # @param key [String]
30
32
  # @return [Object] the corresponding configuration
31
33
  def self.[](key)
32
- @@config[key]
34
+ @config[key]
33
35
  end
34
36
 
35
37
  # Retrieve a session's configuration.
36
38
  # @param sess [Symbol] the session's label
37
39
  # @return [Hash] the session configuration
38
40
  def self.session(sess)
39
- @@config[:sessions][sess]
41
+ @config[:sessions][sess]
40
42
  end
41
43
 
42
44
  # @return [Array<Symbol>] all configured session labels
43
45
  def self.session_labels
44
- @@config[:sessions].keys
46
+ @config[:sessions].keys
45
47
  end
46
48
 
47
49
  # @param sess [Symbol] the session label
@@ -55,8 +57,8 @@ module KBSecret
55
57
  # @param hsh [Hash] the session configuration
56
58
  # @return [void]
57
59
  def self.configure_session(label, hsh)
58
- @@config[:sessions][label.to_sym] = hsh
59
- File.open(CONFIG_FILE, "w") { |io| io.write @@config.to_yaml }
60
+ @config[:sessions][label.to_sym] = hsh
61
+ File.open(CONFIG_FILE, "w") { |io| io.write @config.to_yaml }
60
62
  end
61
63
 
62
64
  # Deconfigure a session.
@@ -66,8 +68,8 @@ module KBSecret
66
68
  # it "invisible" to `kbsecret`. To actually remove all files associated
67
69
  # with a session, see {KBSecret::Session#unlink!}.
68
70
  def self.deconfigure_session(label)
69
- @@config[:sessions].delete(label.to_sym)
70
- File.open(CONFIG_FILE, "w") { |io| io.write @@config.to_yaml }
71
+ @config[:sessions].delete(label.to_sym)
72
+ File.open(CONFIG_FILE, "w") { |io| io.write @config.to_yaml }
71
73
  end
72
74
 
73
75
  if File.exist?(CONFIG_FILE)
@@ -78,6 +80,6 @@ module KBSecret
78
80
  File.open(CONFIG_FILE, "w") { |io| io.write DEFAULT_CONFIG.to_yaml }
79
81
  end
80
82
 
81
- @@config = DEFAULT_CONFIG.merge(user_config)
83
+ @config = DEFAULT_CONFIG.merge(user_config)
82
84
  end
83
85
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module KBSecret
2
4
  # A generic error in kbsecret.
3
5
  class KBSecretError < RuntimeError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "json"
2
4
 
3
5
  module KBSecret
@@ -20,6 +22,13 @@ module KBSecret
20
22
  @fields ||= []
21
23
  @fields << field
22
24
 
25
+ gen_methods field
26
+ end
27
+
28
+ # Generate the methods used to access a given field.
29
+ # @param field [Symbol] the new field's name
30
+ # @return [void]
31
+ def gen_methods(field)
23
32
  class_eval %[
24
33
  def #{field}
25
34
  @data[self.class.type.to_sym]["#{field}".to_sym]
@@ -42,7 +51,11 @@ module KBSecret
42
51
  # @example
43
52
  # KBSecret::Record::Abstract.type # => :abstract
44
53
  def type
45
- name.split("::").last.downcase.to_sym
54
+ name.split("::") # ["Foo", "BarBaz"]
55
+ .last # "BarBaz"
56
+ .gsub(/([^A-Z])([A-Z]+)/, '\1_\2') # "Bar_Baz"
57
+ .downcase # "bar_baz"
58
+ .to_sym # :bar_baz
46
59
  end
47
60
 
48
61
  # Load the given hash-representation into a record.
@@ -51,7 +64,7 @@ module KBSecret
51
64
  # @return [Record::AbstractRecord] the created record
52
65
  # @api private
53
66
  def load!(session, hsh)
54
- instance = allocate
67
+ instance = allocate
55
68
  instance.session = session
56
69
  instance.initialize_from_hash(hsh)
57
70
 
@@ -64,11 +77,11 @@ module KBSecret
64
77
  # @param label [Symbol] the new record's label
65
78
  # @note Creation does *not* sync the new record; see {#sync!} for that.
66
79
  def initialize(session, label)
67
- @session = session
80
+ @session = session
68
81
  @timestamp = Time.now.to_i
69
- @label = label
70
- @type = self.class.type
71
- @data = {}
82
+ @label = label
83
+ @type = self.class.type
84
+ @data = {}
72
85
  end
73
86
 
74
87
  # Fill in instance fields from a record's hash-representation.
@@ -77,9 +90,9 @@ module KBSecret
77
90
  # @api private
78
91
  def initialize_from_hash(hsh)
79
92
  @timestamp = hsh[:timestamp]
80
- @label = hsh[:label]
81
- @type = hsh[:type].to_sym
82
- @data = hsh[:data]
93
+ @label = hsh[:label]
94
+ @type = hsh[:type].to_sym
95
+ @data = hsh[:data]
83
96
  end
84
97
 
85
98
  # The fully qualified path to the record's file.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "shellwords"
2
4
 
3
5
  module KBSecret
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module KBSecret
2
4
  module Record
3
5
  # Represents a record containing a login (username, password) pair.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module KBSecret
2
4
  module Record
3
5
  # Represents a record containing a code snippet and its description.
@@ -11,9 +11,9 @@ module KBSecret
11
11
  # The start time is the date and time at which the item was started via
12
12
  # {#start!}.
13
13
  #
14
- # The stop top is the date and time at which the item was *either*
14
+ # The stop time is the date and time at which the item was *either*
15
15
  # last suspended via {#suspend!} *or* finished via {#complete!}.
16
- class ToDo < Abstract
16
+ class Todo < Abstract
17
17
  data_field :todo
18
18
  data_field :status
19
19
  data_field :start
@@ -57,7 +57,7 @@ module KBSecret
57
57
  return if started?
58
58
 
59
59
  self.status = "started"
60
- self.start = Time.now.to_s
60
+ self.start = Time.now.to_s
61
61
  end
62
62
 
63
63
  # Suspend the to do item.
@@ -66,7 +66,7 @@ module KBSecret
66
66
  def suspend!
67
67
  return if suspended?
68
68
  self.status = "suspended"
69
- self.stop = Time.now.to_s
69
+ self.stop = Time.now.to_s
70
70
  end
71
71
 
72
72
  # Complete the to do item.
@@ -75,7 +75,7 @@ module KBSecret
75
75
  def complete!
76
76
  return if completed?
77
77
  self.status = "complete"
78
- self.stop = Time.now.to_s
78
+ self.stop = Time.now.to_s
79
79
  end
80
80
  end
81
81
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module KBSecret
2
4
  module Record
3
5
  # Represents a record containing unstructured text.
@@ -13,7 +15,7 @@ module KBSecret
13
15
  @data = {
14
16
  unstructured: {
15
17
  text: text,
16
- }
18
+ },
17
19
  }
18
20
  end
19
21
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "json"
2
4
 
3
5
  # we have to require abstract first because ruby's module resolution is bad
@@ -38,9 +40,9 @@ module KBSecret
38
40
  # @return [Record::AbstractRecord] the loaded record
39
41
  # @api private
40
42
  def self.load_record!(session, path)
41
- hsh = JSON.parse(File.read(path), symbolize_names: true)
43
+ hsh = JSON.parse(File.read(path), symbolize_names: true)
42
44
  klass = record_classes.find { |c| c.type == hsh[:type].to_sym }
43
- klass.load!(session, hsh) if klass
45
+ klass&.load!(session, hsh)
44
46
  end
45
47
  end
46
48
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "fileutils"
2
4
 
3
5
  module KBSecret
@@ -19,11 +21,11 @@ module KBSecret
19
21
  # specified in {Config::CONFIG_FILE}. To *create* a new session,
20
22
  # see {Config.configure_session}.
21
23
  def initialize(label: :default)
22
- @label = label.to_sym
23
- @config = Config.session(@label)
24
+ @label = label.to_sym
25
+ @config = Config.session(@label)
24
26
 
25
27
  @directory = rel_path config[:root], mkdir: true
26
- @records = load_records!
28
+ @records = load_records!
27
29
  end
28
30
 
29
31
  # @param type [String, Symbol] the type of the records to return (or `nil` for all)
@@ -51,12 +53,10 @@ module KBSecret
51
53
  # @raise RecordCreationArityError if the number of specified record
52
54
  # arguments does not match the record type's constructor
53
55
  def add_record(type, label, *args)
54
- klass = Record.record_classes.find { |k| k.type == type.to_sym }
56
+ klass = Record.class_for(type.to_sym)
55
57
  arity = klass.instance_method(:initialize).arity - 2
56
58
 
57
- unless arity == args.size
58
- raise RecordCreationArityError.new(arity, args.size)
59
- end
59
+ raise RecordCreationArityError.new(arity, args.size) unless arity == args.size
60
60
 
61
61
  record = klass.new(self, label, *args)
62
62
  records << record
data/lib/kbsecret.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "keybase"
2
4
 
3
5
  require_relative "kbsecret/config"
@@ -8,7 +10,7 @@ require_relative "kbsecret/session"
8
10
  # The primary namespace for kbsecret.
9
11
  module KBSecret
10
12
  # kbsecret's current version
11
- VERSION = "0.2.2".freeze
13
+ VERSION = "0.3.0"
12
14
 
13
15
  # fail very early if the user doesn't have keybase and KBFS running
14
16
  raise Keybase::KeybaseNotRunningError unless Keybase.running?
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.2.2
4
+ version: 0.3.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-05-27 00:00:00.000000000 Z
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: keybase-unofficial