Module: TimeLogRobot

Defined in:
lib/time_log_robot.rb,
lib/time_log_robot/entry.rb,
lib/time_log_robot/tagger.rb,
lib/time_log_robot/version.rb,
lib/time_log_robot/reporter.rb,
lib/time_log_robot/toggl/entry.rb,
lib/time_log_robot/toggl/report.rb,
lib/time_log_robot/toggl/tagger.rb,
lib/time_log_robot/jira/work_logger.rb,
lib/time_log_robot/jira/payload_builder.rb,
lib/time_log_robot/jira/issue_key_parser.rb

Defined Under Namespace

Modules: JIRA, Toggl Classes: Entry, Reporter, Tagger

Constant Summary collapse

VERSION =
'0.2.2'

Class Method Summary collapse

Class Method Details

.envarsObject



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

def self.envars
  envars_help.keys
end

.envars_helpObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/time_log_robot.rb', line 29

def self.envars_help
  {
    'MAPPING_FILE_PATH' =>
      "This is the path to your mapping file. By default, this file is named `.time_log_robot_mapping.yml` and lives in your home directory.\n\n",

    'TOGGL_TOKEN' =>
      "In your Toggl account, go to your profile page and look for the API token at the bottom.\n\n",

    'TOGGL_WORKSPACE_ID' =>
      "This is a little trickier. Your workspaces usually only show a human-readable name to you in Toggl's UI, and here you need the workspace machine ID. But you can do a curl request to find it like this (replacing TOGGL_TOKEN with your token from above):

      \tcurl -v -u TOGGL_TOKEN:api_token \ -X GET https://www.toggl.com/api/v8/workspaces

      Look at the result and find the id given for the workspace you want to use.\n\n",

    'TOGGL_USER_AGENT' =>
      "This is your Toggl username, usually your email.\n\n",

    'TOGGL_DEFAULT_LOG_TAG' =>
      "This is the tag name you would like to use for tagging your Toggl time entries as they are logged to JIRA.\n\n",

    'JIRA_USERNAME' =>
      "This is your JIRA username, which can be found in your JIRA user profile.\n\n",

    'JIRA_PASSWORD' =>
      "I know there's a lot of jargon, but some of these are pretty self-explanatory\n"
  }
end

.fetch_time_report(since) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/time_log_robot.rb', line 17

def self.fetch_time_report(since)
  if since.nil?
    Toggl::Report.fetch
  else
    Toggl::Report.fetch(since: since)
  end
end

.rootObject



5
6
7
# File 'lib/time_log_robot.rb', line 5

def self.root
  File.dirname __dir__
end

.start(since) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/time_log_robot.rb', line 9

def self.start(since)
  report = fetch_time_report(since)
  JIRA::WorkLogger.log_all(
    service: report[:service],
    time_entries: report[:entries]
  )
end