module PoiseService::Utils
Utility methods for PoiseService
.
@api public @since 1.0.0
Constants
- COMMON_SEGMENTS
Common segments to ignore
Public Instance Methods
parse_service_name(path)
click to toggle source
Parse the service name from a path. Look at the last component of the path, ignoring some common names.
@param path [String] Path to parse. @return [String] @example
attribute(:service_name, kind_of: String, default: lazy { PoiseService::Utils.parse_service_name(path) })
# File lib/poise_service/utils.rb, line 39 def parse_service_name(path) parts = Pathname.new(path).each_filename.to_a.reverse! # Find the last segment not in common segments, fall back to the last segment. parts.find {|seg| !COMMON_SEGMENTS[seg] } || parts.first end