Method: Halite::Gem#find_misc_path

Defined in:
lib/halite/gem.rb

#find_misc_path(name) ⇒ String+

Search for a file like README.md or LICENSE.txt in the gem.

Examples:

gem.misc_file('Readme') => /path/to/readme.txt

Parameters:

  • name (String)

    Basename to search for.

Returns:

  • (String, Array<String>)

Since:

  • 1.0.0



182
183
184
185
186
187
188
189
190
191
# File 'lib/halite/gem.rb', line 182

def find_misc_path(name)
  [name, name.upcase, name.downcase].each do |base|
    ['.md', '', '.txt', '.html'].each do |suffix|
      path = File.join(spec.full_gem_path, base+suffix)
      return path if File.exist?(path) && Dir.entries(File.dirname(path)).include?(File.basename(path))
    end
  end
  # Didn't find anything
  nil
end