kbsecret 0.7.0.pre.3 → 0.7.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: 8c5f8f62886813839cd84f823e1b3c5e1d0ef621
4
- data.tar.gz: 7b8bfe9c9672bff900825568001362790b88a1db
3
+ metadata.gz: bd4688af12e409cc9c13577ff5e2471773504790
4
+ data.tar.gz: d72010806cfb3e8f132b3aeae87f53664e34235a
5
5
  SHA512:
6
- metadata.gz: c2f59a671138ea5867c2511e20bb15098ca1f578bf0389b91046d8a17bfa4441c2ad15d62a6bd57a1ea513106e561e8d576f325b54d40a168b44ca2f9e395b79
7
- data.tar.gz: 04e18852305aba35410105cf6371ef76ca2ce8f3a4e6ba5849437e91345d22ead4144eb6de8bd4d911eef3746d24a4c9e578040e41fbf1425dcedbb952cbdaec
6
+ metadata.gz: c520121a121d1a83583391546502e7491a831d090cfb3edc968ec1a6205639f82cc954e0a9793f6b33764c7e5ee61d94c5d85ef3edab634e43efcaa3953d943e
7
+ data.tar.gz: 0bbbabee51ef4a1e2676b5251d25bce45157be2d3f69e9c4e34ba82c3cddba779a6b9c247a5f3576444711d8333ba824bacaffc49d1c5b603aa4db521082c7e9
@@ -128,6 +128,8 @@ module KBSecret
128
128
  @type = self.class.type
129
129
  @data = { @type => body }
130
130
  @path = File.join(session.directory, "#{label}.json")
131
+
132
+ populate_internal_fields
131
133
  end
132
134
 
133
135
  # Fill in instance fields from a record's hash-representation.
@@ -178,6 +180,14 @@ module KBSecret
178
180
 
179
181
  File.write(path, JSON.pretty_generate(to_h))
180
182
  end
183
+
184
+ # Fill in any internal fields that require a default value.
185
+ # @return [void]
186
+ # @note This gets called at the end of {#initialize}, and should be overridden by children
187
+ # of {Abstract} if they need to modify their internal fields during initialization.
188
+ def populate_internal_fields
189
+ nil # stub
190
+ end
181
191
  end
182
192
  end
183
193
  end
@@ -9,14 +9,6 @@ module KBSecret
9
9
  data_field :variable, sensitive: false
10
10
  data_field :value
11
11
 
12
- # @param session [Session] the session to associate with
13
- # @param label [Symbol] the new record's label
14
- # @param variable [String] the new record's variable
15
- # @param value [String] the new record's value
16
- def initialize(session, label, variable, value)
17
- super(session, label, variable: variable.shellescape, value: value.shellescape)
18
- end
19
-
20
12
  # @return [String] a sh-style environment assignment
21
13
  def to_assignment
22
14
  "#{variable}=#{value}"
@@ -6,14 +6,6 @@ module KBSecret
6
6
  class Login < Abstract
7
7
  data_field :username, sensitive: false
8
8
  data_field :password
9
-
10
- # @param session [Session] the session to associate with
11
- # @param label [Symbol] the new record's label
12
- # @param user [String] the new record's username
13
- # @param pass [String] the new record's password
14
- def initialize(session, label, user, pass)
15
- super(session, label, username: user, password: pass)
16
- end
17
9
  end
18
10
  end
19
11
  end
@@ -6,14 +6,6 @@ module KBSecret
6
6
  class Snippet < Abstract
7
7
  data_field :code, sensitive: false
8
8
  data_field :description, sensitive: false
9
-
10
- # @param session [Session] the session to associate with
11
- # @param label [Symbol] the new record's label
12
- # @param code [String] the code
13
- # @param description [String] a description of the code
14
- def initialize(session, label, code, description)
15
- super(session, label, code: code, description: description)
16
- end
17
9
  end
18
10
  end
19
11
  end
@@ -21,11 +21,10 @@ module KBSecret
21
21
  data_field :start, sensitive: false, internal: true
22
22
  data_field :stop, sensitive: false, internal: true
23
23
 
24
- # @param session [Session] the session to associate with
25
- # @param label [Symbol] the new record's label
26
- # @param todo [String] the to do item
27
- def initialize(session, label, todo)
28
- super(session, label, todo: todo, status: "suspended", start: nil, stop: nil)
24
+ # @return [void]
25
+ # @see Abstract#populate_internal_fields
26
+ def populate_internal_fields
27
+ self.status = "suspended"
29
28
  end
30
29
 
31
30
  # @return [Boolean] whether or not the item is marked as started
@@ -5,13 +5,6 @@ module KBSecret
5
5
  # Represents a record containing unstructured text.
6
6
  class Unstructured < Abstract
7
7
  data_field :text, sensitive: false
8
-
9
- # @param session [Session] the session to associate with
10
- # @param label [Symbol] the new record's label
11
- # @param text [String] the new record's unstructured text
12
- def initialize(session, label, text)
13
- super(session, label, text: text)
14
- end
15
8
  end
16
9
  end
17
10
  end
@@ -63,11 +63,13 @@ module KBSecret
63
63
  # arguments does not match the record type's constructor
64
64
  def add_record(type, label, *args)
65
65
  klass = Record.class_for(type.to_sym)
66
- arity = klass.instance_method(:initialize).arity - 2
66
+ arity = klass.external_fields.length
67
67
 
68
68
  raise RecordCreationArityError.new(arity, args.size) unless arity == args.size
69
69
 
70
- record = klass.new(self, label.to_s, *args)
70
+ body = klass.external_fields.zip(args).to_h
71
+ record = klass.new(self, label.to_s, **body)
72
+
71
73
  records << record
72
74
  record.sync!
73
75
  end
data/lib/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module KBSecret
4
4
  # kbsecret's current version
5
- VERSION = "0.7.0.pre.3"
5
+ VERSION = "0.7.0"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kbsecret
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.pre.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
@@ -220,9 +220,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
220
220
  version: 2.3.0
221
221
  required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  requirements:
223
- - - ">"
223
+ - - ">="
224
224
  - !ruby/object:Gem::Version
225
- version: 1.3.1
225
+ version: '0'
226
226
  requirements: []
227
227
  rubyforge_project:
228
228
  rubygems_version: 2.6.11