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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c7d3c4882fa5d1766266d11516647193f2edb6a414aa3901cd2280da98b219e
4
- data.tar.gz: 82609011a18a1ebf7848c8b92654b75ed9721d2f27640b2687fdb4d89e03cec7
3
+ metadata.gz: 3c303bcb102a5a8aff8013c246d584e682aaa960b5ac5dea30f2393aea6de2f8
4
+ data.tar.gz: e2b1f5c44290f4f3f14ba1454fb3a4873673bb20036889d9d1381a1105552382
5
5
  SHA512:
6
- metadata.gz: af17a0f56086a82b143d69d5b02ec070126a8182bd1a6ecb8ce628d10b6063ac6a689e15d69c059e298128202165c9b15ed382ce27f7147a387bb5eb7933bf99
7
- data.tar.gz: 836b7440bf8623edf869c929172c32c4613a89c6ff18b68aff2a3f26fc68bd62da3e2f0d0a123940f6bf28051b3d1aac54f6d0083988b01e36887041ba368e9d
6
+ metadata.gz: cf374696930e396b2b31f9e271311120f440f4e97dee2a07d383c6403cad1851211330ffd568670cd299a000a49d8c3f9bff3e50f6708862bb1ebdbceb03fbd5
7
+ data.tar.gz: c279e1fd5badbc200b19cb657b72f143ff3da312b5d40a7608ef0480a0ac29f38f3e6d689c7f1fe30a143bd19ee691595df8ec18fc8e9efedbcbef4d00369f2e
checksums.yaml.gz.sig CHANGED
@@ -1 +1,3 @@
1
- <���3S-qAa�G�"hsiǯ���S����g^^]C_1���v�������XT����TZܼXc������� cHr��'~&� $aK�廰��L���t������!y����Г<�Ob_lgu�i�NX�S�n�=���Eh<�Lv8x`V��{gP����5
1
+ P;�+,Q�&�;�+�alQ�����̩PI�G/��?�1��K��bY���wL��ʮPag�ӎ�� #w����z8JHo��)g�-$"0���,�},�XȥF����;�XbKiM�V/߅]������>��<�e�i*��U }t��q1����T���"V[��Hۊ�\�����+��QP&�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-2024, by Samuel Williams.
4
+ # Copyright, 2012-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/strings'
7
- require 'mapping/model'
8
- require 'mapping/descendants'
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-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/builder'
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('span') do
35
- builder.inline :input, type: :hidden, name: name_for(**@options), value: 'false'
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-2024, by Samuel Williams.
4
+ # Copyright, 2012-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/builder'
7
- require 'xrb/template'
6
+ require "xrb/builder"
7
+ require "xrb/template"
8
8
 
9
- require_relative 'form_formatter'
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: 'details') {builder.text details}
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
- builder.text title_for(**options)
57
+ builder.text title_for(**options)
58
58
 
59
- if details = details_for(**options)
60
- builder.inline(:small, class: 'details') {builder.text details}
61
- end
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 => 'false'
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: 'details') {builder.text details}
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: 'details') {builder.text details}
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-2024, by Samuel Williams.
4
+ # Copyright, 2014-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/builder'
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] || 'checkbox',
123
+ :type => options[:type] || "checkbox",
124
124
  :id => options[:id],
125
125
  :class => options[:class],
126
126
  :name => name_for(**options),
127
- :value => 'true',
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] || 'submit',
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? ? 'Create' : 'Update')
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] || 'hidden',
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] || 'submit',
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, 'submit').to_sym
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('fieldset') do
211
- builder.inline('legend') do
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-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/builder'
7
- require 'xrb/template'
6
+ require "xrb/builder"
7
+ require "xrb/template"
8
8
 
9
- require_relative 'form_formatter'
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 => 'false'
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-2024, by Samuel Williams.
4
+ # Copyright, 2012-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/builder'
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] ||= 'id'
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-2024, by Samuel Williams.
4
+ # Copyright, 2012-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/builder'
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-2024, by Samuel Williams.
4
+ # Copyright, 2016-2025, by Samuel Williams.
5
5
 
6
- require 'markly'
6
+ require "markly"
7
7
 
8
- require 'xrb/markup'
9
- require 'xrb/sanitize/fragment'
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-2024, by Samuel Williams.
4
+ # Copyright, 2016-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/strings'
7
- require 'mapping/model'
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-2024, by Samuel Williams.
4
+ # Copyright, 2016-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/strings'
7
- require 'mapping/model'
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
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module XRB
7
7
  module Formatters
8
- VERSION = "0.1.0"
8
+ VERSION = "0.1.1"
9
9
  end
10
10
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2012-2024, by Samuel Williams.
4
+ # Copyright, 2024-2025, by Samuel Williams.
5
5
 
6
- require 'xrb/formatters/formatter'
6
+ require "xrb/formatters/formatter"
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2012-2024, by Samuel Williams.
3
+ Copyright, 2012-2025, by Samuel Williams.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -29,20 +29,13 @@ Or install it yourself as:
29
29
 
30
30
  ## Usage
31
31
 
32
- The most basic usage involves converting model data into presentation text by
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
- ``` ruby
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
- For more examples please see `spec/`.
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
- This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
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
- ### Contributor Covenant
54
+ ### Community Guidelines
62
55
 
63
- This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
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
@@ -0,0 +1,3 @@
1
+ # Releases
2
+
3
+ ## v0.1.1
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.0
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: 2024-05-08 00:00:00.000000000 Z
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.1'
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.5.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