dude-cli 1.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +8 -0
  3. data/.gitignore +0 -1
  4. data/.travis.yml +4 -3
  5. data/CHANGELOG.md +25 -0
  6. data/Gemfile +0 -2
  7. data/Gemfile.lock +57 -50
  8. data/README.md +41 -25
  9. data/bin/dude +3 -2
  10. data/dude.gemspec +21 -19
  11. data/lib/dude.rb +14 -0
  12. data/lib/dude/commands.rb +24 -0
  13. data/lib/dude/commands/checkout.rb +21 -0
  14. data/lib/dude/commands/install.rb +57 -0
  15. data/lib/dude/commands/move.rb +15 -0
  16. data/lib/dude/commands/start.rb +29 -0
  17. data/lib/dude/commands/stop.rb +15 -0
  18. data/lib/dude/commands/tasks.rb +31 -0
  19. data/lib/dude/commands/track.rb +28 -0
  20. data/lib/dude/commands/version.rb +11 -0
  21. data/lib/dude/git.rb +5 -0
  22. data/lib/dude/git/checkout.rb +2 -16
  23. data/lib/dude/git/current_branch_name.rb +1 -2
  24. data/lib/dude/project_management/client.rb +25 -0
  25. data/lib/dude/project_management/entities/board.rb +9 -0
  26. data/lib/dude/project_management/entities/issue.rb +37 -0
  27. data/lib/dude/project_management/jira.rb +9 -0
  28. data/lib/dude/project_management/jira/client.rb +49 -0
  29. data/lib/dude/project_management/jira/get_current_tasks.rb +40 -0
  30. data/lib/dude/project_management/jira/get_task_name_by_id.rb +24 -0
  31. data/lib/dude/project_management/jira/move_task_to_list.rb +47 -0
  32. data/lib/dude/project_management/trello.rb +6 -0
  33. data/lib/dude/project_management/trello/checkout.rb +4 -0
  34. data/lib/dude/project_management/trello/client.rb +33 -0
  35. data/lib/dude/project_management/trello/get_current_tasks.rb +24 -0
  36. data/lib/dude/project_management/trello/get_lists.rb +15 -0
  37. data/lib/dude/project_management/trello/move_tasks_to_list.rb +14 -0
  38. data/lib/dude/settings.rb +6 -2
  39. data/lib/dude/time_trackers/toggl.rb +5 -0
  40. data/lib/dude/time_trackers/toggl/base.rb +18 -0
  41. data/lib/dude/{toggl → time_trackers/toggl}/start_time_entry.rb +14 -8
  42. data/lib/dude/{toggl → time_trackers/toggl}/stop_time_entry.rb +4 -2
  43. data/lib/dude/version.rb +1 -1
  44. metadata +72 -89
  45. data/LICENSE.txt +0 -21
  46. data/lib/dude/cli.rb +0 -156
  47. data/lib/dude/gitlab/add_spend_time.rb +0 -36
  48. data/lib/dude/gitlab/base.rb +0 -38
  49. data/lib/dude/gitlab/count_spend_time.rb +0 -13
  50. data/lib/dude/gitlab/estimate.rb +0 -20
  51. data/lib/dude/gitlab/get_issue_info.rb +0 -9
  52. data/lib/dude/gitlab/get_issue_time_spent.rb +0 -9
  53. data/lib/dude/gitlab/get_issue_title.rb +0 -14
  54. data/lib/dude/gitlab/get_my_issues.rb +0 -31
  55. data/lib/dude/gitlab/move_issue.rb +0 -37
  56. data/lib/dude/interface.rb +0 -98
  57. data/lib/dude/report.rb +0 -38
  58. data/lib/dude/service.rb +0 -18
  59. data/lib/dude/toggl.rb +0 -40
  60. data/lib/dude/toggl/base.rb +0 -28
  61. data/lib/dude/toggl/issue_spend_time.rb +0 -59
  62. data/lib/dude/toggl/report.rb +0 -25
@@ -0,0 +1,4 @@
1
+ # TODO
2
+ response = client.get("/1/boards/#{BOARD_ID}/cards/#{id}")
3
+ extracted_branch_name = JSON.parse(response.body).dig('url').rpartition('/').last
4
+ Git::Checkout.new.call(extracted_branch_name)
@@ -0,0 +1,33 @@
1
+ # TODO
2
+
3
+ require 'faraday'
4
+ require 'json'
5
+
6
+ module Dude
7
+ module Trello
8
+ class Client
9
+ private
10
+
11
+ def faraday_client
12
+ @faraday_client ||= Faraday.new('https://api.trello.com/', {
13
+ params: {
14
+ key: "62b20e9eeab2d6e06145c69178521225",
15
+ token: "6285fc2d2ff6100a5c341838d0e4acfed3601ae503beb973ddccf1cfab088537"
16
+ }
17
+ })
18
+ end
19
+
20
+ def method_missing(method, *args, &block)
21
+ faraday_client.send(method, *args, &block)
22
+ end
23
+
24
+ def get_current_tasks
25
+ GetCurrentTasks.new(client).call
26
+ end
27
+
28
+ def move_task_to_list(id, list)
29
+ MoveTasksToList.new(client, id: id, list_name: list).call
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ # TODO
2
+ module Dude
3
+ module ProjectManagement
4
+ module Trello
5
+ class GetCurrentTasks
6
+
7
+ def initialize
8
+ client = Trello::Client.new
9
+
10
+ response = client.get("/1/lists/#{TODO_LIST_ID}/cards", { fields: 'name,idShort' })
11
+
12
+ body = JSON.parse(response.body)
13
+
14
+ puts "To Do list\n".green.bold
15
+
16
+ body.map do |issue|
17
+ binding.pry
18
+ Entities::Issue.new(id: card['idShort'], title: card['name'], description: issue.description, status: issue.status.name)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ # TODO
2
+ module Dude
3
+ module Trello
4
+ class GetLists < Dry::CLI::Command
5
+ desc "Get board lists"
6
+
7
+ def call
8
+ client = Trello::Client.new
9
+ response = client.get "/1/boards/#{BOARD_ID}/lists"
10
+ body = JSON.parse(response.body)
11
+ puts body
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ # TODO
2
+ module Dude
3
+ module Trello
4
+ class MoveTasksToList < Dry::CLI::Command
5
+ desc "Get board lists"
6
+
7
+ def call
8
+ # response = client.get("/1/boards/#{BOARD_ID}/cards/#{id}", { fields: 'id' })
9
+ # card_id = JSON.parse(response.body).dig('id')
10
+ # client.put("/1/cards/#{card_id}", { idList: selected_list(list) })
11
+ end
12
+ end
13
+ end
14
+ end
data/lib/dude/settings.rb CHANGED
@@ -3,10 +3,14 @@ module Dude
3
3
  CONFIG_FILE = '.duderc'
4
4
 
5
5
  def settings
6
- @settings ||= read(file).strip.split("\n").
7
- map {|a| a.split('=').map(&:strip) }.to_h
6
+ @settings ||= read(file).strip.split("\n").map do |line|
7
+ next if line =~ /^#/ || line.empty?
8
+ line.split('=').map(&:strip)
9
+ end.compact.to_h
8
10
  end
9
11
 
12
+ private
13
+
10
14
  def file
11
15
  @file = File.join(Dir.home, CONFIG_FILE)
12
16
  end
@@ -0,0 +1,5 @@
1
+ require_relative './toggl/base'
2
+ require_relative './toggl/start_time_entry'
3
+
4
+ module Toggl
5
+ end
@@ -0,0 +1,18 @@
1
+ module Dude
2
+ module Toggl
3
+ class Base
4
+ include Settings
5
+
6
+ def toggl_api
7
+ Faraday.new('https://api.track.toggl.com') do |conn|
8
+ conn.basic_auth settings['TOGGL_TOKEN'], 'api_token'
9
+ conn.headers['Content-Type'] = 'application/json'
10
+ end
11
+ end
12
+
13
+ def projects_response
14
+ toggl_api.get("/api/v8/workspaces/#{settings['TOGGL_WORKSPACE_ID']}/projects")
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,17 +1,23 @@
1
+ require 'dude/time_trackers/toggl/base'
2
+
1
3
  module Dude
2
4
  module Toggl
3
5
  class StartTimeEntry < Dude::Toggl::Base
4
6
 
5
- def call
7
+ def call(task_title:, project:)
8
+ @task_title = task_title
9
+ @project = project
10
+
6
11
  start_time_entry
7
12
  print_message
8
13
  end
9
14
 
15
+ private
16
+
17
+ attr_reader :task_title, :project
18
+
10
19
  def start_time_entry
11
- toggl_api['time_entries/start'].post(
12
- time_entry_params(options[:title]),
13
- content_type: :json
14
- )
20
+ toggl_api.post('/api/v8/time_entries/start', time_entry_params(task_title))
15
21
  end
16
22
 
17
23
  def time_entry_params(title)
@@ -26,7 +32,7 @@ module Dude
26
32
 
27
33
  def project_id
28
34
  projects_array.each do |arr|
29
- return arr.last if arr.first.eql?(options[:project_title])
35
+ return arr.last if arr.first.eql?(project.downcase)
30
36
  end
31
37
  nil
32
38
  end
@@ -36,11 +42,11 @@ module Dude
36
42
  end
37
43
 
38
44
  def parsed_response
39
- JSON.parse(projects_response)
45
+ JSON.parse(projects_response.body)
40
46
  end
41
47
 
42
48
  def print_message
43
- puts "Toggl task '#{options[:title]}' is started".colorize(:green)
49
+ puts "Toggl task '#{task_title}' is started".colorize(:green)
44
50
  end
45
51
  end
46
52
  end
@@ -1,3 +1,5 @@
1
+ require 'dude/time_trackers/toggl/base'
2
+
1
3
  module Dude
2
4
  module Toggl
3
5
  class StopTimeEntry < Dude::Toggl::Base
@@ -9,11 +11,11 @@ module Dude
9
11
  end
10
12
 
11
13
  def stop_current_time_entry
12
- toggl_api["time_entries/#{current_time_entry['id']}/stop"].put ''
14
+ toggl_api.put("api/v8/time_entries/#{current_time_entry['id']}/stop", '')
13
15
  end
14
16
 
15
17
  def current_time_entry
16
- JSON.parse(toggl_api['time_entries/current'].get)['data']
18
+ JSON.parse(toggl_api.get('api/v8/time_entries/current').body)['data']
17
19
  end
18
20
 
19
21
  def print_success_message
data/lib/dude/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dude
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.2"
3
3
  end
metadata CHANGED
@@ -1,156 +1,129 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dude-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Pupko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-21 00:00:00.000000000 Z
11
+ date: 2021-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: dry-cli
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.16'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: byebug
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '9.1'
48
- type: :development
19
+ version: '0.6'
20
+ type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - "~>"
53
25
  - !ruby/object:Gem::Version
54
- version: '9.1'
26
+ version: '0.6'
55
27
  - !ruby/object:Gem::Dependency
56
- name: rspec
28
+ name: faraday
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - "~>"
60
32
  - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
33
+ version: '1.1'
34
+ type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
38
  - - "~>"
67
39
  - !ruby/object:Gem::Version
68
- version: '3.0'
40
+ version: '1.1'
69
41
  - !ruby/object:Gem::Dependency
70
- name: thor
42
+ name: colorize
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - "~>"
74
46
  - !ruby/object:Gem::Version
75
- version: '0.20'
47
+ version: 0.8.1
76
48
  type: :runtime
77
49
  prerelease: false
78
50
  version_requirements: !ruby/object:Gem::Requirement
79
51
  requirements:
80
52
  - - "~>"
81
53
  - !ruby/object:Gem::Version
82
- version: '0.20'
54
+ version: 0.8.1
83
55
  - !ruby/object:Gem::Dependency
84
- name: colorize
56
+ name: jira-ruby
85
57
  requirement: !ruby/object:Gem::Requirement
86
58
  requirements:
87
59
  - - "~>"
88
60
  - !ruby/object:Gem::Version
89
- version: '0.8'
61
+ version: '2.1'
90
62
  type: :runtime
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: '0.8'
68
+ version: '2.1'
97
69
  - !ruby/object:Gem::Dependency
98
- name: gitlab
70
+ name: pry
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - "~>"
102
74
  - !ruby/object:Gem::Version
103
- version: '4.3'
104
- type: :runtime
75
+ version: 0.14.0
76
+ type: :development
105
77
  prerelease: false
106
78
  version_requirements: !ruby/object:Gem::Requirement
107
79
  requirements:
108
80
  - - "~>"
109
81
  - !ruby/object:Gem::Version
110
- version: '4.3'
82
+ version: 0.14.0
111
83
  - !ruby/object:Gem::Dependency
112
- name: git
84
+ name: rake
113
85
  requirement: !ruby/object:Gem::Requirement
114
86
  requirements:
115
87
  - - "~>"
116
88
  - !ruby/object:Gem::Version
117
- version: '1.3'
118
- type: :runtime
89
+ version: '13.0'
90
+ type: :development
119
91
  prerelease: false
120
92
  version_requirements: !ruby/object:Gem::Requirement
121
93
  requirements:
122
94
  - - "~>"
123
95
  - !ruby/object:Gem::Version
124
- version: '1.3'
96
+ version: '13.0'
125
97
  - !ruby/object:Gem::Dependency
126
- name: rest-client
98
+ name: rspec
127
99
  requirement: !ruby/object:Gem::Requirement
128
100
  requirements:
129
101
  - - "~>"
130
102
  - !ruby/object:Gem::Version
131
- version: '2.0'
132
- type: :runtime
103
+ version: '3.0'
104
+ type: :development
133
105
  prerelease: false
134
106
  version_requirements: !ruby/object:Gem::Requirement
135
107
  requirements:
136
108
  - - "~>"
137
109
  - !ruby/object:Gem::Version
138
- version: '2.0'
139
- description: This program helps to combine such services as Gitlab, Toggl and git
140
- and replace most routine activities with one simple CLI utility.
110
+ version: '3.0'
111
+ description: This program helps to combine such services as Jira, Toggl and git and
112
+ replace most routine activities with one simple CLI utility.
141
113
  email:
142
- - lazynick7@gmail.com
114
+ - work.pupko@gmail.com
143
115
  executables:
144
116
  - dude
145
117
  extensions: []
146
118
  extra_rdoc_files: []
147
119
  files:
120
+ - ".github/dependabot.yml"
148
121
  - ".gitignore"
149
122
  - ".rspec"
150
123
  - ".travis.yml"
124
+ - CHANGELOG.md
151
125
  - Gemfile
152
126
  - Gemfile.lock
153
- - LICENSE.txt
154
127
  - README.md
155
128
  - Rakefile
156
129
  - bin/console
@@ -158,34 +131,45 @@ files:
158
131
  - bin/setup
159
132
  - dude.gemspec
160
133
  - lib/dude.rb
161
- - lib/dude/cli.rb
134
+ - lib/dude/commands.rb
135
+ - lib/dude/commands/checkout.rb
136
+ - lib/dude/commands/install.rb
137
+ - lib/dude/commands/move.rb
138
+ - lib/dude/commands/start.rb
139
+ - lib/dude/commands/stop.rb
140
+ - lib/dude/commands/tasks.rb
141
+ - lib/dude/commands/track.rb
142
+ - lib/dude/commands/version.rb
143
+ - lib/dude/git.rb
162
144
  - lib/dude/git/checkout.rb
163
145
  - lib/dude/git/current_branch_name.rb
164
- - lib/dude/gitlab/add_spend_time.rb
165
- - lib/dude/gitlab/base.rb
166
- - lib/dude/gitlab/count_spend_time.rb
167
- - lib/dude/gitlab/estimate.rb
168
- - lib/dude/gitlab/get_issue_info.rb
169
- - lib/dude/gitlab/get_issue_time_spent.rb
170
- - lib/dude/gitlab/get_issue_title.rb
171
- - lib/dude/gitlab/get_my_issues.rb
172
- - lib/dude/gitlab/move_issue.rb
173
- - lib/dude/interface.rb
174
- - lib/dude/report.rb
175
- - lib/dude/service.rb
146
+ - lib/dude/project_management/client.rb
147
+ - lib/dude/project_management/entities/board.rb
148
+ - lib/dude/project_management/entities/issue.rb
149
+ - lib/dude/project_management/jira.rb
150
+ - lib/dude/project_management/jira/client.rb
151
+ - lib/dude/project_management/jira/get_current_tasks.rb
152
+ - lib/dude/project_management/jira/get_task_name_by_id.rb
153
+ - lib/dude/project_management/jira/move_task_to_list.rb
154
+ - lib/dude/project_management/trello.rb
155
+ - lib/dude/project_management/trello/checkout.rb
156
+ - lib/dude/project_management/trello/client.rb
157
+ - lib/dude/project_management/trello/get_current_tasks.rb
158
+ - lib/dude/project_management/trello/get_lists.rb
159
+ - lib/dude/project_management/trello/move_tasks_to_list.rb
176
160
  - lib/dude/settings.rb
177
- - lib/dude/toggl.rb
178
- - lib/dude/toggl/base.rb
179
- - lib/dude/toggl/issue_spend_time.rb
180
- - lib/dude/toggl/report.rb
181
- - lib/dude/toggl/start_time_entry.rb
182
- - lib/dude/toggl/stop_time_entry.rb
161
+ - lib/dude/time_trackers/toggl.rb
162
+ - lib/dude/time_trackers/toggl/base.rb
163
+ - lib/dude/time_trackers/toggl/start_time_entry.rb
164
+ - lib/dude/time_trackers/toggl/stop_time_entry.rb
183
165
  - lib/dude/version.rb
184
- homepage: https://github.com/Random4405/dude
185
- licenses:
186
- - MIT
187
- metadata: {}
188
- post_install_message:
166
+ homepage: https://github.com/npupko/dude
167
+ licenses: []
168
+ metadata:
169
+ homepage_uri: https://github.com/npupko/dude
170
+ source_code_uri: https://github.com/npupko/dude
171
+ changelog_uri: https://github.com/npupko/dude/blob/master/CHANGELOG.md
172
+ post_install_message:
189
173
  rdoc_options: []
190
174
  require_paths:
191
175
  - lib
@@ -193,16 +177,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
177
  requirements:
194
178
  - - ">="
195
179
  - !ruby/object:Gem::Version
196
- version: 2.2.0
180
+ version: 2.3.0
197
181
  required_rubygems_version: !ruby/object:Gem::Requirement
198
182
  requirements:
199
183
  - - ">="
200
184
  - !ruby/object:Gem::Version
201
185
  version: '0'
202
186
  requirements: []
203
- rubyforge_project:
204
- rubygems_version: 2.7.3
205
- signing_key:
187
+ rubygems_version: 3.1.4
188
+ signing_key:
206
189
  specification_version: 4
207
190
  summary: A daily assistant in the hard work of a programmer.
208
191
  test_files: []