dude-cli 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1b1363a91b57a06932df8d4b80be8b7a709e694
4
- data.tar.gz: 9e65b6ffa950cfd5c4a14e53872040385cb06a88
3
+ metadata.gz: 94e6437616a753a65881406ba1ff48d589adb3c2
4
+ data.tar.gz: 79f21de88cba3c52642dcb49d9955a7da823fee2
5
5
  SHA512:
6
- metadata.gz: 54999e8a1a98d83a94fb3442bc98d06101a54836426b0e5f22e1b3eed4dcfc1035568920b921ddd60b81b00fecfd36763e35b55cb8006653342e91cb56fa15f3
7
- data.tar.gz: f65cb5832180d149fde8d9af81a24468c2fdf747c7174c6ce55ab0f80ce39d9091efbf1ee919975822ca5a9b8aecdcd642d6b6720e50a62c0e3e7e267315eeac
6
+ metadata.gz: fafe9d6d4eba6c8ef9f4ee2543f0da5f0b3573b40e79f95f84c845e0edb74587325ed17d5ec90a39f35e37d0370416aa3b4c27f14702b8b1964ca08fe30a60c2
7
+ data.tar.gz: 8c0c06316e8286b2e861461e3bcdcd5c54ce0be92fb9d66db5602867d24c32633f3619e389f3f1e2b14c33bfec00ba7ac7e6dc9075026e0d2bb21e4f8da290b6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dude-cli (0.2.4)
4
+ dude-cli (0.4.0)
5
5
  colorize (~> 0.8)
6
6
  git (~> 1.3)
7
7
  gitlab (~> 4.2)
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
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dude`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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/[USERNAME]/dude.
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
@@ -67,7 +67,7 @@ module Dude
67
67
  end
68
68
 
69
69
  def get_issue_title(issue_id, project_title)
70
- Gitlab.new(issue_id: issue_id, project_title: project_title).call
70
+ Gitlab.new(issue_id: issue_id, project_title: project_title).issue_title
71
71
  end
72
72
 
73
73
  def duderc_file_content
data/lib/dude/gitlab.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'gitlab'
2
- require 'rest-client'
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 call
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
- ::Gitlab.issues(project_id).select.map {|a| [a.iid, a.title, a.labels]}
25
+ all_issues_on_project.select {|a| a.last.eql?(user.id) }
29
26
  end
30
27
 
31
28
  def estimate_time(duration)
32
- issue_resource['time_estimate'].post duration: duration
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
- issue_info = JSON.parse(issue_resource.get.body)
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 issue_link
43
- @issue_link ||= ::Gitlab.issue(project_id, options[:issue_id])._links.self.gsub(/http/, 'https')
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 issue_resource
47
- @issue_resource ||= RestClient::Resource.new(issue_link, headers: { 'PRIVATE-TOKEN': settings['GITLAB_TOKEN'] })
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].id
65
+ @project_id ||= ::Gitlab.project_search(options[:project_title])[0]&.id
52
66
  end
53
67
  end
54
68
  end
@@ -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.last.include?(group)}
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
@@ -1,3 +1,3 @@
1
1
  module Dude
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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-04 00:00:00.000000000 Z
11
+ date: 2018-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler