Class: KafoModuleLint::TypeLoader
- Inherits:
-
Object
- Object
- KafoModuleLint::TypeLoader
- Defined in:
- lib/kafo_module_lint/type_loader.rb
Instance Attribute Summary collapse
-
#modulepath ⇒ Object
readonly
Returns the value of attribute modulepath.
Instance Method Summary collapse
-
#initialize(modulepath) ⇒ TypeLoader
constructor
A new instance of TypeLoader.
- #with_types(&block) ⇒ Object
Constructor Details
#initialize(modulepath) ⇒ TypeLoader
Returns a new instance of TypeLoader.
8 9 10 11 12 13 |
# File 'lib/kafo_module_lint/type_loader.rb', line 8 def initialize(modulepath) @modulepath = modulepath # Workaround as DataTypeParser assumes KafoConfigure is in use Kafo::KafoConfigure.logger ||= Logger.new(STDERR) end |
Instance Attribute Details
#modulepath ⇒ Object (readonly)
Returns the value of attribute modulepath.
6 7 8 |
# File 'lib/kafo_module_lint/type_loader.rb', line 6 def modulepath @modulepath end |
Instance Method Details
#with_types(&block) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/kafo_module_lint/type_loader.rb', line 15 def with_types(&block) parsers = Dir[type_pattern].map { |manifest| Kafo::DataTypeParser.new(File.read(manifest)) } parsers.each(&:register) yield ensure parsers.each do |parser| parser.types.keys.each { |type| Kafo::DataType.unregister_type(type) } end if parsers end |