record_view_helper 1.2.1 → 1.3.4
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.
- checksums.yaml +4 -4
- data/LICENSE +20 -0
- data/README.md +2 -4
- data/Rakefile +0 -0
- data/lib/record_view_helper.rb +0 -0
- data/lib/record_view_helper/config.rb +0 -0
- data/lib/record_view_helper/dl.rb +0 -0
- data/lib/record_view_helper/railtie.rb +0 -0
- data/lib/record_view_helper/record_value_setting.rb +7 -3
- data/lib/record_view_helper/table.rb +2 -2
- data/lib/record_view_helper/util.rb +3 -0
- data/lib/record_view_helper/version.rb +1 -1
- metadata +8 -121
- data/MIT-LICENSE +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38bdf196e076d0fd86fff125fbf9eba18d131f687bae54422aa7113a74f8863c
|
4
|
+
data.tar.gz: 06c9921060799ad650705a5a18291cde6a3634ebecb9dce9e8baa6436e863846
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eaa0d6b2792f6d5a42b53f0cd0a21d8a2ee6b2abb8b6de790daf11de22a9bdc8e3264d048cb23202a91bbd7d537210eb281ca0caa85da837ae8473ffbfdcca8
|
7
|
+
data.tar.gz: cfcd06a3de83ed113e6a9d4407403d3364a4898c561154c662d9a51a4f5f2639e4c00d45a4d0742dda374d20f5fbd3d3931243cfc0be540458e8bdb3de3c95f3
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2017 Narazaka
|
2
|
+
|
3
|
+
This software is provided 'as-is', without any express or implied
|
4
|
+
warranty. In no event will the authors be held liable for any damages
|
5
|
+
arising from the use of this software.
|
6
|
+
|
7
|
+
Permission is granted to anyone to use this software for any purpose,
|
8
|
+
including commercial applications, and to alter it and redistribute it
|
9
|
+
freely, subject to the following restrictions:
|
10
|
+
|
11
|
+
1. The origin of this software must not be misrepresented; you must not
|
12
|
+
claim that you wrote the original software. If you use this software
|
13
|
+
in a product, an acknowledgment in the product documentation would be
|
14
|
+
appreciated but is not required.
|
15
|
+
|
16
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
17
|
+
misrepresented as being the original software.
|
18
|
+
|
19
|
+
3. This notice may not be removed or altered from any source
|
20
|
+
distribution.
|
data/README.md
CHANGED
@@ -2,10 +2,8 @@
|
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/record_view_helper)
|
4
4
|
[](https://rubygems.org/gems/record_view_helper)
|
5
|
-
[](https://gemnasium.com/Narazaka/record_view_helper)
|
6
5
|
[](http://inch-ci.org/github/Narazaka/record_view_helper)
|
7
|
-
[](https://ci.appveyor.com/project/Narazaka/record-view-helper)
|
6
|
+
[](https://github.com/Narazaka/record_view_helper/actions?query=workflow:Ruby)
|
9
7
|
|
10
8
|
table builder and description list (dl) helper for Rails / ActiveModels
|
11
9
|
|
@@ -50,4 +48,4 @@ $ gem install record_view_helper
|
|
50
48
|
- [table-for](https://github.com/hunterae/table-for)
|
51
49
|
|
52
50
|
## License
|
53
|
-
The gem is available as open source under the terms of the [
|
51
|
+
The gem is available as open source under the terms of the [Zlib License](LICENSE).
|
data/Rakefile
CHANGED
File without changes
|
data/lib/record_view_helper.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -123,14 +123,18 @@ module RecordViewHelper
|
|
123
123
|
# set column link setting
|
124
124
|
# @param [Symbol] column target column
|
125
125
|
# @param [Symbol|Hash<Symbol|Array<Symbol|Array<Symbol>>>] link setting
|
126
|
+
# @yield [record] format function (optional)
|
127
|
+
# @yieldparam [Object] record record
|
128
|
+
# @yieldreturn [String] link uri string
|
126
129
|
# @return [void]
|
127
130
|
#
|
128
131
|
# @example
|
129
132
|
# = dl_for(record) do |s|
|
130
133
|
# - s.link :foo_id, :foo_path
|
131
134
|
# - s.link :id, foo_bar_path: [:foo_id, :id]
|
132
|
-
|
133
|
-
|
135
|
+
# - s.link(:bar_id) {|record| baz_path(record.bar_id) }
|
136
|
+
def link(column, link = nil, &block)
|
137
|
+
@links[column] = block_given? ? block : link
|
134
138
|
end
|
135
139
|
|
136
140
|
# set column value dom tag attrs
|
@@ -178,7 +182,7 @@ module RecordViewHelper
|
|
178
182
|
# calculated columns
|
179
183
|
# @return [Array<Symbol>] (only || default columns) - except
|
180
184
|
def columns
|
181
|
-
(@only.presence || @columns).map(&:to_sym)
|
185
|
+
(@only.presence || @columns).map(&:to_sym) - @except.map(&:to_sym)
|
182
186
|
end
|
183
187
|
end
|
184
188
|
end
|
@@ -55,10 +55,10 @@ module RecordViewHelper
|
|
55
55
|
# - s.only :id, :name
|
56
56
|
# / recommended for complex settings
|
57
57
|
# / see RecordValueSetting for details
|
58
|
-
def table_for(records, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
58
|
+
def table_for(records, options = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
59
59
|
setting = RecordValueSetting.build_from_hash!(
|
60
60
|
records.try(:klass).try(:column_names) || records.first.try(:attributes).try(:keys) || records.first.try(:keys) || [],
|
61
|
-
records.first.try(:class).try(:name).try(:tableize),
|
61
|
+
(records.try(:klass) || records.first.try(:class)).try(:name).try(:tableize),
|
62
62
|
options,
|
63
63
|
)
|
64
64
|
yield setting if block_given?
|
@@ -35,6 +35,9 @@ module RecordViewHelper
|
|
35
35
|
when Hash
|
36
36
|
path_method, param_columns = link.first
|
37
37
|
link_record_value(record, formatted_value, path_method, param_columns)
|
38
|
+
when Proc
|
39
|
+
link_uri = link.call(record)
|
40
|
+
link_uri ? link_to(formatted_value, link_uri) : formatted_value
|
38
41
|
else
|
39
42
|
formatted_value
|
40
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record_view_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Narazaka
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -38,118 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
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: '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: onkcop
|
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: rails
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '4'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '4'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rake
|
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: rspec
|
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
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rspec-rails
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '3'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '3'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: simplecov
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: yard
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
41
|
description: This module provides table_for(model) and dl_for(model) helpers.
|
154
42
|
email:
|
155
43
|
- info@narazaka.net
|
@@ -157,7 +45,7 @@ executables: []
|
|
157
45
|
extensions: []
|
158
46
|
extra_rdoc_files: []
|
159
47
|
files:
|
160
|
-
-
|
48
|
+
- LICENSE
|
161
49
|
- README.md
|
162
50
|
- Rakefile
|
163
51
|
- lib/record_view_helper.rb
|
@@ -170,10 +58,10 @@ files:
|
|
170
58
|
- lib/record_view_helper/version.rb
|
171
59
|
homepage: https://github.com/Narazaka/record_view_helper
|
172
60
|
licenses:
|
173
|
-
-
|
61
|
+
- Zlib
|
174
62
|
metadata:
|
175
63
|
yard.run: yri
|
176
|
-
post_install_message:
|
64
|
+
post_install_message:
|
177
65
|
rdoc_options: []
|
178
66
|
require_paths:
|
179
67
|
- lib
|
@@ -188,9 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
76
|
- !ruby/object:Gem::Version
|
189
77
|
version: '0'
|
190
78
|
requirements: []
|
191
|
-
|
192
|
-
|
193
|
-
signing_key:
|
79
|
+
rubygems_version: 3.2.3
|
80
|
+
signing_key:
|
194
81
|
specification_version: 4
|
195
82
|
summary: table builder and description list (dl) helper for Rails / ActiveModels
|
196
83
|
test_files: []
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2017 Narazaka
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|