paginative 0.0.8 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paginative/models/model_extension.rb +5 -1
- data/lib/paginative/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +83 -0
- data/spec/dummy/log/test.log +36304 -9117
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cddedd919c12871404bc714b08dbfe1c0132f8de
|
4
|
+
data.tar.gz: 30989c919ef281f875555229451a89910eb9b4b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e237a0c2f5c73b760146a58da1151b4364b7ee6bc0f077a5cb8e4f4587d2c1d681cd95aa13ebdde7e77f96d0e7aadf0fcab0e12037eba0e611855fcc88827d63
|
7
|
+
data.tar.gz: 62cc03a5ea20a24e5f77240dfc6c4179cbdc1502b9d9575399054e1e29edd1795a71a6a2729c19ec7a70bdc0bb1d86a8c74af71df31f9ce197c1cd2b484717d0
|
@@ -5,7 +5,7 @@ module Paginative
|
|
5
5
|
included do
|
6
6
|
def self.by_distance_from(latitude, longitude, distance=0, limit=25)
|
7
7
|
return [] unless latitude.present? && longitude.present?
|
8
|
-
distance_sql = send(:distance_sql, latitude.to_f, longitude.to_f, {:units => :km, select_bearing: false})
|
8
|
+
distance_sql = send(:distance_sql, latitude.to_f, longitude.to_f, {:units => :km, select_bearing: false, order: "distance ASC"})
|
9
9
|
|
10
10
|
self.where("#{distance_sql} > #{distance}").offset(0).limit(limit)
|
11
11
|
end
|
@@ -21,6 +21,10 @@ module Paginative
|
|
21
21
|
|
22
22
|
def self.with_field_from(field="", value="", limit=25, order="asc")
|
23
23
|
field = "#{self.name.tableize}.#{field}"
|
24
|
+
|
25
|
+
#replaces the / when tableizing a namespaced class
|
26
|
+
field = field.sub('/','_')
|
27
|
+
|
24
28
|
return self.order("#{field} DESC").where("#{field} < '#{value}'").limit(limit) if order == "desc"
|
25
29
|
self.order("#{field} ASC").where("#{field} > '#{value}'").limit(limit)
|
26
30
|
end
|
data/lib/paginative/version.rb
CHANGED
Binary file
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -0,0 +1,83 @@
|
|
1
|
+
[1m[36m (2.0ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
2
|
+
[1m[35m (0.4ms)[0m select sqlite_version(*)
|
3
|
+
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
4
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
5
|
+
Migrating to CreatePaginativeTestModels (20140415060518)
|
6
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
7
|
+
[1m[35m (0.6ms)[0m CREATE TABLE "paginative_test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime)
|
8
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES (?)[0m [["version", "20140415060518"]]
|
9
|
+
[1m[35m (0.8ms)[0m commit transaction
|
10
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
11
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.3ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
12
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
13
|
+
[1m[36m (1.1ms)[0m [1mCREATE TABLE "paginative_test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime) [0m
|
14
|
+
[1m[35m (0.9ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
15
|
+
[1m[36m (0.4ms)[0m [1mselect sqlite_version(*)[0m
|
16
|
+
[1m[35m (0.9ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
17
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
18
|
+
[1m[35m (0.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20140415060518')
|
19
|
+
[1m[36m (1.2ms)[0m [1mCREATE TABLE "paginative_test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime) [0m
|
20
|
+
[1m[35m (2.8ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
21
|
+
[1m[36m (0.2ms)[0m [1mselect sqlite_version(*)[0m
|
22
|
+
[1m[35m (1.3ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
23
|
+
[1m[36m (0.2ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
24
|
+
[1m[35m (2.1ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20140415060518')
|
25
|
+
[1m[36m (1.0ms)[0m [1mCREATE TABLE "paginative_test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime) [0m
|
26
|
+
[1m[35m (0.9ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
27
|
+
[1m[36m (0.4ms)[0m [1mselect sqlite_version(*)[0m
|
28
|
+
[1m[35m (0.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
29
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
30
|
+
[1m[35m (0.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20140415060518')
|
31
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.9ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
32
|
+
Migrating to AddAddressToTestModels (20140416020706)
|
33
|
+
[1m[35m (0.1ms)[0m begin transaction
|
34
|
+
[1m[36m (0.2ms)[0m [1mALTER TABLE "test_models" ADD "address" varchar(255)[0m
|
35
|
+
SQLite3::SQLException: no such table: test_models: ALTER TABLE "test_models" ADD "address" varchar(255)
|
36
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
37
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
38
|
+
Migrating to AddAddressToTestModels (20140416020706)
|
39
|
+
[1m[35m (0.1ms)[0m begin transaction
|
40
|
+
[1m[36m (3.0ms)[0m [1mALTER TABLE "paginative_test_models" ADD "address" varchar(255)[0m
|
41
|
+
[1m[35mSQL (0.3ms)[0m INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140416020706"]]
|
42
|
+
[1m[36m (0.5ms)[0m [1mcommit transaction[0m
|
43
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
44
|
+
[1m[36m (1.3ms)[0m [1mCREATE TABLE "paginative_test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime, "address" varchar(255)) [0m
|
45
|
+
[1m[36m (1.1ms)[0m [1mCREATE TABLE "paginative_test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime, "address" varchar(255)) [0m
|
46
|
+
[1m[35m (0.7ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
47
|
+
[1m[36m (0.3ms)[0m [1mselect sqlite_version(*)[0m
|
48
|
+
[1m[35m (0.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
49
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
50
|
+
[1m[35m (0.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20140416020706')
|
51
|
+
[1m[36m (0.6ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20140415060518')[0m
|
52
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.3ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
53
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
54
|
+
[1m[36m (0.9ms)[0m [1mCREATE TABLE "paginative_test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime, "address" varchar(255)) [0m
|
55
|
+
[1m[35m (0.9ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
56
|
+
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
57
|
+
[1m[35m (0.8ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
58
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
59
|
+
[1m[35m (0.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20140416020706')
|
60
|
+
[1m[36m (0.6ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20140415060518')[0m
|
61
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.4ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
62
|
+
Migrating to CreateTestModels (20140416035443)
|
63
|
+
[1m[35m (0.1ms)[0m begin transaction
|
64
|
+
[1m[36m (1.0ms)[0m [1mCREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "address" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime) [0m
|
65
|
+
[1m[35mSQL (0.2ms)[0m INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140416035443"]]
|
66
|
+
[1m[36m (1.1ms)[0m [1mcommit transaction[0m
|
67
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|
68
|
+
[1m[36m (1.2ms)[0m [1mCREATE TABLE "paginative_test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime, "address" varchar(255)) [0m
|
69
|
+
[1m[35m (0.9ms)[0m CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "address" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime)
|
70
|
+
[1m[36m (0.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
71
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
72
|
+
[1m[36m (0.7ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
73
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
74
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20140416035443')[0m
|
75
|
+
[1m[36m (1.6ms)[0m [1mCREATE TABLE "paginative_test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime, "address" varchar(255)) [0m
|
76
|
+
[1m[35m (0.9ms)[0m CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "address" varchar(255), "latitude" float, "longitude" float, "created_at" datetime, "updated_at" datetime)
|
77
|
+
[1m[36m (0.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
78
|
+
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
79
|
+
[1m[36m (0.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
80
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
81
|
+
[1m[36m (0.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20140416035443')[0m
|
82
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.4ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
83
|
+
[1m[35mActiveRecord::SchemaMigration Load (0.1ms)[0m SELECT "schema_migrations".* FROM "schema_migrations"
|