rux 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37160ed3c69f6fd3ee0e3b4597db3c41f0244853233b02aae52ba8bda17da87f
4
- data.tar.gz: 20291beda480bab76790dbc9c6c300badd673d5d100aa097ef68244620bec4a7
3
+ metadata.gz: 65ad08596c2e77c802c6f7cb2a458ac8d293d5c80a35c98c8a2eb85a5749b365
4
+ data.tar.gz: cb6487c91a9b21e328f491f5f23b8703a8b4b20a35ddcfa029a19e56bc835dca
5
5
  SHA512:
6
- metadata.gz: d9b6bbf7e49fdd07dd528a24e4c7ab496e29872a84024c1d011ce8026f0e003b0f941ede542728d44d0bd5d67dfa66ffcdd0658514c61a9e59580b86ce946f5e
7
- data.tar.gz: f7f5611e56d78988a6a514f2ae38cfe54848e6e855cdd85d5143963424a4c566bb09cd723c835bd16dcd7470591f21295d75432ef05981b0994533bc0e951949
6
+ metadata.gz: 4bc663ef90eec4c6a8abcfe997f259ccea9d211e898813280f534e4b8b5853a4bbbf3f8358164f4472f9329594a4a8b24e986d7b2fd621ecf74d92ebe09ea3e7
7
+ data.tar.gz: 944d83744f268a221cda2c414e7dd16df13efe37110a99c0d553ff2237be99f17aef37ae88d6653cdff43f0abe56e64cac48614bd5dd7f187e154cfe3cc0cead
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.2
2
+ * Fix bug causing `ArgumentError`s under Ruby 3.0.
3
+ - Related: https://github.com/mbj/unparser/issues/254
4
+
1
5
  ## 1.0.1
2
6
  * Fix bug in default buffer implementation causing `TypeError`s when attempting to shovel in arrays.
3
7
 
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- ## rux [![Build Status](https://travis-ci.com/camertron/rux.svg?branch=master)](https://travis-ci.com/camertron/rux)
1
+ ## rux
2
+
3
+ ![Unit Tests](https://github.com/camertron/rux/actions/workflows/unit_tests.yml/badge.svg?branch=master)
2
4
 
3
5
  Rux is a JSX-inspired way to write HTML tags in your Ruby code. It can be used to render view components in Rails via the [rux-rails gem](https://github.com/camertron/rux-rails). This repo however contains only the rux parser itself.
4
6
 
@@ -29,7 +29,7 @@ module Rux
29
29
  result << "render(#{node.name}.new"
30
30
 
31
31
  unless node.attrs.empty?
32
- result << "({ #{at.join(', ')} })"
32
+ result << "(#{at.join(', ')})"
33
33
  end
34
34
  else
35
35
  result << "Rux.tag('#{node.name}'"
data/lib/rux/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rux
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
data/rux.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.platform = Gem::Platform::RUBY
12
12
 
13
13
  s.add_dependency 'parser', '~> 3.0'
14
- s.add_dependency 'unparser', '~> 0.6'
14
+ s.add_dependency 'unparser', '<= 0.5.5'
15
15
 
16
16
  s.require_path = 'lib'
17
17
  s.executables << 'ruxc'
data/spec/parser_spec.rb CHANGED
@@ -29,67 +29,67 @@ describe Rux::Parser do
29
29
 
30
30
  it 'handles single-quoted rux attributes' do
31
31
  expect(compile("<Hello foo='bar' />")).to eq(
32
- 'render(Hello.new({ foo: "bar" }))'
32
+ 'render(Hello.new(foo: "bar"))'
33
33
  )
34
34
 
35
35
  expect(compile("<Hello foo='bar'></Hello>")).to eq(
36
- 'render(Hello.new({ foo: "bar" }))'
36
+ 'render(Hello.new(foo: "bar"))'
37
37
  )
38
38
  end
39
39
 
40
40
  it 'handles double-quoted rux attributes' do
41
41
  expect(compile('<Hello foo="bar" />')).to eq(
42
- 'render(Hello.new({ foo: "bar" }))'
42
+ 'render(Hello.new(foo: "bar"))'
43
43
  )
44
44
 
45
45
  expect(compile('<Hello foo="bar"></Hello>')).to eq(
46
- 'render(Hello.new({ foo: "bar" }))'
46
+ 'render(Hello.new(foo: "bar"))'
47
47
  )
48
48
  end
49
49
 
50
50
  it 'handles non-uniform spacing between attributes' do
51
51
  expect(compile('<Hello foo="bar" baz= "boo" bix ="bit" />')).to eq(
52
- 'render(Hello.new({ foo: "bar", baz: "boo", bix: "bit" }))'
52
+ 'render(Hello.new(foo: "bar", baz: "boo", bix: "bit"))'
53
53
  )
54
54
  end
55
55
 
56
56
  it 'handles boolean attributes' do
57
57
  expect(compile('<Hello disabled />')).to eq(
58
- 'render(Hello.new({ disabled: "true" }))'
58
+ 'render(Hello.new(disabled: "true"))'
59
59
  )
60
60
 
61
61
  expect(compile('<Hello disabled/>')).to eq(
62
- 'render(Hello.new({ disabled: "true" }))'
62
+ 'render(Hello.new(disabled: "true"))'
63
63
  )
64
64
 
65
65
  expect(compile('<Hello disabled></Hello>')).to eq(
66
- 'render(Hello.new({ disabled: "true" }))'
66
+ 'render(Hello.new(disabled: "true"))'
67
67
  )
68
68
  end
69
69
 
70
70
  it 'converts dashes to underscores in attribute keys' do
71
71
  expect(compile('<Hello foo-bar="baz" />')).to eq(
72
- 'render(Hello.new({ foo_bar: "baz" }))'
72
+ 'render(Hello.new(foo_bar: "baz"))'
73
73
  )
74
74
  end
75
75
 
76
76
  it 'handles simple ruby statements in attributes' do
77
77
  expect(compile('<Hello foo={true} />')).to eq(
78
- 'render(Hello.new({ foo: true }))'
78
+ 'render(Hello.new(foo: true))'
79
79
  )
80
80
  end
81
81
 
82
82
  it 'handles ruby hashes in attributes' do
83
83
  expect(compile('<Hello foo={{ foo: "bar", baz: "boo" }} />')).to eq(
84
- 'render(Hello.new({ foo: { foo: "bar", baz: "boo" } }))'
84
+ 'render(Hello.new(foo: { foo: "bar", baz: "boo" }))'
85
85
  )
86
86
  end
87
87
 
88
88
  it 'handles ruby code with curly braces in attributes' do
89
89
  expect(compile('<Hello foo={[1, 2, 3].map { |n| n * 2 }} />')).to eq(<<~RUBY.strip)
90
- render(Hello.new({ foo: [1, 2, 3].map { |n,|
90
+ render(Hello.new(foo: [1, 2, 3].map { |n,|
91
91
  n * 2
92
- } }))
92
+ }))
93
93
  RUBY
94
94
  end
95
95
 
data/spec/render_spec.rb CHANGED
@@ -29,4 +29,12 @@ describe Rux do
29
29
 
30
30
  expect(result).to eq("<div> <p>Welcome!</p><p>Welcome!</p><p>Welcome!</p> </div>")
31
31
  end
32
+
33
+ it 'correctly handles keyword arguments (ruby 3)' do
34
+ result = render(<<~RUBY)
35
+ <ArgsComponent a="a" b="b" />
36
+ RUBY
37
+
38
+ expect(result).to eq("<p>a and b</p>")
39
+ end
32
40
  end
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,7 @@ module ViewComponent
8
8
  attr_accessor :content
9
9
 
10
10
  def render(component, &block)
11
- component.content = block.call
11
+ component.content = block.call if block
12
12
  component.call
13
13
  end
14
14
  end
@@ -20,5 +20,18 @@ class TestComponent < ViewComponent::Base
20
20
  end
21
21
  end
22
22
 
23
+ class ArgsComponent < ViewComponent::Base
24
+ attr_reader :a, :b
25
+
26
+ def initialize(a:, b:)
27
+ @a = a
28
+ @b = b
29
+ end
30
+
31
+ def call
32
+ "<p>#{a} and #{b}</p>"
33
+ end
34
+ end
35
+
23
36
  RSpec.configure do |config|
24
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rux
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Dutro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-11 00:00:00.000000000 Z
11
+ date: 2021-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: unparser
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - "<="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.6'
33
+ version: 0.5.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - "<="
39
39
  - !ruby/object:Gem::Version
40
- version: '0.6'
40
+ version: 0.5.5
41
41
  description: A jsx-inspired way to write view components.
42
42
  email:
43
43
  - camertron@gmail.com
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.1.4
100
+ rubygems_version: 3.2.3
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: A jsx-inspired way to write view components.