dude-cli 1.0.2 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/.gitignore +0 -2
- data/.travis.yml +4 -3
- data/CHANGELOG.md +25 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +57 -54
- data/README.md +41 -25
- data/bin/dude +3 -2
- data/dude.gemspec +18 -15
- data/lib/dude.rb +13 -0
- data/lib/dude/commands.rb +24 -0
- data/lib/dude/commands/checkout.rb +21 -0
- data/lib/dude/commands/install.rb +57 -0
- data/lib/dude/commands/move.rb +15 -0
- data/lib/dude/commands/start.rb +29 -0
- data/lib/dude/commands/stop.rb +15 -0
- data/lib/dude/commands/tasks.rb +31 -0
- data/lib/dude/commands/track.rb +28 -0
- data/lib/dude/commands/version.rb +11 -0
- data/lib/dude/git.rb +5 -0
- data/lib/dude/git/checkout.rb +2 -16
- data/lib/dude/git/current_branch_name.rb +1 -2
- data/lib/dude/project_management/client.rb +25 -0
- data/lib/dude/project_management/entities/board.rb +9 -0
- data/lib/dude/project_management/entities/issue.rb +37 -0
- data/lib/dude/project_management/jira.rb +9 -0
- data/lib/dude/project_management/jira/client.rb +49 -0
- data/lib/dude/project_management/jira/get_current_tasks.rb +40 -0
- data/lib/dude/project_management/jira/get_task_name_by_id.rb +24 -0
- data/lib/dude/project_management/jira/move_task_to_list.rb +47 -0
- data/lib/dude/project_management/trello.rb +6 -0
- data/lib/dude/project_management/trello/checkout.rb +4 -0
- data/lib/dude/project_management/trello/client.rb +33 -0
- data/lib/dude/project_management/trello/get_current_tasks.rb +24 -0
- data/lib/dude/project_management/trello/get_lists.rb +15 -0
- data/lib/dude/project_management/trello/move_tasks_to_list.rb +14 -0
- data/lib/dude/settings.rb +6 -2
- data/lib/dude/time_trackers/toggl.rb +5 -0
- data/lib/dude/time_trackers/toggl/base.rb +18 -0
- data/lib/dude/{toggl → time_trackers/toggl}/start_time_entry.rb +14 -8
- data/lib/dude/{toggl → time_trackers/toggl}/stop_time_entry.rb +4 -2
- data/lib/dude/version.rb +1 -1
- metadata +69 -86
- data/.ruby-version +0 -1
- data/LICENSE.txt +0 -21
- data/lib/dude/cli.rb +0 -156
- data/lib/dude/gitlab/add_spend_time.rb +0 -36
- data/lib/dude/gitlab/base.rb +0 -38
- data/lib/dude/gitlab/count_spend_time.rb +0 -13
- data/lib/dude/gitlab/estimate.rb +0 -20
- data/lib/dude/gitlab/get_issue_info.rb +0 -9
- data/lib/dude/gitlab/get_issue_time_spent.rb +0 -9
- data/lib/dude/gitlab/get_issue_title.rb +0 -14
- data/lib/dude/gitlab/get_my_issues.rb +0 -31
- data/lib/dude/gitlab/move_issue.rb +0 -37
- data/lib/dude/interface.rb +0 -98
- data/lib/dude/report.rb +0 -38
- data/lib/dude/service.rb +0 -18
- data/lib/dude/toggl.rb +0 -40
- data/lib/dude/toggl/base.rb +0 -36
- data/lib/dude/toggl/issue_spend_time.rb +0 -56
- data/lib/dude/toggl/report.rb +0 -25
data/lib/dude/report.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
require_relative 'settings'
|
3
|
-
|
4
|
-
module Dude
|
5
|
-
class Report
|
6
|
-
include Settings
|
7
|
-
attr_reader :report
|
8
|
-
|
9
|
-
def initialize(report)
|
10
|
-
@report = report
|
11
|
-
end
|
12
|
-
|
13
|
-
def week_time_worked
|
14
|
-
@time_worked ||= report['total_grand'] / 1000
|
15
|
-
end
|
16
|
-
|
17
|
-
def today_time_worked
|
18
|
-
@today_time_worked ||= report['week_totals'].map {|a| a.nil? ? 0 : a / 1000}[Time.now.wday - 1]
|
19
|
-
end
|
20
|
-
|
21
|
-
def days_without_weekends
|
22
|
-
@days_without_weekends ||= report['week_totals'][0..Time.now.wday - 1].compact.count
|
23
|
-
end
|
24
|
-
|
25
|
-
def weekends
|
26
|
-
@weekends ||= report['week_totals'][0..Time.now.wday - 1].
|
27
|
-
select { |a| a.nil? }.count
|
28
|
-
end
|
29
|
-
|
30
|
-
def hours_without_weekends
|
31
|
-
@hours_without_weekends ||= settings['HOURS_PER_WEEK'].to_i - weekends * settings['HOURS_PER_DAY'].to_i
|
32
|
-
end
|
33
|
-
|
34
|
-
def seconds_for_today
|
35
|
-
days_without_weekends * settings['HOURS_PER_DAY'].to_i * 3600
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/lib/dude/service.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Dude
|
2
|
-
module Service
|
3
|
-
attr_reader :options
|
4
|
-
def initialize(options = {})
|
5
|
-
@options = options
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.included(klass)
|
9
|
-
klass.extend(ClassMethods)
|
10
|
-
end
|
11
|
-
|
12
|
-
module ClassMethods
|
13
|
-
def call(options = {})
|
14
|
-
new(options).call
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/dude/toggl.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'rest-client'
|
2
|
-
require 'date'
|
3
|
-
require_relative 'settings'
|
4
|
-
require_relative 'report'
|
5
|
-
|
6
|
-
module Dude
|
7
|
-
class Toggl
|
8
|
-
include Settings
|
9
|
-
attr_accessor :options
|
10
|
-
|
11
|
-
def initialize(options = {})
|
12
|
-
@options = options
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
def stop_current_time_entry
|
17
|
-
toggl_api["time_entries/#{current_time_entry['id']}/stop"].put ''
|
18
|
-
rescue NoMethodError
|
19
|
-
puts 'No runned time entries in Toggl'.colorize(:yellow)
|
20
|
-
end
|
21
|
-
|
22
|
-
def time_entry_params(title)
|
23
|
-
{
|
24
|
-
time_entry: {
|
25
|
-
description: title,
|
26
|
-
pid: project_id,
|
27
|
-
created_with: "dude"
|
28
|
-
}
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
def toggl_api
|
33
|
-
@toggl_api ||= RestClient::Resource.new(
|
34
|
-
'https://www.toggl.com/api/v8',
|
35
|
-
settings['TOGGL_TOKEN'],
|
36
|
-
'api_token'
|
37
|
-
)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/lib/dude/toggl/base.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
module Dude
|
2
|
-
module Toggl
|
3
|
-
class Base
|
4
|
-
include Service
|
5
|
-
include Settings
|
6
|
-
|
7
|
-
def toggl_api
|
8
|
-
@toggl_api ||= RestClient::Resource.new(
|
9
|
-
'https://www.toggl.com/api/v8',
|
10
|
-
settings['TOGGL_TOKEN'],
|
11
|
-
'api_token'
|
12
|
-
)
|
13
|
-
end
|
14
|
-
|
15
|
-
def toggl_report
|
16
|
-
@toggl_report ||= RestClient::Resource.new(
|
17
|
-
'https://www.toggl.com/reports/api/v2/weekly',
|
18
|
-
settings['TOGGL_TOKEN'],
|
19
|
-
'api_token'
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
def toggl_summary
|
24
|
-
@toggl_summary ||= RestClient::Resource.new(
|
25
|
-
'https://www.toggl.com/reports/api/v2/summary',
|
26
|
-
settings['TOGGL_TOKEN'],
|
27
|
-
'api_token'
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
def projects_response
|
32
|
-
toggl_api["workspaces/#{settings['TOGGL_WORKSPACE_ID']}/projects"].get
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Dude
|
2
|
-
module Toggl
|
3
|
-
class IssueSpendTime < Dude::Toggl::Base
|
4
|
-
def call
|
5
|
-
parse_time_entries_list / 1000
|
6
|
-
end
|
7
|
-
|
8
|
-
def params
|
9
|
-
{
|
10
|
-
workspace_id: settings['TOGGL_WORKSPACE_ID'],
|
11
|
-
user_agent: settings['TOGGL_EMAIL'],
|
12
|
-
since: Date.today.prev_year,
|
13
|
-
until: Date.today.to_s
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
def response
|
18
|
-
toggl_summary.get params: params
|
19
|
-
end
|
20
|
-
|
21
|
-
def time_entries
|
22
|
-
JSON.parse(response.body)['data']
|
23
|
-
end
|
24
|
-
|
25
|
-
def all_project_issues
|
26
|
-
time_entries.find { |project| project['id'].eql? project_id }['items']
|
27
|
-
end
|
28
|
-
|
29
|
-
def current_issue_time_entry
|
30
|
-
all_project_issues.find { |entry| match_issue_id?(entry) }
|
31
|
-
end
|
32
|
-
|
33
|
-
def match_issue_id?(time_entry)
|
34
|
-
title = time_entry.dig('title', 'time_entry')
|
35
|
-
title.match?(/\(##{options[:issue_id]}\)/) ||
|
36
|
-
title.match?(/##{options[:issue_id]}\s/)
|
37
|
-
end
|
38
|
-
|
39
|
-
def parse_time_entries_list
|
40
|
-
current_issue_time_entry['time']
|
41
|
-
end
|
42
|
-
|
43
|
-
def project_id
|
44
|
-
# TODO: Concretize project selection
|
45
|
-
@project_id ||= projects_array.find do |title, id|
|
46
|
-
title.eql?(options[:project_title])
|
47
|
-
end.last
|
48
|
-
end
|
49
|
-
|
50
|
-
def projects_array
|
51
|
-
JSON.parse(projects_response)
|
52
|
-
.map { |a| [a['name'].downcase.gsub(/\s/, '-'), a['id']] }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/lib/dude/toggl/report.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module Dude
|
2
|
-
module Toggl
|
3
|
-
class Report < Dude::Toggl::Base
|
4
|
-
def call
|
5
|
-
Dude::Report.new(parsed_response)
|
6
|
-
end
|
7
|
-
|
8
|
-
def response
|
9
|
-
toggl_report.get params: params
|
10
|
-
end
|
11
|
-
|
12
|
-
def params
|
13
|
-
{
|
14
|
-
workspace_id: settings['TOGGL_WORKSPACE_ID'],
|
15
|
-
user_agent: settings['TOGGL_EMAIL'],
|
16
|
-
since: Date.parse('monday').strftime('%Y-%m-%d')
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
def parsed_response
|
21
|
-
@parsed_response = JSON.parse(response.body)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|