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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ivalidate +25 -1
  3. data/lib/idata/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 819b2d2fdfbb0c55e7e0fad65c6bbdb28c5e5b5d
4
- data.tar.gz: 553beaa45ad12795547c87902c18d6d44da58a34
3
+ metadata.gz: 88055107e664ebd906f326d17d66565c7ada1048
4
+ data.tar.gz: 7ee59a09d1c8328f3f479f04c521ceb7ab675ea2
5
5
  SHA512:
6
- metadata.gz: c3e289852ac767f0948e5f835cb0bf937309699c9e6d04ac50386888327de5abc1cfe8465a8ff403f5695bced3ad45e7b5e06f4bbdf91b16a4f4fc2d55c0133f
7
- data.tar.gz: 5fad9fdd602ad71e584e98b0dea174dfa74f9027be7d3d7cac00be55f7f6c231218a7480bcfdbfb948e7b9fdc228db5bb083e13be193b974b8392f2d73d010ed
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
@@ -1,3 +1,3 @@
1
1
  module Idata
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nghi Pham