page_up 0.0.3 → 0.0.4

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: 553fdd8b2d92443f3358224b12fad52de5c6a3d2
4
- data.tar.gz: fb43ddef6e79f50a51f5b8c663bc8c4622e47f2f
3
+ metadata.gz: a4cad306d616a594283a2dfe39bde5bd33dd6164
4
+ data.tar.gz: 33c6ac47219e9a53c08fc81e8a8f9fe0c14f641d
5
5
  SHA512:
6
- metadata.gz: 0dde98238736f5797f96e9581f83af8a22b74940e2f5f4a833c0de4bb078e146064acdfac2d13d1b6f57b82fc04bac3f02accb0e447271e5a93a1b5d6b7f0125
7
- data.tar.gz: 55c243399d334a1f6378826561ba6f54b6630a7318a3a163faa35317ff8a1b5358a0ece94c3e479d074eb6999b433f793d7f7740efb71b8a42f1d9e0ab2daf2d
6
+ metadata.gz: 26ea5deee66abb0a8061674fbae44f9b571efa699069653b6e7c47922e65987f3019b34f4df10bf0e76f19e938167792a57c664f7b7c2bcad28741609ce6c1a4
7
+ data.tar.gz: 9edb21ae0a03cacdb9cd9773a6e32ab39ec5c512f2213280f450571f286eefff42d6f9786472803fe34aa485965adc27127541836085be1441775426e9e1ad3d
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/page_up/pages.rb CHANGED
@@ -8,6 +8,10 @@ module PageUp
8
8
  super collection[page_range]
9
9
  end
10
10
 
11
+ def total_size
12
+ @origin.size
13
+ end
14
+
11
15
  def pages
12
16
  if @origin.size > 0
13
17
  (@origin.size.to_f / per_page).ceil
@@ -22,40 +26,41 @@ module PageUp
22
26
 
23
27
  attr_reader :page, :per_page
24
28
 
25
- private
26
- def page_range
27
- current_page...current_page+per_page
28
- end
29
+ private
29
30
 
30
- def current_page
31
- (page-1)*per_page
32
- end
31
+ def page_range
32
+ current_page...current_page+per_page
33
+ end
33
34
 
34
- def parse value, default
35
- Integer(value)
36
- rescue TypeError
37
- default
38
- end
35
+ def current_page
36
+ (page-1)*per_page
37
+ end
39
38
 
40
- def slice_start
41
- if page - 2 <= 0
42
- 1
43
- elsif page + 2 > pages
44
- pages - 4
45
- else
46
- page - 2
47
- end
39
+ def parse value, default
40
+ Integer(value)
41
+ rescue TypeError
42
+ default
43
+ end
44
+
45
+ def slice_start
46
+ if page - 2 <= 0
47
+ 1
48
+ elsif page + 2 > pages
49
+ pages - 4
50
+ else
51
+ page - 2
48
52
  end
53
+ end
49
54
 
50
- def slice_end
51
- if page + 2 > pages || pages < 5
52
- pages
53
- elsif page - 2 <= 0
54
- 5
55
- else
56
- page + 2
57
- end
55
+ def slice_end
56
+ if page + 2 > pages || pages < 5
57
+ pages
58
+ elsif page - 2 <= 0
59
+ 5
60
+ else
61
+ page + 2
58
62
  end
63
+ end
59
64
 
60
65
  end
61
66
  end
@@ -1,3 +1,3 @@
1
1
  module PageUp
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/page_up.gemspec CHANGED
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rspec", "~> 2.14.0.rc0"
24
+ spec.add_development_dependency "rspec", "~> 2.14.0"
25
25
  end
@@ -30,6 +30,9 @@ describe "pagination" do
30
30
  expect(PageUp[[],1,5].pages).to eq 1
31
31
  end
32
32
 
33
+ it 'exposes original size' do
34
+ expect(PageUp[(1..100).to_a,1,5].total_size).to eq 100
35
+ end
33
36
 
34
37
  describe 'picking the current slice' do
35
38
  specify { expect(PageUp[[],1,1].current_slice).to eq 1..1 }
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Rowe
@@ -29,7 +29,7 @@ cert_chain:
29
29
  2feWfO4gCNmvfFjULOAYHq9JHEjN5SLSXvj5HdSnDcCyIfJKn5Ya3JahWQaWIsXf
30
30
  /NPE/mB57TOwj+d7XUa2NC4HUadF8R51IYEcIB0PpIEzJlKtfXFcOZxO
31
31
  -----END CERTIFICATE-----
32
- date: 2013-07-22 00:00:00.000000000 Z
32
+ date: 2013-10-31 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rake
@@ -65,14 +65,14 @@ dependencies:
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 2.14.0.rc0
68
+ version: 2.14.0
69
69
  type: :development
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: 2.14.0.rc0
75
+ version: 2.14.0
76
76
  description: Simple paginator
77
77
  email:
78
78
  - hello@jonrowe.co.uk
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.0.3
114
+ rubygems_version: 2.1.3
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Simple paginator
metadata.gz.sig CHANGED
Binary file