xrb-formatters 0.1.0 → 0.1.1
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
- checksums.yaml.gz.sig +3 -1
- data/lib/xrb/formatters/formatter.rb +4 -4
- data/lib/xrb/formatters/html/accept_checkbox.rb +4 -4
- data/lib/xrb/formatters/html/definition_list_form.rb +12 -12
- data/lib/xrb/formatters/html/form_formatter.rb +13 -13
- data/lib/xrb/formatters/html/label_form.rb +5 -5
- data/lib/xrb/formatters/html/option_select.rb +4 -4
- data/lib/xrb/formatters/html/radio_select.rb +3 -3
- data/lib/xrb/formatters/markdown.rb +4 -4
- data/lib/xrb/formatters/relative_time.rb +3 -3
- data/lib/xrb/formatters/truncated_text.rb +4 -4
- data/lib/xrb/formatters/version.rb +1 -1
- data/lib/xrb/formatters.rb +2 -2
- data/license.md +1 -1
- data/readme.md +8 -15
- data/releases.md +3 -0
- data.tar.gz.sig +0 -0
- metadata +5 -9
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c303bcb102a5a8aff8013c246d584e682aaa960b5ac5dea30f2393aea6de2f8
|
4
|
+
data.tar.gz: e2b1f5c44290f4f3f14ba1454fb3a4873673bb20036889d9d1381a1105552382
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf374696930e396b2b31f9e271311120f440f4e97dee2a07d383c6403cad1851211330ffd568670cd299a000a49d8c3f9bff3e50f6708862bb1ebdbceb03fbd5
|
7
|
+
data.tar.gz: c279e1fd5badbc200b19cb657b72f143ff3da312b5d40a7608ef0480a0ac29f38f3e6d689c7f1fe30a143bd19ee691595df8ec18fc8e9efedbcbef4d00369f2e
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
|
1
|
+
P;�+,Q�&�;�+�a�lQ�����̩PI�G/��?�1��K��b�Y���wL��ʮP�ag�ӎ��#w����z8J�H�o��)g�-$"�0���,�},�XȥF����;�XbK�iM�V/߅]������>��<�e�i*��U }�t��q1����T���"V[��Hۊ�\�����+��Q�P&�m��0�DV���Ǹ�^���dZ����6z����S�Gj�{���R��r�
|
2
|
+
S\O�k��_�����#0���QaK;��ro.�-V�c����@��#(�rS"�f�s�ә�Q��fX���9(����*���Ĥ4�
|
3
|
+
�j�W��5�n�&�Ұ��qy��/.i ��؏���l�
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2012-
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
6
|
+
require "xrb/strings"
|
7
|
+
require "mapping/model"
|
8
|
+
require "mapping/descendants"
|
9
9
|
|
10
10
|
module XRB
|
11
11
|
module Formatters
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "xrb/builder"
|
7
7
|
|
8
8
|
module XRB
|
9
9
|
module Formatters
|
@@ -31,8 +31,8 @@ module XRB
|
|
31
31
|
|
32
32
|
def call(&block)
|
33
33
|
Builder.fragment(@builder) do |builder|
|
34
|
-
builder.inline(
|
35
|
-
builder.inline :input, type: :hidden, name: name_for(**@options), value:
|
34
|
+
builder.inline("span") do
|
35
|
+
builder.inline :input, type: :hidden, name: name_for(**@options), value: "false"
|
36
36
|
|
37
37
|
builder.tag :input, checkbox_attributes_for(**@options)
|
38
38
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2012-
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "xrb/builder"
|
7
|
+
require "xrb/template"
|
8
8
|
|
9
|
-
require_relative
|
9
|
+
require_relative "form_formatter"
|
10
10
|
|
11
11
|
module XRB
|
12
12
|
module Formatters
|
@@ -27,7 +27,7 @@ module XRB
|
|
27
27
|
builder.tag :input, input_attributes_for(**options)
|
28
28
|
|
29
29
|
if details = details_for(**options)
|
30
|
-
builder.inline(:small, class:
|
30
|
+
builder.inline(:small, class: "details") {builder.text details}
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -54,11 +54,11 @@ module XRB
|
|
54
54
|
|
55
55
|
Builder.fragment do |builder|
|
56
56
|
builder.tag(:dt) do
|
57
|
-
|
57
|
+
builder.text title_for(**options)
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
if details = details_for(**options)
|
60
|
+
builder.inline(:small, class: "details") {builder.text details}
|
61
|
+
end
|
62
62
|
end
|
63
63
|
|
64
64
|
builder.inline(:dd) do
|
@@ -75,7 +75,7 @@ module XRB
|
|
75
75
|
|
76
76
|
Builder.fragment do |builder|
|
77
77
|
builder.tag(:dd) do
|
78
|
-
builder.tag :input, :type => :hidden, :name => name_for(**options), :value =>
|
78
|
+
builder.tag :input, :type => :hidden, :name => name_for(**options), :value => "false"
|
79
79
|
|
80
80
|
builder.inline(:label) do
|
81
81
|
builder.tag :input, checkbox_attributes_for(**options)
|
@@ -84,7 +84,7 @@ module XRB
|
|
84
84
|
end
|
85
85
|
|
86
86
|
if details = details_for(**options)
|
87
|
-
builder.inline(:small, class:
|
87
|
+
builder.inline(:small, class: "details") {builder.text details}
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -112,7 +112,7 @@ module XRB
|
|
112
112
|
klass.call(self, builder, **options, &block)
|
113
113
|
|
114
114
|
if details = details_for(**options)
|
115
|
-
builder.inline(:small, class:
|
115
|
+
builder.inline(:small, class: "details") {builder.text details}
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2014-
|
4
|
+
# Copyright, 2014-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "xrb/builder"
|
7
7
|
|
8
8
|
module XRB
|
9
9
|
module Formatters
|
@@ -11,7 +11,7 @@ module XRB
|
|
11
11
|
module FormFormatter
|
12
12
|
# Return true if the object is begin created or false if it is being updated.
|
13
13
|
def new_record?
|
14
|
-
object.new_record?
|
14
|
+
object.nil? or object.new_record?
|
15
15
|
end
|
16
16
|
|
17
17
|
# Any additional details relating to a field (e.g. explanation text)
|
@@ -32,7 +32,7 @@ module XRB
|
|
32
32
|
# Generate a title from a field name:
|
33
33
|
if field_name = field_for(**options)
|
34
34
|
# Remove postfix "_id" or "_ids":
|
35
|
-
return Strings::to_title(field_name.to_s.sub(/_ids?/,
|
35
|
+
return Strings::to_title(field_name.to_s.sub(/_ids?/, ""))
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -120,11 +120,11 @@ module XRB
|
|
120
120
|
|
121
121
|
def checkbox_attributes_for(**options)
|
122
122
|
return {
|
123
|
-
:type => options[:type] ||
|
123
|
+
:type => options[:type] || "checkbox",
|
124
124
|
:id => options[:id],
|
125
125
|
:class => options[:class],
|
126
126
|
:name => name_for(**options),
|
127
|
-
:value =>
|
127
|
+
:value => "true",
|
128
128
|
:checked => raw_value_for(**options),
|
129
129
|
:required => options[:required],
|
130
130
|
:disabled => options[:disabled],
|
@@ -135,7 +135,7 @@ module XRB
|
|
135
135
|
|
136
136
|
def submit_attributes_for(**options)
|
137
137
|
return {
|
138
|
-
:type => options[:type] ||
|
138
|
+
:type => options[:type] || "submit",
|
139
139
|
:name => name_for(**options),
|
140
140
|
:id => options[:id],
|
141
141
|
:class => options[:class],
|
@@ -146,12 +146,12 @@ module XRB
|
|
146
146
|
end
|
147
147
|
|
148
148
|
def submit_title_for(**options)
|
149
|
-
title_for(**options) || (new_record? ?
|
149
|
+
title_for(**options) || (new_record? ? "Create" : "Update")
|
150
150
|
end
|
151
151
|
|
152
152
|
def hidden_attributes_for(**options)
|
153
153
|
return {
|
154
|
-
:type => options[:type] ||
|
154
|
+
:type => options[:type] || "hidden",
|
155
155
|
:id => options[:id],
|
156
156
|
:class => options[:class],
|
157
157
|
:name => name_for(**options),
|
@@ -171,7 +171,7 @@ module XRB
|
|
171
171
|
|
172
172
|
def button_attributes_for(**options)
|
173
173
|
return {
|
174
|
-
:type => options[:type] ||
|
174
|
+
:type => options[:type] || "submit",
|
175
175
|
:name => name_for(**options),
|
176
176
|
:id => options[:id],
|
177
177
|
:class => options[:class],
|
@@ -182,7 +182,7 @@ module XRB
|
|
182
182
|
end
|
183
183
|
|
184
184
|
def button_title_for(**options)
|
185
|
-
type = options.fetch(:type,
|
185
|
+
type = options.fetch(:type, "submit").to_sym
|
186
186
|
|
187
187
|
if type == :submit
|
188
188
|
submit_title_for(**options)
|
@@ -207,8 +207,8 @@ module XRB
|
|
207
207
|
buffer = XRB::Template.buffer(block.binding)
|
208
208
|
|
209
209
|
Builder.fragment(buffer) do |builder|
|
210
|
-
builder.tag(
|
211
|
-
builder.inline(
|
210
|
+
builder.tag("fieldset") do
|
211
|
+
builder.inline("legend") do
|
212
212
|
builder.text title_for(**options)
|
213
213
|
end
|
214
214
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2020-
|
4
|
+
# Copyright, 2020-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "xrb/builder"
|
7
|
+
require "xrb/template"
|
8
8
|
|
9
|
-
require_relative
|
9
|
+
require_relative "form_formatter"
|
10
10
|
|
11
11
|
module XRB
|
12
12
|
module Formatters
|
@@ -79,7 +79,7 @@ module XRB
|
|
79
79
|
|
80
80
|
Builder.fragment do |builder|
|
81
81
|
builder.inline(:label) do
|
82
|
-
builder.inline :input, :type => :hidden, :name => name_for(**options), :value =>
|
82
|
+
builder.inline :input, :type => :hidden, :name => name_for(**options), :value => "false"
|
83
83
|
|
84
84
|
builder.inline(:span) do
|
85
85
|
if details = details_for(**options)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2012-
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "xrb/builder"
|
7
7
|
|
8
8
|
module XRB
|
9
9
|
module Formatters
|
@@ -59,7 +59,7 @@ module XRB
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def item(**options, &block)
|
62
|
-
options[:field] ||=
|
62
|
+
options[:field] ||= "id"
|
63
63
|
|
64
64
|
Builder.fragment(block&.binding || @builder) do |builder|
|
65
65
|
builder.inline(:option, option_attributes_for(**options)) do
|
@@ -74,7 +74,7 @@ module XRB
|
|
74
74
|
|
75
75
|
def optional_title_for(**options)
|
76
76
|
if options[:optional] == true
|
77
|
-
options[:blank] ||
|
77
|
+
options[:blank] || ""
|
78
78
|
else
|
79
79
|
options[:optional]
|
80
80
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2012-
|
4
|
+
# Copyright, 2012-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "xrb/builder"
|
7
7
|
|
8
8
|
module XRB
|
9
9
|
module Formatters
|
@@ -75,7 +75,7 @@ module XRB
|
|
75
75
|
|
76
76
|
def optional_title_for(**options)
|
77
77
|
if options[:optional] == true
|
78
|
-
options[:blank] ||
|
78
|
+
options[:blank] || ""
|
79
79
|
else
|
80
80
|
options[:optional]
|
81
81
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2016-
|
4
|
+
# Copyright, 2016-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "markly"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "xrb/markup"
|
9
|
+
require "xrb/sanitize/fragment"
|
10
10
|
|
11
11
|
module XRB
|
12
12
|
module Formatters
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2016-
|
4
|
+
# Copyright, 2016-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "xrb/strings"
|
7
|
+
require "mapping/model"
|
8
8
|
|
9
9
|
module XRB
|
10
10
|
module Formatters
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2016-
|
4
|
+
# Copyright, 2016-2025, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "xrb/strings"
|
7
|
+
require "mapping/model"
|
8
8
|
|
9
9
|
module XRB
|
10
10
|
module Formatters
|
@@ -20,7 +20,7 @@ module XRB
|
|
20
20
|
def self.truncate_text(text, truncate_at, omission: nil, separator: nil, **options)
|
21
21
|
return text.dup unless text.length > truncate_at
|
22
22
|
|
23
|
-
omission ||=
|
23
|
+
omission ||= "..."
|
24
24
|
|
25
25
|
length_with_room_for_omission = truncate_at - omission.length
|
26
26
|
|
data/lib/xrb/formatters.rb
CHANGED
data/license.md
CHANGED
data/readme.md
CHANGED
@@ -29,20 +29,13 @@ Or install it yourself as:
|
|
29
29
|
|
30
30
|
## Usage
|
31
31
|
|
32
|
-
|
33
|
-
a mapping corresponding to the objects type:
|
32
|
+
Please see the [project documentation](https://github.com/ioquatix/xrb-formatters) for more details.
|
34
33
|
|
35
|
-
|
36
|
-
formatter = XRB::Formatters::Formatter.new
|
37
|
-
|
38
|
-
formatter.for(String) do |value, **options|
|
39
|
-
"String: #{value}"
|
40
|
-
end
|
41
|
-
|
42
|
-
expect(formatter.format("foobar")).to be == "String: foobar"
|
43
|
-
```
|
34
|
+
## Releases
|
44
35
|
|
45
|
-
|
36
|
+
Please see the [project releases](https://github.com/ioquatix/xrb-formattersreleases/index) for all releases.
|
37
|
+
|
38
|
+
### v0.1.1
|
46
39
|
|
47
40
|
## Contributing
|
48
41
|
|
@@ -56,8 +49,8 @@ We welcome contributions to this project.
|
|
56
49
|
|
57
50
|
### Developer Certificate of Origin
|
58
51
|
|
59
|
-
|
52
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
60
53
|
|
61
|
-
###
|
54
|
+
### Community Guidelines
|
62
55
|
|
63
|
-
This project is
|
56
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
data/releases.md
ADDED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xrb-formatters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain:
|
11
10
|
- |
|
@@ -37,7 +36,7 @@ cert_chain:
|
|
37
36
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
37
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
38
|
-----END CERTIFICATE-----
|
40
|
-
date:
|
39
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
41
40
|
dependencies:
|
42
41
|
- !ruby/object:Gem::Dependency
|
43
42
|
name: mapping
|
@@ -67,8 +66,6 @@ dependencies:
|
|
67
66
|
- - "~>"
|
68
67
|
- !ruby/object:Gem::Version
|
69
68
|
version: '0.6'
|
70
|
-
description:
|
71
|
-
email:
|
72
69
|
executables: []
|
73
70
|
extensions: []
|
74
71
|
extra_rdoc_files: []
|
@@ -87,13 +84,13 @@ files:
|
|
87
84
|
- lib/xrb/formatters/version.rb
|
88
85
|
- license.md
|
89
86
|
- readme.md
|
87
|
+
- releases.md
|
90
88
|
homepage: https://github.com/ioquatix/xrb-formatters
|
91
89
|
licenses:
|
92
90
|
- MIT
|
93
91
|
metadata:
|
94
92
|
funding_uri: https://github.com/sponsors/ioquatix/
|
95
93
|
source_code_uri: https://github.com/ioquatix/xrb-formatters.git
|
96
|
-
post_install_message:
|
97
94
|
rdoc_options: []
|
98
95
|
require_paths:
|
99
96
|
- lib
|
@@ -101,15 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
98
|
requirements:
|
102
99
|
- - ">="
|
103
100
|
- !ruby/object:Gem::Version
|
104
|
-
version: '3.
|
101
|
+
version: '3.2'
|
105
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
103
|
requirements:
|
107
104
|
- - ">="
|
108
105
|
- !ruby/object:Gem::Version
|
109
106
|
version: '0'
|
110
107
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
112
|
-
signing_key:
|
108
|
+
rubygems_version: 3.6.7
|
113
109
|
specification_version: 4
|
114
110
|
summary: Formatters for XRB, to assist with typical views and form based interfaces.
|
115
111
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|