bolter 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/bolter.gemspec +5 -4
- data/lib/bolter/helpers.rb +24 -10
- data/lib/bolter/railtie.rb +2 -2
- data/lib/bolter/searchable.rb +0 -2
- data/lib/bolter/version.rb +1 -1
- metadata +33 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d60b846bd7d86bed20c7abcb1ade4ace715e683d
|
4
|
+
data.tar.gz: 452b092a56b399b074096dc3d5af6ca904adeedd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e137b77848fa81ab8f0af2e8d9857f8ebb9e5400d2469beb08eb383cb27c77abda285b5d53c1567e29390523272d460741990660809a7e07b1a281e9e9e8d47
|
7
|
+
data.tar.gz: 72a94638d5a86b8c6cc5927d7033349ec7a8804dd59216e0d20353c19dd927d239a038f937f058a5e90d21218b5c18668c6f28de0c4a0e3dcef65f560ad5be57
|
data/README.md
CHANGED
@@ -34,10 +34,10 @@ end
|
|
34
34
|
View:
|
35
35
|
```haml
|
36
36
|
.search
|
37
|
-
=
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
= search_form books_path, id: :search do |f|
|
38
|
+
= f.label :with_name, Book.human_attribute_name(:name)
|
39
|
+
= f.text_field :with_name
|
40
|
+
= f.submit 'Search'
|
41
41
|
.index
|
42
42
|
%table
|
43
43
|
%tr
|
data/bolter.gemspec
CHANGED
@@ -11,14 +11,15 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = %q{This gem include sorting and filtering methods}
|
12
12
|
spec.homepage = 'http://github.com/jpascal/bolter'
|
13
13
|
spec.license = 'MIT'
|
14
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
15
15
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
|
18
18
|
spec.add_development_dependency 'bundler', '~> 1.8'
|
19
19
|
spec.add_development_dependency 'rake', '~> 10.0'
|
20
|
-
spec.add_development_dependency '
|
20
|
+
spec.add_development_dependency 'activerecord'
|
21
|
+
spec.add_development_dependency 'sqlite3'
|
21
22
|
spec.add_development_dependency 'mongoid'
|
22
|
-
|
23
|
-
spec.
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_development_dependency 'activesupport'
|
24
25
|
end
|
data/lib/bolter/helpers.rb
CHANGED
@@ -1,19 +1,33 @@
|
|
1
1
|
module Bolter
|
2
|
-
module
|
3
|
-
def sort_link(scope_name, text = nil)
|
4
|
-
|
2
|
+
module SortHelper
|
3
|
+
def sort_link(scope_name, text = nil, options = {})
|
4
|
+
as = options.fetch(:as, :sorting)
|
5
|
+
sorting = params[as] || "#{scope_name}:asc"
|
5
6
|
current_field, direction = sorting.split(':', 2).map(&:to_s)
|
6
7
|
direction = direction == 'asc' ? 'desc' : 'asc'
|
7
8
|
title = text || scope
|
8
|
-
title = title + "#{direction == 'asc' ? '▲' : '▼'}" if scope_name.to_s == current_field and params[
|
9
|
-
link_to title.html_safe, url_for(params.merge(
|
9
|
+
title = title + "#{direction == 'asc' ? '▲' : '▼'}" if scope_name.to_s == current_field and params[as].present?
|
10
|
+
link_to title.html_safe, url_for(params.merge(Hash[as, "#{scope_name}:#{direction}"]))
|
10
11
|
end
|
11
12
|
end
|
12
|
-
module
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
module FormHelper
|
14
|
+
def search_form(url, options = {}, &block)
|
15
|
+
raise ArgumentError, 'Missing block' unless block_given?
|
16
|
+
as = options.fetch(:as, :search)
|
17
|
+
object = OpenStruct.new(params[as])
|
18
|
+
builder = default_form_builder.new(as, object, self, options)
|
19
|
+
|
20
|
+
html_options = options.fetch(:html, {})
|
21
|
+
html_options[:data] = options.delete(:data)
|
22
|
+
html_options[:remote] = options.fetch(:remote, false)
|
23
|
+
html_options[:method] = options.fetch(:method, :get)
|
24
|
+
html_options[:enforce_utf8] = options.fetch(:enforce_utf8, nil)
|
25
|
+
html_options[:authenticity_token] = options.delete(:authenticity_token)
|
26
|
+
html_options = html_options_for_form(url, html_options)
|
27
|
+
|
28
|
+
output = form_tag_html(html_options)
|
29
|
+
output << capture(builder, &block)
|
30
|
+
output.safe_concat('</form>')
|
17
31
|
end
|
18
32
|
end
|
19
33
|
end
|
data/lib/bolter/railtie.rb
CHANGED
@@ -7,8 +7,8 @@ module Bolter
|
|
7
7
|
class Railtie < Rails::Railtie
|
8
8
|
initializer 'bolter.initialization' do
|
9
9
|
ActiveSupport.on_load(:action_view) do
|
10
|
-
ActionView::Base.send :include, Bolter::
|
11
|
-
ActionView::Base.send :include, Bolter::
|
10
|
+
ActionView::Base.send :include, Bolter::FormHelper
|
11
|
+
ActionView::Base.send :include, Bolter::SortHelper
|
12
12
|
end
|
13
13
|
|
14
14
|
ActiveSupport.on_load(:active_record) do
|
data/lib/bolter/searchable.rb
CHANGED
data/lib/bolter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bolter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeniy Shurmin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,7 +39,21 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activerecord
|
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: sqlite3
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
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'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: activesupport
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,7 +101,7 @@ dependencies:
|
|
73
101
|
- - ">="
|
74
102
|
- !ruby/object:Gem::Version
|
75
103
|
version: '0'
|
76
|
-
type: :
|
104
|
+
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
@@ -120,9 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
148
|
version: '0'
|
121
149
|
requirements: []
|
122
150
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.2.0
|
124
152
|
signing_key:
|
125
153
|
specification_version: 4
|
126
154
|
summary: This gem include sorting and filtering methods
|
127
155
|
test_files: []
|
128
|
-
has_rdoc:
|