redis_pagination 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTViNTg2OWQ3Y2U3ZTQyNmQ0ZGRiMjM0ZTBlM2QwZjY2MjcxNmJhMQ==
4
+ YjE2NGQ2M2YxODZmZjRkZTU1YzU5MzUxMjEzMjRhMDYxOGMxZDkzYQ==
5
5
  data.tar.gz: !binary |-
6
- NzE2YWE1NTFlMmZjOTY2NDdkZWFlNGJjYWYzMWM2MjZkOWQyOGEzMA==
6
+ MTJmNDVjMjJjMGY4MzNmZDRmNTBlOGFjYzYzNGQ4NGYzMmM3ODk0Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjZjOWU5MjU1MTUxM2YyODkwMzhkMDBkOTFmMmIwYmI0YWFkMWE3MjU1OTNm
10
- NGU0MDlmYjg5YzcwZDY4MTEzZjZlYjgwNDU4ODZkZDJlYjA1Mzc4ZGFjYzA4
11
- YjZiYjA2NTlhMGQxOWFkZTgzOWJmMjQ3NDc3NTY1NTg1NDg2NWI=
9
+ MTU5ZTM2M2NhOWZiNjI0OWE2ZTVkZWNlYTU2YjUxZDU5YmQ4MGRmZjQ4OTNj
10
+ NWY2Y2Y3MWY3NWIyYmE3ZjAyOWZhOGU0YTE5NGZhMDJiNzY0MjMzNGI5MTUw
11
+ OThiZDk2NGI1NTQwODc1OGI0MzQyYjcyNzkyMThlMjM5ZjhjMTU=
12
12
  data.tar.gz: !binary |-
13
- MzdiYWYzZTA1OTlmNWNjZjNiNWY1NzNlNTFiYzMwMDQyZjQwNTRlNDk5NmE0
14
- ZGJkMjI5Yzk5YjIxNDY5NjA2YzUyZWYxZmM4OGQ0ZWQ3YmVhNTAxMzQyNmFk
15
- MWMwNzI2ZDg1MzdjYzRmZjMyNzM1NjlkOGNiYzE5Y2NkZDY3NDk=
13
+ OTU5N2M0ODFiOTU4OTM0MTI4Njg4NzM2NjVhYzhlODYyNGZlMGVlYjI4YTlj
14
+ OGIyYWM5ZDAwMDM0Njk5YmM3MmU3MjE5ZWQwY2VmZDk0YTk1ZGQ0NTFiYjQ5
15
+ MmE0YWMyNWU3M2RiODY0MTM0Yjk5MDdkZTY5NTRjODc1MDkwMjc=
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.2.0 (2014-05-15)
4
+
5
+ * Added `#all` method to `RedisPagination::Paginator::NonePaginator`.
6
+ * Ensure various `#all` methods return Hash containing
7
+ `:current_page`, `:total_pages`, `:total_items` and `:items`.
8
+
3
9
  ## 1.1.0 (2014-05-14)
4
10
 
5
11
  * Added `#all` method to `RedisPagination::Paginator::SortedSetPaginator` and
@@ -49,9 +49,11 @@ module RedisPagination
49
49
 
50
50
  # Retrieve all items for +key+.
51
51
  #
52
- # @return a +Hash+ containing +:total_items+ and +:items+.
52
+ # @return a +Hash+ containing +:current_page+, +:total_pages+, +:total_items+ and +:items+.
53
53
  def all(options = {})
54
54
  {
55
+ :current_page => 1,
56
+ :total_pages => 1,
55
57
  :total_items => total_items,
56
58
  :items => RedisPagination.redis.lrange(@key, 0, -1)
57
59
  }
@@ -11,7 +11,7 @@ module RedisPagination
11
11
  # Return the total number of pages for +key+.
12
12
  #
13
13
  # @param page_size [int] Page size to calculate total number of pages.
14
- #
14
+ #
15
15
  # @return the total number of pages for +key+.
16
16
  def total_pages(page_size = RedisPagination.page_size)
17
17
  0
@@ -28,7 +28,7 @@ module RedisPagination
28
28
  #
29
29
  # @param page [int] Page of items to retrieve.
30
30
  # @param options [Hash] Options. Valid options are :page_size.
31
- # :page_size controls the page size for the call. Default is +RedisPagination.page_size+.
31
+ # :page_size controls the page size for the call. Default is +RedisPagination.page_size+.
32
32
  #
33
33
  # @return a +Hash+ containing +:current_page+, +:total_pages+, +:total_items+ and +:items+.
34
34
  def page(page, options = {})
@@ -39,7 +39,19 @@ module RedisPagination
39
39
  :total_pages => 0,
40
40
  :total_items => 0,
41
41
  :items => []
42
- }
42
+ }
43
+ end
44
+
45
+ # Retrieve all items for +key+.
46
+ #
47
+ # @return a +Hash+ containing +:current_page+, +:total_pages+, +:total_items+ and +:items+.
48
+ def all(options = {})
49
+ {
50
+ :current_page => 1,
51
+ :total_pages => 0,
52
+ :total_items => 0,
53
+ :items => []
54
+ }
43
55
  end
44
56
  end
45
57
  end
@@ -62,12 +62,14 @@ module RedisPagination
62
62
  # :with_scores controls whether the score is returned along with the item. Default is +true+.
63
63
  # :reverse controls whether to return items in highest-to-lowest (+true+) or loweest-to-highest order (+false+). Default is +true+.
64
64
  #
65
- # @return a +Hash+ containing +:total_items+ and +:items+.
65
+ # @return a +Hash+ containing +:current_page+, +:total_pages+, +:total_items+ and +:items+.
66
66
  def all(options = {})
67
67
  with_scores = options.has_key?(:with_scores) ? options[:with_scores] : true
68
68
  reverse = options.has_key?(:reverse) ? options[:reverse] : true
69
69
 
70
70
  {
71
+ :current_page => 1,
72
+ :total_pages => 1,
71
73
  :total_items => total_items,
72
74
  :items => if reverse
73
75
  RedisPagination.redis.zrevrange(@key, 0, -1, :with_scores => with_scores)
@@ -1,3 +1,3 @@
1
1
  module RedisPagination
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -21,7 +21,7 @@ describe RedisPagination::Paginator::NonePaginator do
21
21
  end
22
22
 
23
23
  describe '#page' do
24
- it 'should return the correct page of items' do
24
+ it 'should return the correct page of items' do
25
25
  items_paginator = RedisPagination.paginate('unknown-key-in-redis')
26
26
  result = items_paginator.page(1)
27
27
  result[:items].length.should == 0
@@ -42,4 +42,14 @@ describe RedisPagination::Paginator::NonePaginator do
42
42
  result[:total_pages].should == 0
43
43
  end
44
44
  end
45
+
46
+ describe '#all' do
47
+ it 'should return all the items with the default options' do
48
+ items_paginator = RedisPagination.paginate('unknown-key-in-redis')
49
+ items_paginator.all.tap do |all_items|
50
+ all_items[:total_items].should == 0
51
+ all_items[:items].length.should == 0
52
+ end
53
+ end
54
+ end
45
55
  end
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe 'RedisPagination::VERSION' do
4
4
  it 'should be the correct version' do
5
- RedisPagination::VERSION.should == '1.1.0'
5
+ RedisPagination::VERSION.should == '1.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Czarnecki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-14 00:00:00.000000000 Z
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis