mobile_pagination 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ *.orig
3
4
  .bundle
4
5
  .config
5
6
  .yardoc
@@ -19,4 +20,4 @@ tmp
19
20
  .ruby-version
20
21
  .bundle
21
22
  vendor/ruby
22
- .rvmrc
23
+ .rvmrc
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # MobilePagination
2
2
 
3
3
  ## Description
4
- Rack gem for producing minimal pagination links.
4
+ Gem for producing minimal pagination links, best suited for smaller screens.
5
5
 
6
6
  ![<Display Name>](http://i.imgur.com/qZcqfx8.png)
7
7
 
8
-
9
8
  ## Installation
10
9
 
11
10
  Add this line to your application's Gemfile:
@@ -24,6 +23,12 @@ Or install it yourself as:
24
23
  Initializes with 4 options: `current_page, total_pages, query, path`
25
24
 
26
25
  ```ruby
26
+ # in your view, you may have something like this:
27
+ ol
28
+ = pagination
29
+
30
+ # in your helpers, you might have something like:
31
+
27
32
  require 'mobile_pagination'
28
33
 
29
34
  # http://local.m.newhomeguide.com/New-Homes/Georgia/Atlanta/?page=2
@@ -41,22 +46,8 @@ def pagination
41
46
  MobilePagination::Paginate.new(opts).html
42
47
  end
43
48
 
44
- # in your view, you may have something like this:
45
- ol
46
- = pagination
47
49
  ```
48
50
 
49
- ### Configuration
50
- Configuration is optional. Say for example you were paginating slides on a slideshow - instead of using page, you could configure the gem to use a different key.
51
-
52
- ```ruby
53
- MobilePagination.configure do |config|
54
- config.page_key = 'slide'
55
- end
56
- ```
57
-
58
- Configuration must run prior to initialization. The resulting pagination links will now contain `/?slide=2, /?slide=3` to suit your custom url structure. The default page_key is `page`.
59
-
60
51
  ### Overrides
61
52
 
62
53
  If you don't like list items, you will need to override `MobilePagination::Templates`
@@ -94,9 +85,23 @@ module MobilePagination
94
85
  end
95
86
  end
96
87
  ```
88
+ ### Configuration
89
+ Configuration is optional.
90
+
91
+ Say for example you were paginating slides on a slideshow - instead of using page, you could configure the gem to use a different key.
92
+
93
+ ```ruby
94
+ MobilePagination.configure do |config|
95
+ config.page_key = 'slide'
96
+ end
97
+ ```
98
+
99
+ Configuration must run prior to initialization. The resulting pagination links will now contain `/?slide=2, /?slide=3` to suit your custom url structure. The default page_key is `page`.
97
100
 
98
101
  Please note, any methods ending in `_link` will need to remain, as these methods are responsible for generating the paginated urls.
99
102
 
103
+ ### Testing
104
+ `rspec spec`
100
105
 
101
106
  ## Contributing
102
107
 
@@ -35,12 +35,24 @@ module MobilePagination
35
35
  @total_pages > 1
36
36
  end
37
37
 
38
+ def first_page?
39
+ @current_page != 1
40
+ end
41
+
38
42
  def previous_page?
39
- @current_page > 1
43
+ @current_page > 2
40
44
  end
41
45
 
42
46
  def next_page?
43
- not next_page_link.nil?
47
+ last_page? && !second_to_last?
48
+ end
49
+
50
+ def last_page?
51
+ @current_page != @total_pages
52
+ end
53
+
54
+ def second_to_last?
55
+ @current_page == (@total_pages - 1)
44
56
  end
45
57
 
46
58
  def current(page)
@@ -56,13 +68,13 @@ module MobilePagination
56
68
  page.nil? ? "#{@path}#{qs_without_key}" : "#{@path}#{qs_with_key(page)}"
57
69
  end
58
70
 
59
-
60
71
  def qs_with_key(page)
61
72
  "?#{hash_to_query(opts_with_key(page))}"
62
73
  end
63
74
 
64
75
  def qs_without_key
65
- "?#{hash_to_query(opts_without_key)}"
76
+ str = "#{hash_to_query(opts_without_key)}"
77
+ str.insert(0, '?') unless str.empty?
66
78
  end
67
79
 
68
80
  def opts_with_key(page)
@@ -28,10 +28,10 @@ module MobilePagination
28
28
  def html
29
29
  return '' unless should_paginate?
30
30
  ''.tap do |markup|
31
- markup << first_page_html if previous_page?
31
+ markup << first_page_html if first_page?
32
32
  markup << previous_page_html if previous_page?
33
33
  markup << next_page_html if next_page?
34
- markup << last_page_html if next_page?
34
+ markup << last_page_html if last_page?
35
35
  end
36
36
  end
37
37
 
@@ -1,3 +1,5 @@
1
+ require 'rack/utils'
2
+
1
3
  module MobilePagination
2
4
  module Utils
3
5
 
@@ -1,3 +1,3 @@
1
1
  module MobilePagination
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  require 'rubygems'
2
2
  require 'simplecov'
3
3
  require 'bundler/setup'
4
- require 'rack/utils'
5
4
 
6
- SimpleCov.start { add_filter '/spec/' }
5
+ SimpleCov.start {
6
+ add_filter '/spec/'
7
+ add_filter '/vendor/'
8
+
9
+ }
7
10
 
8
11
  require 'mobile_pagination'
9
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobile_pagination
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-14 00:00:00.000000000 Z
12
+ date: 2013-09-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake