dude-cli 0.5.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +4 -3
  4. data/CHANGELOG.md +25 -0
  5. data/Gemfile +3 -2
  6. data/Gemfile.lock +55 -50
  7. data/README.md +41 -25
  8. data/bin/dude +3 -2
  9. data/dude.gemspec +18 -18
  10. data/lib/dude.rb +12 -2
  11. data/lib/dude/commands.rb +24 -0
  12. data/lib/dude/commands/checkout.rb +21 -0
  13. data/lib/dude/commands/install.rb +57 -0
  14. data/lib/dude/commands/move.rb +15 -0
  15. data/lib/dude/commands/start.rb +29 -0
  16. data/lib/dude/commands/stop.rb +15 -0
  17. data/lib/dude/commands/tasks.rb +31 -0
  18. data/lib/dude/commands/track.rb +28 -0
  19. data/lib/dude/commands/version.rb +11 -0
  20. data/lib/dude/git.rb +3 -18
  21. data/lib/dude/git/checkout.rb +9 -0
  22. data/lib/dude/git/current_branch_name.rb +9 -0
  23. data/lib/dude/project_management/client.rb +25 -0
  24. data/lib/dude/project_management/entities/board.rb +9 -0
  25. data/lib/dude/project_management/entities/issue.rb +37 -0
  26. data/lib/dude/project_management/jira.rb +9 -0
  27. data/lib/dude/project_management/jira/client.rb +49 -0
  28. data/lib/dude/project_management/jira/get_current_tasks.rb +40 -0
  29. data/lib/dude/project_management/jira/get_task_name_by_id.rb +24 -0
  30. data/lib/dude/project_management/jira/move_task_to_list.rb +47 -0
  31. data/lib/dude/project_management/trello.rb +6 -0
  32. data/lib/dude/project_management/trello/checkout.rb +4 -0
  33. data/lib/dude/project_management/trello/client.rb +33 -0
  34. data/lib/dude/project_management/trello/get_current_tasks.rb +24 -0
  35. data/lib/dude/project_management/trello/get_lists.rb +15 -0
  36. data/lib/dude/project_management/trello/move_tasks_to_list.rb +14 -0
  37. data/lib/dude/settings.rb +6 -2
  38. data/lib/dude/time_trackers/toggl.rb +5 -0
  39. data/lib/dude/time_trackers/toggl/base.rb +18 -0
  40. data/lib/dude/time_trackers/toggl/start_time_entry.rb +53 -0
  41. data/lib/dude/time_trackers/toggl/stop_time_entry.rb +30 -0
  42. data/lib/dude/version.rb +1 -1
  43. metadata +59 -90
  44. data/LICENSE.txt +0 -21
  45. data/lib/dude/cli.rb +0 -114
  46. data/lib/dude/gitlab.rb +0 -82
  47. data/lib/dude/interface.rb +0 -98
  48. data/lib/dude/report.rb +0 -38
  49. data/lib/dude/toggl.rb +0 -81
@@ -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
@@ -0,0 +1,53 @@
1
+ require 'dude/time_trackers/toggl/base'
2
+
3
+ module Dude
4
+ module Toggl
5
+ class StartTimeEntry < Dude::Toggl::Base
6
+
7
+ def call(task_title:, project:)
8
+ @task_title = task_title
9
+ @project = project
10
+
11
+ start_time_entry
12
+ print_message
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :task_title, :project
18
+
19
+ def start_time_entry
20
+ toggl_api.post('/api/v8/time_entries/start', time_entry_params(task_title))
21
+ end
22
+
23
+ def time_entry_params(title)
24
+ {
25
+ time_entry: {
26
+ description: title,
27
+ pid: project_id,
28
+ created_with: 'dude'
29
+ }
30
+ }.to_json
31
+ end
32
+
33
+ def project_id
34
+ projects_array.each do |arr|
35
+ return arr.last if arr.first.eql?(project.downcase)
36
+ end
37
+ nil
38
+ end
39
+
40
+ def projects_array
41
+ parsed_response.map { |a| [a['name'].downcase.gsub(/\s/, '-'), a['id']] }
42
+ end
43
+
44
+ def parsed_response
45
+ JSON.parse(projects_response.body)
46
+ end
47
+
48
+ def print_message
49
+ puts "Toggl task '#{task_title}' is started".colorize(:green)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,30 @@
1
+ require 'dude/time_trackers/toggl/base'
2
+
3
+ module Dude
4
+ module Toggl
5
+ class StopTimeEntry < Dude::Toggl::Base
6
+ def call
7
+ stop_current_time_entry
8
+ print_success_message
9
+ rescue NoMethodError
10
+ print_error_message
11
+ end
12
+
13
+ def stop_current_time_entry
14
+ toggl_api.put("api/v8/time_entries/#{current_time_entry['id']}/stop", '')
15
+ end
16
+
17
+ def current_time_entry
18
+ JSON.parse(toggl_api.get('api/v8/time_entries/current').body)['data']
19
+ end
20
+
21
+ def print_success_message
22
+ puts 'Suspended current time entry in Toggl'.colorize(:green)
23
+ end
24
+
25
+ def print_error_message
26
+ puts 'No runned time entries in Toggl'.colorize(:yellow)
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/dude/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dude
2
- VERSION = "0.5.5"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,145 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dude-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Pupko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-20 00:00:00.000000000 Z
11
+ date: 2021-03-10 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
- - - "~>"
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
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
17
+ - - ">="
53
18
  - !ruby/object:Gem::Version
54
- version: '9.1'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
69
- - !ruby/object:Gem::Dependency
70
- name: thor
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.20'
19
+ version: '0.6'
76
20
  type: :runtime
77
21
  prerelease: false
78
22
  version_requirements: !ruby/object:Gem::Requirement
79
23
  requirements:
80
- - - "~>"
24
+ - - ">="
81
25
  - !ruby/object:Gem::Version
82
- version: '0.20'
26
+ version: '0.6'
83
27
  - !ruby/object:Gem::Dependency
84
- name: colorize
28
+ name: faraday
85
29
  requirement: !ruby/object:Gem::Requirement
86
30
  requirements:
87
31
  - - "~>"
88
32
  - !ruby/object:Gem::Version
89
- version: '0.8'
33
+ version: '1.1'
90
34
  type: :runtime
91
35
  prerelease: false
92
36
  version_requirements: !ruby/object:Gem::Requirement
93
37
  requirements:
94
38
  - - "~>"
95
39
  - !ruby/object:Gem::Version
96
- version: '0.8'
40
+ version: '1.1'
97
41
  - !ruby/object:Gem::Dependency
98
- name: gitlab
42
+ name: colorize
99
43
  requirement: !ruby/object:Gem::Requirement
100
44
  requirements:
101
45
  - - "~>"
102
46
  - !ruby/object:Gem::Version
103
- version: '4.3'
47
+ version: 0.8.1
104
48
  type: :runtime
105
49
  prerelease: false
106
50
  version_requirements: !ruby/object:Gem::Requirement
107
51
  requirements:
108
52
  - - "~>"
109
53
  - !ruby/object:Gem::Version
110
- version: '4.3'
54
+ version: 0.8.1
111
55
  - !ruby/object:Gem::Dependency
112
- name: git
56
+ name: jira-ruby
113
57
  requirement: !ruby/object:Gem::Requirement
114
58
  requirements:
115
59
  - - "~>"
116
60
  - !ruby/object:Gem::Version
117
- version: '1.3'
61
+ version: '2.1'
118
62
  type: :runtime
119
63
  prerelease: false
120
64
  version_requirements: !ruby/object:Gem::Requirement
121
65
  requirements:
122
66
  - - "~>"
123
67
  - !ruby/object:Gem::Version
124
- version: '1.3'
68
+ version: '2.1'
125
69
  - !ruby/object:Gem::Dependency
126
- name: rest-client
70
+ name: pry
127
71
  requirement: !ruby/object:Gem::Requirement
128
72
  requirements:
129
73
  - - "~>"
130
74
  - !ruby/object:Gem::Version
131
- version: '2.0'
132
- type: :runtime
75
+ version: 0.13.1
76
+ type: :development
133
77
  prerelease: false
134
78
  version_requirements: !ruby/object:Gem::Requirement
135
79
  requirements:
136
80
  - - "~>"
137
81
  - !ruby/object:Gem::Version
138
- version: '2.0'
82
+ version: 0.13.1
139
83
  description: This program helps to combine such services as Gitlab, Toggl and git
140
84
  and replace most routine activities with one simple CLI utility.
141
85
  email:
142
- - lazynick7@gmail.com
86
+ - work.pupko@gmail.com
143
87
  executables:
144
88
  - dude
145
89
  extensions: []
@@ -148,9 +92,9 @@ files:
148
92
  - ".gitignore"
149
93
  - ".rspec"
150
94
  - ".travis.yml"
95
+ - CHANGELOG.md
151
96
  - Gemfile
152
97
  - Gemfile.lock
153
- - LICENSE.txt
154
98
  - README.md
155
99
  - Rakefile
156
100
  - bin/console
@@ -158,18 +102,44 @@ files:
158
102
  - bin/setup
159
103
  - dude.gemspec
160
104
  - lib/dude.rb
161
- - lib/dude/cli.rb
105
+ - lib/dude/commands.rb
106
+ - lib/dude/commands/checkout.rb
107
+ - lib/dude/commands/install.rb
108
+ - lib/dude/commands/move.rb
109
+ - lib/dude/commands/start.rb
110
+ - lib/dude/commands/stop.rb
111
+ - lib/dude/commands/tasks.rb
112
+ - lib/dude/commands/track.rb
113
+ - lib/dude/commands/version.rb
162
114
  - lib/dude/git.rb
163
- - lib/dude/gitlab.rb
164
- - lib/dude/interface.rb
165
- - lib/dude/report.rb
115
+ - lib/dude/git/checkout.rb
116
+ - lib/dude/git/current_branch_name.rb
117
+ - lib/dude/project_management/client.rb
118
+ - lib/dude/project_management/entities/board.rb
119
+ - lib/dude/project_management/entities/issue.rb
120
+ - lib/dude/project_management/jira.rb
121
+ - lib/dude/project_management/jira/client.rb
122
+ - lib/dude/project_management/jira/get_current_tasks.rb
123
+ - lib/dude/project_management/jira/get_task_name_by_id.rb
124
+ - lib/dude/project_management/jira/move_task_to_list.rb
125
+ - lib/dude/project_management/trello.rb
126
+ - lib/dude/project_management/trello/checkout.rb
127
+ - lib/dude/project_management/trello/client.rb
128
+ - lib/dude/project_management/trello/get_current_tasks.rb
129
+ - lib/dude/project_management/trello/get_lists.rb
130
+ - lib/dude/project_management/trello/move_tasks_to_list.rb
166
131
  - lib/dude/settings.rb
167
- - lib/dude/toggl.rb
132
+ - lib/dude/time_trackers/toggl.rb
133
+ - lib/dude/time_trackers/toggl/base.rb
134
+ - lib/dude/time_trackers/toggl/start_time_entry.rb
135
+ - lib/dude/time_trackers/toggl/stop_time_entry.rb
168
136
  - lib/dude/version.rb
169
- homepage: https://github.com/Random4405/dude
170
- licenses:
171
- - MIT
172
- metadata: {}
137
+ homepage: https://github.com/npupko/dude
138
+ licenses: []
139
+ metadata:
140
+ homepage_uri: https://github.com/npupko/dude
141
+ source_code_uri: https://github.com/npupko/dude
142
+ changelog_uri: https://github.com/npupko/dude/blob/master/CHANGELOG.md
173
143
  post_install_message:
174
144
  rdoc_options: []
175
145
  require_paths:
@@ -178,15 +148,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
148
  requirements:
179
149
  - - ">="
180
150
  - !ruby/object:Gem::Version
181
- version: 2.2.0
151
+ version: 2.3.0
182
152
  required_rubygems_version: !ruby/object:Gem::Requirement
183
153
  requirements:
184
154
  - - ">="
185
155
  - !ruby/object:Gem::Version
186
156
  version: '0'
187
157
  requirements: []
188
- rubyforge_project:
189
- rubygems_version: 2.7.3
158
+ rubygems_version: 3.1.4
190
159
  signing_key:
191
160
  specification_version: 4
192
161
  summary: A daily assistant in the hard work of a programmer.