Sha256: 12a74a7c741ffc7760f15a8035cff24c951296ce1945b2c0dea871b4b3fb7c1d

Contents?: true

Size: 811 Bytes

Versions: 7

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2024, 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)
				if @paths
					@paths.collect do |path|
						Dir.glob(path)
					end.flatten.sort.uniq.each(&block)
				end
			end
			
			# Build a configuration based on the resolved paths.
			def configuration
				configuration = Configuration.new
				
				self.resolved_paths do |path|
					path = File.expand_path(path)
					
					configuration.load_file(path)
				end
				
				return configuration
			end
		end
	end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
falcon-0.48.3 lib/falcon/command/paths.rb
falcon-0.48.2 lib/falcon/command/paths.rb
falcon-0.48.1 lib/falcon/command/paths.rb
falcon-0.48.0 lib/falcon/command/paths.rb
falcon-0.47.10 lib/falcon/command/paths.rb
falcon-0.47.9 lib/falcon/command/paths.rb
falcon-0.47.8 lib/falcon/command/paths.rb