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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6ebb7f510340a66069f3b5adc839f817d7a89be
4
- data.tar.gz: 44c43b19e281f1eed03243c35e3f41bdbce11b9e
3
+ metadata.gz: 30020b7ecfe41a351064635d06a2c06ae10feb96
4
+ data.tar.gz: '04917a96c6a478f59a1fcf0ff5ac2f6f08632d56'
5
5
  SHA512:
6
- metadata.gz: b073089f1f9232bbc55032bb50f8c4c2ccad63530237660d5f255a72b3ac8020a9fd69897c28134118b34f92ac84b53440df7391ffe0801d806ffdae85d11f7f
7
- data.tar.gz: 7d0cf44472a6916c49554f7d524db7ec98ba834a73c8b191307637ab12292aae8b29e116f88033b278d84271923c04442c9eee1ee356775c511f3ffe162bb107
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 "BUNDLE_GEMFILE='gemfiles/#{version}.gemfile' bundle install --quiet"
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 "BUNDLE_GEMFILE='gemfiles/#{version}.gemfile' bundle install --quiet"
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
@@ -2,4 +2,14 @@ require 'pg_ltree/ltree'
2
2
  require 'pg_ltree/scoped_for'
3
3
  require 'pg_ltree/version'
4
4
 
5
- ActiveRecord::Base.extend(PgLtree::Ltree)
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
@@ -3,5 +3,5 @@
3
3
  # @author a.ponomarenko
4
4
  module PgLtree
5
5
  # Gem Version
6
- VERSION = '1.1.4'.freeze
6
+ VERSION = '1.1.5'.freeze
7
7
  end
@@ -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
@@ -0,0 +1,5 @@
1
+ adapter: postgresql
2
+ host: localhost
3
+ username: postgres
4
+ password: postgres
5
+ database: pg_ltree_test
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
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-04-26 00:00:00.000000000 Z
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.21'
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.21'
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.5.1
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: