Class: GitWakaTime::Controller
- Inherits:
-
Object
- Object
- GitWakaTime::Controller
- Defined in:
- lib/gitwakatime/controller.rb
Overview
Extract Duration Data from Heartbeats for the WAKATIME API
Instance Attribute Summary collapse
-
#heartbeats ⇒ Object
Returns the value of attribute heartbeats.
-
#project ⇒ Object
Returns the value of attribute project.
-
#relevant_commits ⇒ Object
Returns the value of attribute relevant_commits.
-
#time_range ⇒ Object
Returns the value of attribute time_range.
Instance Method Summary collapse
-
#initialize(path: '.', date: nil) ⇒ Controller
constructor
A new instance of Controller.
- #timer ⇒ Object
Constructor Details
#initialize(path: '.', date: nil) ⇒ Controller
Returns a new instance of Controller.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gitwakatime/controller.rb', line 6 def initialize(path: '.', date: nil) @path = path GitWakaTime.config.setup_local_db GitWakaTime.config.root = path GitWakaTime.config.load_config_yaml GitWakaTime.config.git = Git.open(path) GitWakaTime::Query.new(date, Date.today, @project).call @git_map = Mapper.new(start_at: date) @project = File.basename(GitWakaTime.config.git.dir.path) @relevant_commits = Commit.where( 'project = ?', @project ) # Scope by date if one has been passed @relevant_commits = @relevant_commits.where('date > ? ', date) if date @files = CommitedFile.where( 'commit_id IN ?', @relevant_commits.select_map(:id) ).where('project = ?', @project) end |
Instance Attribute Details
#heartbeats ⇒ Object
Returns the value of attribute heartbeats.
4 5 6 |
# File 'lib/gitwakatime/controller.rb', line 4 def heartbeats @heartbeats end |
#project ⇒ Object
Returns the value of attribute project.
4 5 6 |
# File 'lib/gitwakatime/controller.rb', line 4 def project @project end |
#relevant_commits ⇒ Object
Returns the value of attribute relevant_commits.
4 5 6 |
# File 'lib/gitwakatime/controller.rb', line 4 def relevant_commits @relevant_commits end |
#time_range ⇒ Object
Returns the value of attribute time_range.
4 5 6 |
# File 'lib/gitwakatime/controller.rb', line 4 def time_range @time_range end |