tail_merge 0.4.0 → 0.4.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: df9120474172d53dc79d7592c20832032545e05572a437c63b7d342cfd2bb33a
4
- data.tar.gz: 24e6b1bc37558804a3a4fa4afdd06b4a4d21e5ace5ed349def07a5d0b2768584
3
+ metadata.gz: 69e868a893a925f42921b119e9d263f8d3d63a0e47f52b9370df4c8d9f922af2
4
+ data.tar.gz: bfe35ab7e0cad8a31fe05d8dcc020b955ac73817cd703cba598f8f36f0364c73
5
5
  SHA512:
6
- metadata.gz: 904e825d0f09aace9c811225fa59c455eb473d958843b587be89e91dcf2d080ac373c73147699ed3f93ebfed28f9570e2e58025d95eb48ebce4c92e889c25e53
7
- data.tar.gz: 83604251ac57755a2106dfab3544379d8f234fffe3440599ea03a2c217085aa1b9dff583ba3a6041df9e2bffc72713f89aaaf6273c4942d1c1838ee0e622464e
6
+ metadata.gz: 788c748e878459b9d9d24e1c7e2011af07d025f6e3b56fe83370c84b3d5269ed58976444cdfe7da95455cd3a218737ae3461f082a5d6ddc3aa55afe31e739d4c
7
+ data.tar.gz: 7890ac8f823ea2a9dbaf753285175e9d707f294f25935bbf2b921b19a861546bd512fb449935656f701937bcf348d5d762da10463e947f87eaca23ed47562da7
data/.rubocop.yml CHANGED
@@ -6,3 +6,9 @@ Style/StringLiterals:
6
6
 
7
7
  Style/StringLiteralsInInterpolation:
8
8
  EnforcedStyle: double_quotes
9
+
10
+ Metrics/BlockLength:
11
+ Enabled: false
12
+
13
+ Layout/LineLength:
14
+ Enabled: false
data/Cargo.lock CHANGED
@@ -114,9 +114,9 @@ dependencies = [
114
114
 
115
115
  [[package]]
116
116
  name = "magnus"
117
- version = "0.6.4"
117
+ version = "0.7.1"
118
118
  source = "registry+https://github.com/rust-lang/crates.io-index"
119
- checksum = "b1597ef40aa8c36be098249e82c9a20cf7199278ac1c1a1a995eeead6a184479"
119
+ checksum = "3d87ae53030f3a22e83879e666cb94e58a7bdf31706878a0ba48752994146dab"
120
120
  dependencies = [
121
121
  "magnus-macros",
122
122
  "rb-sys",
@@ -146,6 +146,7 @@ name = "merger"
146
146
  version = "0.1.0"
147
147
  dependencies = [
148
148
  "magnus",
149
+ "rb-sys",
149
150
  "rustui_merge",
150
151
  ]
151
152
 
data/README.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # TailMerge
2
2
 
3
- TailMerge is a super fast utility library to merge Tailwind CSS classes without conflicts.
3
+ TailMerge is a super-fast utility library to merge Tailwind CSS classes without conflicts.
4
4
 
5
5
  ```ruby
6
6
  TailMerge.merge %w[px-2 py-1 bg-red hover:bg-dark-red p-3 bg-[#B91C1C]]
7
7
  => "hover:bg-dark-red p-3 bg-[#B91C1C]"
8
8
  ```
9
9
 
10
- Classes on the right will override classes on the left.
10
+ Classes that appear later in the list override earlier ones.
11
11
 
12
- TailMerge wraps the Rust library [rustui_merge](https://docs.rs/rustui_merge/latest/rustui_merge/) so that it can be used in Ruby. This makes it a lot faster than combining classes in Ruby.
12
+ By leveraging the Rust crate [rustui_merge](https://docs.rs/rustui_merge/latest/rustui_merge/), TailMerge merges classes significantly faster than pure Ruby alternatives.
13
13
 
14
14
  ## Purpose
15
15
 
16
- When you use Tailwindcss to style components, you will probably run into the situation where you want to adjust the styling of component in a specific situation.
16
+ When you use Tailwind CSS to style components, you'll often want to adjust the styling of a component in certain situations.
17
17
 
18
18
  An example:
19
19
 
@@ -24,7 +24,7 @@ class Well < ApplicationComponent
24
24
  end
25
25
 
26
26
  def call
27
- tag.div class: default_classes + @classes
27
+ tag.div class: default_classes + @classes do
28
28
  content
29
29
  end
30
30
  end
@@ -61,7 +61,7 @@ class Well < ApplicationComponent
61
61
  end
62
62
 
63
63
  def call
64
- tag.div class: TailMerge.merge(default_classes + @classes)
64
+ tag.div class: TailMerge.merge(default_classes + @classes) do
65
65
  content
66
66
  end
67
67
  end
@@ -86,11 +86,7 @@ Run `bundle install` to install the gem.
86
86
 
87
87
  ## Usage
88
88
 
89
- You can pass a string or an array of strings to the `merge` method.
90
-
91
- Whatever you pass last will override whatever you pass first.
92
-
93
- A string is returned for easy use in ERB.
89
+ You can pass either a string or an array of strings to the merge method. Values passed later override previous ones. The result is always a string, ready for use in ERB templates.
94
90
 
95
91
  ```ruby
96
92
  TailMerge.merge %w[px-2 py-1 bg-red hover:bg-dark-red p-3 bg-[#B91C1C]]
@@ -106,6 +102,8 @@ TailMerge.merge "px-2 py-1 bg-red hover:bg-dark-red p-3 bg-[#B91C1C]"
106
102
 
107
103
  You can create an instance of TailMerge and call `merge` on it instead of on the `TailMerge` class. This will cache the results of the merge.
108
104
 
105
+ This is useful in cases where you need to merge the same classes repeatedly, such as when rendering a list of the same component.
106
+
109
107
  ```ruby
110
108
  tail_merge_instance = TailMerge.new
111
109
  tail_merge_instance.merge %w[px-2 py-1 bg-red hover:bg-dark-red p-3 bg-[#B91C1C]]
@@ -120,30 +118,34 @@ tail_merge_instance.merge "px-2 py-1 bg-red hover:bg-dark-red p-3 bg-[#B91C1C]"
120
118
  => "hover:bg-dark-red p-3 bg-[#B91C1C]" # Read from cache, much faster!
121
119
  ```
122
120
 
123
- This caching technique was inspired by [[Tailwind Merge](https://github.com/dcastil/tailwind-merge)](https://github.com/gjtorikian/tailwind_merge).
121
+ This caching technique was inspired by [Tailwind Merge](https://github.com/dcastil/tailwind-merge).
124
122
 
125
123
  ## Benchmark
126
124
 
127
- So how fast/much faster is TailMerge?
125
+ So how fast is TailMerge?
128
126
 
129
- I've benchmarked TailMerge with an instance (cached) and without an instance against Tailwind Merge with (cached) and without a merger instance, and these are the results:
127
+ I've benchmarked TailMerge with and without caching, and compared it to Tailwind Merge (also with and without caching). Here are the results:
130
128
 
131
129
  ```
132
130
  user system total real
133
- Rust: TailMerge.merge (all samples): 0.216178 0.001744 0.217922 ( 0.219441)
134
- Rust: Cached TailMerge.merge (all samples): 0.005465 0.000092 0.005557 ( 0.005581)
135
- Ruby: TailwindMerge each time (all samples): 50.391383 0.494058 50.885441 ( 52.272354)
136
- Ruby:Cached TailwindMerge (all samples): 0.011672 0.000140 0.011812 ( 0.011813)
131
+ Rust: TailMerge.merge (all samples): 0.371744 0.019642 0.391386 ( 0.391821)
132
+ Rust: Cached TailMerge.merge (all samples): 0.012976 0.000580 0.013556 ( 0.013560)
133
+ Ruby: TailwindMerge each time (all samples): 51.488919 0.225130 51.714049 ( 51.883713)
134
+ Ruby:Cached TailwindMerge (all samples): 0.019882 0.000166 0.020048 ( 0.020051)
137
135
  ```
138
136
 
139
- As you can see TailMerge is much faster using pure Ruby to merge classes.
137
+ As you can see, TailMerge is much faster than using pure Ruby to merge classes.
140
138
 
141
139
  The benchmark loops through an array of strings and arrays and merges them 1000 times.
142
140
 
143
141
  The difference between the cached runs, obviously, is much smaller as we are basically benchmarking the cache lookup and not the actual merge.
144
142
 
145
- In reality we will not deal with 1000 merges to be done per page and I suspect you'd be much closer to the non-cached runs.
143
+ In reality, you will not need to perform 1000 merges per page, and I suspect you'll be much closer to the non-cached runs.
146
144
 
147
145
  ## Contributing
148
146
 
149
147
  Bug reports and pull requests are welcome on GitHub at https://github.com/abuisman/tail_merge . Merging will be done at my own pace and discretion.
148
+
149
+ ## License
150
+
151
+ This gem is available as open source under under the MIT License.
data/Rakefile CHANGED
@@ -5,9 +5,12 @@ require "minitest/test_task"
5
5
 
6
6
  Minitest::TestTask.create
7
7
 
8
- require "rubocop/rake_task"
9
-
10
- RuboCop::RakeTask.new
8
+ begin
9
+ require "rubocop/rake_task"
10
+ RuboCop::RakeTask.new
11
+ rescue LoadError
12
+ # RuboCop is an optional dev dependency; skip in minimal build environments
13
+ end
11
14
 
12
15
  require "rb_sys/extensiontask"
13
16
 
@@ -15,8 +18,35 @@ task build: :compile
15
18
 
16
19
  GEMSPEC = Gem::Specification.load("tail_merge.gemspec")
17
20
 
21
+ # Limit cross-compiled Ruby versions to those supported by this gem and dependencies
22
+ # Format matches rake-compiler's RUBY_CC_VERSION (colon-separated list)
23
+ ENV["RUBY_CC_VERSION"] ||= "3.1.6:3.2.6:3.3.7:3.4.1"
24
+
25
+ PLATFORMS = %w[
26
+ aarch64-linux-gnu
27
+ aarch64-linux-musl
28
+ arm-linux-gnu
29
+ arm-linux-musl
30
+ arm64-darwin
31
+ x64-mingw-ucrt
32
+ x64-mingw32
33
+ x86-linux-gnu
34
+ x86-linux-musl
35
+ x86-mingw32
36
+ x86_64-darwin
37
+ x86_64-linux-gnu
38
+ x86_64-linux-musl
39
+ ].freeze
40
+
18
41
  RbSys::ExtensionTask.new("merger", GEMSPEC) do |ext|
19
42
  ext.lib_dir = "lib/tail_merge"
43
+ ext.cross_compile = true
44
+ ext.cross_platform = %w[x86-mingw32 x64-mingw-ucrt x64-mingw32 x86-linux x86_64-linux x86_64-darwin arm64-darwin]
45
+ end
46
+
47
+ desc "Build native extension for a given platform (i.e. `rake 'native[x86_64-linux]'`)"
48
+ task :native, [:platform] do |_t, platform:|
49
+ sh "bundle", "exec", "rb-sys-dock", "--platform", platform, "--build"
20
50
  end
21
51
 
22
52
  task default: %i[compile test rubocop]
@@ -10,12 +10,12 @@ samples = [
10
10
  ["relative"],
11
11
  ["self-center"],
12
12
  ["self-start"],
13
- ["shadow-inner", "size-4", "text-xs"],
14
- ["shadow-inner", "size-7"],
13
+ %w[shadow-inner size-4 text-xs],
14
+ %w[shadow-inner size-7],
15
15
  ["size-10"],
16
16
  ["static"],
17
17
  ["upload-attachment", "flex-none", "rounded-3xl", "min-h-16", "group", "relative"],
18
- ["w-full", "py-2", "px-2", "rounded-md", "w-44"],
18
+ %w[w-full py-2 px-2 rounded-md w-44],
19
19
  "relative",
20
20
  "self-center",
21
21
  "self-start",
@@ -25,40 +25,53 @@ samples = [
25
25
  "static",
26
26
  "upload-attachment flex-none rounded-3xl min-h-16 group relative",
27
27
  "w-full py-2 px-2 rounded-md w-44",
28
- ["p-4", "px-2", "py-6", "m-3", "mx-8", "my-2", "bg-blue-500", "bg-red-600", "text-sm", "text-lg", "font-bold", "font-normal", "rounded-lg", "rounded-xl", "shadow-md", "shadow-lg", "hover:bg-blue-700", "hover:bg-red-800", "focus:ring-2", "focus:ring-4"],
29
- ["grid", "flex", "inline-flex", "grid-cols-3", "grid-cols-4", "gap-2", "gap-4", "items-center", "items-start", "justify-between", "justify-center", "p-8", "p-4", "bg-gray-100", "bg-white", "border", "border-2", "rounded-full", "rounded-md"],
30
- ["transform", "scale-100", "scale-110", "rotate-45", "rotate-90", "translate-x-2", "translate-x-4", "skew-y-3", "skew-y-6", "transition", "duration-200", "duration-500", "ease-in", "ease-out", "delay-150", "delay-300"],
31
- ["w-full", "w-1/2", "w-3/4", "h-screen", "h-full", "h-32", "min-h-0", "min-h-full", "max-w-xs", "max-w-xl", "overflow-hidden", "overflow-scroll", "object-cover", "object-contain", "opacity-75", "opacity-100"],
32
- ["text-left", "text-center", "text-right", "text-justify", "tracking-wide", "tracking-wider", "leading-tight", "leading-loose", "uppercase", "lowercase", "capitalize", "normal-case", "truncate", "line-clamp-2", "line-clamp-3"],
33
- ["border-t", "border-b", "border-l", "border-r", "border-solid", "border-dashed", "border-red-500", "border-blue-600", "divide-y", "divide-x", "divide-gray-200", "divide-blue-300", "ring-2", "ring-4", "ring-offset-2"],
34
- ["cursor-pointer", "cursor-wait", "select-none", "select-text", "resize", "resize-none", "z-10", "z-50", "float-left", "float-right", "clear-both", "clear-none", "box-border", "box-content"],
35
- ["bg-opacity-50", "bg-opacity-75", "backdrop-blur-sm", "backdrop-blur-lg", "backdrop-filter", "filter", "brightness-90", "brightness-110", "contrast-75", "contrast-125", "saturate-50", "saturate-200"],
36
- ["focus:outline-none", "focus:ring-2", "focus:ring-offset-2", "focus:border-blue-500", "hover:scale-105", "hover:rotate-3", "active:scale-95", "disabled:opacity-50", "disabled:cursor-not-allowed"],
37
- ["sm:text-lg", "md:text-xl", "lg:text-2xl", "xl:text-3xl", "2xl:text-4xl", "sm:w-1/2", "md:w-2/3", "lg:w-3/4", "xl:w-full", "2xl:max-w-screen-xl", "sm:p-4", "md:p-6", "lg:p-8", "xl:p-10"],
38
- ["dark:bg-gray-800", "dark:text-white", "dark:border-gray-600", "dark:hover:bg-gray-700", "dark:focus:ring-blue-800", "bg-white", "text-black", "border-gray-200", "hover:bg-gray-100"],
39
- ["group-hover:scale-110", "group-hover:rotate-6", "group-focus:outline-none", "group-active:scale-95", "peer-checked:bg-blue-500", "peer-checked:text-white", "peer-disabled:opacity-50"],
40
- ["animate-spin", "animate-pulse", "animate-bounce", "animate-ping", "motion-safe:animate-spin", "motion-reduce:animate-none", "transition-all", "duration-300", "ease-in-out", "delay-150"],
41
- ["space-x-4", "space-x-reverse", "space-y-6", "space-y-reverse", "gap-x-4", "gap-y-6", "place-items-center", "place-content-center", "place-self-center", "content-center"],
42
- ["from-blue-500", "to-purple-500", "via-pink-500", "bg-gradient-to-r", "bg-gradient-to-br", "text-transparent", "bg-clip-text", "bg-origin-border", "bg-no-repeat", "bg-cover"],
43
- ["columns-2", "columns-3", "break-inside-avoid", "break-after-column", "aspect-square", "aspect-video", "object-right-top", "object-left-bottom", "isolation-auto", "mix-blend-multiply"],
44
- ["first:pt-0", "last:pb-0", "odd:bg-gray-50", "even:bg-white", "first-letter:text-7xl", "first-line:uppercase", "selection:bg-yellow-200", "selection:text-black"],
45
- ["[mask-type:luminance]", "[mask-type:alpha]", "[transform-style:preserve-3d]", "[clip-path:circle(50%)]", "[-webkit-text-stroke:2px]", "[text-align-last:justify]"],
46
- ["will-change-scroll", "will-change-transform", "scroll-smooth", "scroll-mt-2", "scroll-pb-4", "overscroll-contain", "touch-pan-right", "touch-manipulation"],
47
- ["hyphens-auto", "hyphens-manual", "text-underline-offset-2", "text-decoration-thickness-2", "indent-8", "indent-16", "vertical-align-sub", "vertical-align-super"]
28
+ ["p-4", "px-2", "py-6", "m-3", "mx-8", "my-2", "bg-blue-500", "bg-red-600", "text-sm", "text-lg", "font-bold",
29
+ "font-normal", "rounded-lg", "rounded-xl", "shadow-md", "shadow-lg", "hover:bg-blue-700", "hover:bg-red-800", "focus:ring-2", "focus:ring-4"],
30
+ %w[grid flex inline-flex grid-cols-3 grid-cols-4 gap-2 gap-4 items-center items-start
31
+ justify-between justify-center p-8 p-4 bg-gray-100 bg-white border border-2 rounded-full rounded-md],
32
+ ["transform", "scale-100", "scale-110", "rotate-45", "rotate-90", "translate-x-2", "translate-x-4", "skew-y-3",
33
+ "skew-y-6", "transition", "duration-200", "duration-500", "ease-in", "ease-out", "delay-150", "delay-300"],
34
+ ["w-full", "w-1/2", "w-3/4", "h-screen", "h-full", "h-32", "min-h-0", "min-h-full", "max-w-xs", "max-w-xl",
35
+ "overflow-hidden", "overflow-scroll", "object-cover", "object-contain", "opacity-75", "opacity-100"],
36
+ %w[text-left text-center text-right text-justify tracking-wide tracking-wider leading-tight
37
+ leading-loose uppercase lowercase capitalize normal-case truncate line-clamp-2 line-clamp-3],
38
+ %w[border-t border-b border-l border-r border-solid border-dashed border-red-500
39
+ border-blue-600 divide-y divide-x divide-gray-200 divide-blue-300 ring-2 ring-4 ring-offset-2],
40
+ %w[cursor-pointer cursor-wait select-none select-text resize resize-none z-10 z-50
41
+ float-left float-right clear-both clear-none box-border box-content],
42
+ %w[bg-opacity-50 bg-opacity-75 backdrop-blur-sm backdrop-blur-lg backdrop-filter filter
43
+ brightness-90 brightness-110 contrast-75 contrast-125 saturate-50 saturate-200],
44
+ ["focus:outline-none", "focus:ring-2", "focus:ring-offset-2", "focus:border-blue-500", "hover:scale-105",
45
+ "hover:rotate-3", "active:scale-95", "disabled:opacity-50", "disabled:cursor-not-allowed"],
46
+ ["sm:text-lg", "md:text-xl", "lg:text-2xl", "xl:text-3xl", "2xl:text-4xl", "sm:w-1/2", "md:w-2/3", "lg:w-3/4",
47
+ "xl:w-full", "2xl:max-w-screen-xl", "sm:p-4", "md:p-6", "lg:p-8", "xl:p-10"],
48
+ ["dark:bg-gray-800", "dark:text-white", "dark:border-gray-600", "dark:hover:bg-gray-700", "dark:focus:ring-blue-800",
49
+ "bg-white", "text-black", "border-gray-200", "hover:bg-gray-100"],
50
+ ["group-hover:scale-110", "group-hover:rotate-6", "group-focus:outline-none", "group-active:scale-95",
51
+ "peer-checked:bg-blue-500", "peer-checked:text-white", "peer-disabled:opacity-50"],
52
+ ["animate-spin", "animate-pulse", "animate-bounce", "animate-ping", "motion-safe:animate-spin",
53
+ "motion-reduce:animate-none", "transition-all", "duration-300", "ease-in-out", "delay-150"],
54
+ ["space-x-4", "space-x-reverse", "space-y-6", "space-y-reverse", "gap-x-4", "gap-y-6", "place-items-center",
55
+ "place-content-center", "place-self-center", "content-center"],
56
+ %w[from-blue-500 to-purple-500 via-pink-500 bg-gradient-to-r bg-gradient-to-br text-transparent
57
+ bg-clip-text bg-origin-border bg-no-repeat bg-cover],
58
+ %w[columns-2 columns-3 break-inside-avoid break-after-column aspect-square aspect-video
59
+ object-right-top object-left-bottom isolation-auto mix-blend-multiply],
60
+ ["first:pt-0", "last:pb-0", "odd:bg-gray-50", "even:bg-white", "first-letter:text-7xl", "first-line:uppercase",
61
+ "selection:bg-yellow-200", "selection:text-black"],
62
+ ["[mask-type:luminance]", "[mask-type:alpha]", "[transform-style:preserve-3d]", "[clip-path:circle(50%)]",
63
+ "[-webkit-text-stroke:2px]", "[text-align-last:justify]"],
64
+ %w[will-change-scroll will-change-transform scroll-smooth scroll-mt-2 scroll-pb-4 overscroll-contain
65
+ touch-pan-right touch-manipulation],
66
+ %w[hyphens-auto hyphens-manual text-underline-offset-2 text-decoration-thickness-2 indent-8 indent-16
67
+ vertical-align-sub vertical-align-super]
48
68
  ]
49
69
 
50
- require 'benchmark'
51
- require 'tail_merge'
52
- require 'tailwind_merge'
53
-
54
70
  # Pre-initialize cached mergers
55
71
  cached_merger = TailwindMerge::Merger.new
56
72
 
57
73
  tail_merge_instance = TailMerge.new
58
74
 
59
- # Normalize all samples to strings
60
- normalized_samples = samples.map { |classes| classes.is_a?(Array) ? classes.join(' ') : classes }
61
-
62
75
  puts "Benchmarking class merging strategies (whole set)..."
63
76
  puts "-" * 50
64
77
  puts
@@ -66,7 +79,7 @@ puts
66
79
  Benchmark.bm(30) do |x|
67
80
  x.report("Rust: TailMerge.merge (all samples):") do
68
81
  1000.times do
69
- normalized_samples.each do |classes|
82
+ samples.each do |classes|
70
83
  TailMerge.merge(classes)
71
84
  end
72
85
  end
@@ -74,7 +87,7 @@ Benchmark.bm(30) do |x|
74
87
 
75
88
  x.report("Rust: Cached TailMerge.merge (all samples):") do
76
89
  1000.times do
77
- normalized_samples.each do |classes|
90
+ samples.each do |classes|
78
91
  tail_merge_instance.merge(classes)
79
92
  end
80
93
  end
@@ -82,7 +95,7 @@ Benchmark.bm(30) do |x|
82
95
 
83
96
  x.report("Ruby: TailwindMerge each time (all samples):") do
84
97
  1000.times do
85
- normalized_samples.each do |classes|
98
+ samples.each do |classes|
86
99
  TailwindMerge::Merger.new.merge(classes)
87
100
  end
88
101
  end
@@ -90,7 +103,7 @@ Benchmark.bm(30) do |x|
90
103
 
91
104
  x.report("Ruby:Cached TailwindMerge (all samples):") do
92
105
  1000.times do
93
- normalized_samples.each do |classes|
106
+ samples.each do |classes|
94
107
  cached_merger.merge(classes)
95
108
  end
96
109
  end
@@ -10,5 +10,6 @@ name = "merger"
10
10
  crate-type = ["cdylib"]
11
11
 
12
12
  [dependencies]
13
- magnus = { version = "0.6.2" }
13
+ magnus = "0.7.1"
14
14
  rustui_merge = "0.1.6"
15
+ rb-sys = "0.9.115"
@@ -1,5 +1,5 @@
1
1
  use magnus::{
2
- define_module, function, prelude::*, Error, RArray, RHash, RString, Ruby, Value,
2
+ function, prelude::*, Error, RArray, RHash, RString, Ruby, Value,
3
3
  };
4
4
  use rustui_merge::merge::tw_merge;
5
5
 
@@ -14,13 +14,13 @@ fn merge_tailwind_classes(args: &[Value]) -> Result<RString, Error> {
14
14
 
15
15
  // ---------- 2. collect class tokens ------------------------------------
16
16
  let mut tokens = Vec::<String>::new();
17
- let is_string_input = matches!(args[0].clone().try_convert::<RString>(), Ok(_));
18
- match args[0].clone().try_convert::<RString>() {
17
+ let is_string_input = matches!(RString::try_convert(args[0].clone()), Ok(_));
18
+ match RString::try_convert(args[0].clone()) {
19
19
  Ok(rstr) => tokens.extend(rstr.to_string()?.split_whitespace().map(str::to_owned)),
20
20
  Err(_) => {
21
- let rarray: RArray = args[0].try_convert()?;
22
- for v in rarray.each() {
23
- let s: RString = v?.try_convert()?;
21
+ let rarray: RArray = RArray::try_convert(args[0])?;
22
+ for v in rarray.into_iter() {
23
+ let s: RString = RString::try_convert(v)?;
24
24
  tokens.push(s.to_string()?);
25
25
  }
26
26
  }
@@ -28,7 +28,7 @@ fn merge_tailwind_classes(args: &[Value]) -> Result<RString, Error> {
28
28
 
29
29
  // Early returns for simple cases
30
30
  if is_string_input {
31
- let rstr: RString = args[0].clone().try_convert()?;
31
+ let rstr: RString = RString::try_convert(args[0].clone())?;
32
32
  let s = rstr.to_string()?;
33
33
  if !s.contains(' ') {
34
34
  // Single class string, return as-is
@@ -49,15 +49,15 @@ fn merge_tailwind_classes(args: &[Value]) -> Result<RString, Error> {
49
49
  let mut separator: Option<String> = None;
50
50
 
51
51
  if args.len() == 2 {
52
- let rhash: RHash = args[1].try_convert()?;
52
+ let rhash: RHash = RHash::try_convert(args[1])?;
53
53
  let ruby = Ruby::get().unwrap();
54
54
 
55
55
  if let Some(v) = rhash.get(ruby.to_symbol("prefix")) {
56
- let s: RString = v.try_convert()?;
56
+ let s: RString = RString::try_convert(v)?;
57
57
  prefix = Some(s.to_string()?);
58
58
  }
59
59
  if let Some(v) = rhash.get(ruby.to_symbol("separator")) {
60
- let s: RString = v.try_convert()?;
60
+ let s: RString = RString::try_convert(v)?;
61
61
  separator = Some(s.to_string()?);
62
62
  }
63
63
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TailMerge
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tail_merge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Achilleas Buisman
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.9.91
18
+ version: 0.9.115
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.9.91
25
+ version: 0.9.115
26
26
  description: Merge Tailwind CSS classes
27
27
  email:
28
28
  - accounts@abuisman.nl
@@ -44,7 +44,8 @@ files:
44
44
  - lib/tail_merge/version.rb
45
45
  - sig/tail_merge.rbs
46
46
  homepage: https://github.com/abuisman/tail_merge
47
- licenses: []
47
+ licenses:
48
+ - MIT
48
49
  metadata:
49
50
  allowed_push_host: https://rubygems.org
50
51
  homepage_uri: https://github.com/abuisman/tail_merge