Module: Bake::Format

Defined in:
lib/bake/format.rb,
lib/bake/format/raw.rb,
lib/bake/format/json.rb,
lib/bake/format/yaml.rb,
lib/bake/format/ndjson.rb

Defined Under Namespace

Modules: JSON, Raw, YAML Classes: NDJSON

Constant Summary collapse

REGISTRY =
{}

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bake/format.rb', line 10

def self.[](name)
	unless name =~ /\A[a-z_]+\z/
		raise ArgumentError.new("Invalid format name: #{name}")
	end
	
	begin
		require_relative "format/#{name}"
	rescue LoadError
		raise ArgumentError.new("Unknown format: #{name}")
	end
	
	return REGISTRY[name.to_sym]
end