lib/aruba/config.rb in aruba-0.8.0 vs lib/aruba/config.rb in aruba-0.8.1

- old
+ new

@@ -1,19 +1,25 @@ require 'contracts' + +require 'aruba/version' require 'aruba/basic_configuration' require 'aruba/config_wrapper' require 'aruba/hooks' require 'aruba/contracts/relative_path' +require 'aruba/contracts/absolute_path' require 'aruba/contracts/enum' require 'aruba/contracts/is_a' module Aruba # Aruba Configuration class Configuration < BasicConfiguration - # As of 1.0.0 root_directory is read-only - # option_reader :root_directory, :contract => { None => String }, :default => Dir.getwd - option_accessor :root_directory, :contract => { String => String }, :default => Dir.getwd + if Aruba::VERSION >= '1.0.0' + option_reader :root_directory, :contract => { None => String }, :default => Dir.getwd + else + option_accessor :root_directory, :contract => { String => String }, :default => Dir.getwd + end + option_accessor :working_directory, :contract => { Aruba::Contracts::RelativePath => Aruba::Contracts::RelativePath }, :default => 'tmp/aruba' if RUBY_VERSION < '1.9' option_reader :fixtures_path_prefix, :contract => { None => String }, :default => '%' else @@ -30,9 +36,20 @@ option_accessor :keep_ansi, :contract => { Bool => Bool }, :default => false # rubocop:disable Metrics/LineLength option_accessor :command_launcher, :contract => { Aruba::Contracts::Enum[:in_process, :spawn, :debug] => Aruba::Contracts::Enum[:in_process, :spawn, :debug] }, :default => :spawn # rubocop:enable Metrics/LineLength option_accessor :main_class, :contract => { Aruba::Contracts::IsA[Class] => Or[Aruba::Contracts::IsA[Class], Eq[nil]] }, :default => nil + # rubocop:disable Metrics/LineLength + + # rubocop:disable Metrics/LineLength + if Aruba::VERSION >= '1.0.0' + option_accessor :home_directory, :contract => { Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] => Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] } do |config| + File.join(config.root_directory.value, config.working_directory.value) + end + else + option_accessor :home_directory, :contract => { Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] => Or[Aruba::Contracts::AbsolutePath, Aruba::Contracts::RelativePath] }, :default => ENV['HOME'] + end + # rubocop:enable Metrics/LineLength end end # Main Module module Aruba