acts_as_list 0.7.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ODI0OTU2NzgzMmY0MmI3YjMyMDk2ZDg5YWJjNjkxZDE4ZjViODliYQ==
5
- data.tar.gz: !binary |-
6
- OThlMWNiYjU3MGRmMGQzNjA5NzQ1MDk1MzdiYTg1MGFjODJlNDJmYQ==
2
+ SHA1:
3
+ metadata.gz: 8f0d9ba8f5cf3b633b34697998e60026fbe0e911
4
+ data.tar.gz: ade9d56a50252ff67e5254ac95af5709e3529e1c
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZDMzOWRkNzQ2ZjNmZGRlM2QxYzJkN2VjYzM2MGY1Yzk4MjE1MmZiOWQyZjY1
10
- NmY4Y2FjY2U4YjczNjliZjFmYzYwYmMzYTNlNTA2MjU4NmVlODFmMzg1NGY0
11
- OWNkN2Y4MGU2ZTM4YjM2YjY0MTZkNjcwMjk0NmQ1YzBkMmNjYjE=
12
- data.tar.gz: !binary |-
13
- Mzg4NGQwNmY2NjdjN2MxZWIzYWE4MWNiOTlkMTc5NGM5NTRiMzRmY2MwNDVh
14
- ODI2YTVhZmUwMzE1OTAwNzA1OWZjMjc3ZGNhZmI1Y2ZmNmU4NmYzNGQ3ZTc1
15
- OGUyZDE0NjZkZTVjNmQxZTJhOWUyNjdhOWIwMjJiMTg2YzA2NWI=
6
+ metadata.gz: 4b3799c6c28e9484a89aafa9456d558376da4f9fd9a748ec58ece08398eb618641e44050e9c952221ed260fea7929016a07ffef68f8428e7d2d9e66bda70ab31
7
+ data.tar.gz: 64c1c416482deb55de8c40bbcb3f738eb16967c07df7e0e31729ae4c347268c421f30cf7279d562f910731318646f4dc4daa4e86d2a2a9d5fad8386c7b5e7f16
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ pkg/*
9
9
  .ruby-version
10
10
  # Appraisal generated lockfiles
11
11
  *.gemfile.lock
12
+ .DS_Store
data/.travis.yml CHANGED
@@ -1,17 +1,37 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  # Explicit usage of containerized builds, should provide faster feedback
3
4
  # see https://docs.travis-ci.com/user/workers/container-based-infrastructure/
4
5
  # and https://docs.travis-ci.com/user/ci-environment/#Virtualization-environments
5
6
  sudo: false
6
7
  before_install:
7
- - gem update bundler
8
+ - gem install bundler -v 1.13.7
9
+ before_script:
10
+ - mysql -e 'create database acts_as_list;'
11
+ - psql -c 'create database acts_as_list;' -U postgres
8
12
  rvm:
9
13
  - 1.9.3
10
14
  - 2.0.0
11
- - 2.1.0
15
+ - 2.1.9
16
+ - 2.2.6
17
+ - 2.3.3
12
18
  - jruby-19mode
13
- - rbx-2
19
+ env:
20
+ - DB=sqlite
21
+ - DB=mysql
22
+ - DB=postgresql
14
23
  gemfile:
15
24
  - gemfiles/rails_3_2.gemfile
16
25
  - gemfiles/rails_4_1.gemfile
17
26
  - gemfiles/rails_4_2.gemfile
27
+ - gemfiles/rails_5_0.gemfile
28
+ matrix:
29
+ exclude:
30
+ - rvm: 1.9.3
31
+ gemfile: gemfiles/rails_5_0.gemfile
32
+ - rvm: 2.0.0
33
+ gemfile: gemfiles/rails_5_0.gemfile
34
+ - rvm: 2.1.9
35
+ gemfile: gemfiles/rails_5_0.gemfile
36
+ - rvm: jruby-19mode
37
+ gemfile: gemfiles/rails_5_0.gemfile
data/Appraisals CHANGED
@@ -1,11 +1,21 @@
1
1
  appraise "rails-3-2" do
2
- gem "activerecord", "~> 3.2.21"
2
+ gem "activerecord", "~> 3.2.22.2"
3
+ group :test do
4
+ gem "after_commit_exception_notification"
5
+ end
3
6
  end
4
7
 
5
8
  appraise "rails-4-1" do
6
- gem "activerecord", "~> 4.1.10"
9
+ gem "activerecord", "~> 4.1.16"
10
+ group :test do
11
+ gem "after_commit_exception_notification"
12
+ end
7
13
  end
8
14
 
9
15
  appraise "rails-4-2" do
10
- gem "activerecord", "~> 4.2.1"
16
+ gem "activerecord", "~> 4.2.7"
17
+ end
18
+
19
+ appraise "rails-5-0" do
20
+ gem "activerecord", "~> 5.0.0"
11
21
  end
data/CHANGELOG.md CHANGED
@@ -1,7 +1,136 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.8.2](https://github.com/swanandp/acts_as_list/tree/v0.8.2) (2016-09-23)
4
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.8.1...v0.8.2)
5
+
6
+ **Closed issues:**
7
+
8
+ - We're a repo now, no longer a fork attached to rails/acts\_as\_list [\#232](https://github.com/swanandp/acts_as_list/issues/232)
9
+ - Break away from rails/acts\_as\_list [\#224](https://github.com/swanandp/acts_as_list/issues/224)
10
+ - Problem when inserting straight at top of list [\#109](https://github.com/swanandp/acts_as_list/issues/109)
11
+
12
+ **Merged pull requests:**
13
+
14
+ - Show items with same position in higher and lower items [\#231](https://github.com/swanandp/acts_as_list/pull/231) ([jpalumickas](https://github.com/jpalumickas))
15
+ - fix setting position when previous position was nil [\#230](https://github.com/swanandp/acts_as_list/pull/230) ([StoneFrog](https://github.com/StoneFrog))
16
+
17
+ ## [v0.8.1](https://github.com/swanandp/acts_as_list/tree/v0.8.1) (2016-09-06)
18
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.8.0...v0.8.1)
19
+
20
+ **Closed issues:**
21
+
22
+ - Rubinius Intermittent testing error [\#218](https://github.com/swanandp/acts_as_list/issues/218)
23
+ - ActiveRecord dependency causes rake assets:compile to fail without access to a database [\#84](https://github.com/swanandp/acts_as_list/issues/84)
24
+
25
+ **Merged pull requests:**
26
+
27
+ - Refactor class\_eval with string into class\_eval with block [\#215](https://github.com/swanandp/acts_as_list/pull/215) ([rdvdijk](https://github.com/rdvdijk))
28
+
29
+ ## [v0.8.0](https://github.com/swanandp/acts_as_list/tree/v0.8.0) (2016-08-23)
30
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.7.7...v0.8.0)
31
+
32
+ **Closed issues:**
33
+
34
+ - Behavior with DB default seems unclear [\#219](https://github.com/swanandp/acts_as_list/issues/219)
35
+
36
+ **Merged pull requests:**
37
+
38
+ - No longer a need specify additional rbx gems [\#225](https://github.com/swanandp/acts_as_list/pull/225) ([brendon](https://github.com/brendon))
39
+ - Fix position when no serial positions [\#223](https://github.com/swanandp/acts_as_list/pull/223) ([jpalumickas](https://github.com/jpalumickas))
40
+ - Bug: Specifying a position with add\_new\_at: :top fails to insert at that position [\#220](https://github.com/swanandp/acts_as_list/pull/220) ([brendon](https://github.com/brendon))
41
+
42
+ ## [v0.7.7](https://github.com/swanandp/acts_as_list/tree/v0.7.7) (2016-08-18)
43
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.7.6...v0.7.7)
44
+
45
+ **Closed issues:**
46
+
47
+ - Issue after upgrading to 0.7.5: No connection pool with id primary found. [\#214](https://github.com/swanandp/acts_as_list/issues/214)
48
+ - Changing scope is inconsistent based on add\_new\_at [\#138](https://github.com/swanandp/acts_as_list/issues/138)
49
+ - Duplicate positions and lost items [\#76](https://github.com/swanandp/acts_as_list/issues/76)
50
+
51
+ **Merged pull requests:**
52
+
53
+ - Add quoted table names to some columns [\#221](https://github.com/swanandp/acts_as_list/pull/221) ([jpalumickas](https://github.com/jpalumickas))
54
+ - Appraisals cleanup [\#217](https://github.com/swanandp/acts_as_list/pull/217) ([brendon](https://github.com/brendon))
55
+ - Fix insert\_at\_position in race condition [\#195](https://github.com/swanandp/acts_as_list/pull/195) ([danielross](https://github.com/danielross))
56
+
57
+ ## [v0.7.6](https://github.com/swanandp/acts_as_list/tree/v0.7.6) (2016-07-15)
58
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.7.5...v0.7.6)
59
+
60
+ **Closed issues:**
61
+
62
+ - add\_new\_at nil with scope causes NoMethodError [\#211](https://github.com/swanandp/acts_as_list/issues/211)
63
+
64
+ **Merged pull requests:**
65
+
66
+ - Add class method acts\_as\_list\_top as reader for configured top\_of\_list [\#213](https://github.com/swanandp/acts_as_list/pull/213) ([krzysiek1507](https://github.com/krzysiek1507))
67
+ - Bugfix/add new at nil on scope change [\#212](https://github.com/swanandp/acts_as_list/pull/212) ([greatghoul](https://github.com/greatghoul))
68
+
69
+ ## [v0.7.5](https://github.com/swanandp/acts_as_list/tree/v0.7.5) (2016-06-30)
70
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.7.4...v0.7.5)
71
+
72
+ **Implemented enhancements:**
73
+
74
+ - Touch when reordering [\#173](https://github.com/swanandp/acts_as_list/pull/173) ([botandrose](https://github.com/botandrose))
75
+
76
+ **Closed issues:**
77
+
78
+ - Exception raised when calling destroy "NameError - instance variable @scope\_changed not defined:" [\#206](https://github.com/swanandp/acts_as_list/issues/206)
79
+ - Undefined instance variable @scope\_changed since 0.7.3 [\#199](https://github.com/swanandp/acts_as_list/issues/199)
80
+ - Reordering large lists is slow [\#198](https://github.com/swanandp/acts_as_list/issues/198)
81
+ - Reparenting child leaves gap in source list in rails 5 [\#194](https://github.com/swanandp/acts_as_list/issues/194)
82
+ - Support rails 5 ? [\#186](https://github.com/swanandp/acts_as_list/issues/186)
83
+ - I get a NoMethodError: undefined method `acts\_as\_list' when trying to include acts\_as\_list [\#176](https://github.com/swanandp/acts_as_list/issues/176)
84
+ - Phenomenon of mysterious value of the position is skipped by one [\#166](https://github.com/swanandp/acts_as_list/issues/166)
85
+ - Model.find being called twice with acts\_as\_list on destroy [\#161](https://github.com/swanandp/acts_as_list/issues/161)
86
+ - `scope\_changed?` problem with acts\_as\_paranoid [\#158](https://github.com/swanandp/acts_as_list/issues/158)
87
+ - Inconsistent behaviour between Symbol and Array scopes [\#155](https://github.com/swanandp/acts_as_list/issues/155)
88
+ - insert\_at doesn't seem to be working in ActiveRecord callback \(Rails 4.2\) [\#150](https://github.com/swanandp/acts_as_list/issues/150)
89
+ - Project Documentation link redirects to expired domain [\#149](https://github.com/swanandp/acts_as_list/issues/149)
90
+ - Problem when updating an position of array of AR objects. [\#137](https://github.com/swanandp/acts_as_list/issues/137)
91
+ - Unexpected behaviour when inserting consecutive items with default positions [\#124](https://github.com/swanandp/acts_as_list/issues/124)
92
+ - self.reload prone to error [\#122](https://github.com/swanandp/acts_as_list/issues/122)
93
+ - Rails 3.0.x in\_list causes the return of default\_scope [\#120](https://github.com/swanandp/acts_as_list/issues/120)
94
+ - Relationships with dependency:destroy cause ActiveRecord::RecordNotFound [\#118](https://github.com/swanandp/acts_as_list/issues/118)
95
+ - Using insert\_at with values with type String [\#117](https://github.com/swanandp/acts_as_list/issues/117)
96
+ - Batch setting of position [\#112](https://github.com/swanandp/acts_as_list/issues/112)
97
+ - position: 0 now makes model pushed to top? [\#110](https://github.com/swanandp/acts_as_list/issues/110)
98
+ - Create element in default position [\#103](https://github.com/swanandp/acts_as_list/issues/103)
99
+ - Enhancement: Expose scope object [\#97](https://github.com/swanandp/acts_as_list/issues/97)
100
+ - Shuffle list [\#96](https://github.com/swanandp/acts_as_list/issues/96)
101
+ - Creating an item with a nil scope should not add it to the list [\#92](https://github.com/swanandp/acts_as_list/issues/92)
102
+ - Performance Improvements [\#88](https://github.com/swanandp/acts_as_list/issues/88)
103
+ - has\_many :through or has\_many\_and\_belongs\_to\_many support [\#86](https://github.com/swanandp/acts_as_list/issues/86)
104
+ - move\_higher/move\_lower vs move\_to\_top/move\_to\_bottom act differently when item is already at top or bottom [\#77](https://github.com/swanandp/acts_as_list/issues/77)
105
+ - Limiting the list size [\#61](https://github.com/swanandp/acts_as_list/issues/61)
106
+ - Adding multiple creates strange ordering [\#55](https://github.com/swanandp/acts_as_list/issues/55)
107
+ - Feature: sort [\#26](https://github.com/swanandp/acts_as_list/issues/26)
108
+
109
+ **Merged pull requests:**
110
+
111
+ - Fix position when no serial positions [\#208](https://github.com/swanandp/acts_as_list/pull/208) ([PoslinskiNet](https://github.com/PoslinskiNet))
112
+ - Removed duplicated assignment [\#207](https://github.com/swanandp/acts_as_list/pull/207) ([shunwen](https://github.com/shunwen))
113
+ - Quote all identifiers [\#205](https://github.com/swanandp/acts_as_list/pull/205) ([fabn](https://github.com/fabn))
114
+ - Start testing Rails 5 [\#203](https://github.com/swanandp/acts_as_list/pull/203) ([brendon](https://github.com/brendon))
115
+ - Lock! the record before destroying [\#201](https://github.com/swanandp/acts_as_list/pull/201) ([brendon](https://github.com/brendon))
116
+ - Fix ambiguous column error when joining some relations [\#180](https://github.com/swanandp/acts_as_list/pull/180) ([natw](https://github.com/natw))
117
+
118
+ ## [v0.7.4](https://github.com/swanandp/acts_as_list/tree/v0.7.4) (2016-04-15)
119
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.7.3...v0.7.4)
120
+
121
+ **Closed issues:**
122
+
123
+ - Releasing a new gem version [\#196](https://github.com/swanandp/acts_as_list/issues/196)
124
+
125
+ **Merged pull requests:**
126
+
127
+ - Fix scope changed [\#200](https://github.com/swanandp/acts_as_list/pull/200) ([brendon](https://github.com/brendon))
128
+
3
129
  ## [v0.7.3](https://github.com/swanandp/acts_as_list/tree/v0.7.3) (2016-04-14)
4
- [Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.7.1...v0.7.3)
130
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.7.2...v0.7.3)
131
+
132
+ ## [v0.7.2](https://github.com/swanandp/acts_as_list/tree/v0.7.2) (2016-04-01)
133
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.7.2...v0.7.2)
5
134
 
6
135
  **Closed issues:**
7
136
 
@@ -238,4 +367,4 @@
238
367
 
239
368
 
240
369
 
241
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
370
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/Gemfile CHANGED
@@ -1,23 +1,30 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "sqlite3", platforms: [:ruby]
4
- gem "activerecord-jdbcsqlite3-adapter", platforms: [:jruby]
3
+ gem "rack", "~> 1", platforms: [:ruby_19, :ruby_20, :ruby_21, :jruby]
5
4
 
6
- platforms :rbx do
7
- gem "rubysl", "~> 2.0"
8
- gem "rubinius-developer_tools"
9
- gem "rubysl-test-unit"
10
- end
11
-
12
- # Specify your gem"s dependencies in acts_as_list-rails3.gemspec
13
5
  gemspec
14
6
 
15
7
  gem "rake"
16
8
  gem "appraisal"
17
- # Used to automatically generate changelog file
18
9
  gem "github_changelog_generator", "1.9.0"
19
10
 
20
11
  group :test do
21
- gem "minitest", "~> 5.0"
12
+ gem "minitest", "~> 5.0"
22
13
  gem "test_after_commit", "~> 0.4.2"
14
+ gem "timecop"
15
+ end
16
+
17
+ group :sqlite do
18
+ gem "sqlite3", platforms: [:ruby]
19
+ gem "activerecord-jdbcsqlite3-adapter", platforms: [:jruby]
20
+ end
21
+
22
+ group :postgresql do
23
+ gem "pg", "~> 0.18.0", platforms: [:ruby]
24
+ gem "activerecord-jdbcpostgresql-adapter", platforms: [:jruby]
25
+ end
26
+
27
+ group :mysql do
28
+ gem "mysql2", "~> 0.3.10", platforms: [:ruby]
29
+ gem "activerecord-jdbcmysql-adapter", platforms: [:jruby]
23
30
  end
data/README.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  This `acts_as` extension provides the capabilities for sorting and reordering a number of objects in a list. The class that has this specified needs to have a `position` column defined as an integer on the mapped database table.
6
6
 
7
+ ## 0.8.0 Upgrade Notes
8
+
9
+ There are a couple of changes of behaviour from `0.8.0` onwards:
10
+
11
+ - If you specify `add_new_at: :top`, new items will be added to the top of the list like always. But now, if you specify a position at insert time: `.create(position: 3)`, the position will be respected. In this example, the item will end up at position `3` and will move other items further down the list. Before `0.8.0` the position would be ignored and the item would still be added to the top of the list. [#220](https://github.com/swanandp/acts_as_list/pull/220)
12
+ - `acts_as_list` now copes with disparate position integers (i.e. gaps between the numbers). There has been a change in behaviour for the `higher_items` method. It now returns items with the first item in the collection being the closest item to the reference item, and the last item in the collection being the furthest from the reference item (a.k.a. the first item in the list). [#223](https://github.com/swanandp/acts_as_list/pull/223)
13
+
7
14
  ## Installation
8
15
 
9
16
  In your Gemfile:
@@ -70,9 +77,31 @@ In `acts_as_list`, "higher" means further up the list (a lower `position`), and
70
77
  - `list_item.lower_item`
71
78
  - `list_item.lower_items` will return all the items below `list_item` in the list (ordered by the position, ascending)
72
79
 
73
- ## Notes
74
- If the `position` column has a default value, then there is a slight change in behavior, i.e if you have 4 items in the list, and you insert 1, with a default position 0, it would be pushed to the bottom of the list. Please look at the tests for this and some recent pull requests for discussions related to this.
80
+ ## Adding `acts_as_list` To An Existing Model
81
+ As it stands `acts_as_list` requires position values to be set on the model before the instance methods above will work. Adding something like the below to your migration will set the default position. Change the parameters to order if you want a different initial ordering.
75
82
 
83
+ ```ruby
84
+ class AddPositionToTodoItem < ActiveRecord::Migration
85
+ def change
86
+ add_column :todo_items, :position, :integer
87
+ TodoItem.order(:updated_at).each.with_index(1) do |todo_item, index|
88
+ todo_item.update_column :position, index
89
+ end
90
+ end
91
+ end
92
+ ```
93
+
94
+ If you are using the scope option things can get a bit more complicated. Let's say you have `acts_as_list scope: :todo_list`, you might instead need something like this:
95
+
96
+ ```ruby
97
+ TodoList.all.each do |todo_list|
98
+ todo_list.todo_items.order(:updated_at).each.with_index(1) do |todo_item, index|
99
+ todo_item.update_column :position, index
100
+ end
101
+ end
102
+ ```
103
+
104
+ ## Notes
76
105
  All `position` queries (select, update, etc.) inside gem methods are executed without the default scope (i.e. `Model.unscoped`), this will prevent nasty issues when the default scope is different from `acts_as_list` scope.
77
106
 
78
107
  The `position` column is set after validations are called, so you should not put a `presence` validation on the `position` column.
@@ -88,13 +117,28 @@ end
88
117
 
89
118
  ## More Options
90
119
  - `column`
91
- default: 'position'. Use this option if the column name in your database is different from position.
120
+ default: `position`. Use this option if the column name in your database is different from position.
92
121
  - `top_of_list`
93
- default: '1'. Use this option to define the top of the list. Use 0 to make the collection act more like an array in its indexing.
122
+ default: `1`. Use this option to define the top of the list. Use 0 to make the collection act more like an array in its indexing.
94
123
  - `add_new_at`
95
- default: ':bottom'. Use this option to specify whether objects get added to the :top or :bottom of the list. `nil` will result in new items not being added to the list on create, i.e, position will be kept nil after create.
124
+ default: `:bottom`. Use this option to specify whether objects get added to the `:top` or `:bottom` of the list. `nil` will result in new items not being added to the list on create, i.e, position will be kept nil after create.
125
+
126
+ ## Disabling temporarily
127
+
128
+ If you need to temporarily disable `acts_as_list` during specific operations such as mass-update or imports:
129
+ ```ruby
130
+ TodoItem.acts_as_list_no_update do
131
+ perform_mass_update
132
+ end
133
+ ```
134
+ In an `acts_as_list_no_update` block, all callbacks are disabled, and positions are not updated. New records will be created with
135
+ the default value from the database. It is your responsibility to correctly manage `positions` values.
96
136
 
97
137
  ## Versions
138
+ Version `0.9.0` adds `acts_as_list_no_update` (https://github.com/swanandp/acts_as_list/pull/244) and compatibility with not-null and uniqueness constraints on the database (https://github.com/swanandp/acts_as_list/pull/246). These additions shouldn't break compatibility with existing implementations.
139
+
140
+ As of version `0.7.5` Rails 5 is supported.
141
+
98
142
  All versions `0.1.5` onwards require Rails 3.0.x and higher.
99
143
 
100
144
  ## Build Status
@@ -106,7 +150,6 @@ All versions `0.1.5` onwards require Rails 3.0.x and higher.
106
150
  ## Roadmap
107
151
 
108
152
  1. Sort based feature
109
- 2. Rails 4 compatibility and bye bye Rails 2! Older versions would of course continue to work with Rails 2, but there won't be any support on those.
110
153
 
111
154
  ## Contributing to `acts_as_list`
112
155
 
@@ -2,23 +2,32 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "sqlite3", :platforms => [:ruby]
6
- gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
5
+ gem "rack", "~> 1", :platforms => [:ruby_19, :ruby_20, :ruby_21, :jruby]
7
6
  gem "rake"
8
7
  gem "appraisal"
9
8
  gem "github_changelog_generator", "1.9.0"
10
- gem "activerecord", "~> 3.2.21"
9
+ gem "activerecord", "~> 3.2.22.2"
11
10
 
12
11
  group :test do
13
12
  gem "minitest", "~> 5.0"
14
13
  gem "test_after_commit", "~> 0.4.2"
14
+ gem "timecop"
15
15
  gem "after_commit_exception_notification"
16
16
  end
17
17
 
18
- platforms :rbx do
19
- gem "rubysl", "~> 2.0"
20
- gem "rubinius-developer_tools"
21
- gem "rubysl-test-unit"
18
+ group :sqlite do
19
+ gem "sqlite3", :platforms => [:ruby]
20
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
21
+ end
22
+
23
+ group :postgresql do
24
+ gem "pg", "~> 0.18.0", :platforms => [:ruby]
25
+ gem "activerecord-jdbcpostgresql-adapter", :platforms => [:jruby]
26
+ end
27
+
28
+ group :mysql do
29
+ gem "mysql2", "~> 0.3.10", :platforms => [:ruby]
30
+ gem "activerecord-jdbcmysql-adapter", :platforms => [:jruby]
22
31
  end
23
32
 
24
33
  gemspec :path => "../"
@@ -2,23 +2,32 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "sqlite3", :platforms => [:ruby]
6
- gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
5
+ gem "rack", "~> 1", :platforms => [:ruby_19, :ruby_20, :ruby_21, :jruby]
7
6
  gem "rake"
8
7
  gem "appraisal"
9
8
  gem "github_changelog_generator", "1.9.0"
10
- gem "activerecord", "~> 4.1.10"
9
+ gem "activerecord", "~> 4.1.16"
11
10
 
12
11
  group :test do
13
12
  gem "minitest", "~> 5.0"
14
13
  gem "test_after_commit", "~> 0.4.2"
14
+ gem "timecop"
15
15
  gem "after_commit_exception_notification"
16
16
  end
17
17
 
18
- platforms :rbx do
19
- gem "rubysl", "~> 2.0"
20
- gem "rubinius-developer_tools"
21
- gem "rubysl-test-unit"
18
+ group :sqlite do
19
+ gem "sqlite3", :platforms => [:ruby]
20
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
21
+ end
22
+
23
+ group :postgresql do
24
+ gem "pg", "~> 0.18.0", :platforms => [:ruby]
25
+ gem "activerecord-jdbcpostgresql-adapter", :platforms => [:jruby]
26
+ end
27
+
28
+ group :mysql do
29
+ gem "mysql2", "~> 0.3.10", :platforms => [:ruby]
30
+ gem "activerecord-jdbcmysql-adapter", :platforms => [:jruby]
22
31
  end
23
32
 
24
33
  gemspec :path => "../"
@@ -2,22 +2,31 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "sqlite3", :platforms => [:ruby]
6
- gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
5
+ gem "rack", "~> 1", :platforms => [:ruby_19, :ruby_20, :ruby_21, :jruby]
7
6
  gem "rake"
8
7
  gem "appraisal"
9
8
  gem "github_changelog_generator", "1.9.0"
10
- gem "activerecord", "~> 4.2.1"
9
+ gem "activerecord", "~> 4.2.7"
11
10
 
12
11
  group :test do
13
12
  gem "minitest", "~> 5.0"
14
13
  gem "test_after_commit", "~> 0.4.2"
14
+ gem "timecop"
15
15
  end
16
16
 
17
- platforms :rbx do
18
- gem "rubysl", "~> 2.0"
19
- gem "rubinius-developer_tools"
20
- gem "rubysl-test-unit"
17
+ group :sqlite do
18
+ gem "sqlite3", :platforms => [:ruby]
19
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
20
+ end
21
+
22
+ group :postgresql do
23
+ gem "pg", "~> 0.18.0", :platforms => [:ruby]
24
+ gem "activerecord-jdbcpostgresql-adapter", :platforms => [:jruby]
25
+ end
26
+
27
+ group :mysql do
28
+ gem "mysql2", "~> 0.3.10", :platforms => [:ruby]
29
+ gem "activerecord-jdbcmysql-adapter", :platforms => [:jruby]
21
30
  end
22
31
 
23
32
  gemspec :path => "../"
@@ -0,0 +1,32 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rack", "~> 1", :platforms => [:ruby_19, :ruby_20, :ruby_21, :jruby]
6
+ gem "rake"
7
+ gem "appraisal"
8
+ gem "github_changelog_generator", "1.9.0"
9
+ gem "activerecord", "~> 5.0.0"
10
+
11
+ group :test do
12
+ gem "minitest", "~> 5.0"
13
+ gem "test_after_commit", "~> 0.4.2"
14
+ gem "timecop"
15
+ end
16
+
17
+ group :sqlite do
18
+ gem "sqlite3", :platforms => [:ruby]
19
+ gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
20
+ end
21
+
22
+ group :postgresql do
23
+ gem "pg", "~> 0.18.0", :platforms => [:ruby]
24
+ gem "activerecord-jdbcpostgresql-adapter", :platforms => [:jruby]
25
+ end
26
+
27
+ group :mysql do
28
+ gem "mysql2", "~> 0.3.10", :platforms => [:ruby]
29
+ gem "activerecord-jdbcmysql-adapter", :platforms => [:jruby]
30
+ end
31
+
32
+ gemspec :path => "../"
@@ -0,0 +1,9 @@
1
+ module ActiveRecord::Acts::List::AddNewAtMethodDefiner #:nodoc:
2
+ def self.call(caller_class, add_new_at)
3
+ caller_class.class_eval do
4
+ define_method :add_new_at do
5
+ add_new_at
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module ActiveRecord::Acts::List::AuxMethodDefiner #:nodoc:
2
+ def self.call(caller_class)
3
+ caller_class.class_eval do
4
+ define_method :acts_as_list_class do
5
+ caller_class
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ module ActiveRecord::Acts::List::CallbackDefiner #:nodoc:
2
+ def self.call(caller_class, add_new_at)
3
+ caller_class.class_eval do
4
+ before_validation :check_top_position, unless: :act_as_list_no_update?
5
+
6
+ before_destroy :lock!
7
+ after_destroy :decrement_positions_on_lower_items, unless: :act_as_list_no_update?
8
+
9
+ before_update :check_scope, unless: :act_as_list_no_update?
10
+ after_update :update_positions, unless: :act_as_list_no_update?
11
+
12
+ after_commit :clear_scope_changed
13
+
14
+ if add_new_at.present?
15
+ before_create "add_to_list_#{add_new_at}".to_sym, unless: :act_as_list_no_update?
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,50 @@
1
+ module ActiveRecord::Acts::List::ColumnMethodDefiner #:nodoc:
2
+ def self.call(caller_class, column)
3
+ caller_class.class_eval do
4
+ attr_reader :position_changed
5
+
6
+ define_method :position_column do
7
+ column
8
+ end
9
+
10
+ define_method :"#{column}=" do |position|
11
+ write_attribute(column, position)
12
+ @position_changed = true
13
+ end
14
+
15
+ # only add to attr_accessible
16
+ # if the class has some mass_assignment_protection
17
+ if defined?(accessible_attributes) and !accessible_attributes.blank?
18
+ attr_accessible :"#{column}"
19
+ end
20
+
21
+ define_singleton_method :quoted_position_column do
22
+ @_quoted_position_column ||= connection.quote_column_name(column)
23
+ end
24
+
25
+ define_singleton_method :quoted_position_column_with_table_name do
26
+ @_quoted_position_column_with_table_name ||= "#{caller_class.quoted_table_name}.#{quoted_position_column}"
27
+ end
28
+
29
+ define_singleton_method :decrement_all do
30
+ update_all_with_touch "#{quoted_position_column} = (#{quoted_position_column_with_table_name} - 1)"
31
+ end
32
+
33
+ define_singleton_method :increment_all do
34
+ update_all_with_touch "#{quoted_position_column} = (#{quoted_position_column_with_table_name} + 1)"
35
+ end
36
+
37
+ define_singleton_method :update_all_with_touch do |updates|
38
+ record = new
39
+ attrs = record.send(:timestamp_attributes_for_update_in_model)
40
+ now = record.send(:current_time_from_proper_timezone)
41
+
42
+ attrs.each do |attr|
43
+ updates << ", #{connection.quote_column_name(attr)} = #{connection.quote(connection.quoted_date(now))}"
44
+ end
45
+
46
+ update_all(updates)
47
+ end
48
+ end
49
+ end
50
+ end