shopify-kaminari 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 570e3cec212e5ffa136c2fdd279ab02c568f252eb41972d3f0d1c339f31999b9
4
+ data.tar.gz: d2c2956304dcd1e2819d7da01921ecf401f5bf42079a5ac7fe7519483b9138c6
5
+ SHA512:
6
+ metadata.gz: fb6eedc2d04d4c137dce13f6cd2771913e2cf8f411bf415d835055cc4a0580e72ba8f3a77b10d99708751bca08cb3bda02866616215c2e4e61b8aa2dc7c044d8
7
+ data.tar.gz: 7945a630991dc163ef1ed01e9c31529bbcc0c9d5e7ae1825b544065762ca925aaa3cc32ac09ec69ebd2ce394fc5a82203466b375c0f3baeff7d57f8a016d6b6c
data/.gitignore CHANGED
@@ -1,4 +1,13 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
1
+ .DS_Store
2
+ /.bundle/
3
+ /.code/
4
+ /.idea/
5
+ /.ruby-gemset
6
+ /.ruby-version
7
+ /.yardoc
8
+ /_yardoc/
9
+ /coverage/
10
+ /doc/
11
+ /pkg/
12
+ /spec/reports/
13
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ sudo: false
2
+
3
+ language: ruby
4
+
5
+ rvm:
6
+ - 2.5.0
7
+
8
+ before_install: gem install bundler -v 1.16.1
data/Gemfile CHANGED
@@ -1,8 +1,8 @@
1
- source "http://rubygems.org"
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- # Specify your gem's dependencies in shopify-kaminari.gemspec
4
- gemspec
4
+ source 'https://rubygems.org'
5
+
6
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
5
7
 
6
- group :test do
7
- gem 'rspec'
8
- end
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,121 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ shopify-kaminari (1.0.0)
5
+ kaminari
6
+ shopify_api
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionview (5.2.0)
12
+ activesupport (= 5.2.0)
13
+ builder (~> 3.1)
14
+ erubi (~> 1.4)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
17
+ activemodel (5.2.0)
18
+ activesupport (= 5.2.0)
19
+ activemodel-serializers-xml (1.0.2)
20
+ activemodel (> 5.x)
21
+ activesupport (> 5.x)
22
+ builder (~> 3.1)
23
+ activerecord (5.2.0)
24
+ activemodel (= 5.2.0)
25
+ activesupport (= 5.2.0)
26
+ arel (>= 9.0)
27
+ activeresource (5.0.0)
28
+ activemodel (>= 5.0, < 6)
29
+ activemodel-serializers-xml (~> 1.0)
30
+ activesupport (>= 5.0, < 6)
31
+ activesupport (5.2.0)
32
+ concurrent-ruby (~> 1.0, >= 1.0.2)
33
+ i18n (>= 0.7, < 2)
34
+ minitest (~> 5.1)
35
+ tzinfo (~> 1.1)
36
+ ansi (1.5.0)
37
+ arel (9.0.0)
38
+ builder (3.2.3)
39
+ concurrent-ruby (1.0.5)
40
+ coveralls (0.7.2)
41
+ multi_json (~> 1.3)
42
+ rest-client (= 1.6.7)
43
+ simplecov (>= 0.7)
44
+ term-ansicolor (= 1.2.2)
45
+ thor (= 0.18.1)
46
+ crass (1.0.4)
47
+ docile (1.3.0)
48
+ erubi (1.7.1)
49
+ i18n (1.0.1)
50
+ concurrent-ruby (~> 1.0)
51
+ json (2.1.0)
52
+ kaminari (1.1.1)
53
+ activesupport (>= 4.1.0)
54
+ kaminari-actionview (= 1.1.1)
55
+ kaminari-activerecord (= 1.1.1)
56
+ kaminari-core (= 1.1.1)
57
+ kaminari-actionview (1.1.1)
58
+ actionview
59
+ kaminari-core (= 1.1.1)
60
+ kaminari-activerecord (1.1.1)
61
+ activerecord
62
+ kaminari-core (= 1.1.1)
63
+ kaminari-core (1.1.1)
64
+ loofah (2.2.2)
65
+ crass (~> 1.0.2)
66
+ nokogiri (>= 1.5.9)
67
+ mime-types (3.1)
68
+ mime-types-data (~> 3.2015)
69
+ mime-types-data (3.2016.0521)
70
+ mini_portile2 (2.3.0)
71
+ minitest (5.11.3)
72
+ minitest-reporters (1.2.0)
73
+ ansi
74
+ builder
75
+ minitest (>= 5.0)
76
+ ruby-progressbar
77
+ multi_json (1.13.1)
78
+ nokogiri (1.8.2)
79
+ mini_portile2 (~> 2.3.0)
80
+ rack (2.0.5)
81
+ rails-dom-testing (2.0.3)
82
+ activesupport (>= 4.2.0)
83
+ nokogiri (>= 1.6)
84
+ rails-html-sanitizer (1.0.4)
85
+ loofah (~> 2.2, >= 2.2.2)
86
+ rake (10.5.0)
87
+ rest-client (1.6.7)
88
+ mime-types (>= 1.16)
89
+ ruby-progressbar (1.9.0)
90
+ shopify_api (4.11.0)
91
+ activeresource (>= 3.0.0)
92
+ rack
93
+ simplecov (0.16.1)
94
+ docile (~> 1.1)
95
+ json (>= 1.8, < 3)
96
+ simplecov-html (~> 0.10.0)
97
+ simplecov-html (0.10.2)
98
+ term-ansicolor (1.2.2)
99
+ tins (~> 0.8)
100
+ thor (0.18.1)
101
+ thread_safe (0.3.6)
102
+ tins (0.13.2)
103
+ tzinfo (1.2.5)
104
+ thread_safe (~> 0.1)
105
+ yard (0.9.12)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ bundler (~> 1.16)
112
+ coveralls
113
+ minitest (~> 5.0)
114
+ minitest-reporters (~> 1.2)
115
+ rake (~> 10.0)
116
+ shopify-kaminari!
117
+ simplecov (~> 0.16)
118
+ yard (~> 0.9)
119
+
120
+ BUNDLED WITH
121
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 Hi5 Development, LLC
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # Shopify::Kaminari
2
+
3
+ [![Build Status](https://travis-ci.org/hi5dev/shopify-kaminari.svg?branch=master)](https://travis-ci.org/hi5dev/shopify-kaminari)
4
+ [![Coverage Status](https://coveralls.io/repos/github/hi5dev/shopify-kaminari/badge.svg?branch=master)](https://coveralls.io/github/hi5dev/shopify-kaminari?branch=master)
5
+
6
+ Makes the [shopify_api gem](https://github.com/shopify/shopify_api) compatible
7
+ with the [kaminari](https://github.com/kaminari/kaminari) pagination gem.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'shopify-kaminari'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install shopify-kaminari
22
+
23
+ ## Usage
24
+
25
+ Just `require "shopify-kaminari"` in your project, and you're good to go! If
26
+ you're using a Bundler backed project, like Rails, then you don't have to
27
+ even do that much. Just add the gem to your Gemfile, and all of your Shopify
28
+ resources will be paginatable with Kaminari.
29
+
30
+ Example:
31
+
32
+ ```ruby
33
+ ShopifyAPI::Session.temp(domain, token) do
34
+ @products = ShopifyAPI::Product.all(params: { page: 2, limit: 250 })
35
+ end
36
+ ```
37
+
38
+ ### Rails Example
39
+
40
+ Here's a simplified example of how to paginate a Shopify product in a Rails
41
+ controller:
42
+
43
+ ```ruby
44
+ class ProductsController < ApplicationController
45
+ around_action :shopify_session
46
+
47
+ def index
48
+ @products = ShopifyAPI::Product.all(params: pagination_params)
49
+ end
50
+
51
+ private
52
+
53
+ def current_shop
54
+ @current_shop ||= Shop.find_by(id: session[:shop_id])
55
+ end
56
+
57
+ def pagination_params
58
+ params.slice(:page, :limit).permit!
59
+ end
60
+
61
+ def shopify_session(&block)
62
+ ShopifyAPI::Session.temp(current_shop.domain, current_shop.token, &block)
63
+ end
64
+ end
65
+ ```
66
+
67
+ Then you could paginate the products in the view as you would with any other
68
+ model:
69
+
70
+ ```erb
71
+ <%= paginate(@products) %>
72
+ ```
73
+
74
+ ## Development
75
+
76
+ After checking out the repo, run `bin/setup` to install dependencies. Then,
77
+ run `rake test` to run the tests. You can also run `bin/console` for an
78
+ interactive prompt that will allow you to experiment.
79
+
80
+ To install this gem onto your local machine, run `bundle exec rake install`.
81
+
82
+ ## Contributing
83
+
84
+ Bug reports and pull requests are welcome on GitHub at
85
+ https://github.com/hi5dev/shopify-kaminari.
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- require 'bundler/gem_tasks'
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- task :default => [:spec]
4
+ require 'bundler/gem_tasks'
5
+ require 'rake/testtask'
4
6
 
5
- desc "runs all specs"
6
- task :spec do
7
- files = Dir[File.expand_path("../spec/**/*_spec.rb", __FILE__)].join(" ")
8
- puts files
9
- exec "bundle exec rspec #{files}"
7
+ Rake::TestTask.new do |t|
8
+ t.libs += %w[lib test]
9
+ t.test_files = FileList['test/**/*_test.rb']
10
10
  end
11
+
12
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'shopify-kaminari'
5
+ require 'irb'
6
+
7
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+ IFS=$'\n\t'
5
+ set -vx
6
+
7
+ bundle install
@@ -0,0 +1,77 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Shopify resources are paginated server-side. This custom
5
+ # +ActiveResource::Collection+ provides pagination that is compatible with the
6
+ # "kaminari" gem. Requiring this gem in your project configures the ShopifyAPI
7
+ # so that every Shopify resource will use this collection by default.
8
+ #
9
+ # @example Paginating products.
10
+ # products = Shopify::Product.all(params: { page: 2, limit: 25 })
11
+ class Shopify::Kaminari::Collection < ActiveResource::Collection
12
+ alias_method :model, :resource_class
13
+
14
+ # Shopify returns this many records by default if no limit is given.
15
+ DEFAULT_LIMIT_VALUE = 50
16
+
17
+ # The page that was requested from the API.
18
+ #
19
+ # @return [Integer] The current page.
20
+ def current_page
21
+ @current_page ||= original_params.fetch(:page, 1).to_i
22
+ end
23
+
24
+ # The maximum amount of records each page will have.
25
+ #
26
+ # @return [Integer] Maximum amount of resources per page.
27
+ def limit_value
28
+ @limit_value ||= original_params.fetch(:limit, DEFAULT_LIMIT_VALUE).to_i
29
+ end
30
+
31
+ # Provides a Rails compatible model name for Kaminari's view helpers.
32
+ #
33
+ # @return [ActiveModel::Name] The model's name.
34
+ def model_name
35
+ @model_name ||= begin
36
+ # Find the name of the resource with the ShopifyAPI:: prefix.
37
+ name = resource_class.name.rpartition('::').last
38
+
39
+ # Providing the name prevents every name from being prefixed with
40
+ # "shopify_api_".
41
+ ActiveModel::Name.new(resource_class, nil, name)
42
+ end
43
+ end
44
+
45
+ # Gets the number of the next page.
46
+ #
47
+ # @return [Integer, NilClass] The next page number, or nil if on the last.
48
+ def next_page
49
+ @next_page ||= current_page + 1 if current_page < total_pages
50
+ end
51
+
52
+ # Gets the number of the previous page.
53
+ #
54
+ # @return [Integer, NilClass] The previous page number or nil if on the first.
55
+ def prev_page
56
+ @prev_page ||= current_page - 1 if current_page > 1
57
+ end
58
+
59
+ # Calculates the total number of expected pages based on the number
60
+ # reported by the API.
61
+ #
62
+ # @return [Integer] Total number of pages.
63
+ def total_pages
64
+ @total_pages ||= begin
65
+ # Get the parameters without the pagination parameters.
66
+ params = original_params.with_indifferent_access.except(:page, :limit)
67
+
68
+ options = params.empty? ? {} : params
69
+
70
+ # Ask Shopify how many records there are for the given query.
71
+ count = resource_class.count(options)
72
+
73
+ # Calculate the number of pages.
74
+ (count.to_f / limit_value.to_f).ceil
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,9 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ module Shopify
5
+ module Kaminari
6
+ # The gem's semantic version.
7
+ VERSION = '1.0.0'
8
+ end
9
+ end
@@ -1,77 +1,14 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
1
4
  require 'shopify_api'
2
5
 
3
- module ShopifyAPI
4
-
5
- # add Kaminari pagination support to ShopifyAPI
6
+ module Shopify
6
7
  module Kaminari
7
- @@per = 25
8
-
9
- class << self
10
- # get limit of rows per page
11
- # @return [Integer] the per
12
- # @example Get the current per per page
13
- # current_per = ShopifyAPI::Kaminari.per
14
- # @api public
15
- def per
16
- @@per
17
- end
18
-
19
- # set limit of rows to return per page
20
- # @param [Integer] value The new limit per row value
21
- # @return [Integer] the limit per row
22
- # @example Set limit per page to 50
23
- # ShopifyAPI::Kaminari.per = 50
24
- # @api public
25
- def per=(value)
26
- @@per = value
27
- end
28
- end
29
-
30
- # paginates a ShopifyAPI::Base resource
31
- # @param [Hash, Integer] options Can be either a Hash like this: {:page => Integer, :per => Integer}, or the page number
32
- # @return [Array] Array of ShopifyAPI resources
33
- # @example Paginate all ShopifyAPI::Product
34
- # @products = ShopifyAPI::Product.page :page => params[:page]
35
- # @example Paginate per 15
36
- # @products = ShopifyAPI::Product.page :page => params[:page], :per => 15
37
- # @api public
38
- def paginate(options = {})
39
- options = {:page => options} if options.class == Fixnum
40
- options = {} if options.nil?
41
-
42
- # create params for pagination
43
- params = {
44
- :page => options[:page] || 1,
45
- :limit => options[:per] || 25
46
- }
47
-
48
- # remove pagination params from options
49
- options.delete :page
50
- options.delete :per
51
-
52
- # merge any params from options
53
- params = params.merge options[:params] if options.include? :params
54
-
55
- # remove params from options
56
- options.delete :params
57
-
58
- # create arguments to pass to ActiveResource find
59
- args = {:params => params}.merge options
60
-
61
- # run the query
62
- result = self.find :all, args
63
-
64
- # add instance methods to result Array to support paginating with Kaminari
65
- result.instance_eval <<-EVAL
66
- def current_page; #{args[:params][:page]}; end
67
- def total_pages; #{self.count / args[:params][:limit] + 1}; end
68
- def limit_value; #{args[:params][:limit]}; end
69
- EVAL
70
-
71
- result
72
- end
8
+ autoload :Collection, 'shopify/kaminari/collection'
9
+ autoload :VERSION, 'shopify/kaminari/version'
73
10
  end
74
-
75
11
  end
76
12
 
77
- ShopifyAPI::Base.send :extend, ShopifyAPI::Kaminari
13
+ # Set the Shopify API's default collection parser.
14
+ ShopifyAPI::Base.collection_parser = Shopify::Kaminari::Collection
@@ -1,22 +1,38 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "shopify-kaminari"
6
- s.version = "0.1.0"
7
- s.authors = ["Travis Haynes"]
8
- s.email = ["travis.j.haynes@gmail.com"]
9
- s.homepage = ""
10
- s.summary = %q{Provides shopify_api with pagination support via Kaminari}
11
- s.description = %q{Extends ShopifyAPI, adding support to paginate using the Kaminari gem.}
12
-
13
- s.rubyforge_project = "shopify-kaminari"
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
19
-
20
- s.add_dependency("shopify_api", [">= 1.2.5"])
21
- s.add_dependency("kaminari", [">= 0.12.4"])
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path('lib', __dir__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+
7
+ require 'shopify/kaminari/version'
8
+
9
+ Gem::Specification.new do |spec|
10
+ spec.name = 'shopify-kaminari'
11
+ spec.version = Shopify::Kaminari::VERSION
12
+ spec.authors = ['Travis Haynes']
13
+ spec.email = ['travis@hi5dev.com']
14
+ spec.homepage = 'https://github.com/hi5dev/shopify-kaminari.git'
15
+ spec.summary = %q{Provides shopify_api with pagination support via Kaminari}
16
+
17
+ spec.bindir = 'exe'
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |file|
21
+ file.match(%r{^(test)/})
22
+ end
23
+
24
+ spec.executables = spec.files.grep(%r{^#{spec.bindir}/}) do |file|
25
+ File.basename(file)
26
+ end
27
+
28
+ spec.add_dependency 'shopify_api'
29
+ spec.add_dependency 'kaminari'
30
+
31
+ spec.add_development_dependency 'bundler', '~> 1.16'
32
+ spec.add_development_dependency 'coveralls'
33
+ spec.add_development_dependency 'minitest', '~> 5.0'
34
+ spec.add_development_dependency 'minitest-reporters', '~> 1.2'
35
+ spec.add_development_dependency 'rake', '~> 10.0'
36
+ spec.add_development_dependency 'simplecov', '~> 0.16'
37
+ spec.add_development_dependency 'yard', '~> 0.9'
22
38
  end
metadata CHANGED
@@ -1,87 +1,182 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-kaminari
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Travis Haynes
9
8
  autorequire:
10
- bindir: bin
9
+ bindir: exe
11
10
  cert_chain: []
12
- date: 2012-12-20 00:00:00.000000000 Z
11
+ date: 2018-04-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: shopify_api
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 1.2.5
19
+ version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 1.2.5
26
+ version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: kaminari
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
- version: 0.12.4
33
+ version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
- version: 0.12.4
46
- description: Extends ShopifyAPI, adding support to paginate using the Kaminari gem.
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-reporters
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.16'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.16'
125
+ - !ruby/object:Gem::Dependency
126
+ name: yard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.9'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.9'
139
+ description:
47
140
  email:
48
- - travis.j.haynes@gmail.com
141
+ - travis@hi5dev.com
49
142
  executables: []
50
143
  extensions: []
51
144
  extra_rdoc_files: []
52
145
  files:
53
- - .gitignore
54
- - .rspec
146
+ - ".gitignore"
147
+ - ".travis.yml"
55
148
  - Gemfile
56
- - README.rdoc
149
+ - Gemfile.lock
150
+ - LICENSE.txt
151
+ - README.md
57
152
  - Rakefile
153
+ - bin/console
154
+ - bin/setup
58
155
  - lib/shopify-kaminari.rb
156
+ - lib/shopify/kaminari/collection.rb
157
+ - lib/shopify/kaminari/version.rb
59
158
  - shopify-kaminari.gemspec
60
- - spec/shopify-kaminari_spec.rb
61
- - spec/spec_helper.rb
62
- - spec/support/shopify_test_resource.rb
63
- homepage: ''
159
+ homepage: https://github.com/hi5dev/shopify-kaminari.git
64
160
  licenses: []
161
+ metadata: {}
65
162
  post_install_message:
66
163
  rdoc_options: []
67
164
  require_paths:
68
165
  - lib
69
166
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
167
  requirements:
72
- - - ! '>='
168
+ - - ">="
73
169
  - !ruby/object:Gem::Version
74
170
  version: '0'
75
171
  required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
172
  requirements:
78
- - - ! '>='
173
+ - - ">="
79
174
  - !ruby/object:Gem::Version
80
175
  version: '0'
81
176
  requirements: []
82
- rubyforge_project: shopify-kaminari
83
- rubygems_version: 1.8.24
177
+ rubyforge_project:
178
+ rubygems_version: 2.7.3
84
179
  signing_key:
85
- specification_version: 3
180
+ specification_version: 4
86
181
  summary: Provides shopify_api with pagination support via Kaminari
87
182
  test_files: []
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --colour
2
- --format d
data/README.rdoc DELETED
@@ -1,56 +0,0 @@
1
- = shopify-kaminari
2
-
3
- Extends ShopifyAPI with support for paginating the resources via the Kaminari gem.
4
-
5
- == Install
6
-
7
- To install, just add the gem to your Gemfile:
8
-
9
- gem 'shopify-kaminari'
10
-
11
- And run bundle:
12
-
13
- $ bundle
14
-
15
- == Examples
16
-
17
- View code:
18
-
19
- ul
20
- - @products.each do |product|
21
- li= product.title
22
-
23
- = paginate @products
24
-
25
- To paginate all the products:
26
-
27
- @products = ShopifyAPI::Product.paginate per: 25,
28
- page: params[:page]
29
-
30
- To pass some parameters:
31
-
32
- @products = ShopifyAPI::Product.paginate per: 25,
33
- page: 1,
34
- params: {published_status: 'published'}
35
-
36
- == Default values
37
-
38
- Both the :per and :page params are optional, and default to:
39
-
40
- :per => 25
41
- :page => 1
42
-
43
- == Contributing to shopify-kaminari
44
-
45
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
46
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
47
- * Fork the project
48
- * Start a feature/bugfix branch
49
- * Commit and push until you are happy with your contribution
50
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
51
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
52
-
53
- == Copyright
54
-
55
- Copyright (c) 2011 Travis Haynes. See LICENSE.txt for further details.
56
-
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ShopifyAPI::Kaminari do
4
-
5
- describe "#per" do
6
- it "should default to 25" do
7
- described_class.per.should eq 25
8
- end
9
- it "should persist a custom value" do
10
- described_class.per.should_not eq 10
11
- described_class.per = 10
12
- described_class.per.should eq 10
13
- end
14
- end
15
-
16
- describe "#paginate" do
17
- it "should respond to current_page" do
18
- results = ShopifyAPI::Test.paginate
19
- results.should respond_to :current_page
20
- end
21
- it "should respond to total_pages" do
22
- results = ShopifyAPI::Test.paginate
23
- results.should respond_to :total_pages
24
- end
25
- it "should respond to limit_value" do
26
- results = ShopifyAPI::Test.paginate
27
- results.should respond_to :limit_value
28
- end
29
- end
30
-
31
- end
data/spec/spec_helper.rb DELETED
@@ -1,4 +0,0 @@
1
- require File.expand_path("../../lib/shopify-kaminari", __FILE__)
2
-
3
- # load support files
4
- Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| load f}
@@ -1,13 +0,0 @@
1
- module ShopifyAPI
2
- class Test < Base
3
- end
4
- end
5
-
6
- test_response = { "tests" => [] }.to_json
7
-
8
- ActiveResource::HttpMock.respond_to do |mock|
9
- mock.get "/tests.json?limit=25&page=1", {}, test_response
10
- mock.get "/tests/count.json", {}, { "count" => 0 }.to_json
11
- end
12
-
13
- ShopifyAPI::Base.site = "http://localhost"