hairtrigger 0.2.24 → 0.2.25

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
- SHA1:
3
- metadata.gz: b3a4b255f8184decc442a9c455f5b8a5a5c9bd48
4
- data.tar.gz: b6c202c7328de121c67161cc4d31d83926076044
2
+ SHA256:
3
+ metadata.gz: 0537ad012af8bad34a62b81241c8517ac38fabeae279954e3e27ecc86e89cc9a
4
+ data.tar.gz: fe75190bc7fb5b8d2956929f5e72d2b48b0dbc81b5bdd27eac6fd48ccedf81cb
5
5
  SHA512:
6
- metadata.gz: 5eb6f48db749f2841ee9a0b986dbaf9cf2d93f48f687822e8a6dda52c90e45165fba783510e7fb1e5ec8a490ce4a6dd58df5f2ebd04567e3d2839f87ef82815f
7
- data.tar.gz: c8eebfc8a7a45d4987f1d6ea5281a06c333a4eee929830a73a78521c442983b1743f14a4f677fb31de9d4a7ce6b144f67000f84cd7c068d08160ef260bb815cf
6
+ metadata.gz: f8df4419131442b648d2ed1a8315281e5d289638a228cf112882faacbcc27ebf5ca136474d1bf34d2b84e920187b23ec42365de67d1856112aa2449413571b52
7
+ data.tar.gz: 97193387286d4ed659612eca3d4d4a3266965f259a95c15494a627e494904d7a48c3b40a705455400aa5fb65bb90219a1485fd5494d8f006b472e8ac690eca6e
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2015 Jon Jensen
1
+ Copyright (c) 2011-2022 Jon Jensen
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # HairTrigger
2
- [<img src="https://secure.travis-ci.org/jenseng/hair_trigger.svg?branch=master" />](http://travis-ci.org/jenseng/hair_trigger)
2
+ [<img src="https://github.com/jenseng/hair_trigger/workflows/CI/badge.svg" />](https://github.com/jenseng/hair_trigger/actions?query=workflow%3ACI)
3
3
 
4
4
  HairTrigger lets you create and manage database triggers in a concise,
5
5
  db-agnostic, Rails-y way. You declare triggers right in your models in Ruby,
@@ -101,10 +101,10 @@ Only fire the update trigger if at least one of the columns is specified in the
101
101
  Permissions/role to check when calling trigger. PostgreSQL supports `:invoker` (default) and `:definer`, MySQL supports `:definer` (default) and arbitrary users (syntax: `'user'@'host'`).
102
102
 
103
103
  #### timing(timing)
104
- Required (but may be satisified by `before`/`after`). Possible values are `:before`/`:after`.
104
+ Required (but may be satisfied by `before`/`after`). Possible values are `:before`/`:after`.
105
105
 
106
106
  #### events(*events)
107
- Required (but may be satisified by `before`/`after`). Possible values are `:insert`/`:update`/`:delete`/`:truncate`. MySQL/SQLite only support one action per trigger, and don't support `:truncate`.
107
+ Required (but may be satisfied by `before`/`after`). Possible values are `:insert`/`:update`/`:delete`/`:truncate`. MySQL/SQLite only support one action per trigger, and don't support `:truncate`.
108
108
 
109
109
  #### nowrap(flag = true)
110
110
  PostgreSQL-specific option to prevent the trigger action from being wrapped in a `CREATE FUNCTION`. This is useful for executing existing triggers/functions directly, but is not compatible with the `security` setting nor can it be used with pre-9.0 PostgreSQL when supplying a `where` condition.
@@ -240,6 +240,21 @@ As long as you don't delete old migrations and schema.rb prior to running
240
240
  If you have deleted all trigger migrations, you can regenerate a new
241
241
  baseline for model triggers via `rake db:generate_trigger_migration`.
242
242
 
243
+ ### Filtering
244
+
245
+ It is possible to filter which triggers are dumped by setting any of these
246
+ configuration values:
247
+
248
+ ```ruby
249
+ HairTrigger::SchemaDumper::Configuration.ignore_triggers = 'exact_trigger_name'
250
+ HairTrigger::SchemaDumper::Configuration.ignore_tables = [/partial_/, 'exact_table_name']
251
+ HairTrigger::SchemaDumper::Configuration.allow_triggers = [/partial_/, 'exact_trigger_name']
252
+ HairTrigger::SchemaDumper::Configuration.allow_tables = 'exact_table_name'
253
+ ```
254
+
255
+ Each option can accept a single String or Regexp, or a mixed array of both.
256
+
257
+
243
258
  ## Testing
244
259
 
245
260
  To stay on top of things, it's strongly recommended that you add a test or
@@ -327,10 +342,10 @@ gem in years 😬) but am happy to take contributions. If I'm slow to respond, d
327
342
  hesitate to @ me repeatedly, sometimes those github notifications slip through
328
343
  the cracks. 😆.
329
344
 
330
- If you want to add a feature/bugfix, you can rely on Travis to run the tests, but
331
- do also run them locally (especially if you are changing supported railses/etc).
332
- HairTrigger uses [appraisal](https://github.com/thoughtbot/appraisal) to manage all
333
- that w/ automagical gemfiles. So the tl;dr when testing locally is:
345
+ If you want to add a feature/bugfix, you can rely on Github Actions to run the
346
+ tests, but do also run them locally (especially if you are changing supported
347
+ railses/etc). HairTrigger uses [appraisal](https://github.com/thoughtbot/appraisal)
348
+ to manage all that w/ automagical gemfiles. So the tl;dr when testing locally is:
334
349
 
335
350
  1. make sure you have mysql and postgres installed (homebrew or whatever)
336
351
  2. `bundle exec appraisal install` -- get all the dependencies
@@ -348,4 +363,4 @@ that w/ automagical gemfiles. So the tl;dr when testing locally is:
348
363
 
349
364
  ## Copyright
350
365
 
351
- Copyright (c) 2011-2021 Jon Jensen. See LICENSE.txt for further details.
366
+ Copyright (c) 2011-2022 Jon Jensen. See LICENSE.txt for further details.
@@ -1,5 +1,12 @@
1
1
  module HairTrigger
2
2
  module SchemaDumper
3
+ module Configuration
4
+ mattr_accessor :allow_tables
5
+ mattr_accessor :allow_triggers
6
+ mattr_accessor :ignore_tables
7
+ mattr_accessor :ignore_triggers
8
+ end
9
+
3
10
  module TrailerWithTriggersSupport
4
11
  def trailer(stream)
5
12
  orig_show_warnings = Builder.show_warnings
@@ -91,9 +98,35 @@ module HairTrigger
91
98
  end
92
99
 
93
100
  def whitelist_triggers(triggers)
94
- triggers.reject do |name, source|
101
+ triggers = triggers.reject do |name, source|
95
102
  ActiveRecord::SchemaDumper.ignore_tables.any? { |ignored_table_name| source =~ /ON\s+#{@connection.quote_table_name(ignored_table_name)}\s/ }
96
103
  end
104
+
105
+ if Configuration.allow_tables.present?
106
+ triggers = triggers.select do |name, source|
107
+ Array(Configuration.allow_tables).any? { |allowed_table_name| source =~ /ON\s+#{@connection.quote_table_name(allowed_table_name)}\s/ }
108
+ end
109
+ end
110
+
111
+ if Configuration.allow_triggers.present?
112
+ triggers = triggers.select do |name, source|
113
+ Array(Configuration.allow_triggers).any? { |allowed_trigger_name| allowed_trigger_name === name } # Triple equals to allow regexps or strings as allowed_trigger_name
114
+ end
115
+ end
116
+
117
+ if Configuration.ignore_tables.present?
118
+ triggers = triggers.reject do |name, source|
119
+ Array(Configuration.ignore_tables).any? { |allowed_table_name| source =~ /ON\s+#{@connection.quote_table_name(allowed_table_name)}\s/ }
120
+ end
121
+ end
122
+
123
+ if Configuration.ignore_triggers.present?
124
+ triggers = triggers.reject do |name, source|
125
+ Array(Configuration.ignore_triggers).any? { |allowed_trigger_name| allowed_trigger_name === name } # Triple equals to allow regexps or strings as allowed_trigger_name
126
+ end
127
+ end
128
+
129
+ triggers
97
130
  end
98
131
 
99
132
  def self.included(base)
@@ -1,5 +1,5 @@
1
1
  module HairTrigger
2
- VERSION = "0.2.24"
2
+ VERSION = "0.2.25"
3
3
 
4
4
  def VERSION.<=>(other)
5
5
  split(/\./).map(&:to_i) <=> other.split(/\./).map(&:to_i)
data/lib/hair_trigger.rb CHANGED
@@ -62,7 +62,7 @@ module HairTrigger
62
62
  options[:skip_pending_migrations] = true
63
63
  end
64
64
 
65
- # if we're in a db:schema:dump task (explict or kicked off by db:migrate),
65
+ # if we're in a db:schema:dump task (explicit or kicked off by db:migrate),
66
66
  # we evaluate the previous schema.rb (if it exists), and then all applied
67
67
  # migrations in order (even ones older than schema.rb). this ensures we
68
68
  # handle db:migrate:down scenarios correctly
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hairtrigger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.24
4
+ version: 0.2.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Jensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-01 00:00:00.000000000 Z
11
+ date: 2022-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: ruby_parser
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -98,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.5.2.3
101
+ rubygems_version: 3.0.3
103
102
  signing_key:
104
103
  specification_version: 4
105
104
  summary: easy database triggers for active record