mikras_utils 0.10.1 → 0.11.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
  SHA256:
3
- metadata.gz: 664cc0291b18e0f9068704c14f3e65adb808c099510b0334684a3b5a13a0d83a
4
- data.tar.gz: 1e372dae3fb50ada2eb071a5d4b679777cb159b43db1e71a343e02802f279771
3
+ metadata.gz: d40acc7f4c2837481e47b7f46cc1dbcb79af1259fbafc8ad48284592da8f585e
4
+ data.tar.gz: 7d1a196b2b3a56394c7359877386eb4fd4cd7c5e54867754c2b8d94d9f51582a
5
5
  SHA512:
6
- metadata.gz: 195f1c258a5e54092eae258420f850b8719ea7bc3e2d5ebbba3ffb2cf8ec813d008dc0e0ba8263f0383064914c0dc96267c7652b5a052008c307824c2f76bca2
7
- data.tar.gz: 5827e7fdaa3d2888b341b4a1d70d4d2a42b3890ab00b090747556e3a85d8b459418a3b669302b6ed53b7392911680f833e5c01938831182f9ecfe02627bcdf7f
6
+ metadata.gz: 4134754e87c32513569e8f2050da0fb0ce9518cb0ab17a105c84e48a55449a5de59389a0e5a711e6076fb6228f8d471dbe03b3ff1a1a665b63b242787737a7f8
7
+ data.tar.gz: f84cbcdf08dab513d0dcc8a129e122444ccf46b6e5018012ce8f944660b48d2346f80e4b8aa2f3e4c4f72d9210e8e5c55176de5cd2b17659a4b6e5aaa9087cb1
@@ -21,6 +21,7 @@ module MkAcl
21
21
  private
22
22
  def clean_tables
23
23
  puts %(
24
+ delete from acl_portal.acl_timestamps;
24
25
  delete from acl_portal.acl_rules;
25
26
  delete from acl_portal.acl_actions;
26
27
  delete from acl_portal.acl_tables;
@@ -68,8 +69,13 @@ module MkAcl
68
69
 
69
70
  action.timestamps.each { |timestamp|
70
71
  puts %(
71
- insert into acl_portal.acl_timestamps (action_id, watch, stamp)
72
- values (:action_id, #{conn.quote_value(timestamp.watch)}, '#{timestamp.stamp}');
72
+ insert into acl_portal.acl_timestamps (action_id, watch, assign, stamp)
73
+ values (
74
+ :action_id,
75
+ #{conn.quote_value(timestamp.watch)},
76
+ #{conn.quote_value(timestamp.assign)},
77
+ #{conn.quote_value(timestamp.stamp)}
78
+ );
73
79
  ).align
74
80
  puts
75
81
  }
@@ -88,14 +88,23 @@ module MkAcl
88
88
  case timestamps
89
89
  when String
90
90
  timestamps.split.each { |watch_field|
91
- Timestamp.new(table, watch_field)
91
+ case watch_field
92
+ when /^(.*)(?:_by_id|_to_id)$/
93
+ Timestamp.new(table, watch_field, nil, "#{$1}_at")
94
+ when /^(created|updated|deleted)_at$/
95
+ Timestamp.new(table, nil, "#{$1}_by_id", watch_field)
96
+ else
97
+ raise ArgumentError, "Illegal timestamp specifier: #{watch_field.inspect}"
98
+ end
92
99
  }
100
+
93
101
  when Array
94
102
  for entry in timestamps
95
103
  timestamp = Timestamp.new(table)
96
104
  for key, value in entry
97
105
  case key
98
106
  when :watch; timestamp.watch = value
107
+ when :assign; timestamp.assign = value
99
108
  when :stamp; timestamp.stamp = value
100
109
  else
101
110
  error "Illegal field '#{key}' in #{table} timestamps"
@@ -188,24 +188,16 @@ module MkAcl
188
188
  attr_reader :action
189
189
  forward_to :action, :table, :name
190
190
  attr_accessor :watch
191
+ attr_accessor :assign
191
192
  attr_accessor :stamp
192
193
 
193
- def created_at?() = watch == "insert"
194
- def updated_at?() = watch == "update"
195
- def deleted_at?() = watch == "delete"
194
+ # def created_at?() = watch == "insert"
195
+ # def updated_at?() = watch == "update"
196
+ # def deleted_at?() = watch == "delete"
196
197
 
197
- def initialize(action, watch = nil, stamp = nil)
198
+ def initialize(action, watch = nil, assign = nil, stamp = nil)
198
199
  @action = action
199
-
200
- case watch
201
- when /^(.*)(?:_by_id|_to_id)$/
202
- @watch, @stamp = watch, stamp || "#{$1}_at"
203
- when "created_at", "updated_at", "deleted_at"
204
- @watch, @stamp = nil, watch
205
- else
206
- @watch, @stamp = watch, stamp
207
- end
208
-
200
+ @watch, @assign, @stamp = watch, assign, stamp
209
201
  action.send :attach_timestamp, self
210
202
  end
211
203
 
@@ -213,6 +205,7 @@ module MkAcl
213
205
 
214
206
  def dump
215
207
  puts "watch: #{watch}"
208
+ puts "watch: #{assign}"
216
209
  puts "stamp: #{stamp}"
217
210
  end
218
211
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MikrasUtils
4
- VERSION = "0.10.1"
4
+ VERSION = "0.11.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mikras_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen