Sha256: 8fc103a6027b4cdc2bd44b09cf9b880cc9725ff2ea1d0728029ac22f4835a0ea

Contents?: true

Size: 907 Bytes

Versions: 3

Compression:

Stored size: 907 Bytes

Contents

module GitWakaTime
  # Extract Duration Data from Heartbeats for the WAKATIME API
  class Controller
    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)
      @git_map = Mapper.new(start_at: date)
      @project = File.basename(GitWakaTime.config.git.dir.path)
      @relevant_commits = Commit.where(
        'date > ? and project = ?', date, @project
      )

      @files = CommitedFile.where(
        'commit_id IN ?',  @relevant_commits.select_map(:id)
      ).where('project = ?', @project)

      @heartbeats = Query.new(
        @relevant_commits, @files, File.basename(path)
      ).get
    end

    def timer
      Timer.new(
        @relevant_commits.all, @heartbeats, File.basename(@path)
      ).process
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gitwakatime-0.2.2 lib/gitwakatime/controller.rb
gitwakatime-0.2.1 lib/gitwakatime/controller.rb
gitwakatime-0.2.0 lib/gitwakatime/controller.rb