# frozen_string_literal: true

require "#{File.dirname(__FILE__)}/req/mini-test"

# Encoding Settings
Encoding.default_internal = 'UTF-8'
Encoding.default_external = 'UTF-8'

# Ruby test file.
class MiniTestOne
  attr_reader :mini_test

  def initialize
    @mini_test = Dir["#{File.dirname(__FILE__)}/mini_test/*.rb"].sort.filter { |file| require file }
  end

  def remove
    remove_instance_variable(:@mini_test)
  end
end

# Ruby file find
class MiniFilename
  attr_reader :mini_find

  def initialize
    @mini_find = Dir.glob("#{File.dirname(__FILE__)}/mini_test/*.rb")
  end

  def remove
    remove_instance_variable(:@mini_find)
  end
end

# refinement use module
module Load
  refine MiniFilename do
    def find_test
      mini_find
    end
  end
end

# refinement use module
module LoadR
  refine MiniTestOne do
    def test_run
      mini_test
    end
  end
end

begin
  puts ''
  puts ' TimeStamp '.center(60, '-')
  puts ''
  Himekuri.new.cal
  puts ''
  puts ' TimeStamp '.center(60, '-')
  puts ''
  puts ' current_directory '.center(60, '-')
  puts ''
  puts Dir.getwd
  puts ''
  puts ' current_directory '.center(60, '-')
  puts ''
  puts ''
  puts ' mini_test in filename list...start '.center(60, '-')
  puts ''
  using Load
  puts MiniFilename.new.remove
  puts ''
  puts ' mini_test in filename list...exit '.center(60, '-')
  puts ''
  using LoadR
  MiniTestOne.new.remove
  puts ''
rescue LoadError => e
  puts e.backtrace
ensure
  GC.compact
end

__END__
