Class: Spandx::Rubygems::Backup
- Inherits:
-
Object
- Object
- Spandx::Rubygems::Backup
- Defined in:
- lib/spandx/rubygems/backup.rb
Constant Summary collapse
- SQL =
<<~DATA SELECT rg.name AS name, v.number AS version, v.licenses AS licenses FROM versions v INNER JOIN rubygems rg ON rg.id = v.rubygem_id WHERE v.licenses IS NOT NULL AND v.latest = true AND v.yanked_at IS NULL ORDER BY rg.name DATA
- LOAD_SCRIPT =
File.(File.join(File.dirname(__FILE__), '../../../', 'bin/load'))
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #each ⇒ Object
- #execute(sql) ⇒ Object
-
#initialize(uri, db_connection) ⇒ Backup
constructor
A new instance of Backup.
- #to_s ⇒ Object
Constructor Details
#initialize(uri, db_connection) ⇒ Backup
Returns a new instance of Backup.
18 19 20 21 |
# File 'lib/spandx/rubygems/backup.rb', line 18 def initialize(uri, db_connection) @uri = uri @db_connection = db_connection end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
16 17 18 |
# File 'lib/spandx/rubygems/backup.rb', line 16 def uri @uri end |
Instance Method Details
#each ⇒ Object
23 24 25 26 27 |
# File 'lib/spandx/rubygems/backup.rb', line 23 def each execute(SQL) do |row| yield row end end |
#execute(sql) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/spandx/rubygems/backup.rb', line 29 def execute(sql) download do @db_connection.exec(sql) do |result| result.each do |row| yield row end end end end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/spandx/rubygems/backup.rb', line 39 def to_s @uri.to_s end |