kaminari-cells 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b796bbdb4b82e6f89cc458b717ea4efa9d667485
4
+ data.tar.gz: 89f2ed23cd9289e2f94a80be7a74f839c6fac7d8
5
+ SHA512:
6
+ metadata.gz: 5d0f9bfbdf25157cea6bcdfd07a67d6ac4be20bf6d990233d6c3c528c711164aa9b225ed5eb6e8a4d17173b561d9f95bf2446611e2ff674f1fc2c03ff387eaba
7
+ data.tar.gz: deadec3bf086de71dc73764aa762328bea2f2bfb363dbc9ecd708b9a7ccdbcc6e27571f35268796d2ab52723d9281018d1bf334e8e682dfde12646c40dae1a1a
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.0
@@ -0,0 +1,7 @@
1
+ # 0.0.2
2
+
3
+ First officially working version, with kaminari 0.16.x and above!
4
+
5
+ # 0.0.1
6
+
7
+ * First release in an unsuspecting world.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Nick Sutterer
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.
@@ -0,0 +1,29 @@
1
+ # Kaminari::Cells
2
+
3
+ _Use Kaminari in Cells._
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'kaminari-cells'
11
+
12
+
13
+ ## Usage
14
+
15
+ To use the wonderful [Kaminari](https://github.com/amatsuda/kaminari) gem in your Cells, just do
16
+
17
+ ```ruby
18
+ class CommentsCell < Cell::Rails
19
+ include Kaminari::Cells
20
+ ```
21
+
22
+ The same works with Cells [view models](https://github.com/apotonick/cells#view-models).
23
+
24
+ ```ruby
25
+ class CommentsCell < Cell::ViewModel
26
+ include Kaminari::Cells
27
+ ```
28
+
29
+ You can now use `#paginate` in your cell and it will work.
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ Rake::TestTask.new(:test) do |test|
9
+ test.libs << 'test'
10
+ test.test_files = FileList['test/*_test.rb']
11
+ test.verbose = true
12
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kaminari/cells/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kaminari-cells"
8
+ spec.version = Kaminari::Cells::VERSION
9
+ spec.authors = ["Nick Sutterer"]
10
+ spec.email = ["apotonick@gmail.com"]
11
+ spec.summary = %q{Kaminari pagination in Cells.}
12
+ spec.description = %q{Simple Kaminari pagination in Cells.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "kaminari", ">= 0.16.0"
22
+ spec.add_dependency "cells"
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "minitest"
26
+ spec.add_development_dependency "activerecord"
27
+ spec.add_development_dependency "sqlite3"
28
+ end
@@ -0,0 +1,17 @@
1
+ require "kaminari/cells/version"
2
+
3
+ module Kaminari
4
+ module Helpers
5
+ module CellsHelper
6
+ include Kaminari::ActionViewExtension
7
+ include ActionView::Helpers::OutputSafetyHelper
8
+
9
+ def paginate(scope, options = {}, &block)
10
+ options = options.reverse_merge(:views_prefix => "../views/")
11
+ super
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ require 'kaminari/cells'
@@ -0,0 +1,14 @@
1
+ module Kaminari
2
+ module Cells
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # compat with 3.10's ViewModel.
7
+ if (::Cell::Rails.const_defined?(:ViewModel) and self < Cell::Rails::ViewModel) or (::Cell.const_defined?(:ViewModel) and self < Cell::ViewModel)
8
+ include Kaminari::Helpers::CellsHelper
9
+ else
10
+ helper Kaminari::Helpers::CellsHelper
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module Kaminari
2
+ module Cells
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+
3
+ Cell::Base.class_eval do
4
+ include Rails.application.routes.url_helpers # FIXME: that SUCKS.
5
+
6
+ append_view_path "test/fake_app/app-cells/"
7
+ end
8
+
9
+
10
+ class KaminariCellsTest < ActionController::TestCase
11
+ tests UsersController
12
+
13
+ setup do
14
+ @routes = Rails.application.routes
15
+
16
+ 50.times {|i| User.create! :name => "user#{i}"}
17
+ end
18
+
19
+ test "rendering normal cell" do
20
+ get :index
21
+ assert_equal "<p>1</p>\n\n", @response.body
22
+ end
23
+
24
+ test "rendering view model cell" do
25
+ get :show, :id => 1
26
+ assert_equal "<p>1</p>\n\n", @response.body
27
+ end
28
+ end
File without changes
@@ -0,0 +1,21 @@
1
+ class UserCell < Cell::Rails
2
+ include Kaminari::Cells
3
+
4
+ def show(users)
5
+ @users = users
6
+
7
+ render :inline => <<-ERB
8
+ <%= paginate @users %>
9
+ ERB
10
+ end
11
+ end
12
+
13
+ class ViewModelCell < Cell::ViewModel
14
+ include Kaminari::Cells
15
+
16
+ def show
17
+ render :inline => <<-ERB
18
+ <%= paginate model %>
19
+ ERB
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ # database
2
+ ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database => ':memory:'}}
3
+ ActiveRecord::Base.establish_connection('test')
@@ -0,0 +1,13 @@
1
+ # models
2
+ class User < ActiveRecord::Base
3
+ end
4
+
5
+
6
+ #migrations
7
+ class CreateAllTables < ActiveRecord::Migration
8
+ def self.up
9
+ create_table(:users) {|t| t.string :name; t.integer :age}
10
+ end
11
+ end
12
+ ActiveRecord::Migration.verbose = false
13
+ CreateAllTables.up
@@ -0,0 +1,48 @@
1
+ # require 'rails/all'
2
+ require 'action_controller/railtie'
3
+ require 'action_view/railtie'
4
+ require 'active_record'
5
+
6
+ require 'fake_app/config'
7
+
8
+
9
+ # config
10
+ app = Class.new(Rails::Application)
11
+ app.config.secret_token = '3b7cd727ee24e8444053437c36cc66c4'
12
+ app.config.session_store :cookie_store, :key => '_myapp_session'
13
+ app.config.active_support.deprecation = :log
14
+ app.config.eager_load = false
15
+ # Rais.root
16
+ app.config.root = File.dirname(__FILE__)
17
+ Rails.backtrace_cleaner.remove_silencers!
18
+ app.initialize!
19
+
20
+ # routes
21
+ app.routes.draw do
22
+ resources :users
23
+ end
24
+
25
+ #models
26
+ require 'fake_app/models'
27
+
28
+ # controllers
29
+ class ApplicationController < ActionController::Base; end
30
+ class UsersController < ApplicationController
31
+ def index
32
+ @users = User.all.page params[:page]
33
+ render :inline => <<-ERB
34
+ <%= render_cell(:user, :show, @users) %>
35
+ ERB
36
+ end
37
+
38
+ def show
39
+ @users = User.all.page params[:page]
40
+ render :inline => <<-ERB
41
+ <%= cell(:view_model, @users).show %>
42
+ ERB
43
+ end
44
+ end
45
+
46
+ # helpers
47
+ Object.const_set(:ApplicationHelper, Module.new)
48
+
@@ -0,0 +1 @@
1
+ <p><%= current_page %></p>
@@ -0,0 +1,10 @@
1
+ require 'minitest/autorun'
2
+ require 'kaminari'
3
+
4
+
5
+ require 'fake_app/rails_app'
6
+
7
+ require 'cells'
8
+
9
+ require 'kaminari-cells'
10
+ require 'fake_app/cells'
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kaminari-cells
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Nick Sutterer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kaminari
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.16.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.16.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: cells
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
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.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activerecord
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Simple Kaminari pagination in Cells.
112
+ email:
113
+ - apotonick@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .travis.yml
120
+ - CHANGES.md
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - kaminari-cells.gemspec
126
+ - lib/kaminari-cells.rb
127
+ - lib/kaminari/cells.rb
128
+ - lib/kaminari/cells/version.rb
129
+ - test/cells_test.rb
130
+ - test/fake_app/app-cells/.gitkeep
131
+ - test/fake_app/cells.rb
132
+ - test/fake_app/config.rb
133
+ - test/fake_app/models.rb
134
+ - test/fake_app/rails_app.rb
135
+ - test/fake_app/views/kaminari/_paginator.erb
136
+ - test/test_helper.rb
137
+ homepage: ''
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.2.2
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Kaminari pagination in Cells.
161
+ test_files:
162
+ - test/cells_test.rb
163
+ - test/fake_app/app-cells/.gitkeep
164
+ - test/fake_app/cells.rb
165
+ - test/fake_app/config.rb
166
+ - test/fake_app/models.rb
167
+ - test/fake_app/rails_app.rb
168
+ - test/fake_app/views/kaminari/_paginator.erb
169
+ - test/test_helper.rb