zh_kostev_ext 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/controller_extensions/url_ext.rb +31 -0
- data/lib/zh_kostev_ext.rb +1 -0
- metadata +20 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'addressable/uri'
|
|
2
|
+
module ControllerExtensions
|
|
3
|
+
module UrlExt
|
|
4
|
+
#override default url_for method. Add ability to set default params.
|
|
5
|
+
#
|
|
6
|
+
# Example:
|
|
7
|
+
# 'auctions_path' return '/auctions' by default
|
|
8
|
+
# if you set @hash_of_additional_params = {:test => 1, my_param => 2} 'auctions_path' will return '/auctions?test=1&my_param=2'
|
|
9
|
+
#
|
|
10
|
+
#You can use before_filer to do this stuff automatically.
|
|
11
|
+
# Example:
|
|
12
|
+
# in HomeController:
|
|
13
|
+
# before_filter { @hash_of_additional_params = {:test => '1'} } #this will add test param to all urls in home views
|
|
14
|
+
#
|
|
15
|
+
def url_for(options = {})
|
|
16
|
+
options = case options
|
|
17
|
+
when String
|
|
18
|
+
uri = Addressable::URI.new
|
|
19
|
+
uri.query_values = @hash_of_additional_params
|
|
20
|
+
options + (options.index('?').nil? ? '?' : '&') + "#{uri.query}"
|
|
21
|
+
when Hash
|
|
22
|
+
options.reverse_merge(@hash_of_additional_params || {})
|
|
23
|
+
else
|
|
24
|
+
options
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
data/lib/zh_kostev_ext.rb
CHANGED
|
@@ -3,6 +3,7 @@ require "controller_extensions/export_to_excel"
|
|
|
3
3
|
class ActionController::Base
|
|
4
4
|
include ControllerExtensions::GeneralMethods
|
|
5
5
|
include ControllerExtensions::ExportToExcel
|
|
6
|
+
include ControllerExtensions::UrlExt
|
|
6
7
|
end
|
|
7
8
|
|
|
8
9
|
require "ruby_classes_extensions/hash_extensions"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zh_kostev_ext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.12
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-11-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: spreadsheet
|
|
@@ -27,6 +27,22 @@ dependencies:
|
|
|
27
27
|
- - ! '>='
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
29
|
version: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: addressable
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ~>
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: 2.3.2
|
|
38
|
+
type: :runtime
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 2.3.2
|
|
30
46
|
- !ruby/object:Gem::Dependency
|
|
31
47
|
name: shoulda
|
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -117,6 +133,7 @@ extra_rdoc_files:
|
|
|
117
133
|
files:
|
|
118
134
|
- lib/controller_extensions/export_to_excel.rb
|
|
119
135
|
- lib/controller_extensions/general_methods.rb
|
|
136
|
+
- lib/controller_extensions/url_ext.rb
|
|
120
137
|
- lib/ruby_classes_extensions/hash_extensions.rb
|
|
121
138
|
- lib/zh_kostev_ext.rb
|
|
122
139
|
- LICENSE.txt
|
|
@@ -136,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
136
153
|
version: '0'
|
|
137
154
|
segments:
|
|
138
155
|
- 0
|
|
139
|
-
hash:
|
|
156
|
+
hash: 1034836403
|
|
140
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
158
|
none: false
|
|
142
159
|
requirements:
|