resort 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +6 -5
- data/Gemfile +14 -8
- data/Rakefile +12 -16
- data/Readme.md +2 -2
- data/lib/generators/active_record/resort_generator.rb +5 -5
- data/lib/resort.rb +34 -34
- data/lib/resort/version.rb +2 -1
- data/resort.gemspec +17 -15
- data/spec/generators/migration_spec.rb +9 -10
- data/spec/resort_spec.rb +152 -157
- data/spec/spec_helper.rb +9 -8
- metadata +41 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18ba5e9a6d45075e2c0877aae9297009823ac3aa
|
4
|
+
data.tar.gz: 56880c681b3d71690d91df09cbb7a111641a13d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c2bff8cdb82f97ca81a996d6b4bba7edab38c1a0856d789c8177be9781beb5f5aa2a3da809c6b9ce690fee80b7f3096d37032ab8b3f46bd47d40fffbc387108
|
7
|
+
data.tar.gz: 134a890b66dbbe3907ecf3ee8da7cf5d7ac1763db631b00de6815c30820cecc62fadbcfc48ed6db7c8a70ebe81d4eff1079674e881a51cb7098c8efb86720dd5
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.1
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
source 'http://rubygems.org'
|
2
3
|
|
3
4
|
gemspec
|
4
5
|
|
5
|
-
|
6
|
-
# # For debugging under ruby 1.9 special gems are needed
|
7
|
-
# gem 'ruby-debug19', :platform => :mri
|
8
|
-
# # See http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
|
9
|
-
# gem 'ruby-debug-base19', '>=0.11.26'
|
10
|
-
# gem 'linecache19', '>=0.5.13'
|
11
|
-
#end
|
6
|
+
active_record_version = ENV['ACTIVE_RECORD_VERSION'] || 'default'
|
12
7
|
|
8
|
+
active_record_opts =
|
9
|
+
case active_record_version
|
10
|
+
when 'master'
|
11
|
+
{ github: 'rails/rails' }
|
12
|
+
when 'default'
|
13
|
+
'~> 5'
|
14
|
+
else
|
15
|
+
"~> #{active_record_version}"
|
16
|
+
end
|
17
|
+
|
18
|
+
gem 'activerecord', active_record_opts
|
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'bundler'
|
2
3
|
Bundler::GemHelper.install_tasks
|
3
4
|
|
4
5
|
require 'rspec/core/rake_task'
|
5
|
-
desc
|
6
|
+
desc 'Run resort specs'
|
6
7
|
RSpec::Core::RakeTask.new
|
7
8
|
|
8
9
|
require 'yard'
|
@@ -15,33 +16,28 @@ site = 'doc'
|
|
15
16
|
source_branch = 'master'
|
16
17
|
deploy_branch = 'gh-pages'
|
17
18
|
|
18
|
-
desc
|
19
|
+
desc 'generate and deploy documentation website to github pages'
|
19
20
|
multitask :pages do
|
20
21
|
puts ">>> Deploying #{deploy_branch} branch to Github Pages <<<"
|
21
22
|
require 'git'
|
22
23
|
repo = Git.open('.')
|
23
24
|
puts "\n>>> Checking out #{deploy_branch} branch <<<\n"
|
24
|
-
repo.branch(
|
25
|
-
(Dir[
|
26
|
-
Dir["#{site}/*"].each {|f| mv(f,
|
25
|
+
repo.branch(deploy_branch.to_s).checkout
|
26
|
+
(Dir['*'] - [site]).each { |f| rm_rf(f) }
|
27
|
+
Dir["#{site}/*"].each { |f| mv(f, './') }
|
27
28
|
rm_rf(site)
|
28
29
|
puts "\n>>> Moving generated site files <<<\n"
|
29
|
-
Dir[
|
30
|
-
repo.status.deleted.each {|f,
|
30
|
+
Dir['**/*'].each { |f| repo.add(f) }
|
31
|
+
repo.status.deleted.each { |f, _s| repo.remove(f) }
|
31
32
|
puts "\n>>> Commiting: Site updated at #{Time.now.utc} <<<\n"
|
32
|
-
message = ENV[
|
33
|
+
message = ENV['MESSAGE'] || "Site updated at #{Time.now.utc}"
|
33
34
|
repo.commit(message)
|
34
35
|
puts "\n>>> Pushing generated site to #{deploy_branch} branch <<<\n"
|
35
36
|
repo.push
|
36
37
|
puts "\n>>> Github Pages deploy complete <<<\n"
|
37
|
-
repo.branch(
|
38
|
+
repo.branch(source_branch.to_s).checkout
|
38
39
|
end
|
39
40
|
|
40
|
-
task :
|
41
|
+
task doc: [:docs]
|
41
42
|
|
42
|
-
|
43
|
-
task :graph do |t|
|
44
|
-
`bundle exec yard graph -d --full --no-private | dot -Tpng -o graph.png && open graph.png`
|
45
|
-
end
|
46
|
-
|
47
|
-
task :default => [:spec]
|
43
|
+
task default: [:spec]
|
data/Readme.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#resort [![Build Status](https://secure.travis-ci.org/codegram/resort.png)](http://travis-ci.org/codegram/resort)
|
2
2
|
|
3
|
-
Resort provides sorting capabilities to your Rails models.
|
3
|
+
Resort provides sorting capabilities to your Rails (4+) models.
|
4
4
|
|
5
5
|
##Install
|
6
6
|
|
@@ -72,7 +72,7 @@ Moreover, now a `product` responds to the following methods:
|
|
72
72
|
|
73
73
|
* `first?` — Returns true if the element is the first of the tree.
|
74
74
|
* `append_to(other_element)` — Appends the element _after_ another element.
|
75
|
-
* `prepend` — Moves the
|
75
|
+
* `prepend` — Moves the element to the beginning of the list (sets it as
|
76
76
|
first).
|
77
77
|
* `next` — Returns the next element in the list.
|
78
78
|
* `previous` — Returns the previous element in the list.
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rails/generators'
|
2
3
|
require 'rails/generators/active_record'
|
3
4
|
|
4
5
|
module Resort
|
5
6
|
# Module containing Resort generators
|
6
7
|
module Generators
|
7
|
-
|
8
8
|
# Rails generator to add a migration for Resort
|
9
9
|
class MigrationGenerator < ActiveRecord::Generators::Base
|
10
10
|
# Implement the required interface for `Rails::Generators::Migration`.
|
@@ -12,14 +12,14 @@ module Resort
|
|
12
12
|
# @see http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
13
13
|
def self.next_migration_number(dirname)
|
14
14
|
if ActiveRecord::Base.timestamped_migrations
|
15
|
-
Time.now.utc.strftime(
|
15
|
+
Time.now.utc.strftime('%Y%m%d%H%M%S')
|
16
16
|
else
|
17
|
-
|
17
|
+
'%.3d' % (current_migration_number(dirname) + 1)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
desc
|
22
|
-
source_root File.expand_path(
|
21
|
+
desc 'Creates a Resort migration.'
|
22
|
+
source_root File.expand_path('../templates', __FILE__)
|
23
23
|
|
24
24
|
# Copies a migration file adding resort fields to a given model
|
25
25
|
def copy_migration_file
|
data/lib/resort.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'generators/active_record/resort_generator' if defined?(Rails)
|
2
3
|
require 'active_record' unless defined?(ActiveRecord)
|
3
4
|
|
@@ -60,8 +61,8 @@ module Resort
|
|
60
61
|
base.extend ClassMethods
|
61
62
|
base.send :include, InstanceMethods
|
62
63
|
|
63
|
-
base.has_one :previous, :
|
64
|
-
base.belongs_to :next, :
|
64
|
+
base.has_one :previous, class_name: base.name, foreign_key: 'next_id', inverse_of: :next
|
65
|
+
base.belongs_to :next, class_name: base.name, inverse_of: :previous
|
65
66
|
|
66
67
|
base.after_create :include_in_list!
|
67
68
|
base.after_destroy :delete_from_list
|
@@ -74,17 +75,16 @@ module Resort
|
|
74
75
|
#
|
75
76
|
# @return [ActiveRecord::Base] the first element of the list.
|
76
77
|
def first_in_order
|
77
|
-
all.where(:
|
78
|
+
all.where(first: true).first
|
78
79
|
end
|
79
80
|
|
80
81
|
# Returns the last element of the list.
|
81
82
|
#
|
82
83
|
# @return [ActiveRecord::Base] the last element of the list.
|
83
84
|
def last_in_order
|
84
|
-
all.where(:
|
85
|
+
all.where(next_id: nil).first
|
85
86
|
end
|
86
87
|
|
87
|
-
|
88
88
|
# Returns eager-loaded Components in order.
|
89
89
|
#
|
90
90
|
# OPTIMIZE: Use IdentityMap when available
|
@@ -101,7 +101,7 @@ module Resort
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
-
raise
|
104
|
+
raise 'Multiple or no first items in the list where found. Consider defining a siblings method' if ordered_elements.length != 1 && elements.length > 0
|
105
105
|
|
106
106
|
elements.length.times do
|
107
107
|
ordered_elements << elements[ordered_elements.last.next_id]
|
@@ -112,7 +112,6 @@ module Resort
|
|
112
112
|
|
113
113
|
# Instance methods to use.
|
114
114
|
module InstanceMethods
|
115
|
-
|
116
115
|
# Default definition of siblings, i.e. every instance of the model.
|
117
116
|
#
|
118
117
|
# Can be overriden to specify a different scope for the siblings.
|
@@ -135,6 +134,7 @@ module Resort
|
|
135
134
|
def siblings
|
136
135
|
self.class.all
|
137
136
|
end
|
137
|
+
|
138
138
|
# Includes the object in the linked list.
|
139
139
|
#
|
140
140
|
# If there are no other objects, it prepends the object so that it is
|
@@ -142,7 +142,7 @@ module Resort
|
|
142
142
|
# empty list.
|
143
143
|
def include_in_list!
|
144
144
|
self.class.transaction do
|
145
|
-
|
145
|
+
lock!
|
146
146
|
_siblings.count > 0 ? last!\
|
147
147
|
: prepend
|
148
148
|
end
|
@@ -151,53 +151,64 @@ module Resort
|
|
151
151
|
# Puts the object in the first position of the list.
|
152
152
|
def prepend
|
153
153
|
self.class.transaction do
|
154
|
-
|
154
|
+
lock!
|
155
155
|
return if first?
|
156
156
|
if _siblings.count > 0
|
157
157
|
delete_from_list
|
158
158
|
old_first = _siblings.first_in_order
|
159
|
-
raise
|
160
|
-
raise
|
159
|
+
raise ActiveRecord::RecordNotSaved, "[Resort] - Couldn't set next_id from previous first element." unless update_attribute(:next_id, old_first.id)
|
160
|
+
raise ActiveRecord::RecordNotSaved, "[Resort] - Couldn't reset previous first element" unless old_first.update_attribute(:first, false)
|
161
161
|
end
|
162
|
-
raise(ActiveRecord::RecordNotSaved) unless
|
162
|
+
raise(ActiveRecord::RecordNotSaved) unless update_attribute(:first, true)
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
166
|
# Puts the object in the last position of the list.
|
167
167
|
def push
|
168
168
|
self.class.transaction do
|
169
|
-
|
170
|
-
|
169
|
+
lock!
|
170
|
+
append_to(_siblings.last_in_order) unless last?
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
174
|
# Puts the object right after another object in the list.
|
175
175
|
def append_to(another)
|
176
176
|
self.class.transaction do
|
177
|
-
|
177
|
+
lock!
|
178
178
|
return if another.next_id == id
|
179
179
|
another.lock!
|
180
180
|
delete_from_list
|
181
|
-
if
|
182
|
-
raise
|
181
|
+
if next_id || (another && another.next_id)
|
182
|
+
raise ActiveRecord::RecordNotSaved, "[Resort] - Couldn't append element" unless update_attribute(:next_id, another.next_id)
|
183
183
|
end
|
184
184
|
if another
|
185
|
-
raise
|
185
|
+
raise ActiveRecord::RecordNotSaved, "[Resort] - Couldn't set this element to another's next" unless another.update_attribute(:next_id, id)
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
|
+
def last?
|
191
|
+
!first && !next_id
|
192
|
+
end
|
193
|
+
|
194
|
+
def last!
|
195
|
+
self.class.transaction do
|
196
|
+
lock!
|
197
|
+
raise(ActiveRecord::RecordNotSaved) unless _siblings.last_in_order.update_attribute(:next_id, id)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
190
201
|
private
|
191
202
|
|
192
203
|
def delete_from_list
|
193
204
|
if first? && self.next
|
194
205
|
self.next.lock!
|
195
206
|
raise(ActiveRecord::RecordNotSaved) unless self.next.update_attribute(:first, true)
|
196
|
-
elsif
|
197
|
-
|
198
|
-
p =
|
207
|
+
elsif previous
|
208
|
+
previous.lock!
|
209
|
+
p = previous
|
199
210
|
self.previous = nil unless frozen?
|
200
|
-
raise(ActiveRecord::RecordNotSaved) unless p.
|
211
|
+
raise(ActiveRecord::RecordNotSaved) unless p.update_column(:next_id, next_id)
|
201
212
|
end
|
202
213
|
unless frozen?
|
203
214
|
self.first = false
|
@@ -206,20 +217,9 @@ module Resort
|
|
206
217
|
end
|
207
218
|
end
|
208
219
|
|
209
|
-
def last?
|
210
|
-
!self.first && !self.next_id
|
211
|
-
end
|
212
|
-
|
213
|
-
def last!
|
214
|
-
self.class.transaction do
|
215
|
-
self.lock!
|
216
|
-
raise(ActiveRecord::RecordNotSaved) unless _siblings.last_in_order.update_attribute(:next_id, self.id)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
220
|
def _siblings
|
221
221
|
table = self.class.arel_table
|
222
|
-
siblings.where(table[:id].not_eq(
|
222
|
+
siblings.where(table[:id].not_eq(id))
|
223
223
|
end
|
224
224
|
end
|
225
225
|
end
|
data/lib/resort/version.rb
CHANGED
data/resort.gemspec
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
4
|
+
require 'resort/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
7
|
+
s.name = 'resort'
|
7
8
|
s.version = Resort::VERSION
|
8
9
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = [
|
10
|
-
s.email = [
|
11
|
-
s.homepage =
|
12
|
-
s.summary =
|
13
|
-
s.description =
|
10
|
+
s.authors = ['Oriol Gual', 'Josep M. Bach', 'Josep Jaume Rey']
|
11
|
+
s.email = ['info@codegram.com']
|
12
|
+
s.homepage = 'http://codegram.github.com/resort'
|
13
|
+
s.summary = 'Positionless model sorting for Rails.'
|
14
|
+
s.description = 'Positionless model sorting for Rails.'
|
14
15
|
|
15
|
-
s.
|
16
|
+
s.required_ruby_version = '>= 2.2.2'
|
16
17
|
|
17
|
-
s.
|
18
|
+
s.add_dependency 'activerecord', ['>= 4.0.0']
|
19
|
+
s.add_dependency 'activesupport', ['>= 4.0.0']
|
20
|
+
s.add_dependency 'railties', ['>= 4.0.0']
|
18
21
|
s.add_development_dependency 'sqlite3'
|
19
|
-
s.add_development_dependency 'rspec', '~>
|
22
|
+
s.add_development_dependency 'rspec', '~> 3.5'
|
23
|
+
s.add_development_dependency 'generator_spec'
|
20
24
|
s.add_development_dependency 'yard'
|
21
|
-
s.add_development_dependency 'bluecloth'
|
22
|
-
s.add_development_dependency 'generator_spec', '~> 0.9.2'
|
23
25
|
|
24
26
|
s.files = `git ls-files`.split("\n")
|
25
27
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
|
-
s.require_paths = [
|
28
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
29
|
+
s.require_paths = ['lib']
|
28
30
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'action_controller'
|
3
4
|
require 'action_view'
|
@@ -14,23 +15,21 @@ module Resort
|
|
14
15
|
|
15
16
|
before(:all) do
|
16
17
|
prepare_destination
|
17
|
-
mkdir File.join(
|
18
|
+
mkdir File.join(test_case.destination_root, 'config')
|
18
19
|
run_generator
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'generates Resort migration' do
|
22
|
-
destination_root.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
contains
|
28
|
-
contains
|
29
|
-
contains ":articles, :first"
|
23
|
+
expect(destination_root).to have_structure {
|
24
|
+
directory 'db' do
|
25
|
+
directory 'migrate' do
|
26
|
+
migration 'add_resort_fields_to_articles' do
|
27
|
+
contains 'class AddResortFieldsToArticles'
|
28
|
+
contains ':articles, :next_id'
|
29
|
+
contains ':articles, :first'
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
33
|
}
|
35
34
|
end
|
36
35
|
end
|
data/spec/resort_spec.rb
CHANGED
@@ -1,34 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
module Resort
|
4
5
|
describe Sortable do
|
5
|
-
|
6
6
|
subject { Article.new }
|
7
7
|
|
8
8
|
context 'when included' do
|
9
9
|
it 'creates previous and next relationships' do
|
10
|
-
subject.
|
10
|
+
expect(subject).to respond_to(:previous, :next)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'includes base with InstanceMethods' do
|
14
|
-
subject.class.ancestors.
|
14
|
+
expect(subject.class.ancestors).to include(Sortable::InstanceMethods)
|
15
15
|
end
|
16
16
|
it 'extend base with ClassMethods' do
|
17
|
-
(class << subject.class; self; end).ancestors.
|
17
|
+
expect((class << subject.class; self; end).ancestors).to include(Sortable::ClassMethods)
|
18
18
|
end
|
19
19
|
it 'defines a siblings method' do
|
20
|
-
subject.
|
20
|
+
expect(subject).to respond_to(:siblings)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe 'ClassMethods' do
|
25
|
-
|
26
|
-
describe "ordering" do
|
25
|
+
describe 'ordering' do
|
27
26
|
before do
|
28
27
|
Article.destroy_all
|
29
28
|
|
30
29
|
4.times do |i|
|
31
|
-
Article.create(:
|
30
|
+
Article.create(name: i.to_s)
|
32
31
|
end
|
33
32
|
|
34
33
|
Article.find_by_name('0').append_to(Article.find_by_name('3'))
|
@@ -41,21 +40,21 @@ module Resort
|
|
41
40
|
@article4 = Article.find_by_name('0')
|
42
41
|
end
|
43
42
|
|
44
|
-
describe
|
43
|
+
describe '#first_in_order' do
|
45
44
|
it 'returns the first element of the list' do
|
46
|
-
Article.first_in_order.
|
45
|
+
expect(Article.first_in_order).to eq @article1
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
|
-
describe
|
49
|
+
describe '#last_in_order' do
|
51
50
|
it 'returns the last element of the list' do
|
52
|
-
Article.last_in_order.
|
51
|
+
expect(Article.last_in_order).to eq @article4
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
56
|
-
describe
|
55
|
+
describe '#ordered' do
|
57
56
|
it 'returns all elements ordered' do
|
58
|
-
Article.ordered.
|
57
|
+
expect(Article.ordered).to eq [@article1, @article2, @article3, @article4]
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
@@ -65,42 +64,41 @@ module Resort
|
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
68
|
-
describe
|
67
|
+
describe 'siblings' do
|
69
68
|
before do
|
70
|
-
one_list = OrderedList.create(:
|
71
|
-
another_list = OrderedList.create(:
|
69
|
+
one_list = OrderedList.create(name: 'My list')
|
70
|
+
another_list = OrderedList.create(name: 'My other list')
|
72
71
|
|
73
72
|
4.times do |i|
|
74
|
-
one_list.items << ListItem.new(:
|
75
|
-
another_list.items << ListItem.new(:
|
73
|
+
one_list.items << ListItem.new(name: "My list item #{i}")
|
74
|
+
another_list.items << ListItem.new(name: "My other list item #{i}")
|
76
75
|
end
|
77
|
-
|
78
76
|
end
|
79
77
|
|
80
|
-
describe
|
78
|
+
describe '#first_in_order' do
|
81
79
|
it 'returns the first element of the list' do
|
82
|
-
OrderedList.find_by_name('My list').items.first_in_order.name.
|
83
|
-
OrderedList.find_by_name('My other list').items.first_in_order.name.
|
80
|
+
expect(OrderedList.find_by_name('My list').items.first_in_order.name).to eq 'My list item 0'
|
81
|
+
expect(OrderedList.find_by_name('My other list').items.first_in_order.name).to eq 'My other list item 0'
|
84
82
|
end
|
85
83
|
end
|
86
84
|
|
87
|
-
describe
|
85
|
+
describe '#last_in_order' do
|
88
86
|
it 'returns the last element of the list' do
|
89
|
-
OrderedList.find_by_name('My list').items.last_in_order.name.
|
90
|
-
OrderedList.find_by_name('My other list').items.last_in_order.name.
|
87
|
+
expect(OrderedList.find_by_name('My list').items.last_in_order.name).to eq 'My list item 3'
|
88
|
+
expect(OrderedList.find_by_name('My other list').items.last_in_order.name).to eq 'My other list item 3'
|
91
89
|
end
|
92
90
|
end
|
93
91
|
|
94
|
-
describe
|
92
|
+
describe '#ordered' do
|
95
93
|
it 'returns all elements ordered' do
|
96
|
-
OrderedList.find_by_name('My list').items.ordered.map(&:name).
|
97
|
-
OrderedList.find_by_name('My other list').items.ordered.map(&:name).
|
94
|
+
expect(OrderedList.find_by_name('My list').items.ordered.map(&:name)).to eq ['My list item 0', 'My list item 1', 'My list item 2', 'My list item 3']
|
95
|
+
expect(OrderedList.find_by_name('My other list').items.ordered.map(&:name)).to eq ['My other list item 0', 'My other list item 1', 'My other list item 2', 'My other list item 3']
|
98
96
|
end
|
99
97
|
|
100
98
|
it 'raises when ordering without scope' do
|
101
|
-
expect
|
99
|
+
expect do
|
102
100
|
ListItem.ordered
|
103
|
-
|
101
|
+
end.to raise_error(NoMethodError)
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
@@ -110,84 +108,82 @@ module Resort
|
|
110
108
|
end
|
111
109
|
end
|
112
110
|
|
113
|
-
describe
|
111
|
+
describe 'after create' do
|
114
112
|
context 'when there are no siblings' do
|
115
113
|
it 'prepends the element' do
|
116
|
-
article = Article.create(:
|
114
|
+
article = Article.create(name: 'first!')
|
117
115
|
|
118
|
-
article.
|
119
|
-
article.next.
|
120
|
-
article.previous.
|
116
|
+
expect(article).to be_first
|
117
|
+
expect(article.next).to be_nil
|
118
|
+
expect(article.previous).to be_nil
|
121
119
|
end
|
122
120
|
end
|
123
121
|
context 'otherwise' do
|
124
122
|
it 'appends the element' do
|
125
|
-
Article.create(:
|
126
|
-
Article.create(:
|
123
|
+
Article.create(name: '1')
|
124
|
+
Article.create(name: 'last!')
|
127
125
|
|
128
126
|
article = Article.find_by_name('last!')
|
129
127
|
first = Article.find_by_name('1')
|
130
128
|
|
131
|
-
article.
|
132
|
-
article.next_id.
|
133
|
-
article.previous.name.
|
129
|
+
expect(article).to be_last
|
130
|
+
expect(article.next_id).to be_nil
|
131
|
+
expect(article.previous.name).to eq '1'
|
134
132
|
|
135
|
-
first.next_id.
|
133
|
+
expect(first.next_id).to eq(article.id)
|
136
134
|
end
|
137
135
|
end
|
138
136
|
after do
|
139
137
|
Article.destroy_all
|
140
138
|
end
|
141
139
|
|
142
|
-
context
|
143
|
-
|
140
|
+
context 'with custom siblings' do
|
144
141
|
context 'when there are no siblings' do
|
145
142
|
it 'prepends the element' do
|
146
|
-
one_list = OrderedList.create(:
|
147
|
-
|
148
|
-
item = ListItem.create(:
|
143
|
+
one_list = OrderedList.create(name: 'My list')
|
144
|
+
OrderedList.create(name: 'My other list')
|
145
|
+
item = ListItem.create(name: 'My list item', ordered_list: one_list)
|
149
146
|
|
150
|
-
item.
|
151
|
-
item.next.
|
152
|
-
item.previous.
|
147
|
+
expect(item).to be_first
|
148
|
+
expect(item.next).to be_nil
|
149
|
+
expect(item.previous).to be_nil
|
153
150
|
end
|
154
151
|
end
|
155
152
|
context 'otherwise' do
|
156
153
|
it 'appends the element' do
|
157
|
-
one_list = OrderedList.create(:
|
158
|
-
|
159
|
-
ListItem.create(:
|
160
|
-
ListItem.create(:
|
154
|
+
one_list = OrderedList.create(name: 'My list')
|
155
|
+
OrderedList.create(name: 'My other list')
|
156
|
+
ListItem.create(name: '1', ordered_list: one_list)
|
157
|
+
ListItem.create(name: 'last!', ordered_list: one_list)
|
161
158
|
|
162
159
|
first = ListItem.find_by_name('1')
|
163
160
|
last = ListItem.find_by_name('last!')
|
164
161
|
|
165
|
-
last.
|
166
|
-
last.next_id.
|
167
|
-
last.previous.name.
|
162
|
+
expect(last).to be_last
|
163
|
+
expect(last.next_id).to be_nil
|
164
|
+
expect(last.previous.name).to eq '1'
|
168
165
|
|
169
|
-
first.next_id.
|
166
|
+
expect(first.next_id).to eq(last.id)
|
170
167
|
end
|
171
168
|
|
172
169
|
it 'prepends the last element' do
|
173
|
-
one_list = OrderedList.create(:
|
174
|
-
ListItem.create(:
|
175
|
-
ListItem.create(:
|
176
|
-
third = ListItem.create(:
|
170
|
+
one_list = OrderedList.create(name: 'My list')
|
171
|
+
ListItem.create(name: 'First', ordered_list: one_list)
|
172
|
+
ListItem.create(name: 'Second', ordered_list: one_list)
|
173
|
+
third = ListItem.create(name: 'Third', ordered_list: one_list)
|
177
174
|
|
178
175
|
third.prepend
|
179
|
-
first = ListItem.where(:
|
180
|
-
second = ListItem.where(:
|
181
|
-
third = ListItem.where(:
|
182
|
-
|
183
|
-
first.
|
184
|
-
second.
|
185
|
-
third.
|
186
|
-
third.next.name.
|
187
|
-
first.next.name.
|
188
|
-
second.next.
|
176
|
+
first = ListItem.where(name: 'First', ordered_list_id: one_list).first
|
177
|
+
second = ListItem.where(name: 'Second', ordered_list_id: one_list).first
|
178
|
+
third = ListItem.where(name: 'Third', ordered_list_id: one_list).first
|
179
|
+
|
180
|
+
expect(first).to_not be_first
|
181
|
+
expect(second).to_not be_first
|
182
|
+
expect(third).to be_first
|
183
|
+
expect(third.next.name).to eq 'First'
|
184
|
+
expect(first.next.name).to eq 'Second'
|
185
|
+
expect(second.next).to be_nil
|
189
186
|
end
|
190
|
-
|
191
187
|
end
|
192
188
|
after do
|
193
189
|
OrderedList.destroy_all
|
@@ -196,27 +192,27 @@ module Resort
|
|
196
192
|
end
|
197
193
|
end
|
198
194
|
|
199
|
-
describe
|
195
|
+
describe 'after destroy' do
|
200
196
|
context 'when the element is the first' do
|
201
197
|
it 'removes the element' do
|
202
|
-
article = Article.create(:
|
203
|
-
article2 = Article.create(:
|
204
|
-
|
198
|
+
article = Article.create(name: 'first!')
|
199
|
+
article2 = Article.create(name: 'second!')
|
200
|
+
Article.create(name: 'last!')
|
205
201
|
|
206
202
|
article = Article.find_by_name('first!')
|
207
203
|
article.destroy
|
208
204
|
|
209
205
|
article2 = Article.find_by_name('second!')
|
210
206
|
|
211
|
-
article2.
|
212
|
-
article2.previous.
|
207
|
+
expect(article2).to be_first
|
208
|
+
expect(article2.previous).to be_nil
|
213
209
|
end
|
214
210
|
end
|
215
211
|
context 'when the element is in the middle' do
|
216
212
|
it 'removes the element' do
|
217
|
-
article = Article.create(:
|
218
|
-
article2 = Article.create(:
|
219
|
-
article3 = Article.create(:
|
213
|
+
article = Article.create(name: 'first!')
|
214
|
+
article2 = Article.create(name: 'second!')
|
215
|
+
article3 = Article.create(name: 'last!')
|
220
216
|
|
221
217
|
article = Article.find_by_name('first!')
|
222
218
|
|
@@ -226,20 +222,20 @@ module Resort
|
|
226
222
|
article = Article.find_by_name('first!')
|
227
223
|
article3 = Article.find_by_name('last!')
|
228
224
|
|
229
|
-
article.
|
230
|
-
article.next.name.
|
231
|
-
article3.previous.name.
|
225
|
+
expect(article).to be_first
|
226
|
+
expect(article.next.name).to eq 'last!'
|
227
|
+
expect(article3.previous.name).to eq 'first!'
|
232
228
|
end
|
233
229
|
end
|
234
230
|
context 'when the element is last' do
|
235
231
|
it 'removes the element' do
|
236
|
-
|
237
|
-
article2 = Article.create(:
|
238
|
-
article3 = Article.create(:
|
232
|
+
Article.create(name: 'first!')
|
233
|
+
article2 = Article.create(name: 'second!')
|
234
|
+
article3 = Article.create(name: 'last!')
|
239
235
|
|
240
236
|
article3.destroy
|
241
237
|
|
242
|
-
article2.next.
|
238
|
+
expect(article2.next).to be_nil
|
243
239
|
end
|
244
240
|
end
|
245
241
|
after do
|
@@ -250,10 +246,10 @@ module Resort
|
|
250
246
|
describe 'InstanceMethods' do
|
251
247
|
before do
|
252
248
|
Article.destroy_all
|
253
|
-
Article.create(:
|
254
|
-
Article.create(:
|
255
|
-
Article.create(:
|
256
|
-
Article.create(:
|
249
|
+
Article.create(name: '1')
|
250
|
+
Article.create(name: '2')
|
251
|
+
Article.create(name: '3')
|
252
|
+
Article.create(name: '4')
|
257
253
|
|
258
254
|
@article1 = Article.find_by_name('1')
|
259
255
|
@article2 = Article.find_by_name('2')
|
@@ -261,47 +257,47 @@ module Resort
|
|
261
257
|
@article4 = Article.find_by_name('4')
|
262
258
|
end
|
263
259
|
|
264
|
-
describe
|
265
|
-
it
|
260
|
+
describe '#push' do
|
261
|
+
it 'appends the element to the list' do
|
266
262
|
@article1.push
|
267
263
|
|
268
264
|
article1 = Article.find_by_name('1')
|
269
|
-
article1.previous.
|
270
|
-
article1.next.
|
265
|
+
expect(article1.previous).to eq @article4
|
266
|
+
expect(article1.next).to be_nil
|
271
267
|
end
|
272
268
|
context 'when the article is already last' do
|
273
269
|
it 'does nothing' do
|
274
270
|
@article4.push
|
275
271
|
|
276
|
-
@article4.previous.name.
|
277
|
-
@article4.next.
|
272
|
+
expect(@article4.previous.name).to eq '3'
|
273
|
+
expect(@article4.next).to be_nil
|
278
274
|
end
|
279
275
|
end
|
280
276
|
end
|
281
277
|
|
282
|
-
describe
|
283
|
-
it
|
278
|
+
describe '#prepend' do
|
279
|
+
it 'prepends the element' do
|
284
280
|
@article3.prepend
|
285
281
|
|
286
282
|
article3 = Article.find_by_name('3')
|
287
283
|
|
288
|
-
article3.
|
289
|
-
article3.previous.
|
290
|
-
article3.next.name.
|
284
|
+
expect(article3).to be_first
|
285
|
+
expect(article3.previous).to be_nil
|
286
|
+
expect(article3.next.name).to eq '1'
|
291
287
|
end
|
292
288
|
|
293
|
-
it
|
289
|
+
it 'prepends the last element' do
|
294
290
|
@article4.prepend
|
295
291
|
|
296
292
|
article4 = Article.find_by_name('4')
|
297
293
|
|
298
|
-
article4.
|
299
|
-
article4.previous.
|
300
|
-
article4.next.name.
|
294
|
+
expect(article4).to be_first
|
295
|
+
expect(article4.previous).to be_nil
|
296
|
+
expect(article4.next.name).to eq '1'
|
301
297
|
end
|
302
298
|
|
303
299
|
it 'will raise ActiveRecord::RecordNotSaved if update fails' do
|
304
|
-
@article2.
|
300
|
+
expect(@article2).to receive(:update_attribute).and_return(false)
|
305
301
|
expect { @article2.prepend }.to raise_error(ActiveRecord::RecordNotSaved)
|
306
302
|
end
|
307
303
|
|
@@ -309,123 +305,123 @@ module Resort
|
|
309
305
|
it 'does nothing' do
|
310
306
|
@article1.prepend
|
311
307
|
|
312
|
-
@article1.previous.
|
313
|
-
@article1.next.name.
|
308
|
+
expect(@article1.previous).to be_nil
|
309
|
+
expect(@article1.next.name).to eq '2'
|
314
310
|
end
|
315
311
|
end
|
316
312
|
end
|
317
313
|
|
318
|
-
describe
|
314
|
+
describe '#append_to' do
|
319
315
|
it 'will raise ActiveRecord::RecordNotSaved if update fails' do
|
320
|
-
@article2.
|
316
|
+
expect(@article2).to receive(:update_attribute).and_return(false)
|
321
317
|
expect { @article2.append_to(@article3) }.to raise_error(ActiveRecord::RecordNotSaved)
|
322
318
|
end
|
323
319
|
|
324
320
|
context 'appending 1 after 2' do
|
325
|
-
it
|
321
|
+
it 'appends the element after another element' do
|
326
322
|
@article1.append_to(@article2)
|
327
323
|
|
328
324
|
article1 = Article.find_by_name('1')
|
329
|
-
article1.next.name.
|
330
|
-
article1.previous.name.
|
331
|
-
@article3.previous.name.
|
325
|
+
expect(article1.next.name).to eq '3'
|
326
|
+
expect(article1.previous.name).to eq '2'
|
327
|
+
expect(@article3.previous.name).to eq '1'
|
332
328
|
end
|
333
329
|
|
334
|
-
it
|
330
|
+
it 'sets the other element as first' do
|
335
331
|
@article1.append_to(@article2)
|
336
332
|
|
337
333
|
article2 = Article.find_by_name('2')
|
338
|
-
article2.next.name.
|
339
|
-
article2.
|
334
|
+
expect(article2.next.name).to eq '1'
|
335
|
+
expect(article2).to be_first
|
340
336
|
end
|
341
337
|
end
|
342
338
|
|
343
339
|
context 'appending 1 after 3' do
|
344
|
-
it
|
340
|
+
it 'appends the element after another element' do
|
345
341
|
@article1.append_to(@article3)
|
346
342
|
|
347
343
|
article1 = Article.find_by_name('1')
|
348
|
-
article1.
|
349
|
-
article1.previous.name.
|
350
|
-
article1.next.name.
|
344
|
+
expect(article1).to_not be_first
|
345
|
+
expect(article1.previous.name).to eq '3'
|
346
|
+
expect(article1.next.name).to eq '4'
|
351
347
|
|
352
|
-
@article3.next.name.
|
353
|
-
@article4.previous.name.
|
348
|
+
expect(@article3.next.name).to eq '1'
|
349
|
+
expect(@article4.previous.name).to eq '1'
|
354
350
|
end
|
355
351
|
|
356
352
|
it 'resets the first element' do
|
357
353
|
@article1.append_to(@article3)
|
358
354
|
|
359
355
|
article2 = Article.find_by_name('2')
|
360
|
-
article2.
|
361
|
-
article2.previous.
|
356
|
+
expect(article2).to be_first
|
357
|
+
expect(article2.previous).to be_nil
|
362
358
|
end
|
363
359
|
end
|
364
360
|
|
365
361
|
context 'appending 2 after 3' do
|
366
|
-
it
|
362
|
+
it 'appends the element after another element' do
|
367
363
|
@article2.append_to(@article3)
|
368
364
|
|
369
365
|
article1 = Article.find_by_name('1')
|
370
|
-
article1.next.name.
|
366
|
+
expect(article1.next.name).to eq '3'
|
371
367
|
|
372
368
|
article2 = Article.find_by_name('2')
|
373
|
-
article2.previous.name.
|
374
|
-
article2.next.name.
|
369
|
+
expect(article2.previous.name).to eq '3'
|
370
|
+
expect(article2.next.name).to eq '4'
|
375
371
|
|
376
|
-
@article3.previous.name.
|
377
|
-
@article3.next.name.
|
372
|
+
expect(@article3.previous.name).to eq '1'
|
373
|
+
expect(@article3.next.name).to eq '2'
|
378
374
|
|
379
|
-
@article4.previous.name.
|
375
|
+
expect(@article4.previous.name).to eq '2'
|
380
376
|
end
|
381
377
|
end
|
382
378
|
context 'appending 2 after 4' do
|
383
|
-
it
|
379
|
+
it 'appends the element after another element' do
|
384
380
|
@article2.append_to(@article4)
|
385
381
|
|
386
382
|
article1 = Article.find_by_name('1')
|
387
383
|
article3 = Article.find_by_name('3')
|
388
384
|
|
389
|
-
article1.next.name.
|
390
|
-
article3.previous.name.
|
385
|
+
expect(article1.next.name).to eq '3'
|
386
|
+
expect(article3.previous.name).to eq '1'
|
391
387
|
|
392
388
|
article2 = Article.find_by_name('2')
|
393
|
-
article2.previous.name.
|
394
|
-
article2.
|
389
|
+
expect(article2.previous.name).to eq '4'
|
390
|
+
expect(article2).to be_last
|
395
391
|
|
396
|
-
@article4.next.name.
|
392
|
+
expect(@article4.next.name).to eq '2'
|
397
393
|
end
|
398
394
|
end
|
399
395
|
context 'appending 4 after 2' do
|
400
|
-
it
|
396
|
+
it 'appends the element after another element' do
|
401
397
|
@article4.append_to(@article2)
|
402
398
|
|
403
399
|
article3 = Article.find_by_name('3')
|
404
|
-
article3.next.
|
405
|
-
article3.previous.name.
|
400
|
+
expect(article3.next).to be_nil
|
401
|
+
expect(article3.previous.name).to eq '4'
|
406
402
|
|
407
403
|
article4 = Article.find_by_name('4')
|
408
|
-
@article2.next.name.
|
409
|
-
article4.previous.name.
|
410
|
-
article4.next.name.
|
404
|
+
expect(@article2.next.name).to eq '4'
|
405
|
+
expect(article4.previous.name).to eq '2'
|
406
|
+
expect(article4.next.name).to eq '3'
|
411
407
|
end
|
412
408
|
end
|
413
409
|
context 'appending 3 after 1' do
|
414
|
-
it
|
410
|
+
it 'appends the element after another element' do
|
415
411
|
@article3.append_to(@article1)
|
416
412
|
|
417
413
|
article1 = Article.find_by_name('1')
|
418
|
-
article1.next.name.
|
414
|
+
expect(article1.next.name).to eq '3'
|
419
415
|
|
420
416
|
article2 = Article.find_by_name('2')
|
421
|
-
article2.previous.name.
|
422
|
-
article2.next.name.
|
417
|
+
expect(article2.previous.name).to eq '3'
|
418
|
+
expect(article2.next.name).to eq '4'
|
423
419
|
|
424
420
|
article3 = Article.find_by_name('3')
|
425
|
-
article3.previous.name.
|
426
|
-
article3.next.name.
|
421
|
+
expect(article3.previous.name).to eq '1'
|
422
|
+
expect(article3.next.name).to eq '2'
|
427
423
|
|
428
|
-
@article4.previous.name.
|
424
|
+
expect(@article4.previous.name).to eq '2'
|
429
425
|
end
|
430
426
|
end
|
431
427
|
|
@@ -436,12 +432,11 @@ module Resort
|
|
436
432
|
article1 = Article.find_by_name('1')
|
437
433
|
article2 = Article.find_by_name('2')
|
438
434
|
|
439
|
-
article1.next.name.
|
440
|
-
article2.previous.name.
|
435
|
+
expect(article1.next.name).to eq '2'
|
436
|
+
expect(article2.previous.name).to eq '1'
|
441
437
|
end
|
442
438
|
end
|
443
439
|
end
|
444
440
|
end
|
445
|
-
|
446
441
|
end
|
447
442
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rspec'
|
2
3
|
|
3
4
|
module Rails
|
4
5
|
class << self
|
5
6
|
# 3.0 defaults this, 3.1 does not
|
6
7
|
def application
|
7
|
-
|
8
|
+
'application'
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
@@ -13,8 +14,8 @@ require 'resort'
|
|
13
14
|
require 'logger'
|
14
15
|
|
15
16
|
ActiveRecord::Base.establish_connection(
|
16
|
-
:
|
17
|
-
:
|
17
|
+
adapter: 'sqlite3',
|
18
|
+
database: ':memory:'
|
18
19
|
)
|
19
20
|
|
20
21
|
ActiveRecord::Schema.define do
|
@@ -25,12 +26,12 @@ ActiveRecord::Schema.define do
|
|
25
26
|
t.boolean :first
|
26
27
|
t.references :next
|
27
28
|
|
28
|
-
t.timestamps
|
29
|
+
t.timestamps null: false
|
29
30
|
end
|
30
31
|
|
31
32
|
create_table :ordered_lists do |t|
|
32
33
|
t.string :name
|
33
|
-
t.timestamps
|
34
|
+
t.timestamps null: false
|
34
35
|
end
|
35
36
|
|
36
37
|
create_table :list_items do |t|
|
@@ -38,7 +39,7 @@ ActiveRecord::Schema.define do
|
|
38
39
|
t.boolean :first
|
39
40
|
t.references :next
|
40
41
|
t.references :ordered_list
|
41
|
-
t.timestamps
|
42
|
+
t.timestamps null: false
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
@@ -49,7 +50,7 @@ class Article < ActiveRecord::Base
|
|
49
50
|
end
|
50
51
|
|
51
52
|
class OrderedList < ActiveRecord::Base
|
52
|
-
has_many :items, :
|
53
|
+
has_many :items, class_name: 'ListItem'
|
53
54
|
end
|
54
55
|
|
55
56
|
class ListItem < ActiveRecord::Base
|
@@ -59,6 +60,6 @@ class ListItem < ActiveRecord::Base
|
|
59
60
|
default_scope { order('created_at desc') }
|
60
61
|
|
61
62
|
def siblings
|
62
|
-
|
63
|
+
ordered_list.items
|
63
64
|
end
|
64
65
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resort
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oriol Gual
|
@@ -10,52 +10,52 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 4.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - "
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
28
|
+
version: 4.0.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
30
|
+
name: activesupport
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
36
|
-
type: :
|
35
|
+
version: 4.0.0
|
36
|
+
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 4.0.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
44
|
+
name: railties
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - "
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
type: :
|
49
|
+
version: 4.0.0
|
50
|
+
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - "
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
56
|
+
version: 4.0.0
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
58
|
+
name: sqlite3
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
@@ -69,7 +69,21 @@ dependencies:
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
72
|
+
name: rspec
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.5'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '3.5'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: generator_spec
|
73
87
|
requirement: !ruby/object:Gem::Requirement
|
74
88
|
requirements:
|
75
89
|
- - ">="
|
@@ -83,20 +97,20 @@ dependencies:
|
|
83
97
|
- !ruby/object:Gem::Version
|
84
98
|
version: '0'
|
85
99
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
100
|
+
name: yard
|
87
101
|
requirement: !ruby/object:Gem::Requirement
|
88
102
|
requirements:
|
89
|
-
- - "
|
103
|
+
- - ">="
|
90
104
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0
|
105
|
+
version: '0'
|
92
106
|
type: :development
|
93
107
|
prerelease: false
|
94
108
|
version_requirements: !ruby/object:Gem::Requirement
|
95
109
|
requirements:
|
96
|
-
- - "
|
110
|
+
- - ">="
|
97
111
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0
|
99
|
-
description: Positionless model sorting for Rails
|
112
|
+
version: '0'
|
113
|
+
description: Positionless model sorting for Rails.
|
100
114
|
email:
|
101
115
|
- info@codegram.com
|
102
116
|
executables: []
|
@@ -130,20 +144,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
144
|
requirements:
|
131
145
|
- - ">="
|
132
146
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
147
|
+
version: 2.2.2
|
134
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
139
153
|
requirements: []
|
140
|
-
rubyforge_project:
|
154
|
+
rubyforge_project:
|
141
155
|
rubygems_version: 2.4.5
|
142
156
|
signing_key:
|
143
157
|
specification_version: 4
|
144
|
-
summary: Positionless model sorting for Rails
|
158
|
+
summary: Positionless model sorting for Rails.
|
145
159
|
test_files:
|
146
160
|
- spec/generators/migration_spec.rb
|
147
161
|
- spec/resort_spec.rb
|
148
162
|
- spec/spec_helper.rb
|
149
|
-
has_rdoc:
|