Class: FixtureReader
- Inherits:
-
Object
- Object
- FixtureReader
- Includes:
- LogUtils::Logging
- Defined in:
- lib/textutils/reader/fixture_reader.rb
Overview
fix: move into TextUtils namespace/module!!
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(path) ⇒ FixtureReader
constructor
A new instance of FixtureReader.
Constructor Details
#initialize(path) ⇒ FixtureReader
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/textutils/reader/fixture_reader.rb', line 11 def initialize( path ) @path = path ## nb: assume/enfore utf-8 encoding (with or without BOM - byte order mark) ## - see textutils/utils.rb text = File.read_utf8( @path ) hash = YAML.load( text ) ### build up array for fixtures from hash @ary = [] hash.each do |key_wild, value_wild| key = key_wild.to_s.strip logger.debug "yaml key:#{key_wild.class.name} >>#{key}<<, value:#{value_wild.class.name} >>#{value_wild}<<" if value_wild.kind_of?( String ) # assume single fixture name @ary << value_wild elsif value_wild.kind_of?( Array ) # assume array of fixture names as strings @ary = @ary + value_wild else logger.error "unknow fixture type in setup (yaml key:#{key_wild.class.name} >>#{key}<<, value:#{value_wild.class.name} >>#{value_wild}<<); skipping" end end logger.debug "fixture setup:" logger.debug @ary.to_json end |
Instance Method Details
#each ⇒ Object
42 43 44 45 46 |
# File 'lib/textutils/reader/fixture_reader.rb', line 42 def each @ary.each do |fixture| yield( fixture ) end end |