mighty_grid 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.travis.yml +13 -0
- data/Appraisals +14 -0
- data/Gemfile +0 -5
- data/README.md +5 -1
- data/Rakefile +5 -0
- data/gemfiles/3.2.gemfile +8 -0
- data/gemfiles/4.0.gemfile +8 -0
- data/gemfiles/4.1.gemfile +8 -0
- data/lib/generators/mighty_grid/config_generator.rb +16 -0
- data/lib/generators/mighty_grid/templates/mighty_grid_config.rb +6 -0
- data/lib/mighty_grid/column.rb +3 -6
- data/lib/mighty_grid/config.rb +27 -0
- data/lib/mighty_grid/helpers/mighty_grid_view_helpers.rb +3 -1
- data/lib/mighty_grid/version.rb +1 -1
- data/lib/mighty_grid.rb +4 -3
- data/mighty_grid.gemspec +2 -0
- data/spec/config_spec.rb +49 -0
- data/spec/mighty_grid_spec.rb +7 -0
- data/spec/spec_helper.rb +11 -6
- metadata +42 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bf4b292efadf47108043a38323994528942f54b
|
4
|
+
data.tar.gz: c713b40944b7ae79d2260da50bd55171c0a0685f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2a03b8b0f8cab841e7be0fe6cbd48796c4969bc9b66895022c43cbe7e38d92a1cb3f3b39553fea76a4a5deef716918fd8c449645db88af3fcb017687bb63c32
|
7
|
+
data.tar.gz: 5e71182beb7743bfd57da54799ffe16c0ba33ae61b76381cb87eb08d4ea14dbc8f26b2e0ec0d8fc978d1fad2d0f2b394a51442395bfce5fa523f13d6990683d9
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Appraisals
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
appraise "3.2" do
|
2
|
+
gem "rails", "~> 3.2.15"
|
3
|
+
gem "mighty_grid", :path => "../"
|
4
|
+
end
|
5
|
+
|
6
|
+
appraise "4.0" do
|
7
|
+
gem "rails", "~> 4.0.0"
|
8
|
+
gem "mighty_grid", :path => "../"
|
9
|
+
end
|
10
|
+
|
11
|
+
appraise "4.1" do
|
12
|
+
gem "rails", "~> 4.1.0.beta"
|
13
|
+
gem "mighty_grid", :path => "../"
|
14
|
+
end
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# MightyGrid
|
2
2
|
|
3
|
-
|
3
|
+
MightyGrid is a flexible grid solution for Rails.
|
4
|
+
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/mighty_grid.svg)](http://badge.fury.io/rb/mighty_grid)
|
6
|
+
[![Build Status](https://travis-ci.org/jurrick/mighty_grid.svg?branch=master)](https://travis-ci.org/jurrick/mighty_grid)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/jurrick/mighty_grid/badge.png)](https://coveralls.io/r/jurrick/mighty_grid)
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
data/Rakefile
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module MightyGrid
|
2
|
+
module Generators
|
3
|
+
class ConfigGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
5
|
+
|
6
|
+
desc <<DESC
|
7
|
+
Description:
|
8
|
+
Copies MightyGrid configuration file to your application's initializer directory.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
def copy_config_file
|
12
|
+
template 'mighty_grid_config.rb', 'config/initializers/mighty_grid_config.rb'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/mighty_grid/column.rb
CHANGED
@@ -10,18 +10,15 @@ module MightyGrid
|
|
10
10
|
@options = attr_or_options
|
11
11
|
@display_property = :block
|
12
12
|
@render_value = block
|
13
|
-
@attrs = options[:html] if options && options.has_key?(:html)
|
14
|
-
@th_attrs = options[:th_html] if options && options.has_key?(:th_html)
|
15
|
-
@title = options[:title] || ''
|
16
13
|
else
|
17
14
|
@options = options
|
18
15
|
@attribute = attr_or_options
|
19
16
|
@display_property = :attr
|
20
17
|
@render_value = attribute
|
21
|
-
@attrs = options[:html] if options && options.has_key?(:html)
|
22
|
-
@th_attrs = options[:th_html] if options && options.has_key?(:th_html)
|
23
|
-
@title = options[:title] || ''
|
24
18
|
end
|
19
|
+
@attrs = options[:html] if options && options.has_key?(:html)
|
20
|
+
@th_attrs = options[:th_html] if options && options.has_key?(:th_html)
|
21
|
+
@title = options[:title] || ''
|
25
22
|
end
|
26
23
|
|
27
24
|
def render(record)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'active_support/configurable'
|
2
|
+
|
3
|
+
module MightyGrid
|
4
|
+
def self.configure(&block)
|
5
|
+
yield @config ||= MightyGrid::Configuration.new
|
6
|
+
end
|
7
|
+
|
8
|
+
# Global settings for MightyGrid
|
9
|
+
def self.config
|
10
|
+
@config
|
11
|
+
end
|
12
|
+
|
13
|
+
class Configuration #:nodoc:
|
14
|
+
include ActiveSupport::Configurable
|
15
|
+
config_accessor :per_page
|
16
|
+
config_accessor :order_direction
|
17
|
+
config_accessor :grid_name
|
18
|
+
config_accessor :table_class
|
19
|
+
end
|
20
|
+
|
21
|
+
configure do |config|
|
22
|
+
config.per_page = 15
|
23
|
+
config.order_direction = 'asc'
|
24
|
+
config.grid_name = 'grid'
|
25
|
+
config.table_class = ''
|
26
|
+
end
|
27
|
+
end
|
@@ -12,7 +12,9 @@ module MightyGrid
|
|
12
12
|
block.call(rendering)
|
13
13
|
|
14
14
|
table_html_attrs = options[:html] || {}
|
15
|
-
table_html_attrs[:class]
|
15
|
+
table_html_attrs[:class] ||= ''
|
16
|
+
table_html_classes = ["mighty-grid"] + MightyGrid.config.table_class.split(' ')
|
17
|
+
table_html_attrs[:class] = (table_html_classes + table_html_attrs[:class].split(' ')).reject(&:blank?).join(' ')
|
16
18
|
|
17
19
|
header_tr_html = options[:header_tr_html] || {}
|
18
20
|
|
data/lib/mighty_grid/version.rb
CHANGED
data/lib/mighty_grid.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mighty_grid/version'
|
2
|
+
require 'mighty_grid/config'
|
2
3
|
require 'mighty_grid/mighty_grid_ext'
|
3
4
|
require 'mighty_grid/column'
|
4
5
|
require 'mighty_grid/grid_renderer'
|
@@ -36,8 +37,8 @@ module MightyGrid
|
|
36
37
|
|
37
38
|
@options = {
|
38
39
|
page: 1,
|
39
|
-
per_page:
|
40
|
-
name:
|
40
|
+
per_page: MightyGrid.config.per_page,
|
41
|
+
name: MightyGrid.config.grid_name
|
41
42
|
}
|
42
43
|
|
43
44
|
opts.assert_valid_keys(@options.keys)
|
@@ -75,7 +76,7 @@ module MightyGrid
|
|
75
76
|
end
|
76
77
|
|
77
78
|
def order_direction
|
78
|
-
(current_grid_params.has_key?('order_direction')) ? (['asc', 'desc'] - [current_grid_params['order_direction']]).first :
|
79
|
+
(current_grid_params.has_key?('order_direction')) ? (['asc', 'desc'] - [current_grid_params['order_direction']]).first : MightyGrid.config.order_direction
|
79
80
|
end
|
80
81
|
|
81
82
|
end
|
data/mighty_grid.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.5"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec-rails"
|
24
|
+
spec.add_development_dependency 'appraisal'
|
23
25
|
|
24
26
|
spec.add_dependency 'kaminari', '~> 0.15.0'
|
25
27
|
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MightyGrid::Configuration do
|
4
|
+
subject { MightyGrid.config }
|
5
|
+
|
6
|
+
describe 'per_page' do
|
7
|
+
context 'by default' do
|
8
|
+
its(:per_page) { should == 15 }
|
9
|
+
end
|
10
|
+
context 'configured via config block' do
|
11
|
+
before { MightyGrid.configure {|c| c.per_page = 17} }
|
12
|
+
its(:per_page) { should == 17 }
|
13
|
+
after { MightyGrid.configure {|c| c.per_page = 15} }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'order_direction' do
|
18
|
+
context 'by default' do
|
19
|
+
its(:order_direction) { should == 'asc' }
|
20
|
+
end
|
21
|
+
context 'configured via config block' do
|
22
|
+
before { MightyGrid.configure {|c| c.order_direction = 'desc'} }
|
23
|
+
its(:order_direction) { should == 'desc' }
|
24
|
+
after { MightyGrid.configure {|c| c.order_direction = 'asc'} }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'grid_name' do
|
29
|
+
context 'by default' do
|
30
|
+
its(:grid_name) { should == 'grid' }
|
31
|
+
end
|
32
|
+
context 'configured via config block' do
|
33
|
+
before { MightyGrid.configure {|c| c.grid_name = 'g1'} }
|
34
|
+
its(:grid_name) { should == 'g1' }
|
35
|
+
after { MightyGrid.configure {|c| c.grid_name = 'grid'} }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'table_class' do
|
40
|
+
context 'by default' do
|
41
|
+
its(:table_class) { should == '' }
|
42
|
+
end
|
43
|
+
context 'configured via config block' do
|
44
|
+
before { MightyGrid.configure {|c| c.table_class = 'table'} }
|
45
|
+
its(:table_class) { should == 'table' }
|
46
|
+
after { MightyGrid.configure {|c| c.table_class = ''} }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rails'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'bundler/setup'
|
10
|
+
Bundler.require
|
11
|
+
|
7
12
|
RSpec.configure do |config|
|
8
13
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
14
|
config.run_all_when_everything_filtered = true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mighty_grid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jurrick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: appraisal
|
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'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: kaminari
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,6 +89,8 @@ extra_rdoc_files: []
|
|
61
89
|
files:
|
62
90
|
- ".gitignore"
|
63
91
|
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Appraisals
|
64
94
|
- Gemfile
|
65
95
|
- LICENSE.txt
|
66
96
|
- README.md
|
@@ -72,8 +102,14 @@ files:
|
|
72
102
|
- app/views/kaminari/mighty_grid/_page.html.erb
|
73
103
|
- app/views/kaminari/mighty_grid/_paginator.html.erb
|
74
104
|
- app/views/kaminari/mighty_grid/_prev_page.html.erb
|
105
|
+
- gemfiles/3.2.gemfile
|
106
|
+
- gemfiles/4.0.gemfile
|
107
|
+
- gemfiles/4.1.gemfile
|
108
|
+
- lib/generators/mighty_grid/config_generator.rb
|
109
|
+
- lib/generators/mighty_grid/templates/mighty_grid_config.rb
|
75
110
|
- lib/mighty_grid.rb
|
76
111
|
- lib/mighty_grid/column.rb
|
112
|
+
- lib/mighty_grid/config.rb
|
77
113
|
- lib/mighty_grid/grid_renderer.rb
|
78
114
|
- lib/mighty_grid/helpers/mighty_grid_view_helpers.rb
|
79
115
|
- lib/mighty_grid/kaminari_monkey_patching.rb
|
@@ -81,6 +117,8 @@ files:
|
|
81
117
|
- lib/mighty_grid/mighty_grid_ext.rb
|
82
118
|
- lib/mighty_grid/version.rb
|
83
119
|
- mighty_grid.gemspec
|
120
|
+
- spec/config_spec.rb
|
121
|
+
- spec/mighty_grid_spec.rb
|
84
122
|
- spec/spec_helper.rb
|
85
123
|
- vendor/assets/stylesheets/mighty_grid.css
|
86
124
|
homepage: http://github.com/jurrick/mighty_grid
|
@@ -108,4 +146,6 @@ signing_key:
|
|
108
146
|
specification_version: 4
|
109
147
|
summary: Flexible grid for Rails
|
110
148
|
test_files:
|
149
|
+
- spec/config_spec.rb
|
150
|
+
- spec/mighty_grid_spec.rb
|
111
151
|
- spec/spec_helper.rb
|