Sha256: 747b966eb3cd09028ced7f2a4d5a5bc08560d6a65fd5768f6cdce0eed52d133e
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 KB
Contents
require 'sqlite3' module Dev # # Branches table # Name text e.g. google/devgem/trunk # Uri text e.g. https://devgem.googlecode.com/svn/trunk # # create table Branches(Name text,Uri text,UNIQUE(Name)); # class Database attr_accessor :db def self.filename return Dev::Environment.dev_root + "/dev.db" end def self.get_table_names(filename) names=Array.new db = SQLite3::Database.new filename db.execute("select name from sqlite_master where type='table' ORDER BY name") do |row| names << row[0] end return names end def initialize filename=Dev::Database.filename table_names=Dev::Database.get_table_names(filename) @db = SQLite3::Database.new filename @db.execute("create table Branches(Name text,Uri text,UNIQUE(Name));") if !table_names.include? "Branches" end def set_branch_uri(name,uri) @db.execute("insert or replace into Branches (Name,Uri) VALUES ('#{name}','#{uri}');") end def get_branch_uri(name,uri) @db.execute("select Uri from Branches where Name='#{name}';") do |row| return row[0] end return "" end def find_branches(pattern) names=Array.new sql="select Name from Branches where Name LIKE '#{pattern}';" sql="select Name from Branches;" if pattern.nil? || pattern.length==0 @db.execute(sql) do |row| names << row[0] end return names end end # class Database end # module Dev
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dev-1.0.147 | lib/dev/Database.rb |
dev-1.0.146 | lib/dev/Database.rb |
dev-1.0.145 | lib/dev/Database.rb |
dev-1.0.144 | lib/dev/Database.rb |