diff --git a/classy-yaml-0.8.0.gem b/classy-yaml-0.8.0.gem deleted file mode 100644 index 4c0840d..0000000 Binary files a/classy-yaml-0.8.0.gem and /dev/null differ diff --git a/classy-yaml-0.8.5.gem b/classy-yaml-0.8.5.gem new file mode 100644 index 0000000..0b57ed8 Binary files /dev/null and b/classy-yaml-0.8.5.gem differ diff --git a/lib/classy/yaml/component_helpers.rb b/lib/classy/yaml/component_helpers.rb index a478b43..9e221c8 100644 --- a/lib/classy/yaml/component_helpers.rb +++ b/lib/classy/yaml/component_helpers.rb @@ -2,10 +2,12 @@ module Classy module Yaml module ComponentHelpers def yass(*args) - component_name = self.class.source_location.split("/").last.split(".").first calling_path = self.class.source_location.split("/")[0...-1].join("/") - classy_file = if Dir.exist?("#{calling_path}/#{component_name}") - "#{calling_path}/#{component_name}/#{component_name}.yml" + calling_file = self.class.source_location.split("/").last.split(".").first + component_name = self.class.name.underscore.split("/").last.split(".").first + + classy_file = if Dir.exist?("#{calling_path}/#{calling_file}") + "#{calling_path}/#{calling_file}/#{component_name}.yml" else "#{calling_path}/#{component_name}.yml" end diff --git a/lib/classy/yaml/version.rb b/lib/classy/yaml/version.rb index 2d19a1d..920b486 100644 --- a/lib/classy/yaml/version.rb +++ b/lib/classy/yaml/version.rb @@ -1,5 +1,5 @@ module Classy module Yaml - VERSION = '0.8.0' + VERSION = '0.8.5' end end diff --git a/test/classy/yaml_component_test.rb b/test/classy/yaml_component_test.rb index 0928ce0..c8ccbaa 100644 --- a/test/classy/yaml_component_test.rb +++ b/test/classy/yaml_component_test.rb @@ -56,4 +56,14 @@ class Classy::YamlComponentTest < ViewComponent::TestCase assert_text "inherited" end + test "can find nested component utility classes" do + render_inline(TestComponent::NestedComponent.new classy: :nested) + assert_text "nested" + end + + test "can find nested component utility classes through inherited function call" do + render_inline(TestComponent::NestedComponent.new classy: :nested_inherited, inherited: true) + assert_text "nested-inherited" + end + end diff --git a/test/dummy/app/components/test_component.rb b/test/dummy/app/components/test_component.rb index a2f16ac..dd8b464 100644 --- a/test/dummy/app/components/test_component.rb +++ b/test/dummy/app/components/test_component.rb @@ -2,4 +2,10 @@ class TestComponent < ApplicationComponent def call @inherited ? inherited_call : yass(@classy) end + + class NestedComponent < TestComponent + def call + @inherited ? inherited_call : yass(@classy) + end + end end diff --git a/test/dummy/app/components/test_component/nested_component.yml b/test/dummy/app/components/test_component/nested_component.yml new file mode 100644 index 0000000..c489cd7 --- /dev/null +++ b/test/dummy/app/components/test_component/nested_component.yml @@ -0,0 +1,2 @@ +nested: "nested" +nested_inherited: "nested-inherited"