Module: Kibutsu

Defined in:
lib/kibutsu.rb,
lib/kibutsu/fixture.rb,
lib/kibutsu/fixture_table.rb,
lib/kibutsu/fixture_world.rb,
lib/kibutsu/fixture_finder.rb,
lib/kibutsu/fixture_loader.rb,
lib/kibutsu/foreign_key_column.rb,
lib/kibutsu/database_connection.rb

Overview

Main module containing the public API of Kibutsu

Defined Under Namespace

Classes: DatabaseConnection, Fixture, FixtureFinder, FixtureLoader, FixtureTable, FixtureWorld, ForeignKeyColumn

Class Method Summary collapse

Class Method Details

.dont_care(type) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/kibutsu.rb', line 20

def self.dont_care(type)
  case type
  when :string
    "don't care about this string"
  when :number
    0
  when :boolean
    false
  end
end

.fixture_name_to_id(fixture_name) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/kibutsu.rb', line 12

def self.fixture_name_to_id(fixture_name)
  # hash algorithm based on djb2 (see http://www.cse.yorku.ca/~oz/hash.html)
  # scaled to signed int range for postgres int compatibility
  hash = 5381
  fixture_name.to_s.each_char { |c| hash = ((hash << 5) + hash) + c.ord }
  (hash % 4_294_967_295) - 2_147_483_648
end

.load_fixtures!(database_connection_url, fixtures_path) ⇒ Object



7
8
9
10
# File 'lib/kibutsu.rb', line 7

def self.load_fixtures!(database_connection_url, fixtures_path)
  fixture_world = FixtureWorld.instance
  fixture_world.load(database_connection_url, fixtures_path)
end