idata 0.1.0 → 0.1.1
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 +4 -4
- data/bin/ivalidate +25 -1
- data/lib/idata/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88055107e664ebd906f326d17d66565c7ada1048
|
4
|
+
data.tar.gz: 7ee59a09d1c8328f3f479f04c521ceb7ab675ea2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d05abf741cb5b6cf44eaeb49a2992739ad5805174cbdb655383e1856791f37e8429893a76b4620f8267c33860085fb19caf7dce27266a96edeec20fde7a3733a
|
7
|
+
data.tar.gz: 8020ab90eb44d7ff467f06c102de45fa60d34465ad31855f244245c620a202085b021788be9ae7c823549a513f690e915cf4c3e38b41ac04d172e61f6d325b36
|
data/bin/ivalidate
CHANGED
@@ -22,7 +22,8 @@ $options = {
|
|
22
22
|
:not_null => [],
|
23
23
|
:match => [],
|
24
24
|
:not_match => [],
|
25
|
-
:cross_reference => []
|
25
|
+
:cross_reference => [],
|
26
|
+
:query => []
|
26
27
|
}
|
27
28
|
parser = OptionParser.new("", 24) do |opts|
|
28
29
|
opts.banner = "\nProgram: Data Validator\nAuthor: MCKI\n\n"
|
@@ -46,6 +47,10 @@ parser = OptionParser.new("", 24) do |opts|
|
|
46
47
|
opts.on("--cross-reference EXPR", "Reference") do |v|
|
47
48
|
$options[:cross_reference] << v
|
48
49
|
end
|
50
|
+
|
51
|
+
opts.on("--query QUERY", "Custom query") do |v|
|
52
|
+
$options[:query] << v
|
53
|
+
end
|
49
54
|
|
50
55
|
opts.on("-t", "--table TABLE", "Table to verify") do |v|
|
51
56
|
$options[:table] = v
|
@@ -256,3 +261,22 @@ $options[:cross_reference].each do |value|
|
|
256
261
|
|
257
262
|
ActiveRecord::Base.connection.execute(ref_sql)
|
258
263
|
end
|
264
|
+
|
265
|
+
# --------------------------------------------------------------------
|
266
|
+
# Custom validation
|
267
|
+
# --------------------------------------------------------------------
|
268
|
+
$options[:query].each do |query|
|
269
|
+
puts "Checking with custom query: #{query}"
|
270
|
+
|
271
|
+
# @todo: poor performance here, think of a better SQL!!!
|
272
|
+
custom_sql = <<-eos
|
273
|
+
UPDATE #{$options[:table]} SET #{$options[:log_to]} = array_to_string(string_to_array(#{$options[:log_to]}, ' || ') || string_to_array('custom-validation', ' || '), ' || ')
|
274
|
+
WHERE NOT #{query}
|
275
|
+
eos
|
276
|
+
|
277
|
+
ActiveRecord::Base.connection.execute(custom_sql)
|
278
|
+
end
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
data/lib/idata/version.rb
CHANGED