class Licensee::FSProject

Public Class Methods

new(path, **args) click to toggle source
Calls superclass method Licensee::Project.new
# File lib/licensee/projects/fs_project.rb, line 6
def initialize(path, **args)
  if ::File.file?(path)
    @pattern = ::File.basename(path)
    @dir = ::File.dirname(path)
  else
    @pattern = '*'
    @dir = path
  end
  super(**args)
end

Private Instance Methods

files() click to toggle source

Returns an array of hashes representing the project's files. Hashes will have the :name key, with the relative path to the file

# File lib/licensee/projects/fs_project.rb, line 21
def files
  files = []

  Dir.glob(::File.join(@dir, @pattern).tr('\', '/')) do |file|
    next unless ::File.file?(file)
    files.push(name: ::File.basename(file))
  end

  files
end
load_file(file) click to toggle source

Retrieve a file's content from disk

file - the file hash, with the :name key as the file's relative path

Returns the file contents as a string

# File lib/licensee/projects/fs_project.rb, line 37
def load_file(file)
  ::File.read(::File.join(@dir, file[:name]))
end