class Licensee::FSProject
Attributes
path[R]
Public Class Methods
new(path, **args)
click to toggle source
Calls superclass method
Licensee::Project.new
# File lib/licensee/projects/fs_project.rb, line 8 def initialize(path, **args) @path = path super(**args) end
Private Instance Methods
find_file() { |file) > 0| ... }
click to toggle source
# File lib/licensee/projects/fs_project.rb, line 15 def find_file files = [] if ::File.file?(path) pattern = ::File.basename(path) @path = ::File.dirname(path) else pattern = '*' end Dir.glob(::File.join(path, pattern)) do |file| next unless ::File.file?(file) file = ::File.basename(file) if (score = yield file) > 0 files.push(name: file, score: score) end end return if files.empty? files.sort! { |a, b| b[:score] <=> a[:score] } f = files.first [::File.read(::File.join(path, f[:name])), f[:name]] end