module Grably::Module
Methods for working with submodules
Constants
- DEFAULT_FILES
List of file names we can load as submodule entry
Public Class Methods
ensure_filename(path)
click to toggle source
Ensures that provided path points to one of allowed to load files
# File lib/grably/core/module.rb, line 48 def ensure_filename(path) basename = File.basename(path) return path if DEFAULT_FILES.include?(basename) exp = DEFAULT_FILES.join(', ') raise "Wrong file name #{basename} expected one of #{exp}" end
ensure_module_dir(path)
click to toggle source
# File lib/grably/core/module.rb, line 56 def ensure_module_dir(path) base_path = Dir["#{path}/*"] .find { |f| DEFAULT_FILES.include?(File.basename(f)) } raise "Can't find any file to load in #{path}" unless base_path base_path end
reference(path, task)
click to toggle source
Get submodule object @param [String] path relative path to sumbodule @return [Grably::Module::ModuleCall] addresed submodule
# File lib/grably/core/module.rb, line 36 def reference(path, task) base_path = File.expand_path(File.join(Dir.pwd, path)) raise "#{path} does not exist" unless File.exist?(path) path = if File.directory?(base_path) ensure_module_dir(base_path) else ensure_filename(base_path) end ModuleCall.new(path, task) end