dude-cli 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +29 -9
- data/lib/dude/cli.rb +1 -1
- data/lib/dude/gitlab.rb +28 -14
- data/lib/dude/interface.rb +12 -1
- data/lib/dude/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94e6437616a753a65881406ba1ff48d589adb3c2
|
4
|
+
data.tar.gz: 79f21de88cba3c52642dcb49d9955a7da823fee2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fafe9d6d4eba6c8ef9f4ee2543f0da5f0b3573b40e79f95f84c845e0edb74587325ed17d5ec90a39f35e37d0370416aa3b4c27f14702b8b1964ca08fe30a60c2
|
7
|
+
data.tar.gz: 8c0c06316e8286b2e861461e3bcdcd5c54ce0be92fb9d66db5602867d24c32633f3619e389f3f1e2b14c33bfec00ba7ac7e6dc9075026e0d2bb21e4f8da290b6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
# Dude
|
1
|
+
# Dude [![Gem Version](https://badge.fury.io/rb/dude-cli.svg)](https://badge.fury.io/rb/dude-cli)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
A daily assistant in the hard work of a programmer
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -20,19 +18,41 @@ Or install it yourself as:
|
|
20
18
|
|
21
19
|
$ gem install dude-cli
|
22
20
|
|
21
|
+
After that create .duderc file in your HOME directory by command:
|
22
|
+
|
23
|
+
$ dude install
|
24
|
+
|
25
|
+
And configure all variables in this file
|
26
|
+
|
27
|
+
`TOGGL_EMAIL` - Your email, registered in Toggl
|
28
|
+
|
29
|
+
`TOGGL_TOKEN=` - Your Toggl [token](https://toggl.com/app/profile)
|
30
|
+
|
31
|
+
`TOGGL_WORKSPACE_ID` - Your Toggl Workspace ID (You can find it in Toggl [team](https://toggl.com/app/team) or [projects](https://toggl.com/app/projects/) url)
|
32
|
+
|
33
|
+
`GITLAB_ENDPOINT=https://gitlab.yoursite.com/api/v4/` - Change yoursite.com to your site
|
34
|
+
|
35
|
+
`GITLAB_TOKEN=imyiKqwsQBbn1zCMY2PJ` - Your Gitlab token (<https://gitlab.yoursite.com/profile/personal_access_tokens>)
|
36
|
+
|
37
|
+
`HOURS_PER_DAY=8` - Work hours per day
|
38
|
+
|
39
|
+
`HOURS_PER_WEEK=40` - Work hours per week
|
40
|
+
|
23
41
|
## Usage
|
24
42
|
|
25
|
-
|
43
|
+
All commands will be described here later, but how you can use `dude help` for short description of every command.
|
44
|
+
|
45
|
+
<!-- TODO: Write usage instructions here -->
|
26
46
|
|
27
|
-
## Development
|
47
|
+
<!-- ## Development -->
|
28
48
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
49
|
+
<!-- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. -->
|
30
50
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
51
|
+
<!-- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). -->
|
32
52
|
|
33
53
|
## Contributing
|
34
54
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Random4405/dude.
|
36
56
|
|
37
57
|
## License
|
38
58
|
|
data/lib/dude/cli.rb
CHANGED
data/lib/dude/gitlab.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'gitlab'
|
2
|
-
require '
|
2
|
+
require 'colorize'
|
3
3
|
require_relative 'settings'
|
4
4
|
require_relative 'interface'
|
5
5
|
|
@@ -16,39 +16,53 @@ module Dude
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def issue_title
|
20
|
+
test_input_data
|
20
21
|
::Gitlab.issue(project_id, options[:issue_id]).title
|
21
|
-
rescue StandardError
|
22
|
-
puts "Issue ##{options[:issue_id]} not found " \
|
23
|
-
"in project #{options[:project_title]}\n" \
|
24
|
-
"Please, check the entered issue_id and project"
|
25
22
|
end
|
26
23
|
|
27
24
|
def my_issues
|
28
|
-
|
25
|
+
all_issues_on_project.select {|a| a.last.eql?(user.id) }
|
29
26
|
end
|
30
27
|
|
31
28
|
def estimate_time(duration)
|
32
|
-
|
29
|
+
test_input_data
|
30
|
+
::Gitlab.estimate_time_of_issue(project_id, options[:issue_id], duration)
|
31
|
+
time = ::Gitlab.issue(project_id, options[:issue_id]).
|
32
|
+
to_h['time_stats']['human_time_estimate']
|
33
|
+
Interface.new.draw_time_estimate(time)
|
33
34
|
end
|
34
35
|
|
35
36
|
def issue_info
|
36
|
-
|
37
|
+
test_input_data
|
38
|
+
issue_info = ::Gitlab.issue(project_id, options[:issue_id]).to_h
|
37
39
|
Interface.new.draw_issue_info(issue_info)
|
38
40
|
end
|
39
41
|
|
40
42
|
private
|
41
43
|
|
42
|
-
def
|
43
|
-
|
44
|
+
def test_input_data
|
45
|
+
if options[:issue_id].to_i.zero? || !issue_exists?
|
46
|
+
Interface.new.throw_error(options[:issue_id], options[:project_title])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def issue_exists?
|
51
|
+
!::Gitlab.issue(project_id, options[:issue_id]).nil?
|
52
|
+
rescue
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def all_issues_on_project
|
57
|
+
::Gitlab.issues(project_id).map {|a| [a.iid, a.title, a.labels, a.assignee&.id]}
|
44
58
|
end
|
45
59
|
|
46
|
-
def
|
47
|
-
@
|
60
|
+
def user
|
61
|
+
@my_id ||= ::Gitlab.user
|
48
62
|
end
|
49
63
|
|
50
64
|
def project_id
|
51
|
-
@project_id ||= ::Gitlab.project_search(options[:project_title])[0]
|
65
|
+
@project_id ||= ::Gitlab.project_search(options[:project_title])[0]&.id
|
52
66
|
end
|
53
67
|
end
|
54
68
|
end
|
data/lib/dude/interface.rb
CHANGED
@@ -11,6 +11,17 @@ module Dude
|
|
11
11
|
puts ''
|
12
12
|
report_daily
|
13
13
|
end
|
14
|
+
|
15
|
+
def throw_error(issue_id, project_title)
|
16
|
+
puts "Something went wrong. Please, check input data\n".colorize(:red) +
|
17
|
+
"Project: #{project_title.to_s.bold}\n" +
|
18
|
+
"Issue ID: #{issue_id.to_s.bold}"
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
def draw_time_estimate(time)
|
23
|
+
puts "Changed time estimate to #{time.colorize(:green)}"
|
24
|
+
end
|
14
25
|
|
15
26
|
def draw_issue_info(info)
|
16
27
|
issue_label = info['labels'].find do |label|
|
@@ -38,7 +49,7 @@ module Dude
|
|
38
49
|
def issues_list(issues)
|
39
50
|
[['To Do', :yellow], ['Doing', :green], ['To Verify', :blue]].each do |group, color|
|
40
51
|
puts "#{group}:".colorize(color).bold
|
41
|
-
grouped = issues.select {|i| i.
|
52
|
+
grouped = issues.select {|i| i[2].include?(group)}
|
42
53
|
if grouped.length.zero?
|
43
54
|
puts 'Nothing'
|
44
55
|
else
|
data/lib/dude/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dude-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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-01-
|
11
|
+
date: 2018-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|