inline_forms 8.1.9 → 8.1.11

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: bba19f36ffc279e71b2fe0c0fa9a8ec9501424f5fddab372d50941c1e4905dc3
4
- data.tar.gz: 6a0473bcf4539bddf580dabaae2a5ecfc9decc36c0e691cd63aa79a3127a8478
3
+ metadata.gz: 0e33b151ebeda5706914feaf6ac97bd11b0b379ac8b03435cf9d948c40dbdd9b
4
+ data.tar.gz: 975d48a428e045905e0fd29acf6b2d136ec7cc5f4a7825db9c951eb0ab3bba3d
5
5
  SHA512:
6
- metadata.gz: 4f33889510601ad516280f0727f73a2e33a023d82cae3bf0bf28f46747ecb3e0a53f4b89554b5c016fd04657ecab69bdf171091e252e2efd3abaaa274166f4fe
7
- data.tar.gz: 3c452681ce7d64bcf4d5716e1e41c2ad4d9d830e6a68cdd2a294d256b20308703d73811ef514f7940b634794cf4521dd18cdd4ee9e8e9e68613692129ca0691b
6
+ metadata.gz: 37d86c5be4e09df199b6d23b8ee91c2488bb98b178b352213dce075234152cc9ef03d119cd2ccd0eb41632d4e6ec5724918d6f2cfdbd70889ed5a0e4b7a959d1
7
+ data.tar.gz: 3b40a5c9b0de4707715d43d2186f3d1e4570b7c0cfa17f55f6aa7aa2c151b325bf91a670897ebc3379a1ba086081953f4a0d2f3806a3cd83a13c4fd6149443bb
data/CHANGELOG.md CHANGED
@@ -4,6 +4,38 @@ All notable changes to this project are documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [8.1.11] - 2026-05-28
8
+
9
+ ### Fixed
10
+
11
+ - **Installer's prerelease gem discovery now looks in `pkg/` too.** `Bundler::GemHelper.install_tasks` (the standard Rakefile boilerplate) puts `rake build` output in `pkg/`, not in the checkout root where `gem build` writes. 8.1.10's `dev_checkout_with_gems` + `install_prerelease_gems_from_roots!` only globbed the checkout root, so the moment a maintainer ran `rake build` the freshly-built gem was invisible — the installer fell back to whatever stale `<name>-*.gem` was still sitting in the root from a previous `gem build`. This is the exact shape that caused 8.1.10 to silently use 8.1.6 templates today (default RVM gemset had `inline_forms_installer 8.1.6` as its highest, the checkout root had only the stale `inline_forms-8.1.7.gem`, and the 8.1.8/8.1.9/8.1.10 builds were sitting in `/home/code/inline_forms/pkg/` where nothing was looking). Both helpers now glob `<root>/<name>-*.gem` and `<root>/pkg/<name>-*.gem`.
12
+
13
+ ### Changed
14
+
15
+ - **Example-app gate caps test parallelism at `PARALLEL_WORKERS=2` by default.** Rails' minitest parallelizer defaults to `workers: number_of_processors`, which on a 20-core box forks 20 full Rails processes — each ~200-300 MB resident with the example app's gem stack (CarrierWave + Devise + PaperTrail + Foundation + tabs_on_rails + money-rails). On a memory-pressured host that's 4-6 GB of workers alone, on top of the parent installer/bundler state, and `systemd-oomd` can (and did, 2026-05-28 07:50:35) kill the whole terminal session before the gate finishes, with no useful signal back to the user. `PARALLEL_WORKERS=2` keeps the worker footprint to ~600 MB and roughly doubles wall-clock vs 20 workers — fine for a one-shot gate. The new `INLINE_FORMS_TEST_WORKERS` env override lets machines with RAM headroom crank it back up (`0` = Rails' default, any positive integer = pin to that count).
16
+
17
+ ### Lockstep
18
+
19
+ - `inline_forms`, `inline_forms_installer`, and `validation_hints` bumped from 8.1.10 to 8.1.11 in lockstep, even though `inline_forms` (the engine) and `validation_hints` have no behavior change in this release — both are only here so the version trio stays in step.
20
+
21
+ ## [8.1.10] - 2026-05-27
22
+
23
+ ### Changed
24
+
25
+ - **`:decimal_field` is now a real `decimal(p, s)` column instead of a `varchar`.** The FormElementRegistry mapping moves from `:decimal_field => :string` to `:decimal_field => :decimal`, so `rails g inline_forms Foo price:decimal_field` now emits `t.decimal :price, precision: 10, scale: 2` (the sensible default — invoice/balance up to 99,999,999.99). This closes a long-standing inconsistency: `decimal_field` was the only "numeric" Tier 1 helper that stored its value as text, so `"ace"` would happily round-trip and `Foo.sum(:price)` was a runtime cast error. Existing apps generated before 8.1.10 keep their varchar columns until they migrate; only newly-generated tables get `:decimal`.
26
+ - **New CLI syntax: `name:decimal_field{p,s}` overrides precision/scale.** Mirrors Rails' built-in `name:decimal{p,s}` grammar. Examples: `latitude:decimal_field{9,6}` -> `decimal(9, 6)` (~11 cm GPS accuracy), `longitude:decimal_field{10,6}` -> `decimal(10, 6)`, `dose:decimal_field{6,3}` -> `decimal(6, 3)`. Rails' own `Rails::Generators::GeneratedAttribute.parse` only honors `{…}` on a hardcoded list of built-in types and glues the braces onto custom types as part of the type symbol; `inline_forms_attribute_overrides.rb` now pre-processes the suffix off `:decimal_field` and stores precision/scale in `attr_options` for the migration emitter to read.
27
+ - **`decimal_field_show` / `_edit` render `BigDecimal` as fixed-point.** Once the column became a real `:decimal`, `object[attribute]` started returning `BigDecimal`, whose `to_s` defaults to scientific notation (`"0.1234e2"`). Both helpers now call `value.to_s("F")` for BigDecimal and fall through to the generic `to_s` for legacy varchar values, so existing apps display correctly with either column shape.
28
+
29
+ ### Added
30
+
31
+ - **`FormElementShowcase` demos the new `{p,s}` syntax.** Two new attributes (`latitude:decimal_field{9,6}`, `longitude:decimal_field{10,6}`) sit alongside `price:decimal_field` in the "Numbers" header, exercising both the default `(10, 2)` and explicit overrides. Seed values are Curaçao's Willemstad coordinates (`12.123456 / -68.987654`) — exactly representable in the chosen scale so the round-trip test is bit-identical rather than float-fuzzy.
32
+ - **`validates :price, latitude, longitude, numericality: …` in the showcase model.** Without an explicit validation, ActiveRecord silently casts `"ace"` to `BigDecimal("0")` on a `:decimal` column. The validation keeps the round-trip honest (the new integration test asserts a 422 on `"ace"`), and the `:latitude` / `:longitude` validations also pin the lat/lon ranges (±90, ±180).
33
+ - **Model + integration tests** cover the precision/scale schema (`columns_hash["latitude"].precision == 9`), the BigDecimal round-trip at full scale, the rejection of out-of-range GPS values, and the rejection of non-numeric input.
34
+
35
+ ### Lockstep
36
+
37
+ - `inline_forms`, `inline_forms_installer`, and `validation_hints` bumped from 8.1.9 to 8.1.10 in lockstep, even though `validation_hints` has no behavior change in this release.
38
+
7
39
  ## [8.1.9] - 2026-05-27
8
40
 
9
41
  ### Fixed
@@ -22,6 +22,37 @@ Rails::Generators::GeneratedAttribute.class_eval do
22
22
  true
23
23
  end
24
24
 
25
+ # Recognize `name:decimal_field{p,s}` on the command line and hoist the
26
+ # precision/scale into `attr_options`. Rails' own
27
+ # `Rails::Generators::GeneratedAttribute.parse` only honors the `{…}`
28
+ # suffix for a hardcoded list of built-in types (`:string`, `:integer`,
29
+ # `:primary_key`, `:decimal`, ...); for our custom `:decimal_field` it
30
+ # just glues the braces onto the type symbol (`:"decimal_field{10,2}"`)
31
+ # and `column_type` falls through to `:unknown`. Strip the braces here,
32
+ # delegate to the original parse with a clean `name:decimal_field`, and
33
+ # then attach the parsed numbers to attr_options so the migration
34
+ # emitter can render `t.decimal :name, precision: P, scale: S`.
35
+ #
36
+ # Bare `name:decimal_field` (no braces) parses unchanged — the
37
+ # migration emitter applies precision: 10, scale: 2 as the default.
38
+ class << self
39
+ unless method_defined?(:parse_with_inline_forms_decimal) || private_method_defined?(:parse_with_inline_forms_decimal)
40
+ alias_method :parse_without_inline_forms_decimal, :parse
41
+ end
42
+
43
+ def parse(column_definition)
44
+ if column_definition.is_a?(String) &&
45
+ (m = column_definition.match(/\A(\w+):decimal_field\{(\d+),(\d+)\}\z/))
46
+ attr = parse_without_inline_forms_decimal("#{m[1]}:decimal_field")
47
+ attr.attr_options[:precision] = m[2].to_i
48
+ attr.attr_options[:scale] = m[3].to_i
49
+ attr
50
+ else
51
+ parse_without_inline_forms_decimal(column_definition)
52
+ end
53
+ end
54
+ end
55
+
25
56
  # Deducts the column_type for migrations from the type.
26
57
  #
27
58
  # We first merge the Special Column Types with the Default Column Types,
@@ -164,11 +164,29 @@ module InlineForms
164
164
  else
165
165
  if attribute.migration?
166
166
  attribute.attribute_type == :unknown ? commenter = '#' : commenter = ' '
167
+ # Render precision/scale for real :decimal columns. The override
168
+ # in lib/generators/inline_forms_attribute_overrides.rb teaches
169
+ # `Rails::Generators::GeneratedAttribute.parse` to extract
170
+ # `{p,s}` off the type for :decimal_field (Rails' own parser
171
+ # only honors `{…}` for a hardcoded list of built-in types
172
+ # and otherwise glues the braces onto the type symbol).
173
+ # Apply sensible defaults — precision: 10, scale: 2 — so a
174
+ # bare `name:decimal_field` becomes a real decimal column
175
+ # instead of the legacy varchar that 8.1.9 and earlier
176
+ # emitted. Existing apps keep their varchar columns until
177
+ # they migrate; only newly-generated tables get :decimal.
178
+ column_opts = ""
179
+ if attribute.column_type == :decimal
180
+ precision = attribute.attr_options[:precision] || 10
181
+ scale = attribute.attr_options[:scale] || 2
182
+ column_opts = ", precision: #{precision}, scale: #{scale}"
183
+ end
167
184
  @columns << commenter +
168
185
  ' t.' +
169
186
  attribute.column_type.to_s +
170
187
  " :" +
171
188
  attribute.name +
189
+ column_opts +
172
190
  " \n"
173
191
  end
174
192
  end
@@ -8,7 +8,7 @@ module InlineForms
8
8
  :check_list => :no_migration,
9
9
  :ckeditor => :text,
10
10
  :date_select => :date,
11
- :decimal_field => :string,
11
+ :decimal_field => :decimal,
12
12
  :devise_password_field => :string,
13
13
  :dropdown => :belongs_to,
14
14
  :dropdown_with_integers => :integer,
@@ -6,13 +6,33 @@ module InlineForms
6
6
  # -*- encoding : utf-8 -*-
7
7
 
8
8
  def decimal_field_show(object, attribute)
9
- link_to_inline_edit object, attribute, object[attribute].nil? ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
9
+ # `:decimal_field` columns are real `:decimal(p, s)` since 8.1.10,
10
+ # which means `object[attribute]` returns a `BigDecimal`. Calling
11
+ # `to_s` on a BigDecimal without arguments returns scientific
12
+ # notation (`"0.1234e2"`), not the `"12.34"` users expect — render
13
+ # fixed-point. Strings (legacy varchar columns on apps generated
14
+ # before 8.1.10) and integers/floats also work with `to_s("F")` via
15
+ # their generic `to_s` fallback.
16
+ value = object[attribute]
17
+ label = if value.nil?
18
+ "<i class='fi-plus'></i>".html_safe
19
+ elsif value.is_a?(BigDecimal)
20
+ value.to_s("F")
21
+ else
22
+ value.to_s
23
+ end
24
+ link_to_inline_edit object, attribute, label, from_callee: __callee__
10
25
  end
11
-
26
+
12
27
  def decimal_field_edit(object, attribute)
13
- text_field_tag attribute, (object.send attribute.to_sym), :class => 'input_decimal_field' # for abide: , :required => true
28
+ # Render with fixed-point in the edit textbox for the same reason
29
+ # decimal_field_show does — otherwise the user sees "0.1234e2" in
30
+ # the edit field on an existing value, and round-trips it back.
31
+ value = object.send(attribute.to_sym)
32
+ value = value.to_s("F") if value.is_a?(BigDecimal)
33
+ text_field_tag attribute, value, :class => 'input_decimal_field' # for abide: , :required => true
14
34
  end
15
-
35
+
16
36
  def decimal_field_update(object, attribute)
17
37
  object.send :write_attribute, attribute.to_sym, params[attribute.to_sym]
18
38
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "8.1.9"
3
+ VERSION = "8.1.11"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.9
4
+ version: 8.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares