kbsecret 0.7.0.pre.1 → 0.7.0.pre.2

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: d6b4bbb559dfea85bc7b7d767db97dd609ec9117
4
- data.tar.gz: '009586cb565eb93ba6ea4d605527748dbb9d7ad5'
3
+ metadata.gz: 880375c3b35cffd81cc94adba77037fb59fdbeaa
4
+ data.tar.gz: 05c2e322dfe48b7fa3b526b32c7233d6778c0651
5
5
  SHA512:
6
- metadata.gz: 19a290acff300d2ff4b1f7bf5fe58bd94586fc1c05757aa53dc5126794e51bfd7ceafb5a2a309e557b1456ff9d01664d354602b6494104fc0a49937aa7b5821d
7
- data.tar.gz: aa0b5abe37669dfabbdc2f904aa5edd10e8b8144afbaab639d2504360339a30bd9b0a1b2539a82c08d3cef9cb63f5ca24d9838b4ae271f9fe1ec03c401681628
6
+ metadata.gz: 33a12d9bc5c28081e036a546ee05256dadfde708fe6dafd9ad211174cbf97f5efdd455e36f0b2d3a479a42aa4a46e920d88878c78bdab6bf461642032c8295d8
7
+ data.tar.gz: a068a60e73e107793ffee460cc86524f701a87dae2b4a987789f1d5f9c882a9a4284fd95b9dc532284f5c2769a15019b37cb5bb728fa640f9184252b72cbfe49
@@ -3,8 +3,8 @@
3
3
  require "keybase"
4
4
 
5
5
  require_relative "version"
6
- require_relative "kbsecret/config"
7
6
  require_relative "kbsecret/exceptions"
7
+ require_relative "kbsecret/config"
8
8
  require_relative "kbsecret/record"
9
9
  require_relative "kbsecret/session"
10
10
  require_relative "kbsecret/generator"
@@ -14,6 +14,20 @@ module KBSecret
14
14
  # @api private
15
15
  CONFIG_FILE = File.join(CONFIG_DIR, "config.yml").freeze
16
16
 
17
+ # Configuration facets used for method generation.
18
+ # @api private
19
+ CONFIG_FACETS = {
20
+ session: {
21
+ plural: :sessions,
22
+ except: SessionUnknownError,
23
+ },
24
+
25
+ generator: {
26
+ plural: :generators,
27
+ except: GeneratorUnknownError,
28
+ },
29
+ }.freeze
30
+
17
31
  # The default session configuration.
18
32
  DEFAULT_SESSION = {
19
33
  default: {
@@ -55,87 +69,73 @@ module KBSecret
55
69
  @config[key]
56
70
  end
57
71
 
58
- # Retrieve a session's configuration.
59
- # @param sess [String, Symbol] the session's label
60
- # @return [Hash] the session configuration
61
- # @raise [SessionUnknownError] if no such session exists
62
- def self.session(sess)
63
- hsh = @config[:sessions][sess.to_sym]
64
-
65
- raise SessionUnknownError, sess unless hsh
66
-
67
- hsh
68
- end
69
-
70
- # @return [Array<Symbol>] all configured session labels
71
- def self.session_labels
72
- @config[:sessions].keys
73
- end
74
-
75
- # @param sess [String, Symbol] the session label
76
- # @return [Boolean] whether or not the given session is configured
77
- def self.session?(sess)
78
- session_labels.include?(sess.to_sym)
79
- end
80
-
81
- # Configure a session.
82
- # @param label [String, Symbol] the session label
83
- # @param hsh [Hash] the session configuration
84
- # @return [void]
85
- def self.configure_session(label, hsh)
86
- @config[:sessions][label.to_sym] = hsh
87
- sync!
88
- end
89
-
90
- # Deconfigure a session.
91
- # @param label [String, Symbol] the session label
92
- # @return [void]
93
- # @note This only removes the given session from the configuration, making
94
- # it "invisible" to `kbsecret`. To actually remove all files associated
95
- # with a session, see {KBSecret::Session#unlink!}.
96
- def self.deconfigure_session(label)
97
- @config[:sessions].delete(label.to_sym)
98
- sync!
99
- end
100
-
101
- # Retrieve a generator's configuration.
102
- # @param gen [String, Symbol] the generator's label
103
- # @return [Hash] the generator configuration
104
- # @raise [GeneratorUnknownError] if no such generator exists
105
- def self.generator(gen)
106
- hsh = @config[:generators][gen.to_sym]
107
-
108
- raise GeneratorUnknownError, gen unless hsh
109
-
110
- hsh
111
- end
112
-
113
- # @return [Array<Symbol>] all configured session labels
114
- def self.generator_labels
115
- @config[:generators].keys
116
- end
117
-
118
- # @param gen [String, Symbol] the generator label
119
- # @return [Boolean] whether or not the given generator is configured
120
- def self.generator?(gen)
121
- generator_labels.include?(gen.to_sym)
122
- end
123
-
124
- # Configure a secret generator.
125
- # @param label [String, Symbol] the generator label (profile name)
126
- # @param hsh [Hash] the generator configuration
127
- # @return [void]
128
- def self.configure_generator(label, **hsh)
129
- @config[:generators][label.to_sym] = hsh
130
- sync!
131
- end
132
-
133
- # Deconfigure a generator.
134
- # @param label [String, Symbol] the generator label (profile name)
135
- # @return [void]
136
- def self.deconfigure_generator(label)
137
- @config[:generators].delete(label.to_sym)
138
- sync!
72
+ # @!method session
73
+ # Retrieve a session's configuration.
74
+ # @param label [String, Symbol] the session's label
75
+ # @return [Hash] the session configuration
76
+ # @raise [SessionUnknownError] if no such session exists
77
+ # @!method session_labels
78
+ # @return [Array<Symbol>] all configured session labels
79
+ # @!method session?
80
+ # @param label [String, Symbol] the session label
81
+ # @return [Boolean] whether or not the given session is configured
82
+ # @!method configure_session
83
+ # Configure a session.
84
+ # @param label [String, Symbol] the session label
85
+ # @param hsh [Hash] the session configuration
86
+ # @return [void]
87
+ # @!method deconfigure_session
88
+ # Deconfigure a session.
89
+ # @param label [String, Symbol] the session label
90
+ # @return [void]
91
+ # @note This only removes the given session from the configuration, making
92
+ # it "invisible" to `kbsecret`. To actually remove all files associated
93
+ # with a session, see {KBSecret::Session#unlink!}.
94
+ # @!method generator
95
+ # Retrieve a generator's configuration.
96
+ # @param gen [String, Symbol] the generator's label
97
+ # @return [Hash] the generator configuration
98
+ # @raise [GeneratorUnknownError] if no such generator exists
99
+ # @!method generator_labels
100
+ # @return [Array<Symbol>] all configured session labels
101
+ # @!method generator?
102
+ # @param gen [String, Symbol] the generator label
103
+ # @return [Boolean] whether or not the given generator is configured
104
+ # @!method configure_generator
105
+ # Configure a secret generator.
106
+ # @param label [String, Symbol] the generator label (profile name)
107
+ # @param hsh [Hash] the generator configuration
108
+ # @return [void]
109
+ # @!method deconfigure_generator
110
+ # Deconfigure a generator.
111
+ # @param label [String, Symbol] the generator label (profile name)
112
+ # @return [void]
113
+ CONFIG_FACETS.each do |facet, data|
114
+ define_singleton_method facet do |label|
115
+ hsh = @config[data[:plural]][label.to_sym]
116
+
117
+ raise data[:except], label unless hsh
118
+
119
+ hsh
120
+ end
121
+
122
+ define_singleton_method "#{facet}_labels" do
123
+ @config[data[:plural]].keys
124
+ end
125
+
126
+ define_singleton_method "#{facet}?" do |label|
127
+ @config[data[:plural]].keys.include? label.to_sym
128
+ end
129
+
130
+ define_singleton_method "configure_#{facet}" do |label, **hsh|
131
+ @config[data[:plural]][label.to_sym] = hsh
132
+ sync!
133
+ end
134
+
135
+ define_singleton_method "deconfigure_#{facet}" do |label|
136
+ @config[data[:plural]].delete(label.to_sym)
137
+ sync!
138
+ end
139
139
  end
140
140
 
141
141
  if File.exist?(CONFIG_FILE)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module KBSecret
4
4
  # kbsecret's current version
5
- VERSION = "0.7.0.pre.1"
5
+ VERSION = "0.7.0.pre.2"
6
6
  end
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.7.0.pre.1
4
+ version: 0.7.0.pre.2
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-07-10 00:00:00.000000000 Z
11
+ date: 2017-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fpm