class Packagecloud::Maven::Importer::Database
Constants
- CREATE_SCHEMA
Attributes
database[RW]
Public Class Methods
new(path:)
click to toggle source
# File lib/packagecloud/maven/importer/database.rb, line 13 def initialize(path:) self.database = SQLite3::Database.new(path) self.database.execute(CREATE_SCHEMA) end
Public Instance Methods
clear!()
click to toggle source
# File lib/packagecloud/maven/importer/database.rb, line 18 def clear! self.database.execute <<-SQL DELETE FROM artifacts; SQL end
finish!(full_path)
click to toggle source
# File lib/packagecloud/maven/importer/database.rb, line 30 def finish!(full_path) self.database.execute <<-SQL UPDATE artifacts SET state='uploaded' WHERE (full_path='#{full_path}'); SQL end
peek()
click to toggle source
# File lib/packagecloud/maven/importer/database.rb, line 49 def peek full_path, base_path = self.database.get_first_row("SELECT * from artifacts where state='queued';") if full_path [full_path, base_path] else nil end end
push(full_path, base_path)
click to toggle source
# File lib/packagecloud/maven/importer/database.rb, line 24 def push(full_path, base_path) self.database.execute <<-SQL INSERT OR IGNORE INTO artifacts VALUES('#{full_path}', '#{base_path}', 'queued'); SQL end
queued_count()
click to toggle source
# File lib/packagecloud/maven/importer/database.rb, line 41 def queued_count self.database.get_first_value "SELECT COUNT(*) FROM artifacts where state='queued';" end
reset!()
click to toggle source
# File lib/packagecloud/maven/importer/database.rb, line 36 def reset! self.database.execute("DROP TABLE artifacts;") self.database.execute(CREATE_SCHEMA) end
total_count()
click to toggle source
# File lib/packagecloud/maven/importer/database.rb, line 45 def total_count self.database.get_first_value "SELECT COUNT(*) FROM artifacts;" end