Sha256: bfc2784df55a85378d91c9da8325c7a97a121b3bf200271379a8b3a98fda4bda

Contents?: true

Size: 791 Bytes

Versions: 9

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2023, by Samuel Williams.

require_relative '../configuration'

module Falcon
	module Command
		# A helper for resolving wildcard configuration paths.
		module Paths
			# Resolve a set of `@paths` that may contain wildcards, into a sorted, unique array.
			# @returns [Array(String)]
			def resolved_paths(&block)
				@paths.collect do |path|
					Dir.glob(path)
				end.flatten.sort.uniq.each(&block)
			end
			
			# Build a configuration based on the resolved paths.
			def configuration
				configuration = Configuration.new
				
				self.resolved_paths.each do |path|
					path = File.expand_path(path)
					
					configuration.load_file(path)
				end
				
				return configuration
			end
		end
	end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
falcon-0.47.1 lib/falcon/command/paths.rb
falcon-0.47.0 lib/falcon/command/paths.rb
falcon-0.46.1 lib/falcon/command/paths.rb
falcon-0.46.0 lib/falcon/command/paths.rb
falcon-0.45.2 lib/falcon/command/paths.rb
falcon-0.45.1 lib/falcon/command/paths.rb
falcon-0.45.0 lib/falcon/command/paths.rb
falcon-0.44.0 lib/falcon/command/paths.rb
falcon-0.43.0 lib/falcon/command/paths.rb