Sha256: 10860a19e0c9b81373a35b025e415356cee48b8fe8afc9d7f08fb651015216b6
Contents?: true
Size: 1.12 KB
Versions: 19
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true module Carioca module Helpers def log get_service name: :logger end def i18n get_service name: :i18n end def debug(message:) log.debug(config.name) { message.to_s } end # facility to find a file in gem path # @param [String] gem a Gem name # @param [String] file a file relative path in the gem # @return [String] the path of the file, if found. # @return [False] if not found def search_file_in_gem(gem, file) if Gem::Specification.respond_to?(:find_by_name) begin spec = Gem::Specification.find_by_name(gem) rescue LoadError spec = nil end else spec = Gem.searcher.find(gem) end if spec res = if Gem::Specification.respond_to?(:find_by_name) spec.lib_dirs_glob.split('/') else Gem.searcher.lib_dirs_for(spec).split('/') end res.pop services_path = res.join('/').concat("/#{file}") return services_path if File.exist?(services_path) end false end end end
Version data entries
19 entries across 19 versions & 1 rubygems