Sha256: be6e9db020ef7279164dbe0f8a6b16b882c01df9d80f848ce659f02e09a49d1b
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
require_relative "base_naming_convention.rb" module Docks module NamingConventions class SUIT < Base STATEFUL_WORDS = %w(is) def base_component(component_name) component_name.split("-").first end def base_component?(component_name) component_name == base_component(component_name) end def component(component_name) component_name.gsub(/--[^\-]*/, "") end def parent_component(component_name) component_name = component(component_name) component_name.sub(/-[^\-]*$/, "") end def clean_variation_name(variation_name, component_name) return variation_name if disconnected_state?(variation_name) variation_name = variation_name.sub(Regexp.new("^(?:#{component_name})?(?:--)?"), "") "#{component_name}--#{variation_name}" end def state?(state_name) state_name = state_name.split("--").last STATEFUL_WORDS.any? { |word| state_name.start_with?(word) } end def variant?(variant_name) variant_name.split("--").length > 1 && !state?(variant_name) end def disconnected_state?(state_name) state?(state_name) && !state_name.include?("--") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems