ancestry 3.2.0 → 3.2.1

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: d11437b15407107e0d4690084bc462a50d97d4fe9615445ff295a96d74943c67
4
- data.tar.gz: e2bdffb78316b524828c0a6d38c0c0e4101ef71c57bda836272d41e0381b44c3
3
+ metadata.gz: 2f1ae94346d7ad0aa07830437239dc7f13dda73408c61a118e60f53ef21e6282
4
+ data.tar.gz: 1eb3e39a50b257dddc13559d52b03955c8174682f990a723614ca9e2e3dc6945
5
5
  SHA512:
6
- metadata.gz: 533b6b0cc2db821091081f09c7680cbe163abbcc85500d278c52625861bdd901a7623232cde8ccbf21f3e0960a5231adb889055555e4849d75ede13651f626ad
7
- data.tar.gz: 6f754739730731009eee294e9a6fed1d268d3f0cbf4024cec96221a0a68b5f59569ac47bb42f13e3e7798f76982d35ff35b03a01fe44f4d217b7e3e37c9c62d4
6
+ metadata.gz: 87a3c689530416fd20fa4064bb7c610e8e9e3b013324776e5a7c96ad7cb0a8f1a136dfbe71ada9e53b5116ef41602dab7d2d7664e2fc047e8a31f7a6598e2238
7
+ data.tar.gz: f420ad732aca06c42116a97db60898db8712163aae660d13b8f0d32b806eaa6e81edac4ba2eb167986456995859cfd52da829abbbdf7d3377177b9f9049b73d5
@@ -0,0 +1,277 @@
1
+ # Ancestry Changelog
2
+
3
+ Doing our best at supporting [SemVer](http://semver.org/) with
4
+ a nice looking [Changelog](http://keepachangelog.com).
5
+
6
+ ## Version [HEAD] <small>now</small>
7
+
8
+ * dropped support for rails 4.2 and 5.0
9
+
10
+ ## Versions [3.2.1] <small>2020-09-23</small>
11
+
12
+ * fixed gemspec to include locales and pg (thx @HectorMF)
13
+
14
+ ## Versions [3.2.0] <small>2020-09-23</small>
15
+
16
+ * introduce i18n
17
+ * pg sql optimization for ancestry changes (thx @suonlight and @geis)
18
+ * pg sql optimization for sorting (thx @brendon and @d-m-u)
19
+ * fix to humanise model name (thx @mkllnk)
20
+ * able to convert to ancestry from a parent_id column with a different name
21
+ * documentation fixes for better diagrams and grammar (thx @dtamais, @d-m-u, and @CamilleDrapier)
22
+
23
+ ## Versions [3.1.0] <small>2020-08-03</small>
24
+
25
+ * `:primary_key_format` method lets you change syntax. good for uuids.
26
+ * changed code from being `ancestry` string to `ancestry_ids` focused. May break monkey patches.
27
+ * Moved many methods from `has_ancestry` and `InstanceMethods` to `MaterializedPath`. May break monkey patches.
28
+ * Removed tests for `mysql` driver. Starting with rails 4.1, it supports `mysql2` driver.
29
+ * Better documentation for relationships (thnx @dtamai and @d-m-u)
30
+ * Fix creating children in `after_*` callbacks (thx @jstirk)
31
+
32
+ ## Version [3.0.7] <small>2018-11-06</small>
33
+
34
+ * Fixed rails 5.1 change detection (thx @jrafanie)
35
+ * Introduce counter cache (thx @hw676018683)
36
+
37
+ ## Version [3.0.6] <small>2018-11-06</small>
38
+
39
+ * Fixed rails 4.1 version check (thx @myxoh)
40
+
41
+ ## Version [3.0.5] <small>2018-11-06</small>
42
+
43
+ ## Changed
44
+
45
+ * Added indirect children support (thx @tilo)
46
+ * Fixed test sorting for pg on mac osx
47
+
48
+ ## Fixes
49
+
50
+ * Reduced memory footprint of parsing ancestry column (thx @NickLaMuro)
51
+
52
+ ## Version [3.0.4] <small>2018-10-27</small>
53
+
54
+ ## Fixes
55
+
56
+ * Properly detects non-integer columns (thx @adam101)
57
+ * Arrange no longer drops nodes due to missing parents (thx @trafium)
58
+
59
+ ## Version [3.0.3] <small>2018-10-23</small>
60
+
61
+ This branch (3.x) should still be compatible with rails 3 and 4.
62
+ Rails 5.1 and 5.2 support were introduced in this version, but ongoing support
63
+ has been moved to ancestry 4.0
64
+
65
+ ## Fixes
66
+
67
+ * Reduce object allocation (thx @NickLaMuro)
68
+ * Rails 5.1 fixes (thx @ctrombley)
69
+ * Avoid redundant query to DB in subtree_of scope (thx @Slike9)
70
+ * Syntax tweaks (thx @ekohl, @richardonrails)
71
+ * Fixed reverse ordering
72
+ * Dropped builds for ruby 1.9.3, 2.0, 2.1, and 2.2
73
+ * Dropped builds for Rails 3.x and 4.x (will use Active Record `or` syntax)
74
+
75
+ ## Version [3.0.2] <small>2018-04-24</small>
76
+
77
+ ## Fixes
78
+
79
+ * fixed `order_by_ancestry` bug
80
+ * fixed order tests for postgres on mac (it uses a different collation)
81
+ * fixed documentation (thx @besquared, @danfrenette, @eiwi1101, @isimluk, @mabusaad, @tilsammans)
82
+ * added missing `Ancestry::version`
83
+ * added Rails 5.2 support (thx @jjuliano)
84
+
85
+ ## Version [3.0.1] <small>2017-07-05</small>
86
+
87
+ ## Fixes
88
+
89
+ * added gem metadata
90
+ * fixed keep a changelog link (thx @mattbrictson)
91
+ * added alias has_parent?
92
+ * fixed bug where unscoping too much (thx @brendon)
93
+ * fixed tests on mysql 5.7 and rails 3.2
94
+ * Dropped 3.1 scope changes
95
+
96
+ ## Version [3.0.0] <small>2017-05-18</small>
97
+
98
+ ## Changed
99
+
100
+ * Dropping Rails 3.0, and 3.1. Added Rails 5.1 support (thx @ledermann)
101
+ * Dropping Rails 4.0, 4.1 for build reasons. Since 4.2 is supported, all 4.x should still work.
102
+
103
+ ## Fixes
104
+
105
+ * Performance: Use `pluck` vs `map` for ids (thx @njakobsen and @culturecode)
106
+ * Fixed acts_as_tree compatibility (thx @crazymykl)
107
+ * Fixed loading ActiveRails prematurely (thx @vovimayhem)
108
+ * Fixes exist (thx @ledermann)
109
+ * Properly touches parents when different class for STI (thx @samtgarson)
110
+ * Fixed issues with parent_id (only present on master) (thx @domcleal)
111
+
112
+ ## Version [2.2.2] <small>2016-11-01</small>
113
+
114
+ ### Changed
115
+
116
+ * Use `COALESCE` only for sorting versions greater than 5.0
117
+ * Fixed bug with explicit order clauses (introduced in 2.2.0)
118
+ * No longer load schema on `has_ancestry` load (thx @ledermann)
119
+
120
+ ## Version [2.2.1] <small>2016-10-25</small>
121
+
122
+ Sorry for blip, local master got out of sync with upstream master.
123
+ Missed 2 commits (which are feature adds)
124
+
125
+ ### Added
126
+ * Use like (vs ilike) for rails 5.0 (performance enhancement)
127
+ * Use `COALESCE` for sorting on pg, mysql, and sqlite vs `CASE`
128
+
129
+ ## Version [2.2.0] <small>2016-10-25</small>
130
+
131
+ ### Added
132
+ * Predicates for scopes: e.g.: `ancestor_of?`, `parent_of?` (thx @neglectedvalue)
133
+ * Scope `path_of`
134
+
135
+ ### Changed
136
+ * `arrange` now accepts blocks (thx @mastfish)
137
+ * Performance tuning `arrange_node` (thx @fryguy)
138
+ * In orphan strategy, set `ancestry` to `nil` for no parents (thx @haslinger)
139
+ * Only updates `updated_at` when a record is changed (thx @brocktimus)
140
+ * No longer casts text primary key as an integer
141
+ * Upgrading tests for ruby versions (thx @brocktimus, @fryguy, @yui-knk)
142
+ * Fix non-default ancestry not getting used properly (thx @javiyu)
143
+
144
+ ## Version [2.1.0] <small>2014-04-16</small>
145
+ * Added arrange_serializable (thx @krishandley, @chicagogrrl)
146
+ * Add the :touch to update ancestors on save (thx @adammck)
147
+ * Change conditions into arel (thx @mlitwiniuk)
148
+ * Added children? & siblings? alias (thx @bigtunacan)
149
+ * closure_tree compatibility (thx @gzigzigzeo)
150
+ * Performance tweak (thx @mjc)
151
+ * Improvements to organization (thx @xsuchy, @ryakh)
152
+
153
+ ## Version [2.0.0] <small>2013-05-17</small>
154
+ * Removed rails 2 compatibility
155
+ * Added table name to condition constructing methods (thx @aflatter)
156
+ * Fix depth_cache not being updated when moving up to ancestors (thx @scottatron)
157
+ * add alias :root? to existing is_root? (thx @divineforest)
158
+ * Add block to sort_by_ancestry (thx @Iliya)
159
+ * Add attribute query method for parent_id (thx @sj26)
160
+ * Fixed and tested for rails 4 (thx @adammck, @Nihad, @Systho, @Philippe, e.a.)
161
+ * Fixed overwriting ActiveRecord::Base.base_class (thx @Rozhnov)
162
+ * New adopt strategy (thx unknown)
163
+ * Many more improvements
164
+
165
+ ## Version [1.3.0] <small>2012-05-04</small>
166
+ * Ancestry now ignores default scopes when moving or destroying nodes, ensuring tree consistency
167
+ * Changed ActiveRecord dependency to 2.3.14
168
+
169
+ ## Version [1.2.5] <small>2012-03-15</small>
170
+ * Fixed warnings: "parenthesize argument(s) for future version"
171
+ * Fixed a bug in the restore_ancestry_integrity! method (thx Arthur Holstvoogd)
172
+
173
+ ## Version [1.2.4] <small>2011-04-22</small>
174
+ * Prepended table names to column names in queries (thx @raelik)
175
+ * Better check to see if acts_as_tree can be overloaded (thx @jims)
176
+ * Performance inprovements (thx @kueda)
177
+
178
+ ## Version [1.2.3] <small>2010-10-28</small>
179
+ * Fixed error with determining ActiveRecord version
180
+ * Added option to specify :primary_key_format (thx @rolftimmermans)
181
+
182
+ ## Version [1.2.2] <small>2010-10-24</small>
183
+ * Fixed all deprecation warnings for rails 3.0.X
184
+ * Added `:report` option to `check_ancestry_integrity!`
185
+ * Changed ActiveRecord dependency to 2.2.2
186
+ * Tested and fixed for ruby 1.8.7 and 1.9.2
187
+ * Changed usage of `update_attributes` to `update_attribute` to allow ancestry column protection
188
+
189
+ ## Version [1.2.0] <small>2009-11-07</small>
190
+ * Removed some duplication in has_ancestry
191
+ * Cleaned up plugin pattern according to http://yehudakatz.com/2009/11/12/better-ruby-idioms/
192
+ * Moved parts of ancestry into seperate files
193
+ * Made it possible to pass options into the arrange method
194
+ * Renamed acts_as_tree to has_ancestry
195
+ * Aliased has_ancestry as acts_as_tree if acts_as_tree is available
196
+ * Added subtree_of scope
197
+ * Updated ordered_by_ancestry scope to support Microsoft SQL Server
198
+ * Added empty hash as parameter to exists? calls for older ActiveRecord versions
199
+
200
+ ## Version [1.1.4] <small>2009-11-07</small>
201
+ * Thanks to a patch from tom taylor, Ancestry now works with different primary keys
202
+
203
+ ## Version [1.1.3] <small>2009-11-01</small>
204
+ * Fixed a pretty bad bug where several operations took far too many queries
205
+
206
+ ## Version [1.1.2] <small>2009-10-29</small>
207
+ * Added validation for depth cache column
208
+ * Added STI support (reported broken)
209
+
210
+ ## Version [1.1.1] <small>2009-10-28</small>
211
+ * Fixed some parentheses warnings that where reported
212
+ * Fixed a reported issue with arrangement
213
+ * Fixed issues with ancestors and path order on postgres
214
+ * Added ordered_by_ancestry scope (needed to fix issues)
215
+
216
+ ## Version [1.1.0] <small>2009-10-22</small>
217
+ * Depth caching (and cache rebuilding)
218
+ * Depth method for nodes
219
+ * Named scopes for selecting by depth
220
+ * Relative depth options for tree navigation methods:
221
+ * ancestors
222
+ * path
223
+ * descendants
224
+ * descendant_ids
225
+ * subtree
226
+ * subtree_ids
227
+ * Updated README
228
+ * Easy migration from existing plugins/gems
229
+ * acts_as_tree checks unknown options
230
+ * acts_as_tree checks that options are hash
231
+ * Added a bang (!) to the integrity functions
232
+ * Since these functions should only be used from ./script/console and not
233
+ from your application, this change is not considered as breaking backwards
234
+ compatibility and the major version wasn't bumped.
235
+ * Updated install script to point to documentation
236
+ * Removed rails specific init
237
+ * Removed uninstall script
238
+
239
+ ## Version 1.0.0 <small>2009-10-16</small>
240
+ * Initial version
241
+ * Tree building
242
+ * Tree navigation
243
+ * Integrity checking / restoration
244
+ * Arrangement
245
+ * Orphan strategies
246
+ * Subtree movement
247
+ * Named scopes
248
+ * Validations
249
+
250
+
251
+ [HEAD]: https://github.com/stefankroes/ancestry/compare/v3.2.0...HEAD
252
+ [3.1.0]: https://github.com/stefankroes/ancestry/compare/v3.1.0...v3.2.0
253
+ [3.1.0]: https://github.com/stefankroes/ancestry/compare/v3.0.7...v3.1.0
254
+ [3.0.7]: https://github.com/stefankroes/ancestry/compare/v3.0.6...v3.0.7
255
+ [3.0.6]: https://github.com/stefankroes/ancestry/compare/v3.0.5...v3.0.6
256
+ [3.0.5]: https://github.com/stefankroes/ancestry/compare/v3.0.4...v3.0.5
257
+ [3.0.4]: https://github.com/stefankroes/ancestry/compare/v3.0.3...v3.0.4
258
+ [3.0.3]: https://github.com/stefankroes/ancestry/compare/v3.0.2...v3.0.3
259
+ [3.0.2]: https://github.com/stefankroes/ancestry/compare/v3.0.1...v3.0.2
260
+ [3.0.1]: https://github.com/stefankroes/ancestry/compare/v3.0.0...v3.0.1
261
+ [3.0.0]: https://github.com/stefankroes/ancestry/compare/v2.2.2...v3.0.0
262
+ [2.2.2]: https://github.com/stefankroes/ancestry/compare/v2.2.1...v2.2.2
263
+ [2.2.1]: https://github.com/stefankroes/ancestry/compare/v2.2.0...v2.2.1
264
+ [2.2.0]: https://github.com/stefankroes/ancestry/compare/v2.1.0...v2.2.0
265
+ [2.1.0]: https://github.com/stefankroes/ancestry/compare/v2.0.0...v2.1.0
266
+ [2.0.0]: https://github.com/stefankroes/ancestry/compare/v1.3.0...v2.0.0
267
+ [1.3.0]: https://github.com/stefankroes/ancestry/compare/v1.2.5...v1.3.0
268
+ [1.2.5]: https://github.com/stefankroes/ancestry/compare/v1.2.4...v1.2.5
269
+ [1.2.4]: https://github.com/stefankroes/ancestry/compare/v1.2.3...v1.2.4
270
+ [1.2.3]: https://github.com/stefankroes/ancestry/compare/v1.2.2...v1.2.3
271
+ [1.2.2]: https://github.com/stefankroes/ancestry/compare/v1.2.0...v1.2.2
272
+ [1.2.0]: https://github.com/stefankroes/ancestry/compare/v1.1.4...v1.2.0
273
+ [1.1.4]: https://github.com/stefankroes/ancestry/compare/v1.1.3...v1.1.4
274
+ [1.1.3]: https://github.com/stefankroes/ancestry/compare/v1.1.2...v1.1.3
275
+ [1.1.2]: https://github.com/stefankroes/ancestry/compare/v1.1.1...v1.1.2
276
+ [1.1.1]: https://github.com/stefankroes/ancestry/compare/v1.1.0...v1.1.1
277
+ [1.1.0]: https://github.com/stefankroes/ancestry/compare/v1.0.0...v1.1.0
@@ -0,0 +1,16 @@
1
+ en:
2
+ ancestry:
3
+ unknown_depth_option: "Unknown depth option: %{scope_name}."
4
+ invalid_orphan_strategy: "Invalid orphan strategy, valid ones are :rootify, :adopt, :restrict and :destroy."
5
+ invalid_ancestry_column: "Invalid format for ancestry column of node %{node_id}: %{ancestry_column}."
6
+ reference_nonexistent_node: "Reference to nonexistent node in node %{node_id}: %{ancestor_id}."
7
+ conflicting_parent_id: "Conflicting parent id found in node %{node_id}: %{parent_id} for node %{node_id} while expecting %{expected}"
8
+ cannot_rebuild_depth_cache: "Cannot rebuild depth cache for model without depth caching."
9
+
10
+ option_must_be_hash: "Options for has_ancestry must be in a hash."
11
+ unknown_option: "Unknown option for has_ancestry: %{key} => %{value}."
12
+ named_scope_depth_cache: "Named scope '%{scope_name}' is only available when depth caching is enabled."
13
+
14
+ exclude_self: "%{class_name} cannot be a descendant of itself."
15
+ cannot_delete_descendants: "Cannot delete record because it has descendants."
16
+ no_child_for_new_record: "No child ancestry for new record. Save record before performing tree operations."
@@ -0,0 +1,23 @@
1
+ module Ancestry
2
+ module MaterializedPathPg
3
+ # Update descendants with new ancestry (before save)
4
+ def update_descendants_with_new_ancestry
5
+ # If enabled and node is existing and ancestry was updated and the new ancestry is sane ...
6
+ if !ancestry_callbacks_disabled? && !new_record? && ancestry_changed? && sane_ancestry?
7
+ ancestry_column = ancestry_base_class.ancestry_column
8
+ old_ancestry = path_ids_in_database.join(Ancestry::MaterializedPath::ANCESTRY_DELIMITER)
9
+ new_ancestry = path_ids.join(Ancestry::MaterializedPath::ANCESTRY_DELIMITER)
10
+ update_clause = [
11
+ "#{ancestry_column} = regexp_replace(#{ancestry_column}, '^#{old_ancestry}', '#{new_ancestry}')"
12
+ ]
13
+
14
+ if ancestry_base_class.respond_to?(:depth_cache_column) && respond_to?(ancestry_base_class.depth_cache_column)
15
+ depth_cache_column = ancestry_base_class.depth_cache_column.to_s
16
+ update_clause << "#{depth_cache_column} = length(regexp_replace(regexp_replace(ancestry, '^#{old_ancestry}', '#{new_ancestry}'), '\\d', '', 'g')) + 1"
17
+ end
18
+
19
+ unscoped_descendants.update_all update_clause.join(', ')
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Ancestry
2
- VERSION = "3.2.0"
2
+ VERSION = "3.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ancestry
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kroes
@@ -94,17 +94,17 @@ executables: []
94
94
  extensions: []
95
95
  extra_rdoc_files: []
96
96
  files:
97
+ - CHANGELOG.md
97
98
  - MIT-LICENSE
98
99
  - README.md
99
- - ancestry.gemspec
100
- - init.rb
101
- - install.rb
102
100
  - lib/ancestry.rb
103
101
  - lib/ancestry/class_methods.rb
104
102
  - lib/ancestry/exceptions.rb
105
103
  - lib/ancestry/has_ancestry.rb
106
104
  - lib/ancestry/instance_methods.rb
105
+ - lib/ancestry/locales/en.yml
107
106
  - lib/ancestry/materialized_path.rb
107
+ - lib/ancestry/materialized_path_pg.rb
108
108
  - lib/ancestry/version.rb
109
109
  homepage: https://github.com/stefankroes/ancestry
110
110
  licenses:
@@ -114,7 +114,8 @@ metadata:
114
114
  changelog_uri: https://github.com/stefankroes/ancestry/blob/master/CHANGELOG.md
115
115
  source_code_uri: https://github.com/stefankroes/ancestry/
116
116
  bug_tracker_uri: https://github.com/stefankroes/ancestry/issues
117
- post_install_message:
117
+ post_install_message: Thank you for installing Ancestry. You can visit http://github.com/stefankroes/ancestry
118
+ to read the documentation.
118
119
  rdoc_options: []
119
120
  require_paths:
120
121
  - lib
@@ -1,51 +0,0 @@
1
- lib = File.expand_path('../lib/', __FILE__)
2
- $:.unshift lib unless $:.include?(lib)
3
- require 'ancestry/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'ancestry'
7
- s.summary = 'Organize ActiveRecord model into a tree structure'
8
- s.description = <<-EOF
9
- Ancestry allows the records of a ActiveRecord model to be organized in a tree
10
- structure, using the materialized path pattern. It exposes the standard
11
- relations (ancestors, parent, root, children, siblings, descendants)
12
- and allows them to be fetched in a single query. Additional features include
13
- named scopes, integrity checking, integrity restoration, arrangement
14
- of (sub)tree into hashes and different strategies for dealing with orphaned
15
- records.
16
- EOF
17
- s.metadata = {
18
- "homepage_uri" => "https://github.com/stefankroes/ancestry",
19
- "changelog_uri" => "https://github.com/stefankroes/ancestry/blob/master/CHANGELOG.md",
20
- "source_code_uri" => "https://github.com/stefankroes/ancestry/",
21
- "bug_tracker_uri" => "https://github.com/stefankroes/ancestry/issues",
22
- }
23
- s.version = Ancestry::VERSION
24
-
25
- s.authors = ['Stefan Kroes', 'Keenan Brock']
26
- s.email = 'keenan@thebrocks.net'
27
- s.homepage = 'https://github.com/stefankroes/ancestry'
28
- s.license = 'MIT'
29
-
30
- s.files = [
31
- 'ancestry.gemspec',
32
- 'init.rb',
33
- 'install.rb',
34
- 'lib/ancestry.rb',
35
- 'lib/ancestry/has_ancestry.rb',
36
- 'lib/ancestry/exceptions.rb',
37
- 'lib/ancestry/class_methods.rb',
38
- 'lib/ancestry/instance_methods.rb',
39
- 'lib/ancestry/materialized_path.rb',
40
- 'lib/ancestry/version.rb',
41
- 'MIT-LICENSE',
42
- 'README.md'
43
- ]
44
-
45
- s.required_ruby_version = '>= 2.0.0'
46
- s.add_runtime_dependency 'activerecord', '>= 4.2.0'
47
- s.add_development_dependency 'appraisal'
48
- s.add_development_dependency 'minitest'
49
- s.add_development_dependency 'rake', '~> 13.0'
50
- s.add_development_dependency 'yard'
51
- end
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'ancestry'
data/install.rb DELETED
@@ -1 +0,0 @@
1
- puts "Thank you for installing Ancestry. You can visit http://github.com/stefankroes/ancestry to read the documentation."