Class: Codebeacon::Tracer::TreeNodeMapper
- Inherits:
-
Object
- Object
- Codebeacon::Tracer::TreeNodeMapper
- Defined in:
- lib/codebeacon/tracer/src/data/tree_node_mapper.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(database) ⇒ TreeNodeMapper
constructor
A new instance of TreeNodeMapper.
- #insert(file, line, called_method, method, tp_class, tp_defined_class, tp_class_name, self_type, depth, caller, gem_entry, parent_id, block, node_source_id, return_type, return_value) ⇒ Object
Constructor Details
#initialize(database) ⇒ TreeNodeMapper
Returns a new instance of TreeNodeMapper.
7 8 9 |
# File 'lib/codebeacon/tracer/src/data/tree_node_mapper.rb', line 7 def initialize(database) @db = database end |
Class Method Details
.create_indexes(database) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/codebeacon/tracer/src/data/tree_node_mapper.rb', line 55 def self.create_indexes(database) database.execute("CREATE INDEX IF NOT EXISTS IDX_treenode_parent_id ON treenodes(parent_id)") database.execute("CREATE INDEX IF NOT EXISTS IDX_treenode_node_source_id ON treenodes(node_source_id)") database.execute("CREATE INDEX IF NOT EXISTS IDX_treenode_file ON treenodes(file)") database.execute("CREATE INDEX IF NOT EXISTS IDX_treenode_called_method ON treenodes(called_method)") end |
.create_table(database) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/codebeacon/tracer/src/data/tree_node_mapper.rb', line 29 def self.create_table(database) database.execute " CREATE TABLE IF NOT EXISTS treenodes (\n id INTEGER PRIMARY KEY,\n file TEXT,\n line INTEGER,\n called_method TEXT,\n method TEXT,\n tp_class TEXT,\n tp_defined_class TEXT,\n tp_class_name TEXT,\n self_type TEXT,\n depth INTEGER,\n caller TEXT,\n gemEntry INTEGER,\n parent_id INTEGER,\n block INTEGER,\n node_source_id INTEGER,\n return_type TEXT,\n return_value TEXT,\n FOREIGN KEY (parent_id) REFERENCES treenodes(id),\n FOREIGN KEY (node_source_id) REFERENCES node_sources(id)\n )\n SQL\nend\n" |
Instance Method Details
#insert(file, line, called_method, method, tp_class, tp_defined_class, tp_class_name, self_type, depth, caller, gem_entry, parent_id, block, node_source_id, return_type, return_value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/codebeacon/tracer/src/data/tree_node_mapper.rb', line 11 def insert(file, line, called_method, method, tp_class, tp_defined_class, tp_class_name, self_type, depth, caller, gem_entry, parent_id, block, node_source_id, return_type, return_value) @db.execute(" INSERT INTO treenodes \n (\n file, line, called_method, method, tp_class, tp_defined_class, tp_class_name, self_type, depth, caller, \n gemEntry, parent_id, block, node_source_id, return_type, return_value\n )\n VALUES \n (\n ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?\n )\n SQL\n file, line, called_method, method, tp_class, tp_defined_class, tp_class_name, self_type, depth, caller, \n gem_entry ? 1 : 0, parent_id, block ? 1 : 0, node_source_id, return_type, return_value)\n \n @db.last_insert_row_id\nend\n", |