Class: GitWakaTime::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



27
28
29
30
# File 'lib/gitwakatime.rb', line 27

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

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



25
26
27
# File 'lib/gitwakatime.rb', line 25

def api_key
  @api_key
end

#gitObject

Returns the value of attribute git.



25
26
27
# File 'lib/gitwakatime.rb', line 25

def git
  @git
end

#log_levelObject

Returns the value of attribute log_level.



25
26
27
# File 'lib/gitwakatime.rb', line 25

def log_level
  @log_level
end

#projectObject

Returns the value of attribute project.



25
26
27
# File 'lib/gitwakatime.rb', line 25

def project
  @project
end

#rootObject

Returns the value of attribute root.



25
26
27
# File 'lib/gitwakatime.rb', line 25

def root
  @root
end

Instance Method Details

#load_config_yamlObject



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

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



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/gitwakatime.rb', line 42

def setup_local_db
  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

  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 :project
    index :dependent_sha
    index :sha
  end

  DB.create_table? :actions do
    primary_key :id
    String :uuid
    DateTime :time
    integer :duration, default: 0
    String :file
    String :branch
    String :project
    index :uuid, unique: true
  end
end

#user_nameObject



32
33
34
# File 'lib/gitwakatime.rb', line 32

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