Class: GitWakaTime::Configuration
- Inherits:
-
Object
- Object
- GitWakaTime::Configuration
- Defined in:
- lib/gitwakatime.rb
Overview
Stores primary config and project information Currently not thread safe.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#git ⇒ Object
Returns the value of attribute git.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#project ⇒ Object
Returns the value of attribute project.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
- #create_commited_files_table ⇒ Object
- #create_commits_table ⇒ Object
- #create_heartbeats_table ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #load_config_yaml ⇒ Object
- #setup_local_db ⇒ Object
- #user_name ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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_key ⇒ Object
Returns the value of attribute api_key.
34 35 36 |
# File 'lib/gitwakatime.rb', line 34 def api_key @api_key end |
#git ⇒ Object
Returns the value of attribute git.
34 35 36 |
# File 'lib/gitwakatime.rb', line 34 def git @git end |
#log_level ⇒ Object
Returns the value of attribute log_level.
34 35 36 |
# File 'lib/gitwakatime.rb', line 34 def log_level @log_level end |
#project ⇒ Object
Returns the value of attribute project.
34 35 36 |
# File 'lib/gitwakatime.rb', line 34 def project @project end |
#root ⇒ Object
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_table ⇒ Object
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_table ⇒ Object
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_table ⇒ Object
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_yaml ⇒ Object
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_db ⇒ Object
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_name ⇒ Object
41 42 43 |
# File 'lib/gitwakatime.rb', line 41 def user_name GitWakaTime.config.git.config('user.name') end |