basic_table_sorter 0.0.1.beta

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
+ .idea/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in basic_table_sorter.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,153 @@
1
+ Copyright (c) 2013 Daniel Grawunder, Christian Mierich
2
+
3
+ Eclipse Public License - v 1.0
4
+
5
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION
6
+ OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
7
+
8
+ 1. DEFINITIONS
9
+
10
+ "Contribution" means:
11
+
12
+ a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
13
+ b) in the case of each subsequent Contributor:
14
+ i) changes to the Program, and
15
+ ii) additions to the Program;
16
+ where such changes and/or additions to the Program originate from and are distributed by that particular
17
+ Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor
18
+ itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which:
19
+ (i) are separate modules of software distributed in conjunction with the Program under their own license agreement,
20
+ and (ii) are not derivative works of the Program.
21
+
22
+ "Contributor" means any person or entity that distributes the Program.
23
+
24
+ "Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of
25
+ its Contribution alone or when combined with the Program.
26
+
27
+ "Program" means the Contributions distributed in accordance with this Agreement.
28
+
29
+ "Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
30
+
31
+ 2. GRANT OF RIGHTS
32
+
33
+ a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide,
34
+ royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform,
35
+ distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code
36
+ and object code form.
37
+ b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide,
38
+ royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer
39
+ the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply
40
+ to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor,
41
+ such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license
42
+ shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
43
+
44
+ c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein,
45
+ no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual
46
+ property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any
47
+ other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the
48
+ rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other
49
+ intellectual property rights needed, if any. For example, if a third party patent license is required to allow
50
+ Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing
51
+ the Program.
52
+
53
+ d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution,
54
+ if any, to grant the copyright license set forth in this Agreement.
55
+
56
+ 3. REQUIREMENTS
57
+
58
+ A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
59
+
60
+ a) it complies with the terms and conditions of this Agreement; and
61
+ b) its license agreement:
62
+ i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied,
63
+ including warranties or conditions of title and non-infringement, and implied warranties or conditions of
64
+ merchantability and fitness for a particular purpose;
65
+ ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect,
66
+ special, incidental and consequential damages, such as lost profits;
67
+ iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and
68
+ not by any other party; and
69
+ iv) states that source code for the Program is available from such Contributor, and informs licensees how to
70
+ obtain it in a reasonable manner on or through a medium customarily used for software exchange.
71
+
72
+ When the Program is made available in source code form:
73
+
74
+ a) it must be made available under this Agreement; and
75
+ b) a copy of this Agreement must be included with each copy of the Program.
76
+
77
+ Contributors may not remove or alter any copyright notices contained within the Program.
78
+
79
+ Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows
80
+ subsequent Recipients to identify the originator of the Contribution.
81
+
82
+ 4. COMMERCIAL DISTRIBUTION
83
+
84
+ Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and
85
+ the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes
86
+ the Program in a commercial product offering should do so in a manner which does not create potential liability for
87
+ other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor
88
+ ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor")
89
+ against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions
90
+ brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such
91
+ Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The
92
+ obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property
93
+ infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in
94
+ writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor
95
+ in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim
96
+ at its own expense.
97
+
98
+ For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is
99
+ then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties
100
+ related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone.
101
+ Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to
102
+ those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result,
103
+ the Commercial Contributor must pay those damages.
104
+
105
+ 5. NO WARRANTY
106
+
107
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
108
+ CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
109
+ NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for
110
+ determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise
111
+ of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with
112
+ applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
113
+
114
+ 6. DISCLAIMER OF LIABILITY
115
+
116
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
117
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS),
118
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
119
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
120
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
121
+
122
+ 7. GENERAL
123
+
124
+ If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or
125
+ enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such
126
+ provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
127
+
128
+ If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit)
129
+ alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such
130
+ Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such
131
+ litigation is filed.
132
+
133
+ All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or
134
+ conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such
135
+ noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution
136
+ of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses
137
+ granted by Recipient relating to the Program shall continue and survive.
138
+
139
+ Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement
140
+ is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new
141
+ versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the
142
+ right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may
143
+ assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the
144
+ Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed
145
+ subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement
146
+ is published, Contributor may elect to distribute the Program (including its Contributions) under the new version.
147
+ Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual
148
+ property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights
149
+ in the Program not expressly granted under this Agreement are reserved.
150
+
151
+ This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States
152
+ of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause
153
+ of action arose. Each party waives its rights to a jury trial in any resulting litigation.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # BasicTableSorter
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'basic_table_sorter'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install basic_table_sorter
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'basic_table_sorter/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "basic_table_sorter"
8
+ gem.version = BasicTableSorter::VERSION
9
+ gem.authors = ["Daniel Grawunder, Christian Mierich"]
10
+ gem.email = ["gramie.sw@gmail.com"]
11
+ gem.description = %q{A Ruby on Rails basic table sorter gem}
12
+ gem.summary = %q{An easy to use basic table sorter for Ruby on Rails.}
13
+ gem.license = "EPL 1.0"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "rspec"
21
+ gem.add_development_dependency "activesupport", "~>3.2"
22
+ gem.add_development_dependency "guard-rspec", "~>2.6.0"
23
+ end
data/epl-v10.html ADDED
@@ -0,0 +1,261 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1" ?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml">
4
+
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
7
+ <title>Eclipse Public License - Version 1.0</title>
8
+ <style type="text/css">
9
+ body {
10
+ size: 8.5in 11.0in;
11
+ margin: 0.25in 0.5in 0.25in 0.5in;
12
+ tab-interval: 0.5in;
13
+ }
14
+ p {
15
+ margin-left: auto;
16
+ margin-top: 0.5em;
17
+ margin-bottom: 0.5em;
18
+ }
19
+ p.list {
20
+ margin-left: 0.5in;
21
+ margin-top: 0.05em;
22
+ margin-bottom: 0.05em;
23
+ }
24
+ </style>
25
+
26
+ </head>
27
+
28
+ <body lang="EN-US">
29
+
30
+ <h2>Eclipse Public License - v 1.0</h2>
31
+
32
+ <p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
33
+ PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR
34
+ DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
35
+ AGREEMENT.</p>
36
+
37
+ <p><b>1. DEFINITIONS</b></p>
38
+
39
+ <p>&quot;Contribution&quot; means:</p>
40
+
41
+ <p class="list">a) in the case of the initial Contributor, the initial
42
+ code and documentation distributed under this Agreement, and</p>
43
+ <p class="list">b) in the case of each subsequent Contributor:</p>
44
+ <p class="list">i) changes to the Program, and</p>
45
+ <p class="list">ii) additions to the Program;</p>
46
+ <p class="list">where such changes and/or additions to the Program
47
+ originate from and are distributed by that particular Contributor. A
48
+ Contribution 'originates' from a Contributor if it was added to the
49
+ Program by such Contributor itself or anyone acting on such
50
+ Contributor's behalf. Contributions do not include additions to the
51
+ Program which: (i) are separate modules of software distributed in
52
+ conjunction with the Program under their own license agreement, and (ii)
53
+ are not derivative works of the Program.</p>
54
+
55
+ <p>&quot;Contributor&quot; means any person or entity that distributes
56
+ the Program.</p>
57
+
58
+ <p>&quot;Licensed Patents&quot; mean patent claims licensable by a
59
+ Contributor which are necessarily infringed by the use or sale of its
60
+ Contribution alone or when combined with the Program.</p>
61
+
62
+ <p>&quot;Program&quot; means the Contributions distributed in accordance
63
+ with this Agreement.</p>
64
+
65
+ <p>&quot;Recipient&quot; means anyone who receives the Program under
66
+ this Agreement, including all Contributors.</p>
67
+
68
+ <p><b>2. GRANT OF RIGHTS</b></p>
69
+
70
+ <p class="list">a) Subject to the terms of this Agreement, each
71
+ Contributor hereby grants Recipient a non-exclusive, worldwide,
72
+ royalty-free copyright license to reproduce, prepare derivative works
73
+ of, publicly display, publicly perform, distribute and sublicense the
74
+ Contribution of such Contributor, if any, and such derivative works, in
75
+ source code and object code form.</p>
76
+
77
+ <p class="list">b) Subject to the terms of this Agreement, each
78
+ Contributor hereby grants Recipient a non-exclusive, worldwide,
79
+ royalty-free patent license under Licensed Patents to make, use, sell,
80
+ offer to sell, import and otherwise transfer the Contribution of such
81
+ Contributor, if any, in source code and object code form. This patent
82
+ license shall apply to the combination of the Contribution and the
83
+ Program if, at the time the Contribution is added by the Contributor,
84
+ such addition of the Contribution causes such combination to be covered
85
+ by the Licensed Patents. The patent license shall not apply to any other
86
+ combinations which include the Contribution. No hardware per se is
87
+ licensed hereunder.</p>
88
+
89
+ <p class="list">c) Recipient understands that although each Contributor
90
+ grants the licenses to its Contributions set forth herein, no assurances
91
+ are provided by any Contributor that the Program does not infringe the
92
+ patent or other intellectual property rights of any other entity. Each
93
+ Contributor disclaims any liability to Recipient for claims brought by
94
+ any other entity based on infringement of intellectual property rights
95
+ or otherwise. As a condition to exercising the rights and licenses
96
+ granted hereunder, each Recipient hereby assumes sole responsibility to
97
+ secure any other intellectual property rights needed, if any. For
98
+ example, if a third party patent license is required to allow Recipient
99
+ to distribute the Program, it is Recipient's responsibility to acquire
100
+ that license before distributing the Program.</p>
101
+
102
+ <p class="list">d) Each Contributor represents that to its knowledge it
103
+ has sufficient copyright rights in its Contribution, if any, to grant
104
+ the copyright license set forth in this Agreement.</p>
105
+
106
+ <p><b>3. REQUIREMENTS</b></p>
107
+
108
+ <p>A Contributor may choose to distribute the Program in object code
109
+ form under its own license agreement, provided that:</p>
110
+
111
+ <p class="list">a) it complies with the terms and conditions of this
112
+ Agreement; and</p>
113
+
114
+ <p class="list">b) its license agreement:</p>
115
+
116
+ <p class="list">i) effectively disclaims on behalf of all Contributors
117
+ all warranties and conditions, express and implied, including warranties
118
+ or conditions of title and non-infringement, and implied warranties or
119
+ conditions of merchantability and fitness for a particular purpose;</p>
120
+
121
+ <p class="list">ii) effectively excludes on behalf of all Contributors
122
+ all liability for damages, including direct, indirect, special,
123
+ incidental and consequential damages, such as lost profits;</p>
124
+
125
+ <p class="list">iii) states that any provisions which differ from this
126
+ Agreement are offered by that Contributor alone and not by any other
127
+ party; and</p>
128
+
129
+ <p class="list">iv) states that source code for the Program is available
130
+ from such Contributor, and informs licensees how to obtain it in a
131
+ reasonable manner on or through a medium customarily used for software
132
+ exchange.</p>
133
+
134
+ <p>When the Program is made available in source code form:</p>
135
+
136
+ <p class="list">a) it must be made available under this Agreement; and</p>
137
+
138
+ <p class="list">b) a copy of this Agreement must be included with each
139
+ copy of the Program.</p>
140
+
141
+ <p>Contributors may not remove or alter any copyright notices contained
142
+ within the Program.</p>
143
+
144
+ <p>Each Contributor must identify itself as the originator of its
145
+ Contribution, if any, in a manner that reasonably allows subsequent
146
+ Recipients to identify the originator of the Contribution.</p>
147
+
148
+ <p><b>4. COMMERCIAL DISTRIBUTION</b></p>
149
+
150
+ <p>Commercial distributors of software may accept certain
151
+ responsibilities with respect to end users, business partners and the
152
+ like. While this license is intended to facilitate the commercial use of
153
+ the Program, the Contributor who includes the Program in a commercial
154
+ product offering should do so in a manner which does not create
155
+ potential liability for other Contributors. Therefore, if a Contributor
156
+ includes the Program in a commercial product offering, such Contributor
157
+ (&quot;Commercial Contributor&quot;) hereby agrees to defend and
158
+ indemnify every other Contributor (&quot;Indemnified Contributor&quot;)
159
+ against any losses, damages and costs (collectively &quot;Losses&quot;)
160
+ arising from claims, lawsuits and other legal actions brought by a third
161
+ party against the Indemnified Contributor to the extent caused by the
162
+ acts or omissions of such Commercial Contributor in connection with its
163
+ distribution of the Program in a commercial product offering. The
164
+ obligations in this section do not apply to any claims or Losses
165
+ relating to any actual or alleged intellectual property infringement. In
166
+ order to qualify, an Indemnified Contributor must: a) promptly notify
167
+ the Commercial Contributor in writing of such claim, and b) allow the
168
+ Commercial Contributor to control, and cooperate with the Commercial
169
+ Contributor in, the defense and any related settlement negotiations. The
170
+ Indemnified Contributor may participate in any such claim at its own
171
+ expense.</p>
172
+
173
+ <p>For example, a Contributor might include the Program in a commercial
174
+ product offering, Product X. That Contributor is then a Commercial
175
+ Contributor. If that Commercial Contributor then makes performance
176
+ claims, or offers warranties related to Product X, those performance
177
+ claims and warranties are such Commercial Contributor's responsibility
178
+ alone. Under this section, the Commercial Contributor would have to
179
+ defend claims against the other Contributors related to those
180
+ performance claims and warranties, and if a court requires any other
181
+ Contributor to pay any damages as a result, the Commercial Contributor
182
+ must pay those damages.</p>
183
+
184
+ <p><b>5. NO WARRANTY</b></p>
185
+
186
+ <p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
187
+ PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS
188
+ OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
189
+ ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
190
+ OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
191
+ responsible for determining the appropriateness of using and
192
+ distributing the Program and assumes all risks associated with its
193
+ exercise of rights under this Agreement , including but not limited to
194
+ the risks and costs of program errors, compliance with applicable laws,
195
+ damage to or loss of data, programs or equipment, and unavailability or
196
+ interruption of operations.</p>
197
+
198
+ <p><b>6. DISCLAIMER OF LIABILITY</b></p>
199
+
200
+ <p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
201
+ NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
202
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
203
+ WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
204
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
205
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
206
+ DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
207
+ HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
208
+
209
+ <p><b>7. GENERAL</b></p>
210
+
211
+ <p>If any provision of this Agreement is invalid or unenforceable under
212
+ applicable law, it shall not affect the validity or enforceability of
213
+ the remainder of the terms of this Agreement, and without further action
214
+ by the parties hereto, such provision shall be reformed to the minimum
215
+ extent necessary to make such provision valid and enforceable.</p>
216
+
217
+ <p>If Recipient institutes patent litigation against any entity
218
+ (including a cross-claim or counterclaim in a lawsuit) alleging that the
219
+ Program itself (excluding combinations of the Program with other
220
+ software or hardware) infringes such Recipient's patent(s), then such
221
+ Recipient's rights granted under Section 2(b) shall terminate as of the
222
+ date such litigation is filed.</p>
223
+
224
+ <p>All Recipient's rights under this Agreement shall terminate if it
225
+ fails to comply with any of the material terms or conditions of this
226
+ Agreement and does not cure such failure in a reasonable period of time
227
+ after becoming aware of such noncompliance. If all Recipient's rights
228
+ under this Agreement terminate, Recipient agrees to cease use and
229
+ distribution of the Program as soon as reasonably practicable. However,
230
+ Recipient's obligations under this Agreement and any licenses granted by
231
+ Recipient relating to the Program shall continue and survive.</p>
232
+
233
+ <p>Everyone is permitted to copy and distribute copies of this
234
+ Agreement, but in order to avoid inconsistency the Agreement is
235
+ copyrighted and may only be modified in the following manner. The
236
+ Agreement Steward reserves the right to publish new versions (including
237
+ revisions) of this Agreement from time to time. No one other than the
238
+ Agreement Steward has the right to modify this Agreement. The Eclipse
239
+ Foundation is the initial Agreement Steward. The Eclipse Foundation may
240
+ assign the responsibility to serve as the Agreement Steward to a
241
+ suitable separate entity. Each new version of the Agreement will be
242
+ given a distinguishing version number. The Program (including
243
+ Contributions) may always be distributed subject to the version of the
244
+ Agreement under which it was received. In addition, after a new version
245
+ of the Agreement is published, Contributor may elect to distribute the
246
+ Program (including its Contributions) under the new version. Except as
247
+ expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
248
+ rights or licenses to the intellectual property of any Contributor under
249
+ this Agreement, whether expressly, by implication, estoppel or
250
+ otherwise. All rights in the Program not expressly granted under this
251
+ Agreement are reserved.</p>
252
+
253
+ <p>This Agreement is governed by the laws of the State of New York and
254
+ the intellectual property laws of the United States of America. No party
255
+ to this Agreement will bring a legal action under this Agreement more
256
+ than one year after the cause of action arose. Each party waives its
257
+ rights to a jury trial in any resulting litigation.</p>
258
+
259
+ </body>
260
+
261
+ </html>
@@ -0,0 +1,31 @@
1
+ module BasicTableSorter
2
+ module ControllerAdditions
3
+
4
+ def self.included(base)
5
+ base.helper_method :table_sort_direction
6
+ end
7
+
8
+ def table_sort_direction
9
+ %w[asc desc].include?(params[:table_sort_direction]) ? params[:table_sort_direction] : "asc"
10
+ end
11
+
12
+ def custom_table_sort?
13
+ params.has_key? :table_sort
14
+ end
15
+
16
+ def table_sort_order
17
+ Array(params[:table_sort]).join(' ' + table_sort_direction + ', ') + ' ' + table_sort_direction
18
+ end
19
+
20
+ def authorize_sort_params
21
+ if params[:table_sort]
22
+ sort_params_permission_service = SortParamsPermissionService.create
23
+ Array(params[:table_sort]).each do |value|
24
+ unless sort_params_permission_service.allowed_sort_value?(params[:controller], params[:action], value)
25
+ render_500 and return
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ RSpec::Matchers.define :allow_sort_value do |*args|
2
+ match do |sort_params_permission_service|
3
+ sort_params_permission_service.allowed_sort_value?(*args).should be_true
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module BasicTableSorter
2
+ class Railtie < Rails::Railtie
3
+ initializer "basic_table_sorter.controller_additions" do
4
+ ActionController::Base.send :include, ControllerAdditions
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ module BasicTableSorter
2
+ module SortParamsPermissionServiceAdditions
3
+
4
+ def allowed_sort_value? controller, action, value
5
+ allowed = @allowed_sort_values && @allowed_sort_values[[controller.to_s, action.to_s]]
6
+ allowed ? allowed.include?(value) : allowed
7
+ end
8
+
9
+ def allow_sort_values controllers, actions, param_values
10
+ @allowed_sort_values ||= {}
11
+ Array(controllers).each do |controller|
12
+ Array(actions).each do |action|
13
+ unless @allowed_sort_values.has_key? [controller.to_s, action.to_s]
14
+ @allowed_sort_values[[controller.to_s, action.to_s]] = []
15
+ end
16
+ @allowed_sort_values[[controller.to_s, action.to_s]].concat Array(param_values).map(&:to_s)
17
+ end
18
+ end
19
+ end
20
+
21
+ module ClassMethods
22
+
23
+ def create()
24
+ service = self.new
25
+ service.configure_permissions
26
+ service
27
+ end
28
+ end
29
+
30
+ def self.included(base)
31
+ base.extend ClassMethods
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module BasicTableSorter
2
+ VERSION = "0.0.1.beta"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "basic_table_sorter/version"
2
+ require "basic_table_sorter/controller_additions"
3
+ require "basic_table_sorter/sort_params_permission_service_additions"
4
+ require "basic_table_sorter/railtie" if defined? (Rails)
5
+
@@ -0,0 +1,95 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'ControllerAdditions' do
4
+
5
+ before :each do
6
+ @controller_class = Class.new
7
+ @controller_class.stub(:helper_method)
8
+ @controller_class.send(:include, BasicTableSorter::ControllerAdditions)
9
+ @controller = @controller_class.new
10
+ end
11
+
12
+ describe '::included' do
13
+
14
+ it 'should provide table_sort_direction as helper method' do
15
+ controller_class = Class.new
16
+ controller_class.should_receive(:helper_method).with(:table_sort_direction)
17
+ controller = controller_class.new
18
+ controller.singleton_class.send(:include, BasicTableSorter::ControllerAdditions)
19
+ end
20
+ end
21
+
22
+ describe '#table_sort_direction' do
23
+
24
+ it 'should return asc if params table_sort_direction does not exits' do
25
+ @controller.stub(:params).and_return({})
26
+ @controller.table_sort_direction.should eq 'asc'
27
+ end
28
+
29
+ it 'should return asc if params table_sort_direction is not asc or desc' do
30
+ @controller.stub(:params).and_return({table_sort_direction: 'test'})
31
+ @controller.table_sort_direction.should eq 'asc'
32
+ end
33
+
34
+ it 'should return desc if params table_sort_direction has value desc' do
35
+ @controller.stub(:params).and_return({table_sort_direction: 'desc'})
36
+ @controller.table_sort_direction.should eq 'desc'
37
+ end
38
+ end
39
+
40
+ describe '#custom_table_sort?' do
41
+
42
+ it 'should return true if params has key table_sort' do
43
+ @controller.stub(:params).and_return({table_sort: 'test'})
44
+ @controller.custom_table_sort?.should be_true
45
+ end
46
+
47
+ it 'should return false if params has no key table_sort' do
48
+ @controller.stub(:params).and_return({})
49
+ @controller.custom_table_sort?.should be_false
50
+ end
51
+ end
52
+
53
+ describe '#table_sort_order' do
54
+
55
+ it 'should return column with table sort direction as string' do
56
+ @controller.stub(:params).and_return({table_sort: 'last_name', table_sort_direction: 'desc'})
57
+ @controller.table_sort_order.should eq "last_name desc"
58
+ end
59
+
60
+ it 'should return columns together with sort direction as string if multiple given' do
61
+ @controller.stub(:params).and_return({table_sort: ['last_name', 'first_name'], table_sort_direction: 'desc'})
62
+ @controller.table_sort_order.should eq "last_name desc, first_name desc"
63
+ end
64
+ end
65
+
66
+ describe '#authorize_sort_params' do
67
+
68
+ it 'should call allowed_sort_value? if param with value table_sort exits' do
69
+ @controller.stub(:params).and_return(table_sort: 'last_name')
70
+ @controller.stub(:render_500)
71
+ SortParamsPermissionService.any_instance.should_receive(:allowed_sort_value?)
72
+ @controller.authorize_sort_params
73
+ end
74
+
75
+ it 'should call render_500 if allowed_sort_value? returns false' do
76
+ @controller.stub(:params).and_return(table_sort: 'last_name')
77
+ SortParamsPermissionService.any_instance.stub(:allowed_sort_value?).and_return false
78
+ @controller.should_receive(:render_500)
79
+ @controller.authorize_sort_params
80
+ end
81
+
82
+ it 'should not call render_500 if params has no value table sort' do
83
+ @controller.stub(:params).and_return({})
84
+ @controller.should_not_receive(:render_500)
85
+ @controller.authorize_sort_params.should eq nil
86
+ end
87
+
88
+ it 'should not call render_500 if allowed_sort_value? is true' do
89
+ @controller.stub(:params).and_return(table_sort: ['last_name', 'first_name'])
90
+ SortParamsPermissionService.any_instance.stub(:allowed_sort_value?).and_return true
91
+ @controller.should_not_receive(:render_500)
92
+ @controller.authorize_sort_params
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'allow_sort_value' do
4
+
5
+ it 'should delegate to allowed_sort_value?' do
6
+ object = Object.new
7
+ object.should_receive(:allowed_sort_value?).once.with(:comments, :index, :email).and_return(true)
8
+ object.should allow_sort_value(:comments, :index, :email)
9
+ end
10
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'SortParamsPermissionServiceAdditions' do
4
+
5
+ before :each do
6
+ @sort_params_permission_service = SortParamsPermissionService.create
7
+ end
8
+
9
+ describe '::included' do
10
+
11
+ it 'should extend included class with module ClassMethods' do
12
+ clazz = Class.new
13
+ clazz.should_receive(:extend).with(BasicTableSorter::SortParamsPermissionServiceAdditions::ClassMethods)
14
+ clazz.send(:include, BasicTableSorter::SortParamsPermissionServiceAdditions)
15
+ end
16
+ end
17
+
18
+ describe '::create' do
19
+
20
+ it 'should create a SortParamsPermissionService instance object' do
21
+ @sort_params_permission_service.should be_an_instance_of(SortParamsPermissionService)
22
+ end
23
+
24
+ it 'should call configure_permissions' do
25
+ SortParamsPermissionService.any_instance.should_receive(:configure_permissions)
26
+ SortParamsPermissionService.create
27
+ end
28
+ end
29
+
30
+ describe '#allowed_sort_value?' do
31
+
32
+ it 'should return false if @allowed_sort_values is nil' do
33
+ @sort_params_permission_service.instance_variable_set(:@allowed_sort_values, nil)
34
+ @sort_params_permission_service.allowed_sort_value?(nil, nil, nil).should be_false
35
+ end
36
+
37
+ it 'should return false if @allowed_sort_value does not have given value' do
38
+ allowed_sort_values = {}
39
+ allowed_sort_values[['customer', 'index']] = ['last_name']
40
+ @sort_params_permission_service.instance_variable_set(:@allowed_sort_values, allowed_sort_values)
41
+ @sort_params_permission_service.allowed_sort_value?('customer', 'index', 'first_name').should be_false
42
+ end
43
+
44
+ it 'should return true if @allowed_sort_value does have given value' do
45
+ allowed_sort_values = {}
46
+ allowed_sort_values[['customer', 'index']] = ['first_name']
47
+ @sort_params_permission_service.instance_variable_set(:@allowed_sort_values, allowed_sort_values)
48
+ @sort_params_permission_service.allowed_sort_value?('customer', 'index', 'first_name').should be_true
49
+ end
50
+ end
51
+
52
+ describe '#allow_sort_values' do
53
+
54
+ it 'should insert value into @allow sort values' do
55
+ @sort_params_permission_service.allow_sort_values('customer', 'index', 'last_name')
56
+ @sort_params_permission_service.instance_variable_get(:@allowed_sort_values)[['customer', 'index']].should eq ['last_name']
57
+ end
58
+
59
+ it 'should insert values into @allow sort values' do
60
+ @sort_params_permission_service.allow_sort_values('customer', 'index', ['first_name', 'last_name'])
61
+ @sort_params_permission_service.instance_variable_get(:@allowed_sort_values)[['customer', 'index']].should eq ['first_name', 'last_name']
62
+ end
63
+
64
+ it 'should insert value for two keys' do
65
+ @sort_params_permission_service.allow_sort_values(['customer', 'person'], ['index', 'edit'], 'first_name')
66
+ @sort_params_permission_service.instance_variable_get(:@allowed_sort_values)[['customer', 'index']].should eq ['first_name']
67
+ @sort_params_permission_service.instance_variable_get(:@allowed_sort_values)[['person', 'index']].should eq ['first_name']
68
+ @sort_params_permission_service.instance_variable_get(:@allowed_sort_values)[['customer', 'edit']].should eq ['first_name']
69
+ @sort_params_permission_service.instance_variable_get(:@allowed_sort_values)[['person', 'edit']].should eq ['first_name']
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,10 @@
1
+ require 'basic_table_sorter'
2
+ require 'basic_table_sorter/matchers'
3
+
4
+ class SortParamsPermissionService
5
+ include BasicTableSorter::SortParamsPermissionServiceAdditions
6
+
7
+ def configure_permissions
8
+
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: basic_table_sorter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.beta
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Grawunder, Christian Mierich
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: activesupport
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.2'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: guard-rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.6.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.0
62
+ description: A Ruby on Rails basic table sorter gem
63
+ email:
64
+ - gramie.sw@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - .rspec
71
+ - Gemfile
72
+ - Guardfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - basic_table_sorter.gemspec
77
+ - epl-v10.html
78
+ - lib/basic_table_sorter.rb
79
+ - lib/basic_table_sorter/controller_additions.rb
80
+ - lib/basic_table_sorter/matchers.rb
81
+ - lib/basic_table_sorter/railtie.rb
82
+ - lib/basic_table_sorter/sort_params_permission_service_additions.rb
83
+ - lib/basic_table_sorter/version.rb
84
+ - spec/basic_table_sorter/controller_additions_spec.rb
85
+ - spec/basic_table_sorter/matchers_spec.rb
86
+ - spec/basic_table_sorter/sort_params_permission_service_additions_spec.rb
87
+ - spec/spec_helper.rb
88
+ homepage:
89
+ licenses:
90
+ - EPL 1.0
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>'
105
+ - !ruby/object:Gem::Version
106
+ version: 1.3.1
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 1.8.25
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: An easy to use basic table sorter for Ruby on Rails.
113
+ test_files:
114
+ - spec/basic_table_sorter/controller_additions_spec.rb
115
+ - spec/basic_table_sorter/matchers_spec.rb
116
+ - spec/basic_table_sorter/sort_params_permission_service_additions_spec.rb
117
+ - spec/spec_helper.rb