umbrellio-sequel-plugins 0.1.2 → 0.2.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: b4759b5161f25540a10d6187723f49b818962df36a7a70a1fe418cb4b83c6911
4
- data.tar.gz: b04c02c79c7df1d0b70560b211a2d0c175f77b4a000a35ce54d83459594a7c05
3
+ metadata.gz: bf3b1166dd9d29321aadcca70c8fc6b9d0b5fc2ffb470fe07d7878a8dbd71295
4
+ data.tar.gz: 4a5fa36a6f4331a4d8c65a81a921541aa37e47b7bfa4739a74311d6b920924ce
5
5
  SHA512:
6
- metadata.gz: 3bfaa7ddd25b8775c0c1b5f294d10ab85b0a0180fe97cc9509155dc3fef351398073d59a457d8903ce47a602ca38fd201a484f725791f33f4061a260984ef094
7
- data.tar.gz: c01ef3d4b98e62d9780a24992a11a8ce5c047ea91bd5aaa1b4ffea392946e2f0fd9bbac23cc9f2f208e2051c950edbd15ef8a7313dba2b4c830e6514597c3fbf
6
+ metadata.gz: 8baa855e0de9fe3efe2aee03950da764959a7ef2458981802b9386548450656aabfd6b3363892884914295e62ab1fca6c745a07b16eba9d3c740f277ccb88a19
7
+ data.tar.gz: 7630f90fe06cdfd4f5bc53e30694fc808a9e004c774c5d58f5a6b97c5d92c45c4a88a17c76f0de1e51e1a61307bebae94ce741f4f65e76dfefecf05f898c1eb6
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ ## [0.2.0] 2018-03-28
5
+ ### Added
6
+ - `Sequel.extension(:methods_in_migrations)` - support for method definitions in `Sequel.migration` instructions;
data/README.md CHANGED
@@ -17,22 +17,23 @@ And then execute:
17
17
 
18
18
  # Extensions
19
19
 
20
- - CurrencyRates
21
- - PGTools
22
- - Slave
23
- - Synchronize
20
+ - `CurrencyRates`
21
+ - `PGTools`
22
+ - `Slave`
23
+ - `Synchronize`
24
+ - `methods_in_migrations`
24
25
 
25
26
  # Plugins
26
27
 
27
- - Duplicate
28
- - GetColumnValue
29
- - StoreAccessors
30
- - Synchronize
31
- - Upsert
32
- - WithLock
28
+ - `Duplicate`
29
+ - `GetColumnValue`
30
+ - `StoreAccessors`
31
+ - `Synchronize`
32
+ - `Upsert`
33
+ - `WithLock`
33
34
 
34
35
  # Tools
35
- - TimestampMigratorUndoExtension
36
+ - `TimestampMigratorUndoExtension`
36
37
 
37
38
  ## CurrencyRates
38
39
 
@@ -121,6 +122,32 @@ DB.synchronize_with([:ruby, :forever]) { p "Hey, I'm in transaction!"; sleep 5 }
121
122
  # => COMMIT
122
123
  ```
123
124
 
125
+ ## Methods in Migrations
126
+
127
+ Enable: `Sequel.extension(:methods_in_migrations)`
128
+
129
+ Support for method definitions and invocations inside `Sequel.migration`.
130
+
131
+ Example:
132
+
133
+ ```ruby
134
+ Sequel.extension(:methods_in_migrations)
135
+
136
+ Sequel.migration do
137
+ # define
138
+ def get_data
139
+ # ...some code...
140
+ end
141
+
142
+ # use
143
+ up { get_data }
144
+ down { get_data }
145
+
146
+ # without extension:
147
+ # => NameError: undefined local variable or method `get_data' for #<Sequel::Postgres::Database>
148
+ end
149
+ ```
150
+
124
151
  ## Duplicate
125
152
 
126
153
  Enable: `Sequel::Model.plugin :duplicate`
@@ -180,14 +207,14 @@ user.data # => {"first_name": "John"}
180
207
 
181
208
  Same as `DB#synchronize_with`
182
209
 
183
- Enable:
210
+ Enable:
184
211
 
185
212
  ```ruby
186
213
  DB.extension :synchronize
187
214
  Sequel::Model.plugin :synchronize
188
215
  ```
189
216
 
190
- Example:
217
+ Example:
191
218
 
192
219
  ```ruby
193
220
  user = User.first
data/bin/console CHANGED
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "sequel"
5
6
  require "umbrellio-sequel-plugins"
6
- require "irb"
7
- require_relative "../database"
7
+ require "pry"
8
+
9
+ require_relative "../utils/database"
8
10
 
9
11
  Dir["#{__dir__}/lib/**/*.rb"].each { |f| require f }
10
12
 
11
- IRB.start(__FILE__)
13
+ Pry.start
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "symbiont"
4
+
5
+ Sequel::SimpleMigration.prepend(Module.new do
6
+ def apply(db, direction)
7
+ # :nocov:
8
+ unless [:up, :down].include?(direction) # NOTE: original code
9
+ raise(ArgumentError, "Invalid migration direction specified (#{direction.inspect})")
10
+ end
11
+ # :nocov:
12
+
13
+ # NOTE: our extension
14
+ prok = public_send(direction)
15
+ Symbiont::Executor.evaluate_private(db, &prok) if prok
16
+ end
17
+ end)
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "umbrellio-sequel-plugins"
8
- spec.version = "0.1.2"
8
+ spec.version = "0.2.0"
9
9
  spec.authors = ["nulldef"]
10
10
  spec.email = ["nulldefiner@gmail.com"]
11
11
  spec.required_ruby_version = ">= 2.4"
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "sequel"
22
+ spec.add_runtime_dependency "symbiont-ruby", ">= 0.6"
22
23
 
23
24
  spec.add_development_dependency "bundler"
24
25
  spec.add_development_dependency "coveralls"
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-sequel-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nulldef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-12 00:00:00.000000000 Z
11
+ date: 2019-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: symbiont-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0.6'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -133,14 +147,15 @@ files:
133
147
  - ".rspec"
134
148
  - ".rubocop.yml"
135
149
  - ".travis.yml"
150
+ - CHANGELOG.md
136
151
  - Gemfile
137
152
  - LICENSE
138
153
  - README.md
139
154
  - Rakefile
140
155
  - bin/console
141
156
  - bin/setup
142
- - database.rb
143
157
  - lib/sequel/extensions/currency_rates.rb
158
+ - lib/sequel/extensions/methods_in_migrations.rb
144
159
  - lib/sequel/extensions/pg_tools.rb
145
160
  - lib/sequel/extensions/slave.rb
146
161
  - lib/sequel/extensions/synchronize.rb
@@ -156,6 +171,7 @@ files:
156
171
  - lib/umbrellio-sequel-plugins.rb
157
172
  - lib/umbrellio_sequel_plugins.rb
158
173
  - umbrellio-sequel-plugins.gemspec
174
+ - utils/database.rb
159
175
  homepage: https://github.com/umbrellio/umbrellio-sequel-plugins
160
176
  licenses:
161
177
  - MIT