junk_drawer 1.6.3 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c19a96b9707d53151fb3edf626ce443ad60cb4503ac75b108bd46eb6d7694f54
4
- data.tar.gz: a4e87efeacae9353c7784dbad2a47294292b088c39fb50f5ad387dec2a8dcaa9
3
+ metadata.gz: 3530e5bd07d747b2cd7d34ffe7b48df7833f031a1f5dc43ee9c803b1422bff7d
4
+ data.tar.gz: 9abd08c0735f544d9e065b62df069a854e4e3411b3c3252b906c5a1682fdcece
5
5
  SHA512:
6
- metadata.gz: 19a935285fd80b81d4d7c432f1775196032f766bdc78df61967b504d433566be1a36e04992c6266466fc5c480ff69aaef4edf21705ef48e6d9fbd4d9cfa0fffa
7
- data.tar.gz: 2ad821ea7cc213f62c55bd07e96394fe1ea3618684bc13dea806cf83bb94cae883dc8bc392dd988e6ee1f6d80dfdf8e91459fb1907a58666ebca919fe50daa75
6
+ metadata.gz: 349d50e5b1fe6c431fedb262a1736e922110ec414388b7efc43f73d348e0788be2f9535ffede6482eb25f2838b5aaedd7cc419da2874623df8fc71cd345b7737
7
+ data.tar.gz: f8621c8eac83068c5e6d7efc832501cac8e2bb1d06ac7d3efdf729313400e83da01863c3a38e3a6cbd8e4ba9f8bfda24f7cf76e7e7fb57357ed8d59a1f3f6d57
@@ -0,0 +1,52 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby: [2.4, 2.5, 2.6, 2.7]
15
+ postgres: [10, 11, 12, 13, 14]
16
+ name: Ruby ${{ matrix.ruby }} x Postgres ${{ matrix.postgres }}
17
+
18
+ services:
19
+ postgres:
20
+ image: postgres:${{ matrix.postgres }}
21
+ env:
22
+ POSTGRES_DB: junk_drawer_test
23
+ POSTGRES_USER: postgres
24
+ POSTGRES_PASSWORD: postgres
25
+ options: >-
26
+ --health-cmd pg_isready
27
+ --health-interval 10s
28
+ --health-timeout 5s
29
+ --health-retries 5
30
+ ports:
31
+ - 5432:5432
32
+
33
+ steps:
34
+ - uses: actions/checkout@v2
35
+
36
+ - name: Setup Ruby
37
+ uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{ matrix.ruby }}
40
+ bundler-cache: true
41
+
42
+ - name: Install dependencies
43
+ run: bundle install
44
+
45
+ - name: Run linters
46
+ run: bundle exec rubocop
47
+
48
+ - name: Run unit tests
49
+ run: bundle exec rake
50
+
51
+ - name: Build gem
52
+ run: bundle exec rake build
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /pkg/
9
9
  /spec/reports/
10
10
  /tmp/
11
+ vendor/
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'activerecord', '~> 5.1.0'
8
- gem 'activesupport', '~> 5.1.0'
7
+ gem 'activerecord', '~> 5.2.0'
8
+ gem 'activesupport', '~> 5.2.0'
9
9
  gem 'hstore_accessor', '~> 1.1.1'
10
- gem 'jsonb_accessor', '~> 1.0.0'
10
+ gem 'jsonb_accessor', '~> 1.3.6'
data/README.md CHANGED
@@ -27,9 +27,18 @@ gem 'junk_drawer', require: 'junk_drawer/rails'
27
27
 
28
28
  ### Contents
29
29
 
30
- - [JunkDrawer::Callable](#junkdrawercallable)
31
- - [JunkDrawer::Notifier](#junkdrawernotifier)
32
- - [JunkDrawer::BulkUpdatable](#junkdrawerbulkupdatable)
30
+ - [JunkDrawer](#junkdrawer)
31
+ - [Installation](#installation)
32
+ - [Contents](#contents)
33
+ - [Usage](#usage)
34
+ - [JunkDrawer::Callable](#junkdrawercallable)
35
+ - [JunkDrawer::Notifier](#junkdrawernotifier)
36
+ - [Rails](#rails)
37
+ - [JunkDrawer::BulkUpdatable](#junkdrawerbulkupdatable)
38
+ - [Caveats](#caveats)
39
+ - [Development](#development)
40
+ - [Contributing](#contributing)
41
+ - [License](#license)
33
42
 
34
43
  ## Usage
35
44
 
@@ -129,6 +138,28 @@ your selected strategy. The strategies available are as follows:
129
138
  3) `:null` is a noop. If you want to disable notifications temporarily, you can
130
139
  configure the strategy to `:null`.
131
140
 
141
+ 4) To create your own custom notifier, configure `JunkDrawer::Notifier` with
142
+ a callable object as the strategy.
143
+
144
+ ```ruby
145
+ class MyNotifier
146
+ include JunkDrawer::Callable
147
+
148
+ def call(*args)
149
+ SomeMonitoringService.notify(*args)
150
+ end
151
+ end
152
+
153
+ JunkDrawer::Notifier.strategy = MyNotifier
154
+ ```
155
+
156
+ ```ruby
157
+ JunkDrawer::Notifier.strategy = ->(*args) {
158
+ MonitoringServiceA.notify(*args)
159
+ MonitoringServiceB.notify(*args)
160
+ }
161
+ ```
162
+
132
163
  If you're using Rails, you may want to configure `Notifier` based on the
133
164
  environment, so in your `config/environments/development.rb` you might have:
134
165
 
@@ -12,7 +12,12 @@ module JunkDrawer
12
12
 
13
13
  class << self
14
14
 
15
- attr_accessor :strategy
15
+ attr_reader :strategy
16
+
17
+ def strategy=(strategy)
18
+ @strategy =
19
+ strategy.is_a?(Symbol) ? STRATEGIES.fetch(strategy) : strategy
20
+ end
16
21
 
17
22
  end
18
23
 
@@ -23,13 +28,7 @@ module JunkDrawer
23
28
  }.freeze
24
29
 
25
30
  def call(*args)
26
- strategy.(*args)
27
- end
28
-
29
- private
30
-
31
- def strategy
32
- STRATEGIES.fetch(self.class.strategy)
31
+ self.class.strategy.(*args)
33
32
  end
34
33
 
35
34
  end
@@ -15,7 +15,7 @@ module JunkDrawer
15
15
  changed_attributes = extract_changed_attributes(unique_objects)
16
16
  query = build_query_for(unique_objects, changed_attributes)
17
17
  connection.execute(query)
18
- objects.each(&:clear_changes_information)
18
+ objects.each(&:changes_applied)
19
19
  end
20
20
 
21
21
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JunkDrawer
4
- VERSION = '1.6.3'
4
+ VERSION = '1.8.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junk_drawer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fletcher
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-24 00:00:00.000000000 Z
11
+ date: 2022-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2_keywords
@@ -192,17 +192,17 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '2.0'
195
- description:
195
+ description:
196
196
  email:
197
197
  - lobatifricha@gmail.com
198
198
  executables: []
199
199
  extensions: []
200
200
  extra_rdoc_files: []
201
201
  files:
202
+ - ".github/workflows/ruby.yml"
202
203
  - ".gitignore"
203
204
  - ".rspec"
204
205
  - ".rubocop.yml"
205
- - ".travis.yml"
206
206
  - CODE_OF_CONDUCT.md
207
207
  - Gemfile
208
208
  - Guardfile
@@ -228,7 +228,7 @@ homepage: https://github.com/thread-pond/junk_drawer
228
228
  licenses:
229
229
  - MIT
230
230
  metadata: {}
231
- post_install_message:
231
+ post_install_message:
232
232
  rdoc_options: []
233
233
  require_paths:
234
234
  - lib
@@ -243,8 +243,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  - !ruby/object:Gem::Version
244
244
  version: '0'
245
245
  requirements: []
246
- rubygems_version: 3.1.4
247
- signing_key:
246
+ rubygems_version: 3.2.32
247
+ signing_key:
248
248
  specification_version: 4
249
249
  summary: random useful Ruby utilities
250
250
  test_files: []
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3
5
- - 2.4
6
- - 2.5
7
- - 2.6
8
- - 2.7
9
- addons:
10
- postgresql: '9.4'
11
- before_install: gem install bundler -v 2.0.2
12
- before_script:
13
- - createdb junk_drawer_test -U postgres
14
- script:
15
- - bundle exec rubocop
16
- - bundle exec rake
17
- - bundle exec rake build
18
- gemfile:
19
- - Gemfile
20
- - gemfiles/rails_5.0.gems
21
- - gemfiles/rails_4.2.gems