Module: Carbon::Compiler::Metanostic::Defaults
- Defined in:
- lib/carbon/compiler/metanostic/defaults.rb
Overview
Deals with loading default of metanostics. It mostly takes defaults from a defaults.yml file in the same directory as this file.
Class Method Summary collapse
-
.defaults ⇒ {String => Metanostic}
Returns a frozen hash of all the default metanostics.
-
.load_file(file) ⇒ {String => Metanostic}
Load a file and return the metanostics contained within the files.
Class Method Details
.defaults ⇒ {String => Metanostic}
Returns a frozen hash of all the default metanostics. Since it is frozen, it is cached.
34 35 36 37 |
# File 'lib/carbon/compiler/metanostic/defaults.rb', line 34 def self.defaults @_defaults ||= load_file(::File.("../defaults.yml", __FILE__)).freeze end |
.load_file(file) ⇒ {String => Metanostic}
Load a file and return the metanostics contained within the files.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/carbon/compiler/metanostic/defaults.rb', line 16 def self.load_file(file) data = YAML.load_file(file) = {} data["metanostics"].each do |name, | = { name: name, default: Mode.from(["default"]), allowed: Mode.from(["allowed"]), message: ["message"] } [name] = Metanostic.new() end end |