ants 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +0 -1
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/Gemfile.lock +30 -1
- data/README.md +9 -2
- data/Rakefile +17 -1
- data/ants.gemspec +4 -5
- data/lib/ants/version.rb +1 -1
- data/lib/concerns/ants/sorted_relations.rb +2 -2
- data/spec/spec_helper.rb +4 -1
- metadata +40 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8c6a614bddaf771cea07967a40889d1906b77bf
|
4
|
+
data.tar.gz: 2fd8e2ee2a1082cd3553e32a3b339ac82760737f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e274801d1607d7a8183f36900b295a4110db77f3140d4e2102e0cf8d55e1e5b47eb4d850c303fd63e279840d28a8ee8bc74716e0ea5a521571d5b7b4520709d
|
7
|
+
data.tar.gz: 3d09b56d1833ebd0f47eddbcd97e883b746bd5cf43b4e8b7bc3143324b8deabcc35238322c76747d7caba0da76b27ebdac2dc33ebb5aa137f4dca25b693ae620
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ants (0.1.
|
4
|
+
ants (0.1.1)
|
5
5
|
mongoid (>= 4.0)
|
6
6
|
mongoid-slug (>= 4.0.0)
|
7
7
|
|
@@ -47,10 +47,21 @@ GEM
|
|
47
47
|
bson (2.3.0)
|
48
48
|
builder (3.2.2)
|
49
49
|
connection_pool (2.2.0)
|
50
|
+
coveralls (0.8.1)
|
51
|
+
json (~> 1.8)
|
52
|
+
rest-client (>= 1.6.8, < 2)
|
53
|
+
simplecov (~> 0.10.0)
|
54
|
+
term-ansicolor (~> 1.3)
|
55
|
+
thor (~> 0.19.1)
|
50
56
|
diff-lcs (1.2.5)
|
57
|
+
docile (1.1.5)
|
58
|
+
domain_name (0.5.24)
|
59
|
+
unf (>= 0.0.5, < 1.0.0)
|
51
60
|
erubis (2.7.0)
|
52
61
|
globalid (0.3.5)
|
53
62
|
activesupport (>= 4.1.0)
|
63
|
+
http-cookie (1.0.2)
|
64
|
+
domain_name (~> 0.5)
|
54
65
|
i18n (0.7.0)
|
55
66
|
json (1.8.2)
|
56
67
|
loofah (2.0.1)
|
@@ -72,6 +83,7 @@ GEM
|
|
72
83
|
bson (~> 2.2)
|
73
84
|
connection_pool (~> 2.0)
|
74
85
|
optionable (~> 0.2.0)
|
86
|
+
netrc (0.10.3)
|
75
87
|
nokogiri (1.6.6.2)
|
76
88
|
mini_portile (~> 0.6.0)
|
77
89
|
optionable (0.2.0)
|
@@ -104,6 +116,10 @@ GEM
|
|
104
116
|
rake (>= 0.8.7)
|
105
117
|
thor (>= 0.18.1, < 2.0)
|
106
118
|
rake (10.4.2)
|
119
|
+
rest-client (1.8.0)
|
120
|
+
http-cookie (>= 1.0.2, < 2.0)
|
121
|
+
mime-types (>= 1.16, < 3.0)
|
122
|
+
netrc (~> 0.7)
|
107
123
|
rspec (3.2.0)
|
108
124
|
rspec-core (~> 3.2.0)
|
109
125
|
rspec-expectations (~> 3.2.0)
|
@@ -118,6 +134,11 @@ GEM
|
|
118
134
|
diff-lcs (>= 1.2.0, < 2.0)
|
119
135
|
rspec-support (~> 3.2.0)
|
120
136
|
rspec-support (3.2.2)
|
137
|
+
simplecov (0.10.0)
|
138
|
+
docile (~> 1.1.0)
|
139
|
+
json (~> 1.8)
|
140
|
+
simplecov-html (~> 0.10.0)
|
141
|
+
simplecov-html (0.10.0)
|
121
142
|
sprockets (3.0.2)
|
122
143
|
rack (~> 1.0)
|
123
144
|
sprockets-rails (2.2.4)
|
@@ -125,16 +146,24 @@ GEM
|
|
125
146
|
activesupport (>= 3.0)
|
126
147
|
sprockets (>= 2.8, < 4.0)
|
127
148
|
stringex (2.5.2)
|
149
|
+
term-ansicolor (1.3.0)
|
150
|
+
tins (~> 1.0)
|
128
151
|
thor (0.19.1)
|
129
152
|
thread_safe (0.3.5)
|
153
|
+
tins (1.5.1)
|
130
154
|
tzinfo (1.2.2)
|
131
155
|
thread_safe (~> 0.1)
|
156
|
+
unf (0.1.4)
|
157
|
+
unf_ext
|
158
|
+
unf_ext (0.0.7.1)
|
132
159
|
|
133
160
|
PLATFORMS
|
134
161
|
ruby
|
135
162
|
|
136
163
|
DEPENDENCIES
|
137
164
|
ants!
|
165
|
+
bundler
|
166
|
+
coveralls
|
138
167
|
rails (>= 4.1)
|
139
168
|
rake (>= 0.8.7)
|
140
169
|
rspec (>= 2.0)
|
data/README.md
CHANGED
@@ -1,10 +1,17 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
ants
|
3
|
+
======
|
4
|
+
[![GitHub version](https://badge.fury.io/gh/slate-studio%2Fants.svg)](http://badge.fury.io/gh/slate-studio%2Fants)
|
5
|
+
[![Build Status](https://travis-ci.org/slate-studio/ants.svg)](https://travis-ci.org/slate-studio/ants)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/slate-studio/ants/badges/gpa.svg)](https://codeclimate.com/github/slate-studio/ants)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/slate-studio/ants/badge.svg)](https://coveralls.io/r/slate-studio/ants)
|
8
|
+
|
2
9
|
Collection of concerns and helpers for Rails + Mongoid + Character web development
|
3
10
|
|
4
11
|
|
5
12
|
### Sorted Relations
|
6
13
|
|
7
|
-
In Mongoid, the HM & HABTM relations return docs in
|
14
|
+
In Mongoid, the HM & HABTM relations return docs in random order. This workaround provides an ability to retrieve related documents in the same order it was stored.
|
8
15
|
|
9
16
|
Usage example:
|
10
17
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,19 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "rubygems"
|
3
|
-
require "bundler"
|
3
|
+
require "bundler"
|
4
|
+
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
|
13
|
+
Bundler::GemHelper.install_tasks
|
14
|
+
|
15
|
+
require 'rspec/core'
|
16
|
+
require 'rspec/core/rake_task'
|
17
|
+
task :default => :spec
|
18
|
+
|
19
|
+
RSpec::Core::RakeTask.new
|
data/ants.gemspec
CHANGED
@@ -18,6 +18,7 @@ Collection of concerns and helpers for Rails + Mongoid + Character web developme
|
|
18
18
|
s.rubyforge_project = 'ants'
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
s.require_paths = [ 'lib' ]
|
21
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
21
22
|
|
22
23
|
s.add_dependency('mongoid', '>= 4.0' )
|
23
24
|
s.add_dependency('mongoid-slug', '>= 4.0.0')
|
@@ -26,8 +27,6 @@ Collection of concerns and helpers for Rails + Mongoid + Character web developme
|
|
26
27
|
s.add_development_dependency('rake', [ '>= 0.8.7' ])
|
27
28
|
s.add_development_dependency('rspec', [ '>= 2.0' ])
|
28
29
|
s.add_development_dependency('rspec-aspic', [ '>= 0.0.2' ])
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
s.add_development_dependency 'bundler'
|
31
|
+
s.add_development_dependency 'coveralls'
|
32
|
+
end
|
data/lib/ants/version.rb
CHANGED
@@ -60,7 +60,7 @@ module Ants
|
|
60
60
|
sorted_relation_ids = self.send("#{ relation.name.to_s.singularize }_ids").map { |id| id.to_s }
|
61
61
|
|
62
62
|
sorted_documents = related_documents.sort_by do |document|
|
63
|
-
sorted_relation_ids.index(document.id.to_s)
|
63
|
+
sorted_relation_ids.index(document.id.to_s) || -1
|
64
64
|
end
|
65
65
|
|
66
66
|
return Mongoid::FakeCriteria.new(sorted_documents)
|
@@ -87,7 +87,7 @@ module Ants
|
|
87
87
|
|
88
88
|
# missing or new ids are in random order
|
89
89
|
sorted_documents = related_documents.sort_by do |document|
|
90
|
-
sorted_relation_ids.index(document.id.to_s)
|
90
|
+
sorted_relation_ids.index(document.id.to_s) || -1
|
91
91
|
end
|
92
92
|
|
93
93
|
return Mongoid::FakeCriteria.new(sorted_documents)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Kravets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -94,6 +94,34 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.0.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coveralls
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
description: |
|
98
126
|
Collection of concerns and helpers for Rails + Mongoid + Character web development
|
99
127
|
email: alex@slatestudio.com
|
@@ -101,7 +129,10 @@ executables: []
|
|
101
129
|
extensions: []
|
102
130
|
extra_rdoc_files: []
|
103
131
|
files:
|
132
|
+
- ".coveralls.yml"
|
104
133
|
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
105
136
|
- Gemfile
|
106
137
|
- Gemfile.lock
|
107
138
|
- LICENSE.md
|
@@ -150,4 +181,10 @@ rubygems_version: 2.4.6
|
|
150
181
|
signing_key:
|
151
182
|
specification_version: 4
|
152
183
|
summary: Collection of concerns for Rails + Mongoid + Character web development
|
153
|
-
test_files:
|
184
|
+
test_files:
|
185
|
+
- spec/mongoid/fake_criteria_spec.rb
|
186
|
+
- spec/mongoid/sorted_relations_spec.rb
|
187
|
+
- spec/spec_helper.rb
|
188
|
+
- spec/support/models/author.rb
|
189
|
+
- spec/support/models/book.rb
|
190
|
+
- spec/support/models/chapter.rb
|