Class: DakeDB
- Inherits:
-
Object
- Object
- DakeDB
- Defined in:
- lib/dake/database.rb
Overview
require “sqlite3”
Instance Attribute Summary collapse
-
#database_file ⇒ Object
readonly
Returns the value of attribute database_file.
-
#database_path ⇒ Object
readonly
Returns the value of attribute database_path.
Instance Method Summary collapse
-
#initialize(path) ⇒ DakeDB
constructor
A new instance of DakeDB.
Constructor Details
#initialize(path) ⇒ DakeDB
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dake/database.rb', line 6 def initialize(path) workflow_path = File.dirname(path) @database_path = workflow_path + '/.dake' @database_file = database_path + '/step_history.db' FileUtils.mkdir(@database_path) unless File.exist? @database_path # @db = SQLite3::Database.new database_file # @db.execute <<-SQL # create table if not exists step_history ( # id int unsigned auto_increment primary key, # step_sha1 binary(20) not null # target varchar(50), # process_id big int(50), # start_time varchar(5), # end_time varchar(5), # ip_address binary(4) # ); # create table if not exists step_target ( # id int unsigned auto_increment primary key, # target varchar(1024), # type char(50) # ); # SQL # git_opts = { # repository: database_path + '/.git', # index: database_path + '/.git/index', # log: Logger.new(File.open(database_path + '/git.log', 'w+')) # } # if File.exist? database_path + '/.git' # @git = Git.open(workflow_path, git_opts) # else # @git = Git.init(workflow_path, git_opts) # @git.config('user.name', 'Dake User') # @git.config('user.email', '[email protected]') # File.open(database_path + '/.gitignore', 'w') do |f| # f.puts File.basename('.dake') # end # @git.add(database_path + '/.gitignore') # @git.commit('init commit') # end end |
Instance Attribute Details
#database_file ⇒ Object (readonly)
Returns the value of attribute database_file.
5 6 7 |
# File 'lib/dake/database.rb', line 5 def database_file @database_file end |
#database_path ⇒ Object (readonly)
Returns the value of attribute database_path.
5 6 7 |
# File 'lib/dake/database.rb', line 5 def database_path @database_path end |