Class: TimeTrackr::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/timetrackr/database.rb

Direct Known Subclasses

JsonDatabase, SqliteDatabase, YamlDatabase

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(type, options = {}) ⇒ Object



4
5
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
# File 'lib/timetrackr/database.rb', line 4

def self.create(type, options={})
  case type.to_s
  when 'yaml'
    begin
      require 'yaml'
      db = TimeTrackr::YamlDatabase.new(options['path'])
      puts 'Loaded YAML tracker' if options['verbose']
    rescue LoadError
      puts 'YAML not found'
    end

  when 'sqlite'
    begin
      require 'sqlite3'
      db = TimeTrackr::SqliteDatabase.new(options['path'])
      puts 'Loaded sqlite tracker' if options['verbose']
    rescue LoadError
      puts 'Sqlite not found'
    end

  when 'json'
    begin
      require 'json'
      db = TimeTrackr::JsonDatabase.new(options['path'])
      puts 'Loaded JSON database' if options['verbose']
    rescue LoadError
      puts 'JSON not found'
    end

  else
    raise "Bad log type: #{type}"
  end
  db
end

Instance Method Details

#clear(task) ⇒ Object

clear an task



91
92
93
# File 'lib/timetrackr/database.rb', line 91

def clear(task)
  raise 'Not Implemented'
end

#closeObject

cleanup and close



98
99
# File 'lib/timetrackr/database.rb', line 98

def close
end

#currentObject

return an array of current tasks



42
43
44
# File 'lib/timetrackr/database.rb', line 42

def current
  raise 'Not Implemented'
end

#history(task) ⇒ Object

get task history as an array of Periods



77
78
79
# File 'lib/timetrackr/database.rb', line 77

def history(task)
  raise 'Not Implemented'
end

#rename(from, to) ⇒ Object

rename a task



84
85
86
# File 'lib/timetrackr/database.rb', line 84

def rename(from, to)
  raise 'Not implemented'
end

#start(task, notes) ⇒ Object

start a period with optional notes



49
50
51
# File 'lib/timetrackr/database.rb', line 49

def start(task,notes)
  raise 'Not implemented'
end

#stop(task) ⇒ Object

stop a period



56
57
58
# File 'lib/timetrackr/database.rb', line 56

def stop(task)
  raise 'Not implemented'
end

#tasksObject

return an array of all tasks



63
64
65
# File 'lib/timetrackr/database.rb', line 63

def tasks
  raise 'Not Implemented'
end

#time(task) ⇒ Object

time in task in seconds



70
71
72
# File 'lib/timetrackr/database.rb', line 70

def time(task)
  raise 'Not implemented'
end