baza 0.0.32 → 0.0.33
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/VERSION +1 -1
- data/baza.gemspec +4 -4
- data/lib/baza/sql_queries/select.rb +20 -10
- data/spec/info_mysql2_example.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1636cb2175a8d3d441067544e5ab2236cffdaf59
|
4
|
+
data.tar.gz: b435a6ca05bf3a7f0240f0e5bd726a6714c2afaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33ba5182cf87b242e63f700b75d35698ee7a166d41988ac066a50579c899d1f044f057cf4ed7883443693316e7cdf79dfa3b0ecdd7c988815492b91bfbe4f8d5
|
7
|
+
data.tar.gz: ac1b0ce883e7096a806de147e6baa56be67249b3a1890a453072f3dcb22fc508a446320972d8ff8ed11fa4d1f03d17e7d293d3d8b5cb032b97d7275762aca43c
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.33
|
data/baza.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: baza 0.0.
|
5
|
+
# stub: baza 0.0.33 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "baza".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.33"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Kasper Johansen".freeze]
|
14
|
-
s.date = "2018-
|
14
|
+
s.date = "2018-04-26"
|
15
15
|
s.description = "A database abstraction layer, model framework and database framework.".freeze
|
16
16
|
s.email = "kj@gfish.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -202,7 +202,7 @@ Gem::Specification.new do |s|
|
|
202
202
|
]
|
203
203
|
s.homepage = "http://github.com/kaspernj/baza".freeze
|
204
204
|
s.licenses = ["MIT".freeze]
|
205
|
-
s.rubygems_version = "2.
|
205
|
+
s.rubygems_version = "2.6.13".freeze
|
206
206
|
s.summary = "A database abstraction layer, model framework and database framework.".freeze
|
207
207
|
|
208
208
|
if s.respond_to? :specification_version then
|
@@ -11,14 +11,13 @@ class Baza::SqlQueries::Select
|
|
11
11
|
|
12
12
|
def count
|
13
13
|
@count = true
|
14
|
+
query.fetch.fetch(:count).to_i
|
15
|
+
ensure
|
16
|
+
@count = false
|
17
|
+
end
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
ensure
|
18
|
-
@count = false
|
19
|
-
end
|
20
|
-
|
21
|
-
result
|
19
|
+
def current_page
|
20
|
+
@page || 1
|
22
21
|
end
|
23
22
|
|
24
23
|
def select(arg)
|
@@ -51,6 +50,11 @@ class Baza::SqlQueries::Select
|
|
51
50
|
self
|
52
51
|
end
|
53
52
|
|
53
|
+
def page(number)
|
54
|
+
@page = number.try(:to_i) || 1
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
54
58
|
def per_page(number)
|
55
59
|
@per_page = number
|
56
60
|
self
|
@@ -75,6 +79,7 @@ class Baza::SqlQueries::Select
|
|
75
79
|
end
|
76
80
|
|
77
81
|
def total_pages
|
82
|
+
@per_page ||= 30
|
78
83
|
per_page_value = @per_page
|
79
84
|
(count.to_f / per_page_value.to_f).ceil
|
80
85
|
end
|
@@ -184,9 +189,14 @@ private
|
|
184
189
|
end
|
185
190
|
|
186
191
|
def limit_sql
|
187
|
-
|
188
|
-
|
189
|
-
|
192
|
+
unless @count
|
193
|
+
if @page
|
194
|
+
@per_page ||= 30
|
195
|
+
sql = "LIMIT #{@db.sqlval(@per_page)} OFFSET #{@per_page * (current_page - 1)}"
|
196
|
+
elsif @limit
|
197
|
+
sql = "LIMIT #{@db.sqlval(@limit)}"
|
198
|
+
sql << ", #{@db.sqlval(@offset)}" if @offset
|
199
|
+
end
|
190
200
|
end
|
191
201
|
|
192
202
|
sql
|
data/spec/info_mysql2_example.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Johansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: array_enumerator
|
@@ -512,7 +512,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
512
512
|
version: '0'
|
513
513
|
requirements: []
|
514
514
|
rubyforge_project:
|
515
|
-
rubygems_version: 2.
|
515
|
+
rubygems_version: 2.6.13
|
516
516
|
signing_key:
|
517
517
|
specification_version: 4
|
518
518
|
summary: A database abstraction layer, model framework and database framework.
|