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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29581ed5677e51c2208d9d6084fa5a49afc40dc9
4
- data.tar.gz: 92362dc85f0d2593a4f14ed119d4d0d6e33989a4
3
+ metadata.gz: 1636cb2175a8d3d441067544e5ab2236cffdaf59
4
+ data.tar.gz: b435a6ca05bf3a7f0240f0e5bd726a6714c2afaf
5
5
  SHA512:
6
- metadata.gz: b5277487bb87290cd3512b916d531cc8a9a0d3806349c9f83b122fccef6fb3804abdc5ed9aae837e617c4d6df4b4ac7d6941de1627f112f621bd8e1f4bfaa821
7
- data.tar.gz: 78dacdfc195b83d5d982176fa7465dc217bd57bdd36d5e9260c9a3c95dad5e62ad0a3f7ae938fd8599f1f4d4f4064c90246453c9b04172cded58a3ede3a75737
6
+ metadata.gz: 33ba5182cf87b242e63f700b75d35698ee7a166d41988ac066a50579c899d1f044f057cf4ed7883443693316e7cdf79dfa3b0ecdd7c988815492b91bfbe4f8d5
7
+ data.tar.gz: ac1b0ce883e7096a806de147e6baa56be67249b3a1890a453072f3dcb22fc508a446320972d8ff8ed11fa4d1f03d17e7d293d3d8b5cb032b97d7275762aca43c
@@ -1 +1 @@
1
- 2.3.5
1
+ 2.3.6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.32
1
+ 0.0.33
@@ -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.32 ruby lib
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.32"
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-03-28"
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.5.2.1".freeze
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
- begin
16
- result = query.fetch.fetch(:count).to_i
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
- if @limit
188
- sql = "LIMIT #{@db.sqlval(@limit)}"
189
- sql << ", #{@db.sqlval(@offset)}" if @offset
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
@@ -1,4 +1,4 @@
1
- class Baza::InfoMysql
1
+ class Baza::InfoMysql2
2
2
  attr_reader :db
3
3
 
4
4
  def initialize(args = {})
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.32
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-03-28 00:00:00.000000000 Z
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.5.2.1
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.