sequel-asterisk-hunter 1.1.0 → 1.2.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: 184314bd889776102faf9c036f3bf27971a6c223eb58149a81d4c059dba9abb7
4
- data.tar.gz: f983c5d3722513396327fcb19881a2a3cbb7b155e5c51670ec2a5f359d9dddec
3
+ metadata.gz: a9879e4821cf6fb0be3d5b03c8fee2feaa388375460cc5db45133eb0d2bc3fe6
4
+ data.tar.gz: 7e92a385d101069ca0d0c1159cf40ea1bb61c9fd8b4072f60301c2c3b848ba3c
5
5
  SHA512:
6
- metadata.gz: ad5a7cf4369c55267de29faf95b522fb0b7c337d57c38a1d166dab94898a8660606b151b66c2823e8692c45b8a7f3276ba21509ef7efe46fcd52935d2582acf8
7
- data.tar.gz: 56a829e908a4ae83021d79499af11281ef7b18b6b194d48b36197bb95f321e3ce29bd0de6ce97f4ab51de8862d9a379f62d3bab5859171a715ec4d00aef867ad
6
+ metadata.gz: 7da834408353c984a343795de929fae7af77671f68617561d442b6d2ad49f45f41dfe4f4ae1fc17410a36b402d794de4e9f831389aa35f02b8ed93a68d2dde97
7
+ data.tar.gz: 9e16f7c16b044d0f8ae9dacc5b3e295289fe86134aed124e9639032f8555adbe48fbd986ba6ad0faab796701926616ddddc2e9db59694e5ecfb27858e9406a85
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 1.2.0 (2018.12.26)
2
+
3
+ - Change overriden method from `Sequel::Dataset#all` to `Sequel::Dataset#fetch_rows`, to hunt `SELECT *` statements for any query executed.
4
+ - Refactorings
5
+
6
+ ### 1.1.0 (2018.12.22)
7
+
8
+ - Override Sequel::Dataset#all to find for `SELECT *` statements.
9
+ - Add method to define an action to be called if a `SELECT *` statements is found.
10
+
1
11
  ### 1.0.1 (2018.12.21)
2
12
 
3
13
  - Fix extension name passed to method Dataset.register_extension.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SequelAsteriskHunter
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -1,27 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "sequel"
3
+ require 'sequel'
4
4
 
5
5
  module Sequel
6
6
  module Extensions
7
7
  module AsteriskHunter
8
- @@action = -> { puts "Find 'SELECT *' in query!" }
8
+ class << self
9
+ attr_accessor :action
9
10
 
10
- def all
11
- hunt
12
- super
11
+ def define_action(user_action)
12
+ raise TypeError, 'Action parameter must be a callable object!' unless user_action.respond_to?(:call)
13
+ AsteriskHunter.action = user_action
14
+ end
15
+ end
16
+
17
+ class DefaultAction
18
+ def self.call; end
19
+ def call; end
13
20
  end
14
21
 
15
- def self.define_action(action)
16
- raise TypeError, 'Action parameter must be a callable object!' unless action.respond_to?(:call)
17
- @@action = action
22
+ def fetch_rows(sql)
23
+ hunt(sql)
24
+ super
18
25
  end
19
26
 
20
27
  private
21
28
 
22
- def hunt
23
- @@action.call if self.inspect.include?('SELECT *')
24
- self
29
+ def hunt(sql)
30
+ AsteriskHunter.action&.call || AsteriskHunter::DefaultAction if sql.include?('SELECT *')
25
31
  end
26
32
  end
27
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-asterisk-hunter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danilo Barion Nogueira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-22 00:00:00.000000000 Z
11
+ date: 2018-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel