Module: Rndr
- Defined in:
- lib/rndr.rb,
lib/rndr/cli.rb,
lib/rndr/util.rb,
lib/rndr/version.rb,
lib/rndr/template.rb
Overview
Rndr base module
Defined Under Namespace
Constant Summary collapse
- VERSION =
File.read( File.('../../../version.txt', __FILE__) ).chomp
Class Method Summary collapse
-
.matches(path:, ext: 'erb', ignore_path: File.join(Dir.pwd, '.rndrignore')) ⇒ Array<String>
Accepts a path (either file or directory), a file extension, and the name of a file within the working directory that contains a list of file glob patterns to be skipped.
-
.read_vars(path:, merge: true, merge_opts: {}) ⇒ Hash
Accepts a file or directory and will attempt to parse the discovered file(s) as either json or yaml.
Class Method Details
.matches(path:, ext: 'erb', ignore_path: File.join(Dir.pwd, '.rndrignore')) ⇒ Array<String>
Accepts a path (either file or directory), a file extension, and the name of a file within the working directory that contains a list of file glob patterns to be skipped. It returns an array of filtered matched paths.
15 16 17 18 19 20 21 |
# File 'lib/rndr/util.rb', line 15 def self.matches(path:, ext: 'erb', ignore_path: File.join(Dir.pwd, '.rndrignore')) matched_paths = match_files(path: File.absolute_path(path), ext: ext) ignore_file_path = File.absolute_path(ignore_path) return filter_ignored_paths(path_list: matched_paths, ignore_path: ignore_file_path) if !matched_paths.empty? && File.exist?(ignore_file_path) matched_paths end |
.read_vars(path:, merge: true, merge_opts: {}) ⇒ Hash
Accepts a file or directory and will attempt to parse the discovered file(s) as either json or yaml. It will then be returned as a hash intended for use with seeding the binding used for template rendering in Rndr::Template#render.
31 32 33 34 35 36 37 |
# File 'lib/rndr/util.rb', line 31 def self.read_vars(path:, merge: true, merge_opts: {}) vars_path = File.absolute_path(path) return read_vars_file(vars_path) if File.file?(vars_path) return read_vars_dir(path: vars_path, merge: merge, merge_opts: merge_opts) if File.directory?(vars_path) {} end |