Class: Assert::Config
Class Method Summary collapse
-
.method_missing(m, *a, &b) ⇒ Object
map any class methods to the singleton.
- .respond_to?(m) ⇒ Boolean
- .settings(*items) ⇒ Object
Instance Method Summary collapse
- #apply(settings) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/assert.rb', line 52 def initialize @view = Assert::View::DefaultView.new($stdout) @suite = Assert::Suite.new @runner = Assert::Runner.new @test_dir = "test" @test_helper = "helper.rb" # use git, by default, to determine which files have changes @changed_files = proc do |test_paths| cmds = [ "git diff --no-ext-diff --name-only", # changed files "git ls-files --others --exclude-standard" # added files ] cmd = cmds.map{ |c| "#{c} -- #{test_paths.join(' ')}" }.join(' && ') puts " `#{cmd}`" if Assert.config.debug `#{cmd}`.split("\n") end # default option values @runner_seed = begin; srand; srand % 0xFFFF; end.to_i @capture_output = false @halt_on_fail = true @changed_only = false @debug = false end |
Class Method Details
.method_missing(m, *a, &b) ⇒ Object
map any class methods to the singleton
34 |
# File 'lib/assert.rb', line 34 def self.method_missing(m, *a, &b); self.instance.send(m, *a, &b); end |
.respond_to?(m) ⇒ Boolean
35 |
# File 'lib/assert.rb', line 35 def self.respond_to?(m); super || self.instance.respond_to?(m); end |
.settings(*items) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/assert.rb', line 37 def self.settings(*items) items.each do |item| define_method(item) do |*args| if !(value = args.size > 1 ? args : args.first).nil? instance_variable_set("@#{item}", value) end instance_variable_get("@#{item}") end end end |
Instance Method Details
#apply(settings) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/assert.rb', line 78 def apply(settings) settings.keys.each do |name| if !settings[name].nil? && self.respond_to?(name.to_s) self.send(name.to_s, settings[name]) end end end |