pg_ltree 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -3
- data/lib/pg_ltree.rb +11 -1
- data/lib/pg_ltree/version.rb +1 -1
- data/lib/pg_ltree/versions/rails_5_1.rb +32 -0
- data/test/database.yml +5 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30020b7ecfe41a351064635d06a2c06ae10feb96
|
4
|
+
data.tar.gz: '04917a96c6a478f59a1fcf0ff5ac2f6f08632d56'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddc2d2a0dbfee906646a9ebcb0beec03e30cbe0416535d5829c48913d8a5c6f1d29df9ba00aa8c141b2af0129d4f9a62d81b94dcda64d70d53bfeaf3114f9083
|
7
|
+
data.tar.gz: c9d0cc4a179dab9a8f1d45fad7c7d4954cfbdd1c79970db9248d184f4094b52412ae9a52b0f437aa623ecb75c91c8d5127bf74fb03e9aff2906187186bebcf41
|
data/Rakefile
CHANGED
@@ -29,12 +29,13 @@ namespace :test do
|
|
29
29
|
activerecord_41_pg_017 activerecord_41_pg_018
|
30
30
|
activerecord_42_pg_017 activerecord_42_pg_018
|
31
31
|
activerecord_50_pg_018 activerecord_51_pg_020
|
32
|
+
activerecord_51_pg_021
|
32
33
|
).freeze
|
33
34
|
|
34
35
|
AVAILABLE_CASES.each do |version|
|
35
36
|
desc "Test pg_ltree against #{version}"
|
36
37
|
task version do
|
37
|
-
sh "
|
38
|
+
sh "bundle install --gemfile=gemfiles/#{version}.gemfile --quiet"
|
38
39
|
sh "BUNDLE_GEMFILE='gemfiles/#{version}.gemfile' bundle exec rake -t test"
|
39
40
|
end
|
40
41
|
end
|
@@ -42,8 +43,7 @@ namespace :test do
|
|
42
43
|
desc 'Run all tests for pg_ltree'
|
43
44
|
task :all do
|
44
45
|
AVAILABLE_CASES.each do |version|
|
45
|
-
sh "
|
46
|
-
sh "BUNDLE_GEMFILE='gemfiles/#{version}.gemfile' bundle exec rake -t test"
|
46
|
+
sh "rake test:#{version}"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/lib/pg_ltree.rb
CHANGED
@@ -2,4 +2,14 @@ require 'pg_ltree/ltree'
|
|
2
2
|
require 'pg_ltree/scoped_for'
|
3
3
|
require 'pg_ltree/version'
|
4
4
|
|
5
|
-
|
5
|
+
Dir[File.expand_path('../pg_ltree/versions/**/*.rb', __FILE__)].each { |file| require file }
|
6
|
+
|
7
|
+
if defined?(ActiveRecord)
|
8
|
+
ActiveRecord::Base.extend(PgLtree::Ltree)
|
9
|
+
|
10
|
+
# The behavior of _was changes in Rails 5.1
|
11
|
+
# http://blog.toshima.ru/2017/04/06/saved-change-to-attribute.html
|
12
|
+
if ActiveRecord::VERSION::MAJOR > 5 || (ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR >= 1)
|
13
|
+
ActiveRecord::Base.extend(PgLtree::Versions::Rails51)
|
14
|
+
end
|
15
|
+
end
|
data/lib/pg_ltree/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module PgLtree
|
2
|
+
module Versions
|
3
|
+
module Rails51
|
4
|
+
def ltree(column = :path, options: { cascade: true })
|
5
|
+
super
|
6
|
+
|
7
|
+
before_destroy :delete_ltree_column_value if options[:cascade]
|
8
|
+
include InstanceMethods
|
9
|
+
end
|
10
|
+
|
11
|
+
module InstanceMethods
|
12
|
+
# Get lTree previous value
|
13
|
+
#
|
14
|
+
# Related changes in > Rails 5.1.0
|
15
|
+
# https://github.com/rails/rails/pull/25337
|
16
|
+
#
|
17
|
+
# @return [String] ltree previous value
|
18
|
+
def ltree_path_was
|
19
|
+
public_send :"#{ltree_path_column}_before_last_save"
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# In order for for cascade_destroy to work with the current callbacks, let's first delete the column :/.
|
24
|
+
# @author HoyaBoya [https://github.com/HoyaBoya]
|
25
|
+
#
|
26
|
+
def delete_ltree_column_value
|
27
|
+
update!(ltree_path_column => nil)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/test/database.yml
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_ltree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Panamarenka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 0.17.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
42
|
+
version: '0.22'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 0.17.0
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '0.
|
52
|
+
version: '0.22'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,6 +133,8 @@ files:
|
|
133
133
|
- lib/pg_ltree/ltree.rb
|
134
134
|
- lib/pg_ltree/scoped_for.rb
|
135
135
|
- lib/pg_ltree/version.rb
|
136
|
+
- lib/pg_ltree/versions/rails_5_1.rb
|
137
|
+
- test/database.yml
|
136
138
|
- test/database.yml.sample
|
137
139
|
- test/pg_ltree/ltree_test.rb
|
138
140
|
- test/pg_ltree/scoped_for_test.rb
|
@@ -158,14 +160,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
160
|
version: '0'
|
159
161
|
requirements: []
|
160
162
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.6.12
|
162
164
|
signing_key:
|
163
165
|
specification_version: 4
|
164
166
|
summary: Organise ActiveRecord model into a tree structure with PostgreSQL LTree
|
165
167
|
test_files:
|
168
|
+
- test/database.yml
|
166
169
|
- test/database.yml.sample
|
167
170
|
- test/pg_ltree/ltree_test.rb
|
168
171
|
- test/pg_ltree/scoped_for_test.rb
|
169
172
|
- test/pg_ltree_test.rb
|
170
173
|
- test/test_helper.rb
|
171
|
-
has_rdoc:
|