Class: Mrubyc::Test::Config
Class Method Summary collapse
Class Method Details
.mrubycfile ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mrubyc/test/config.rb', line 26 def mrubycfile if File.exists? 'Mrubycfile' 'Mrubycfile' elsif File.exists? '.mrubycconfig' '.mrubycconfig' else FileUtils.touch 'Mrubycfile' 'Mrubycfile' end end |
.read(check: true) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/mrubyc/test/config.rb', line 10 def read(check: true) config = YAML.load_file(mrubycfile) if check if !config || config == [] || !config['test_dir'] raise 'Check if `Mrubycfile or .mrubycconfig` exists.' end end config || {} end |
.write(config) ⇒ Object
20 21 22 23 24 |
# File 'lib/mrubyc/test/config.rb', line 20 def write(config) File.open(mrubycfile, 'r+') do |file| file.write(config.to_yaml) end end |