Sha256: d4d07e76df898ef368dcf8db19c0e31174093c99dc1e3304f0f5f5d8b2e71528
Contents?: true
Size: 1009 Bytes
Versions: 2
Compression:
Stored size: 1009 Bytes
Contents
# Filesystem-based project # # Analyze a folder on the filesystem for license information module Licensee class FSProject < Project attr_reader :path def initialize(path, **args) @path = path super(**args) end private # Returns an array of hashes representing the project's files. # Hashes will have the :name key, with the relative path to the file def files 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) files.push(name: ::File.basename(file)) end files end # Retrieve a file's content from disk # # file - the file hash, with the :name key as the file's relative path # # Returns the fiel contents as a string def load_file(file) ::File.read(::File.join(path, file[:name])) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
licensee-8.6.1 | lib/licensee/projects/fs_project.rb |
licensee-8.6.0 | lib/licensee/projects/fs_project.rb |