pragmatic_serializer 0.2.2 → 0.3.0

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: e30a4f01c73e354ffd10da7b2d1d54be8b03bdb6
4
- data.tar.gz: 74a4572c779c6c78d51674a532162c34db4b31dc
3
+ metadata.gz: 7bdeb10cf2422e9d7834c72348a2f3e76be9f88d
4
+ data.tar.gz: fdae6a01e86e5d555230e9eabcbe5a506e53c2e9
5
5
  SHA512:
6
- metadata.gz: 2846f66b40fa40378803f61475992b7afeb40711461039cb8e4e5f9e740cb16aa1e37b3ce44824e3c30cc044a2dc452f48ddc8209ee3f5ee7dff49e4986d611e
7
- data.tar.gz: 43c1d53e626abd4496fa488bdef6a9614de25125fedb2d688b69daafb19cf86cf74199fd10ee19afd7a216192662c7cd02bdf527fe88bcdbdf1473f326b433e6
6
+ metadata.gz: f579940ad3a9ebe2a10a0bd51c7b53759f9d3648754efc5f5b7534fd18ec898ad7860bdfa7ed9fd684a033e25ccad3d5a452d73ea7c918af30b2958ea71f6fd2
7
+ data.tar.gz: 14ff1076e0f0a4c474e0ac3bfdef84288ce1b6bdfbce315ed7e921a0ebcae621b94902aef7871912114bf728e72d2b088655e6682604ba62206303cf50ac9782
data/.travis.yml CHANGED
@@ -6,9 +6,4 @@ rvm:
6
6
  - 2.2.4
7
7
  - 2.2.3
8
8
  - 2.2.2
9
- - 2.2.1
10
- - 2.2.0
11
- before_install: gem install bundler -v 1.12.2
12
- addons:
13
- code_climate:
14
- repo_token: 040965248b996dd45c137efd4f6db717ce637e62dbb896bd6a12830284e6a12c
9
+ before_install: gem install bundler
data/Gemfile CHANGED
@@ -3,5 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in pragmatic_serializer.gemspec
4
4
  gemspec
5
5
 
6
- gem "codeclimate-test-reporter", group: :test, require: nil
7
6
  gem "pry", group: :test, require: nil
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  [![Build Status](https://travis-ci.org/Pobble/pragmatic_serializer.svg?branch=master)](https://travis-ci.org/Pobble/pragmatic_serializer)
2
- [![Code Climate](https://codeclimate.com/github/Pobble/pragmatic_serializer/badges/gpa.svg)](https://codeclimate.com/github/Pobble/pragmatic_serializer)
3
- [![Test Coverage](https://codeclimate.com/github/Pobble/pragmatic_serializer/badges/coverage.svg)](https://codeclimate.com/github/Pobble/pragmatic_serializer/coverage)
4
2
  ![Gitten](http://gittens.r15.railsrumble.com//badge/Pobble/pragmatic_serializer)
5
- [![Open Thanks](https://thawing-falls-79026.herokuapp.com/images/thanks-1.svg)](https://thawing-falls-79026.herokuapp.com/r/vdygsixm)
6
3
 
7
4
  # PragmaticSerializer
8
5
 
@@ -1,13 +1,11 @@
1
1
  module PragmaticSerializer
2
2
  class PaginationJSON
3
3
  attr_reader :limit, :offset, :pagination_evaluator
4
- attr_accessor :maximum_offset
5
4
 
6
5
  def initialize(limit:, offset:, pagination_evaluator:)
7
6
  @limit = limit
8
7
  @offset = offset
9
8
  @pagination_evaluator = pagination_evaluator
10
- @maximum_offset = Float::INFINITY
11
9
  end
12
10
 
13
11
  def as_json
@@ -26,11 +24,12 @@ module PragmaticSerializer
26
24
  end
27
25
 
28
26
  def next
29
- pagination_evaluator.call(limit: limit, offset: offset+1) unless offset >= maximum_offset
27
+ pagination_evaluator.call(limit: limit, offset: offset + limit)
30
28
  end
31
29
 
32
30
  def prev
33
- pagination_evaluator.call(limit: limit, offset: offset-1) if offset > 0
31
+ prev_offset = offset < limit ? 0 : offset - limit
32
+ pagination_evaluator.call(limit: limit, offset: prev_offset) if offset > 0
34
33
  end
35
34
 
36
35
  def href
@@ -1,3 +1,3 @@
1
1
  module PragmaticSerializer
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pragmatic_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Valent
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-31 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.4.8
121
+ rubygems_version: 2.5.1
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: JSON API serializer following Pragmatic JSON standard