class RBT::DatabaseAdapters::Sequel::Adapter

Public Class Methods

[](i = '') click to toggle source
#

RBT::DatabaseAdapters::Sequel::Adapter[]

#
# File lib/rbt/database_adapters/sequel/adapter.rb, line 123
def self.[](i = '')
  new(i)
end
new( commandline_arguments = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/database_adapters/sequel/adapter.rb, line 32
def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

do_create_the_database() click to toggle source
#

do_create_the_database

This method will create the SQL database.

#
# File lib/rbt/database_adapters/sequel/adapter.rb, line 71
def do_create_the_database
  delete_file(@store_the_database_here) if File.exist? @store_the_database_here
  opne 'Storing into the database at `'+sfile(@store_the_database_here)+'`.'
  unless @database.table_exists?(:all_programs)
    @database.create_table :all_programs do
      primary_key :id
      String :name_of_the_program
      String :local_path_to_the_archive
      #column :name_of_the_program,       String
      #column :local_path_to_the_archive, String
    end
  end
  table = @database[:all_programs]
  all_programs?.each {|this_program|
    e 'Now working on '+steelblue(this_program)+':'
    if File.directory? RBT.base_dir_to_store_expanded_cookbooks?
      target_file = "#{RBT.base_dir_to_store_expanded_cookbooks?}#{this_program}.yml"
      if File.exist? target_file
        dataset = YAML.load_file(target_file)
        local_path = dataset[:program_path]
      else
        e 'No target at '+sfile(target_file)
        e 'Please fix this.'
        exit
      end
    end
    table.insert(
      name_of_the_program:       this_program,
      local_path_to_the_archive: local_path
    )
  }
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/database_adapters/sequel/adapter.rb, line 46
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @store_the_database_here
  # ======================================================================= #
  @store_the_database_here = log_dir?+'all_programs.db'
  # ======================================================================= #
  # === @database
  # ======================================================================= #
  @database = ::Sequel.sqlite(@store_the_database_here)
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/database_adapters/sequel/adapter.rb, line 107
  def run
    do_create_the_database
    # table = @database[:all_programs]
# Todo:
# pp table.count
# pp table.all
# pp @database.fetch("SELECT * from all_programs;").to_a

# @database.fetch("SELECT * from all_programs;") {|data|
#   puts data[:local_path_to_the_archive]
# }
  end
store_the_database_here?() click to toggle source
#

store_the_database_here?

#
# File lib/rbt/database_adapters/sequel/adapter.rb, line 62
def store_the_database_here?
  @store_the_database_here
end