checken 0.0.3 → 0.0.4

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
  SHA256:
3
- metadata.gz: 6bdb1baf6e0ae23735e7a39a8887f8763d547ebc1729c9988db95933dce08f72
4
- data.tar.gz: 689ace3710457f53b88a7928b02f48791ccd36d7054079de5b2faab99b50c4e7
3
+ metadata.gz: 26f7fc494eacd3729c46774a936ba735a317c2835f7df07abf3920afe3cbf792
4
+ data.tar.gz: 5d449e1b99a7fe53e366796c13ad73d09ca332115b770ab6dbac0e04ba709ead
5
5
  SHA512:
6
- metadata.gz: a0c04c549042a1d9049a86aa485b2195af46fd2b92f68da4546455a3c180518a68c7f0135b247e24b4a49761686b2009bad89d650a3523bc52cc8fd629360145
7
- data.tar.gz: 65b881ddbff40c87d633da457f02f925781442a13b45f648777574be0c7a5ed8cd781f1966b6c647e6d04e4c731a2d612e76f9a09bf4370d456941d4310c6745
6
+ metadata.gz: 83c122e8c10a61bfab0a0da4709cc7fbe9241514398b7d1e90a88b8ceecf24a8be0864dd29de0e819f799a5ae3b23544ac18bcbcf493bee04eb69a210d7c5b71
7
+ data.tar.gz: fbea10f7112b0e37480e50a33480a93c5dc91732735c1c1f477009b87b45c00ec1b7ba173462f6ac14b068cb7e1bf0621a5dd975faf186dc81e3d77ce906a06b
@@ -36,6 +36,7 @@ module Checken
36
36
  def group(key, &block)
37
37
  sub_group = @group.groups[key.to_sym] || @group.add_group(key.to_sym)
38
38
  sub_group.dsl(:active_sets => active_sets, &block) if block_given?
39
+ sub_group.update_schema
39
40
  sub_group
40
41
  end
41
42
 
@@ -66,6 +67,7 @@ module Checken
66
67
  end
67
68
 
68
69
  permission.dsl(&block) if block_given?
70
+ permission.update_schema
69
71
  permission
70
72
  end
71
73
 
@@ -295,5 +295,19 @@ module Checken
295
295
  end.flatten
296
296
  end
297
297
 
298
+ def update_schema
299
+ return if path.nil?
300
+
301
+ group.schema.update_schema(
302
+ {
303
+ path => {
304
+ type: :permission,
305
+ description: description,
306
+ group: group.path
307
+ }
308
+ }
309
+ )
310
+ end
311
+
298
312
  end
299
313
  end
@@ -165,5 +165,20 @@ module Checken
165
165
  dsl
166
166
  end
167
167
 
168
+ def update_schema
169
+ return if path.nil?
170
+
171
+ schema.update_schema(
172
+ {
173
+ path => {
174
+ type: :group,
175
+ name: name,
176
+ description: description,
177
+ group: group&.path
178
+ }
179
+ }
180
+ )
181
+ end
182
+
168
183
  end
169
184
  end
@@ -19,6 +19,7 @@ module Checken
19
19
  def initialize
20
20
  @root_group = PermissionGroup.new(self, nil)
21
21
  @config = Config.new
22
+ @schema = {}
22
23
  end
23
24
 
24
25
  # Add configuration for this schema
@@ -128,5 +129,20 @@ module Checken
128
129
  @config.logger
129
130
  end
130
131
 
132
+ # Update the schema with the given entry
133
+ #
134
+ # @param entry [Hash]
135
+ # @return [Hash]
136
+ def update_schema(entry)
137
+ @schema.merge!(entry)
138
+ end
139
+
140
+ # Return the schema sorted alphabetically by key
141
+ #
142
+ # @return [Hash]
143
+ def schema
144
+ @schema.sort.to_h
145
+ end
146
+
131
147
  end
132
148
  end
@@ -1,3 +1,3 @@
1
1
  module Checken
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checken
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
  - Adam Cooke