dude-cli 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/verify.yml +32 -0
  3. data/.rubocop.yml +9 -0
  4. data/CHANGELOG.md +7 -3
  5. data/Gemfile +3 -1
  6. data/Gemfile.lock +33 -1
  7. data/LICENCE +20 -0
  8. data/README.md +12 -4
  9. data/Rakefile +5 -3
  10. data/bin/console +4 -3
  11. data/bin/dude +2 -1
  12. data/dude.gemspec +25 -18
  13. data/lib/dude.rb +8 -6
  14. data/lib/dude/commands.rb +19 -17
  15. data/lib/dude/commands/checkout.rb +4 -2
  16. data/lib/dude/commands/install.rb +7 -5
  17. data/lib/dude/commands/move.rb +5 -3
  18. data/lib/dude/commands/start.rb +4 -2
  19. data/lib/dude/commands/stop.rb +4 -2
  20. data/lib/dude/commands/tasks.rb +6 -3
  21. data/lib/dude/commands/track.rb +5 -3
  22. data/lib/dude/commands/version.rb +3 -1
  23. data/lib/dude/git.rb +2 -0
  24. data/lib/dude/git/checkout.rb +20 -1
  25. data/lib/dude/git/current_branch_name.rb +3 -1
  26. data/lib/dude/project_management/client.rb +6 -3
  27. data/lib/dude/project_management/entities/board.rb +2 -1
  28. data/lib/dude/project_management/entities/issue.rb +3 -1
  29. data/lib/dude/project_management/jira.rb +2 -1
  30. data/lib/dude/project_management/jira/client.rb +9 -7
  31. data/lib/dude/project_management/jira/fetch_current_tasks.rb +47 -0
  32. data/lib/dude/project_management/jira/get_task_name_by_id.rb +1 -1
  33. data/lib/dude/project_management/jira/move_task_to_list.rb +15 -13
  34. data/lib/dude/settings.rb +3 -0
  35. data/lib/dude/time_trackers/toggl.rb +2 -0
  36. data/lib/dude/time_trackers/toggl/base.rb +2 -0
  37. data/lib/dude/time_trackers/toggl/start_time_entry.rb +3 -2
  38. data/lib/dude/time_trackers/toggl/stop_time_entry.rb +3 -1
  39. data/lib/dude/version.rb +3 -1
  40. metadata +61 -14
  41. data/lib/dude/project_management/jira/get_current_tasks.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3db4b4826c0b1b1585760b4e79bf3e9b02820fcee1782841be83dd6d9f439152
4
- data.tar.gz: eb3da77da90e2acf84c4b149f46f13161b1f88f196da14b0ac769a4e24edaace
3
+ metadata.gz: f193ac190cdcd95628911cd674828269e6dfbbc7cc1e5fc0a60d5369ba6dd00e
4
+ data.tar.gz: 9b0ee32f4a20cbc7016fe7b6db792b2af4d9447ebc0356e124a97d0c1b8fee16
5
5
  SHA512:
6
- metadata.gz: e0cad6a457995294bcf3298db28117234426db3551eae14b0eeb7c65d56da7cf11c6fa93f4d3f7d8d60581cd76022fe4fcdabe21496e403857feb50a4c89b660
7
- data.tar.gz: 78aa9e5106c5898452dc79322cd54eebfd37b9a23eff1248938dd6260707b1310310a023640d8069020732805fc0dfb05c75fe114b87ddb76f98721426876d66
6
+ metadata.gz: e7153c965ca0222b34f7cc5dc14ee1e21d77303932b0c27f224a935ea3940ef088f5c907e60871f256080e31771914ab69b883b0bb6549c6731dc10a1d50237d
7
+ data.tar.gz: 1c42491aca9dd9d44d80ee46a08b0babf816bac4dd6c129de45975e0b9923939ae5b3f852a4aeccbb2263b7e1bd7d87817fe3502fda998ff17ccbd19456d6616
@@ -0,0 +1,32 @@
1
+ # Put this in the file: .github/workflows/verify.yml
2
+
3
+ name: Verify
4
+ on: [push, pull_request]
5
+
6
+ jobs:
7
+ rubocop:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.6 # Not needed with a .ruby-version file
14
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
15
+ - name: Run Rubocop
16
+ run: bundle exec rubocop
17
+
18
+ rspec:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: 2.6 # Not needed with a .ruby-version file
25
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
26
+ - name: Run RSpec
27
+ run: COVERAGE=true bundle exec rspec
28
+ - name: Run codacy-coverage-reporter
29
+ uses: codacy/codacy-coverage-reporter-action@master
30
+ with:
31
+ project-token: "8c564cf8054e4575b20b580d47020f52"
32
+ coverage-reports: coverage/coverage.xml
data/.rubocop.yml ADDED
@@ -0,0 +1,9 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ AllCops:
5
+ SuggestExtensions: false
6
+ TargetRubyVersion: 2.5
7
+
8
+ Metrics/BlockLength:
9
+ IgnoredMethods: ['describe', 'context']
data/CHANGELOG.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased]
3
+ ## [2.0.7] - 2021-04-02
4
4
 
5
5
  ### Added
6
-
7
- - Added Trello support
6
+ - RSpec and coverage
7
+ - Rubocop style changes
8
+ - Fixed #15
9
+ - Fixed README errors
10
+ - Changed requires to relatives
8
11
 
9
12
  ## [2.0.0] - 2021-03-10
10
13
 
@@ -23,3 +26,4 @@
23
26
 
24
27
  [2.0.0]: https://github.com/npupko/dude/releases/tag/2.0.0
25
28
  [1.0.2]: https://github.com/npupko/dude/releases/tag/1.0.2
29
+ [1.0.6]: https://github.com/npupko/dude/releases/tag/1.0.6
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in dude.gemspec
4
6
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dude-cli (2.0.5)
4
+ dude-cli (2.0.6)
5
5
  colorize (~> 0.8.1)
6
6
  dry-cli (~> 0.6)
7
7
  faraday (~> 1.1)
@@ -16,12 +16,14 @@ GEM
16
16
  minitest (>= 5.1)
17
17
  tzinfo (~> 2.0)
18
18
  zeitwerk (~> 2.3)
19
+ ast (2.4.2)
19
20
  atlassian-jwt (0.2.0)
20
21
  jwt (~> 2.1.0)
21
22
  coderay (1.1.3)
22
23
  colorize (0.8.1)
23
24
  concurrent-ruby (1.1.8)
24
25
  diff-lcs (1.4.4)
26
+ docile (1.3.5)
25
27
  dry-cli (0.6.0)
26
28
  concurrent-ruby (~> 1.0)
27
29
  faraday (1.3.0)
@@ -41,10 +43,16 @@ GEM
41
43
  minitest (5.14.4)
42
44
  multipart-post (2.1.1)
43
45
  oauth (0.5.5)
46
+ parallel (1.20.1)
47
+ parser (3.0.0.0)
48
+ ast (~> 2.4.1)
44
49
  pry (0.14.0)
45
50
  coderay (~> 1.1)
46
51
  method_source (~> 1.0)
52
+ rainbow (3.0.0)
47
53
  rake (13.0.3)
54
+ regexp_parser (2.1.1)
55
+ rexml (3.2.4)
48
56
  rspec (3.10.0)
49
57
  rspec-core (~> 3.10.0)
50
58
  rspec-expectations (~> 3.10.0)
@@ -58,9 +66,30 @@ GEM
58
66
  diff-lcs (>= 1.2.0, < 2.0)
59
67
  rspec-support (~> 3.10.0)
60
68
  rspec-support (3.10.2)
69
+ rubocop (1.12.0)
70
+ parallel (~> 1.10)
71
+ parser (>= 3.0.0.0)
72
+ rainbow (>= 2.2.2, < 4.0)
73
+ regexp_parser (>= 1.8, < 3.0)
74
+ rexml
75
+ rubocop-ast (>= 1.2.0, < 2.0)
76
+ ruby-progressbar (~> 1.7)
77
+ unicode-display_width (>= 1.4.0, < 3.0)
78
+ rubocop-ast (1.4.1)
79
+ parser (>= 2.7.1.5)
80
+ ruby-progressbar (1.11.0)
61
81
  ruby2_keywords (0.0.4)
82
+ simplecov (0.21.2)
83
+ docile (~> 1.1)
84
+ simplecov-html (~> 0.11)
85
+ simplecov_json_formatter (~> 0.1)
86
+ simplecov-cobertura (1.4.2)
87
+ simplecov (~> 0.8)
88
+ simplecov-html (0.12.3)
89
+ simplecov_json_formatter (0.1.2)
62
90
  tzinfo (2.0.4)
63
91
  concurrent-ruby (~> 1.0)
92
+ unicode-display_width (2.0.0)
64
93
  zeitwerk (2.4.2)
65
94
 
66
95
  PLATFORMS
@@ -71,6 +100,9 @@ DEPENDENCIES
71
100
  pry (~> 0.14.0)
72
101
  rake (~> 13.0)
73
102
  rspec (~> 3.0)
103
+ rubocop (~> 1.12)
104
+ simplecov (~> 0.21.2)
105
+ simplecov-cobertura (~> 1.4)
74
106
 
75
107
  BUNDLED WITH
76
108
  2.1.4
data/LICENCE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020-2021 Nikita Pupko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,10 @@
1
- # Dude [![Gem Version](https://badge.fury.io/rb/dude-cli.svg)](https://badge.fury.io/rb/dude-cli)
1
+ # Dude
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/dude-cli.svg)](https://badge.fury.io/rb/dude-cli)
4
+ ![Codacy coverage](https://img.shields.io/codacy/coverage/8c564cf8054e4575b20b580d47020f52)
5
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/a02f0a87f88542c89ac5bf62d1a7d0f7)](https://www.codacy.com/gh/npupko/dude/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=npupko/dude&amp;utm_campaign=Badge_Grade)
6
+ ![Gem](https://img.shields.io/gem/dv/dude-cli/stable)
7
+ ![GitHub](https://img.shields.io/github/license/npupko/dude)
2
8
 
3
9
  A daily assistant in the hard work of a programmer
4
10
 
@@ -76,9 +82,9 @@ alias dude="rvm 2.7.2 do dude"
76
82
  | dude install | - | - | Create .duderc file in your home directory |
77
83
  | dude checkout | ISSUE_ID | - | Checkout to branch with name "ID-issue-title" |
78
84
  | dude track | ISSUE_ID | - | Start time entry in Toggl with issue project, title and id |
79
- | dude tasks | ISSUE_ID | - | Show all issues in current project (For current sprint) |
85
+ | dude tasks | - | - | Show all issues in current project (For current sprint) |
80
86
  | dude stop | - | - | Stop current time entry in Toggl |
81
- | dude start | - | - | Do `checkout`, `track` and `move` actions |
87
+ | dude start | ISSUE_ID | - | Do `checkout`, `track` and `move` actions |
82
88
  | dude move | ISSUE_ID | --list=NAME | Move issue to another column (Will provide options if called without --list parameter) |
83
89
  | dude version | - | - | Display gem version |
84
90
 
@@ -92,4 +98,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/npupko
92
98
 
93
99
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
94
100
 
95
- ## [Changelog](https://github.com/npupko/dude/CHANGELOG.md)
101
+ ## Changelog
102
+
103
+ https://github.com/npupko/dude/blob/master/CHANGELOG.md
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "dude"
4
+ require 'bundler/setup'
5
+ require 'dude'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "dude"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
data/bin/dude CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "dude"
4
+ require_relative '../lib/dude'
4
5
 
5
6
  Dry::CLI.new(Dude::Commands).call
data/dude.gemspec CHANGED
@@ -1,35 +1,42 @@
1
- lib = File.expand_path("../lib", __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require_relative 'lib/dude/version'
4
6
 
5
7
  Gem::Specification.new do |spec|
6
- spec.name = "dude-cli"
8
+ spec.name = 'dude-cli'
7
9
  spec.version = Dude::VERSION
8
- spec.authors = ["Nikita Pupko"]
9
- spec.email = ["work.pupko@gmail.com"]
10
+ spec.authors = ['Nikita Pupko']
11
+ spec.email = ['work.pupko@gmail.com']
10
12
 
11
- spec.summary = %q{A daily assistant in the hard work of a programmer.}
12
- spec.description = %q{This program helps to combine such services as Jira, Toggl and git and replace most routine activities with one simple CLI utility.}
13
- spec.homepage = "https://github.com/npupko/dude"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+ spec.summary = 'A daily assistant in the hard work of a programmer.'
14
+ spec.description = <<~DESC
15
+ This program helps to combine such services as Jira, Toggl and git and replace most routine activities with one simple CLI utility.
16
+ DESC
17
+ spec.homepage = 'https://github.com/npupko/dude'
18
+ spec.license = 'MIT'
19
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
16
20
 
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/npupko/dude"
19
- spec.metadata["changelog_uri"] = "https://github.com/npupko/dude/blob/master/CHANGELOG.md"
21
+ spec.metadata['homepage_uri'] = spec.homepage
22
+ spec.metadata['source_code_uri'] = 'https://github.com/npupko/dude'
23
+ spec.metadata['changelog_uri'] = 'https://github.com/npupko/dude/blob/master/CHANGELOG.md'
20
24
 
21
25
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
26
 
23
- spec.bindir = "bin"
24
- spec.executables = ["dude"]
25
- spec.require_paths = ["lib"]
27
+ spec.bindir = 'bin'
28
+ spec.executables = ['dude']
29
+ spec.require_paths = ['lib']
26
30
 
31
+ spec.add_runtime_dependency 'colorize', '~> 0.8.1'
27
32
  spec.add_runtime_dependency 'dry-cli', '~> 0.6'
28
- spec.add_runtime_dependency "faraday", "~> 1.1"
29
- spec.add_runtime_dependency "colorize", "~> 0.8.1"
30
- spec.add_runtime_dependency "jira-ruby", "~> 2.1"
33
+ spec.add_runtime_dependency 'faraday', '~> 1.1'
34
+ spec.add_runtime_dependency 'jira-ruby', '~> 2.1'
31
35
 
32
36
  spec.add_development_dependency 'pry', '~> 0.14.0'
33
37
  spec.add_development_dependency 'rake', '~> 13.0'
34
38
  spec.add_development_dependency 'rspec', '~> 3.0'
39
+ spec.add_development_dependency 'rubocop', '~> 1.12'
40
+ spec.add_development_dependency 'simplecov', '~> 0.21.2'
41
+ spec.add_development_dependency 'simplecov-cobertura', '~> 1.4'
35
42
  end
data/lib/dude.rb CHANGED
@@ -1,12 +1,14 @@
1
- require "colorize"
1
+ # frozen_string_literal: true
2
2
 
3
- require "dude/settings"
4
- require "dude/version"
5
- require "dude/commands"
6
- require "dude/git"
3
+ require 'colorize'
4
+
5
+ require_relative './dude/settings'
6
+ require_relative './dude/version'
7
+ require_relative './dude/commands'
8
+ require_relative './dude/git'
7
9
 
8
10
  module Dude
9
11
  class ToBeImplementedError < StandardError; end
10
12
 
11
- LIST_OF_AVAILABLE_PROJECT_MANAGEMENT_TOOLS = %w[jira]
13
+ LIST_OF_AVAILABLE_PROJECT_MANAGEMENT_TOOLS = %w[jira].freeze
12
14
  end
data/lib/dude/commands.rb CHANGED
@@ -1,24 +1,26 @@
1
- require "dry/cli"
2
- require_relative "./commands/version"
3
- require_relative "./commands/tasks"
4
- require_relative "./commands/move"
5
- require_relative "./commands/checkout"
6
- require_relative "./commands/start"
7
- require_relative "./commands/track"
8
- require_relative "./commands/stop"
9
- require_relative "./commands/install"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/cli'
4
+ require_relative './commands/version'
5
+ require_relative './commands/tasks'
6
+ require_relative './commands/move'
7
+ require_relative './commands/checkout'
8
+ require_relative './commands/start'
9
+ require_relative './commands/track'
10
+ require_relative './commands/stop'
11
+ require_relative './commands/install'
10
12
 
11
13
  module Dude
12
14
  module Commands
13
15
  extend Dry::CLI::Registry
14
16
 
15
- register "install", Dude::Commands::Install, aliases: ["install"]
16
- register "version", Dude::Commands::Version, aliases: ["v", "-v", "--version"]
17
- register "tasks", Dude::Commands::Tasks, aliases: ["t", "-t", "--tasks"]
18
- register "move", Dude::Commands::Move, aliases: ["m", "-m", "--move"]
19
- register "checkout", Dude::Commands::Checkout, aliases: ["co"]
20
- register "track", Dude::Commands::Track, aliases: ["tr"]
21
- register "stop", Dude::Commands::Stop
22
- register "start", Dude::Commands::Start, aliases: ["st"]
17
+ register 'install', Dude::Commands::Install, aliases: ['install']
18
+ register 'version', Dude::Commands::Version, aliases: ['v', '-v', '--version']
19
+ register 'tasks', Dude::Commands::Tasks, aliases: ['t', '-t', '--tasks']
20
+ register 'move', Dude::Commands::Move, aliases: ['m', '-m', '--move']
21
+ register 'checkout', Dude::Commands::Checkout, aliases: ['co']
22
+ register 'track', Dude::Commands::Track, aliases: ['tr']
23
+ register 'stop', Dude::Commands::Stop
24
+ register 'start', Dude::Commands::Start, aliases: ['st']
23
25
  end
24
26
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
4
  module Commands
3
5
  class Checkout < Dry::CLI::Command
4
- desc "Checkout to branch named as current issue"
6
+ desc 'Checkout to branch named as current issue'
5
7
 
6
- argument :id, required: true, desc: "The card short ID"
8
+ argument :id, required: true, desc: 'The card short ID'
7
9
 
8
10
  def call(id:)
9
11
  client = ProjectManagement::Client.new
@@ -1,17 +1,19 @@
1
- require 'dude/settings'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../settings'
2
4
 
3
5
  module Dude
4
6
  module Commands
5
7
  class Install < Dry::CLI::Command
6
- desc "Creates .duderc for future configuration"
8
+ desc 'Creates .duderc for future configuration'
7
9
 
8
10
  def call
9
11
  path = File.join(Dir.home, Settings::CONFIG_FILE)
10
12
  if File.exist?(path)
11
- puts "Config file already exists"
13
+ puts 'Config file already exists'
12
14
  else
13
- File.open(path, 'w') {|f| f.write(duderc_file_content) }
14
- puts ".duderc created in your HOME directory"
15
+ File.open(path, 'w') { |f| f.write(duderc_file_content) }
16
+ puts '.duderc created in your HOME directory'
15
17
  end
16
18
  end
17
19
 
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
4
  module Commands
3
5
  class Move < Dry::CLI::Command
4
- desc "Move task between board columns"
6
+ desc 'Move task between board columns'
5
7
 
6
- argument :id, required: true, desc: "The card short ID"
7
- option :list, desc: "List name for moving card"
8
+ argument :id, required: true, desc: 'The card short ID'
9
+ option :list, desc: 'List name for moving card'
8
10
 
9
11
  def call(id:, **options)
10
12
  client = ProjectManagement::Client.new
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
4
  module Commands
3
5
  class Start < Dry::CLI::Command
4
6
  include Settings
5
7
 
6
- desc "Start task (Do checkout, track and move actions)"
8
+ desc 'Start task (Do checkout, track and move actions)'
7
9
 
8
- argument :id, required: true, desc: "The card short ID"
10
+ argument :id, required: true, desc: 'The card short ID'
9
11
 
10
12
  def call(id:)
11
13
  Commands::Move.new.call(id: id, list: selected_list('in_progress'))
@@ -1,11 +1,13 @@
1
- require 'dude/time_trackers/toggl/stop_time_entry'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../time_trackers/toggl/stop_time_entry'
2
4
 
3
5
  module Dude
4
6
  module Commands
5
7
  class Stop < Dry::CLI::Command
6
8
  include Settings
7
9
 
8
- desc "Stop current time entry in Toggl"
10
+ desc 'Stop current time entry in Toggl'
9
11
 
10
12
  def call
11
13
  Dude::Toggl::StopTimeEntry.new.call
@@ -1,4 +1,6 @@
1
- require 'dude/project_management/client'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../project_management/client'
2
4
 
3
5
  module Dude
4
6
  module Commands
@@ -8,8 +10,8 @@ module Dude
8
10
  desc "Print tasks as list with ID's and assignees"
9
11
 
10
12
  def call
11
- tasks = Dude::ProjectManagement::Client.new.get_current_tasks
12
- lists = tasks.map {|issue| issue.status}.uniq
13
+ tasks = Dude::ProjectManagement::Client.new.fetch_current_tasks
14
+ lists = tasks.map(&:status).uniq
13
15
 
14
16
  lists.each do |list|
15
17
  puts "#{list}:".green.bold
@@ -24,6 +26,7 @@ module Dude
24
26
 
25
27
  def printable_issue_template(issue)
26
28
  return "#{issue.id.to_s.bold}: #{issue.title}" + " (#{issue.assignee})".blue if issue.assignee
29
+
27
30
  "#{issue.id.to_s.bold}: #{issue.title}"
28
31
  end
29
32
  end
@@ -1,13 +1,15 @@
1
- require 'dude/time_trackers/toggl/start_time_entry'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../time_trackers/toggl/start_time_entry'
2
4
 
3
5
  module Dude
4
6
  module Commands
5
7
  class Track < Dry::CLI::Command
6
8
  include Settings
7
9
 
8
- desc "Start time entry in Toggl with issue title and id"
10
+ desc 'Start time entry in Toggl with issue title and id'
9
11
 
10
- argument :id, required: true, desc: "The card short ID"
12
+ argument :id, required: true, desc: 'The card short ID'
11
13
 
12
14
  def call(id:)
13
15
  @id = id
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
4
  module Commands
3
5
  class Version < Dry::CLI::Command
4
- desc "Print version"
6
+ desc 'Print version'
5
7
 
6
8
  def call
7
9
  puts Dude::VERSION
data/lib/dude/git.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './git/checkout'
2
4
  require_relative './git/current_branch_name'
3
5
 
@@ -1,8 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
4
  module Git
3
5
  class Checkout
4
6
  def call(branch_name)
5
- %x(git checkout -b #{branch_name})
7
+ @branch_name = branch_name
8
+ branch_exists? ? checkout_on_exising_branch : checkout_and_create
9
+ end
10
+
11
+ private
12
+
13
+ attr_reader :branch_name
14
+
15
+ def branch_exists?
16
+ !`git show-ref refs/heads/#{branch_name}`.empty?
17
+ end
18
+
19
+ def checkout_and_create
20
+ `git checkout -b #{branch_name}`
21
+ end
22
+
23
+ def checkout_on_exising_branch
24
+ `git checkout #{branch_name}`
6
25
  end
7
26
  end
8
27
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
4
  module Git
3
5
  class CurrentBranchName
4
6
  def call
5
- %x(git rev-parse --abbrev-ref HEAD).chomp
7
+ `git rev-parse --abbrev-ref HEAD`.chomp
6
8
  end
7
9
  end
8
10
  end
@@ -1,4 +1,6 @@
1
- require 'dude/project_management/jira/client'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './jira/client'
2
4
 
3
5
  module Dude
4
6
  module ProjectManagement
@@ -9,6 +11,7 @@ module Dude
9
11
 
10
12
  def initialize
11
13
  return unless LIST_OF_AVAILABLE_PROJECT_MANAGEMENT_TOOLS.include? settings['PROJECT_MANAGEMENT_TOOL']
14
+
12
15
  @client = Dude::ProjectManagement::Jira::Client.new
13
16
  end
14
17
 
@@ -16,8 +19,8 @@ module Dude
16
19
  client.respond_to_missing?(method_name, include_private)
17
20
  end
18
21
 
19
- def method_missing(m, *args, &block)
20
- client.send(m, *args, &block)
22
+ def method_missing(method, *args, &block)
23
+ client.send(method, *args, &block)
21
24
  end
22
25
  end
23
26
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
4
  module ProjectManagement
3
5
  module Entities
4
6
  class Issue
5
-
6
7
  end
7
8
  end
8
9
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
4
  module ProjectManagement
3
5
  module Entities
4
6
  class Issue
5
7
  attr_accessor :id, :title, :description, :status, :assignee
6
8
 
7
- def initialize(id: , title:, description:, status:, assignee: nil)
9
+ def initialize(id:, title:, description:, status:, assignee: nil)
8
10
  @id = id
9
11
  @title = title
10
12
  @description = description
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dude/project_management/jira/client'
2
4
 
3
5
  module Dude
4
6
  module ProjectManagement
5
7
  module Jira
6
-
7
8
  end
8
9
  end
9
10
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jira-ruby'
2
- require 'dude/project_management/jira/get_current_tasks'
3
- require 'dude/project_management/jira/move_task_to_list'
4
- require 'dude/project_management/jira/get_task_name_by_id'
4
+ require_relative './fetch_current_tasks'
5
+ require_relative './move_task_to_list'
6
+ require_relative './get_task_name_by_id'
5
7
 
6
8
  module Dude
7
9
  module ProjectManagement
@@ -28,12 +30,12 @@ module Dude
28
30
  client.respond_to_missing?(method_name, include_private)
29
31
  end
30
32
 
31
- def method_missing(m, *args, &block)
32
- client.send(m, *args, &block)
33
+ def method_missing(method, *args, &block)
34
+ client.send(method, *args, &block)
33
35
  end
34
36
 
35
- def get_current_tasks
36
- GetCurrentTasks.new(client).call
37
+ def fetch_current_tasks
38
+ FetchCurrentTasks.new(client).call
37
39
  end
38
40
 
39
41
  def move_task_to_list(id, list)
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../entities/issue'
4
+
5
+ module Dude
6
+ module ProjectManagement
7
+ module Jira
8
+ class FetchCurrentTasks
9
+ include Settings
10
+
11
+ def initialize(client)
12
+ @client = client
13
+ end
14
+
15
+ def call
16
+ board = client.Board.find(settings['ATLASSIAN_BOARD_ID'])
17
+
18
+ all_issues = board_type(board)
19
+
20
+ all_issues.map { |issue| create_issue(issue) }
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :client
26
+
27
+ def board_type(board)
28
+ case board.type
29
+ when 'kanban' then board.issues
30
+ when 'simple', 'scrum' then board.sprints(state: 'active').flat_map(&:issues)
31
+ else raise Dude::ToBeImplementedError
32
+ end
33
+ end
34
+
35
+ def create_issue(issue)
36
+ Entities::Issue.new(
37
+ id: issue.key,
38
+ title: issue.summary,
39
+ description: issue.description,
40
+ status: issue.status.name,
41
+ assignee: issue&.assignee&.displayName
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,4 +1,4 @@
1
- require 'dude/project_management/jira/client'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Dude
4
4
  module ProjectManagement
@@ -1,4 +1,4 @@
1
- require 'dude/project_management/jira/client'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Dude
4
4
  module ProjectManagement
@@ -14,33 +14,35 @@ module Dude
14
14
 
15
15
  def call
16
16
  issue = client.Issue.find(id)
17
- available_transitions = client.Transition.all(:issue => issue)
17
+ available_transitions = client.Transition.all(issue: issue)
18
+ transition_id = generate_transition_id(issue, available_transitions)
19
+ transition = issue.transitions.build
20
+ transition.save!(transition: { id: transition_id })
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :client, :id, :list_name
18
26
 
19
- transition_id = if list_name
27
+ def generate_transition_id(issue, available_transitions)
28
+ if list_name
20
29
  available_transitions.find { |transition| transition.name == list_name }.id
21
30
  else
22
31
  select_list_for_moving(issue, available_transitions).id
23
32
  end
24
-
25
- transition = issue.transitions.build
26
- transition.save!(transition: { id: transition_id })
27
33
  end
28
34
 
29
- private
30
-
31
- def select_list_for_moving(issuem, available_transitions)
32
- puts "Please, select list for moving:".green.bold
35
+ def select_list_for_moving(_issue, available_transitions)
36
+ puts 'Please, select list for moving:'.green.bold
33
37
 
34
38
  available_transitions.each_with_index do |ea, index|
35
39
  puts "#{index + 1}: #{ea.name.bold}"
36
40
  end
37
41
 
38
42
  print "\nList index: ".bold
39
- list_index = STDIN.gets.chomp
43
+ list_index = $stdin.gets.chomp
40
44
  available_transitions[list_index.to_i - 1]
41
45
  end
42
-
43
- attr_reader :client, :id, :list_name
44
46
  end
45
47
  end
46
48
  end
data/lib/dude/settings.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
4
  module Settings
3
5
  CONFIG_FILE = '.duderc'
@@ -5,6 +7,7 @@ module Dude
5
7
  def settings
6
8
  @settings ||= read(file).strip.split("\n").map do |line|
7
9
  next if line =~ /^#/ || line.empty?
10
+
8
11
  line.split('=').map(&:strip)
9
12
  end.compact.to_h
10
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './toggl/base'
2
4
  require_relative './toggl/start_time_entry'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
 
3
5
  module Dude
@@ -1,9 +1,10 @@
1
- require 'dude/time_trackers/toggl/base'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './base'
2
4
 
3
5
  module Dude
4
6
  module Toggl
5
7
  class StartTimeEntry < Dude::Toggl::Base
6
-
7
8
  def call(task_title:, project:)
8
9
  @task_title = task_title
9
10
  @project = project
@@ -1,4 +1,6 @@
1
- require 'dude/time_trackers/toggl/base'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './base'
2
4
 
3
5
  module Dude
4
6
  module Toggl
data/lib/dude/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dude
2
- VERSION = "2.0.6"
4
+ VERSION = '2.0.7'
3
5
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dude-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Pupko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-01 00:00:00.000000000 Z
11
+ date: 2021-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: dry-cli
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
19
+ version: 0.8.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.6'
26
+ version: 0.8.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: faraday
28
+ name: dry-cli
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.1'
33
+ version: '0.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.1'
40
+ version: '0.6'
41
41
  - !ruby/object:Gem::Dependency
42
- name: colorize
42
+ name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.8.1
47
+ version: '1.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.8.1
54
+ version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: jira-ruby
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -108,8 +108,52 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3.0'
111
- description: This program helps to combine such services as Jira, Toggl and git and
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.12'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.12'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.21.2
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.21.2
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov-cobertura
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.4'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.4'
153
+ description: 'This program helps to combine such services as Jira, Toggl and git and
112
154
  replace most routine activities with one simple CLI utility.
155
+
156
+ '
113
157
  email:
114
158
  - work.pupko@gmail.com
115
159
  executables:
@@ -118,12 +162,15 @@ extensions: []
118
162
  extra_rdoc_files: []
119
163
  files:
120
164
  - ".github/dependabot.yml"
165
+ - ".github/workflows/verify.yml"
121
166
  - ".gitignore"
122
167
  - ".rspec"
168
+ - ".rubocop.yml"
123
169
  - ".travis.yml"
124
170
  - CHANGELOG.md
125
171
  - Gemfile
126
172
  - Gemfile.lock
173
+ - LICENCE
127
174
  - README.md
128
175
  - Rakefile
129
176
  - bin/console
@@ -148,7 +195,7 @@ files:
148
195
  - lib/dude/project_management/entities/issue.rb
149
196
  - lib/dude/project_management/jira.rb
150
197
  - lib/dude/project_management/jira/client.rb
151
- - lib/dude/project_management/jira/get_current_tasks.rb
198
+ - lib/dude/project_management/jira/fetch_current_tasks.rb
152
199
  - lib/dude/project_management/jira/get_task_name_by_id.rb
153
200
  - lib/dude/project_management/jira/move_task_to_list.rb
154
201
  - lib/dude/settings.rb
@@ -172,7 +219,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
219
  requirements:
173
220
  - - ">="
174
221
  - !ruby/object:Gem::Version
175
- version: 2.3.0
222
+ version: 2.5.0
176
223
  required_rubygems_version: !ruby/object:Gem::Requirement
177
224
  requirements:
178
225
  - - ">="
@@ -1,40 +0,0 @@
1
- require 'dude/project_management/entities/issue'
2
- require 'dude/project_management/jira/client'
3
-
4
- module Dude
5
- module ProjectManagement
6
- module Jira
7
- class GetCurrentTasks
8
- include Settings
9
-
10
- def initialize(client)
11
- @client = client
12
- end
13
-
14
- def call
15
- board = client.Board.find(settings['ATLASSIAN_BOARD_ID'])
16
-
17
- all_issues = case board.type
18
- when 'kanban' then board.issues
19
- when 'simple', 'scrum' then board.sprints(state: 'active').flat_map { |sprint| sprint.issues }
20
- else raise Dude::ToBeImplementedError
21
- end
22
-
23
- all_issues.map do |issue|
24
- Entities::Issue.new({
25
- id: issue.key,
26
- title: issue.summary,
27
- description: issue.description,
28
- status: issue.status.name,
29
- assignee: issue&.assignee&.displayName
30
- })
31
- end
32
- end
33
-
34
- private
35
-
36
- attr_reader :client
37
- end
38
- end
39
- end
40
- end