Class: GitWakaTime::Configuration

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

Overview

Stores primary config and project information Currently not thread safe.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



36
37
38
39
# File 'lib/gitwakatime.rb', line 36

def initialize
  self.api_key = nil
  self.log_level = :info
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



34
35
36
# File 'lib/gitwakatime.rb', line 34

def api_key
  @api_key
end

#gitObject

Returns the value of attribute git.



34
35
36
# File 'lib/gitwakatime.rb', line 34

def git
  @git
end

#log_levelObject

Returns the value of attribute log_level.



34
35
36
# File 'lib/gitwakatime.rb', line 34

def log_level
  @log_level
end

#projectObject

Returns the value of attribute project.



34
35
36
# File 'lib/gitwakatime.rb', line 34

def project
  @project
end

#rootObject

Returns the value of attribute root.



34
35
36
# File 'lib/gitwakatime.rb', line 34

def root
  @root
end

Instance Method Details

#create_commited_files_tableObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/gitwakatime.rb', line 70

def create_commited_files_table
  DB.create_table? :commited_files do
    primary_key :id
    integer :commit_id
    String :dependent_sha
    DateTime :dependent_date
    integer :time_in_seconds, default: 0
    String :sha
    String :name
    String :entity
    String :project
    index :dependent_sha
    index :sha
  end
end

#create_commits_tableObject



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/gitwakatime.rb', line 57

def create_commits_table
  DB.create_table? :commits do
    primary_key :id
    String :sha
    String :parent_sha
    String :project
    integer :time_in_seconds, default: 0
    datetime :date
    text :message
    String :author
  end
end

#create_heartbeats_tableObject



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/gitwakatime.rb', line 86

def create_heartbeats_table
  DB.create_table? :heartbeats do
    primary_key :id
    String :uuid
    DateTime :time
    integer :duration, default: 0
    String :entity
    String :type
    String :branch
    String :project
    index :uuid, unique: true
  end
end

#load_config_yamlObject



45
46
47
48
49
# File 'lib/gitwakatime.rb', line 45

def load_config_yaml
  yaml = YAML.load_file(File.join(Dir.home, '.wakatime.yml'))
  self.api_key = yaml[:api_key]
  self.log_level = yaml[:log_level]
end

#setup_local_dbObject



51
52
53
54
55
# File 'lib/gitwakatime.rb', line 51

def setup_local_db
  create_commits_table
  create_commited_files_table
  create_heartbeats_table
end

#user_nameObject



41
42
43
# File 'lib/gitwakatime.rb', line 41

def user_name
  GitWakaTime.config.git.config('user.name')
end