Module: Suture

Defined in:
lib/suture/reset.rb,
lib/suture/config.rb,
lib/suture/create.rb,
lib/suture/delete.rb,
lib/suture/verify.rb,
lib/suture/version.rb,
lib/suture/comparator.rb,
lib/suture/create/builds_plan.rb,
lib/suture/verify/tests_patient.rb,
lib/suture/create/validates_plan.rb,
lib/suture/create/chooses_surgeon.rb,
lib/suture/create/performs_surgery.rb,
lib/suture/verify/administers_test.rb,
lib/suture/verify/interprets_results.rb,
lib/suture/verify/prescribes_test_plan.rb

Defined Under Namespace

Modules: Adapter, Error, Surgeon, Util, Value, Wrap Classes: AdministersTest, BuildsPlan, ChoosesSurgeon, Comparator, InterpretsResults, PerformsSurgery, PrescribesTestPlan, TestsPatient, ValidatesPlan

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :database_path => "db/suture.sqlite3",
  :comparator => Comparator.new,
  :log_level => "INFO",
  :log_stdout => true,
  :log_io => nil,
  :log_file => nil,
  :raise_on_result_mismatch => true
}
VERSION =
"1.1.1"

Class Method Summary collapse

Class Method Details

.config(config = {}) ⇒ Object



14
15
16
17
# File 'lib/suture/config.rb', line 14

def self.config(config = {})
  @config ||= DEFAULT_OPTIONS.dup
  @config.merge!(config)
end

.config_reset!Object



19
20
21
# File 'lib/suture/config.rb', line 19

def self.config_reset!
  @config = DEFAULT_OPTIONS.dup
end

.create(name, options) ⇒ Object



7
8
9
10
11
# File 'lib/suture/create.rb', line 7

def self.create(name, options)
  plan = ValidatesPlan.new.validate(BuildsPlan.new.build(name, options))
  surgeon = ChoosesSurgeon.new.choose(plan)
  PerformsSurgery.new.perform(plan, surgeon)
end

.delete!(id, options = {}) ⇒ Object



5
6
7
8
# File 'lib/suture/delete.rb', line 5

def self.delete!(id, options = {})
  plan = BuildsPlan.new.build(:name_not_used_here, options)
  Adapter::Dictaphone.new(plan).delete_by_id!(id)
end

.delete_all!(name, options = {}) ⇒ Object



10
11
12
13
# File 'lib/suture/delete.rb', line 10

def self.delete_all!(name, options = {})
  plan = BuildsPlan.new.build(:name_not_used_here, options)
  Adapter::Dictaphone.new(plan).delete_by_name!(name)
end

.reset!Object



4
5
6
7
# File 'lib/suture/reset.rb', line 4

def self.reset!
  Suture.config_reset!
  Adapter::Log.reset!
end

.verify(name, options) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/suture/verify.rb', line 6

def self.verify(name, options)
  test_plan = Suture::PrescribesTestPlan.new.prescribe(name, options)
  test_results = Suture::TestsPatient.new.test(test_plan)
  if test_results.failed?
    Suture::InterpretsResults.new.interpret(test_plan, test_results)
  end
end