lib/utils/config/config_file.rb in utils-0.0.22 vs lib/utils/config/config_file.rb in utils-0.0.23
- old
+ new
@@ -2,10 +2,12 @@
require 'tins/xt/string'
class Utils::Config::ConfigFile
include DSLKit::Interpreter
+ class ConfigFileError < StandardError; end
+
def initialize
end
def parse_config_file(config_file_name)
File.open(config_file_name) do |cf|
@@ -51,10 +53,34 @@
end
result << "end\n"
end
end
+ class Probe < BlockConfig
+ config :test_framework, :'test-unit'
+
+ config :include_dirs, %w[lib test tests ext spec]
+
+ def include_dirs_argument
+ Array(include_dirs) * ':'
+ end
+
+ def initialize(&block)
+ super
+ test_frameworks_allowed = [ :'test-unit', :rspec ]
+ test_frameworks_allowed.include?(test_framework) or raise ConfigFileError,
+ "test_framework has to be in #{test_frameworks_allowed.inspect}"
+ end
+ end
+
+ def probe(&block)
+ if block
+ @probe = Probe.new(&block)
+ end
+ @probe ||= Probe.new
+ end
+
class FileFinder < BlockConfig
def prune?(basename)
Array(prune_dirs).any? { |pd| pd.match(basename) }
end
@@ -102,10 +128,10 @@
@strip_spaces ||= StripSpaces.new
end
def to_ruby
result = "# vim: set ft=ruby:\n"
- for bc in %w[search discover]
+ for bc in %w[search discover strip_spaces probe]
result << "\n" << __send__(bc).to_ruby
end
result
end
end