view_primitives 0.1.0 → 0.1.2

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: cae6ead2a2d30db140973eb5f5a925e2845a3d6dc4caae79bbd8a461fb56eb9f
4
- data.tar.gz: 5ece5bd38e0e0db26522fb29fcec2f466396b58caff8a172a41f2bdc8b14ecaa
3
+ metadata.gz: 8c238e3e54f7adcde5c4deac58db808e62b8602534c8f72921c2a266347dd0d9
4
+ data.tar.gz: a2d11d3988be3ebbe6926f673ea8dc6deef422409ff83fd0b2857afb2c14a47e
5
5
  SHA512:
6
- metadata.gz: 7175d71aa115dce9d0f34f6275b6d05a8997e41328f40809aaee7b127337f011b4323ef9a984085f01f2e9d56cfdb822c593a1bf6188028d6e9eb76658774573
7
- data.tar.gz: 35a018df2effe68ffccc863056e503f12a0fd3e101f38bba557f2e42247109091d9f2b50edea55e8f1da29ea06517109619f826428a70291329d26b03fe01cc8
6
+ metadata.gz: a6c5cc252992ae249a0679881fa8d9eb4ddd87ebd71e9c7de7686f4e0ae56ccaf0354c53b5d9f38c7a6958e8a2cbbd35ca2ce68e69a2dff4c8f8f2a79577c107
7
+ data.tar.gz: 0d325f0d79a32e0d015e263c0cd44c8d3d32abee0744c8f5d6afeab49855018c68087ad89c3dc800216edee71438bd4dacf8ba096f78ce8d386c421f1a980dab
data/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.2] - 2026-06-04
11
+
12
+ ### Fixed
13
+
14
+ - `InstallGenerator#verify_ui_inflection` checked `"ui/button".camelize` which can never equal `"UI::ButtonComponent"`, causing the warning to fire unconditionally even when inflections were correctly configured; fixed to check `"ui/button_component".camelize`
15
+ - `InstallGenerator#inject_css_import` used `String#include?` to detect `@import "tailwindcss"` (matches with or without semicolon) but passed `after: "@import \"tailwindcss\"\n"` (no semicolon) to `inject_into_file`; the anchor mismatch left the entry point unchanged ("File unchanged!") on Tailwind CSS v4 projects that use `@import "tailwindcss";`; fixed by probing for all four variants (double/single quotes × with/without semicolon) and passing the exact matching line as the anchor
16
+
17
+ ## [0.1.1] - 2026-06-01
18
+
19
+ ### Fixed
20
+
21
+ - `AddGenerator#copy_component` called `source_root` as an instance method; changed to `self.class.source_root` (caught by Ruby 4.0 stricter method dispatch)
22
+ - `template` and `copy_file` overrides in `AddGenerator` were treated as Thor generator actions and invoked with zero arguments; wrapped in `no_tasks` to exclude them from action dispatch
23
+ - Test helper did not require `ViewPrimitives::Generators::Components`, causing two tests to error with `NameError: uninitialized constant`
24
+
10
25
  ## [0.1.0] - 2026-05-30
11
26
 
12
27
  ### Added
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # ViewPrimitives
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/view_primitives.svg)](https://badge.fury.io/rb/view_primitives)
4
+ [![Build Status](https://github.com/alec-c4/view_primitives/actions/workflows/main.yml/badge.svg)](https://github.com/alec-c4/view_primitives/actions)
5
+
3
6
  A [shadcn/ui](https://ui.shadcn.com)-inspired component library for Rails built on [ViewComponent](https://viewcomponent.org).
4
7
 
5
8
  > **Acknowledgements** — The visual design, CSS class choices, and component structure of ViewPrimitives are heavily inspired by [shadcn/ui](https://ui.shadcn.com) and its Svelte port [shadcn-svelte](https://www.shadcn-svelte.com). We are grateful to [@shadcn](https://github.com/shadcn) and all contributors for their outstanding open-source work. ViewPrimitives is an independent Rails adaptation and is not affiliated with or endorsed by the shadcn/ui project.
@@ -49,22 +49,24 @@ module ViewPrimitives
49
49
  end
50
50
  end
51
51
 
52
- def template(source, *args, **options, &block)
53
- destination = args.first || options[:to]
54
- warn_overwrite(destination) if destination
55
- super
56
- end
52
+ no_tasks do
53
+ def template(source, *args, **options, &block)
54
+ destination = args.first || options[:to]
55
+ warn_overwrite(destination) if destination
56
+ super
57
+ end
57
58
 
58
- def copy_file(source, *args, **options)
59
- destination = args.first || options[:to]
60
- warn_overwrite(destination) if destination
61
- super
59
+ def copy_file(source, *args, **options)
60
+ destination = args.first || options[:to]
61
+ warn_overwrite(destination) if destination
62
+ super
63
+ end
62
64
  end
63
65
 
64
66
  private
65
67
 
66
68
  def copy_component(name)
67
- dir = File.join(source_root, name)
69
+ dir = File.join(self.class.source_root, name)
68
70
  Dir.each_child(dir).sort.each { |file| copy_template_file(name, file) }
69
71
  copy_extra_stimulus(name)
70
72
  end
@@ -38,6 +38,18 @@ module ViewPrimitives
38
38
  File.exist?(File.join(destination_root, dir))
39
39
  end
40
40
  end
41
+
42
+ # Returns the exact line (including newline) that inject_into_file should anchor after,
43
+ # or nil if no tailwindcss @import is present. Checks with and without semicolons so
44
+ # the after: anchor always matches what the file actually contains.
45
+ def tailwind_import_anchor(content)
46
+ [
47
+ "@import \"tailwindcss\";\n",
48
+ "@import \"tailwindcss\"\n",
49
+ "@import 'tailwindcss';\n",
50
+ "@import 'tailwindcss'\n"
51
+ ].find { |anchor| content.include?(anchor) }
52
+ end
41
53
  end
42
54
  end
43
55
  end
@@ -10,7 +10,7 @@ module ViewPrimitives
10
10
  source_root File.expand_path("templates", __dir__)
11
11
 
12
12
  def verify_ui_inflection
13
- return if "ui/button".camelize == "UI::ButtonComponent"
13
+ return if "ui/button_component".camelize == "UI::ButtonComponent"
14
14
 
15
15
  say "\n Warning: ActiveSupport inflection for `UI` is not configured.", :yellow
16
16
  say " ViewPrimitives expects `ui/button` to resolve to `UI::ButtonComponent`.", :yellow
@@ -52,10 +52,9 @@ module ViewPrimitives
52
52
 
53
53
  import_line = "@import \"#{css_import_path}\";\n"
54
54
 
55
- if entry_content.include?('@import "tailwindcss"')
56
- inject_into_file entry, import_line, after: "@import \"tailwindcss\"\n"
57
- elsif entry_content.include?("@import 'tailwindcss'")
58
- inject_into_file entry, import_line, after: "@import 'tailwindcss'\n"
55
+ anchor = tailwind_import_anchor(entry_content)
56
+ if anchor
57
+ inject_into_file entry, import_line, after: anchor
59
58
  else
60
59
  append_to_file entry, "\n#{import_line}"
61
60
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ViewPrimitives
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_primitives
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Poimtsev
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  - !ruby/object:Gem::Version
262
262
  version: '0'
263
263
  requirements: []
264
- rubygems_version: 4.0.12
264
+ rubygems_version: 4.0.10
265
265
  specification_version: 4
266
266
  summary: Primitive view components and helpers for Rails applications
267
267
  test_files: []