Module: Literally

Defined in:
lib/literally.rb,
lib/literally/version.rb

Defined Under Namespace

Classes: BaseProcessor, Configuration, Processor

Constant Summary collapse

EMPTY_ARRAY =
[].freeze
EVERYTHING =
["**/*"].freeze
METHOD_METHOD =
Module.instance_method(:method)
CONFIG =
Configuration.new
VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.init(include: EMPTY_ARRAY, exclude: EMPTY_ARRAY) ⇒ Object

Initializes Literally so that code loaded after this point will be guarded against undefined instance variable reads. You can pass an array of globs to include: and exclude:.

Literally.init(
  include: ["#{Dir.pwd}/**/*"],
  exclude: ["#{Dir.pwd}/vendor/**/*"]
)

: (include: Array, exclude: Array) -> void



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/literally.rb', line 32

def self.init(include: EMPTY_ARRAY, exclude: EMPTY_ARRAY)
	CONFIG.include(*include)
	CONFIG.exclude(*exclude)

	RequireHooks.source_transform(
		patterns: EVERYTHING,
		exclude_patterns: EMPTY_ARRAY
	) do |path, source|
		source ||= File.read(path)

		if CONFIG.match?(path)
			Processor.call(source)
		else
			BaseProcessor.call(source)
		end
	end
end