branch-name 3.10.4 → 3.10.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e4530135fd14912b126a23e3db17710d647c80b97b38b7320c3d93c385c16fb
4
- data.tar.gz: d87d2863a7999bb093630e013c94959bfa2351947ac696be448e59d71853a5b0
3
+ metadata.gz: '0578a4f2c431daabe0d6de987fc512f6fd08484bfb1bc3c69be72b48bdc9d610'
4
+ data.tar.gz: 7888b0ff8f0db646740779e3813ed29b8f27203b0ebdfa0255155cbd442a88eb
5
5
  SHA512:
6
- metadata.gz: 1641bc9f6cd8d9b98a0fd80d910af2c59f332dcd2df6d1bc87b8f2dbde98d9aedf810a4cdea0d53982789afd20a242c8ef5c7c7c7b3aa4911876f1872560cd4b
7
- data.tar.gz: 858eb02458c7324a8c9020e7dd8dfe0236e6c865dee2c5577c35fdeb20feb5cde0c8ae4b70e09aa9368d7d6aa2e3581a92a29130d75a534f164e711cf69711e1
6
+ metadata.gz: 2946f11df45515c6a49d6dafa1a35d162735dc2ffedadc9a52d282ce08c6a8890bbccaea02ef0c8f795f7dacf346f9f3f9c7a2f916d67d7601258a48e81e9e1d
7
+ data.tar.gz: 28e378e1513c22d839b49387c44fd5cc5329bd7cfe2148ec55703a23591f66e4df52e57159d361e3a4294037d9bc7be70a3222949851028abf17ddb11843c6c0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## ['3.10.6'] - 2023-12-02
2
+
3
+ Changes
4
+
5
+ - Update gems.
6
+
7
+ ## ['3.10.5'] - 2023-11-03
8
+
9
+ Changes
10
+
11
+ - Various code refactors.
12
+ - Update gems.
13
+
1
14
  ## ['3.10.4'] - 2023-11-01
2
15
 
3
16
  Changes
data/Gemfile CHANGED
@@ -5,11 +5,14 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in branch-name.gemspec
6
6
  gemspec
7
7
 
8
+ gem 'dotenv', '~> 2.8', '>= 2.8.1'
8
9
  gem 'pry-byebug', '~> 3.10', '>= 3.10.1'
9
10
  gem 'rake', '~> 13.0', '>= 13.0.6'
10
11
  gem 'reek', '~> 6.1', '>= 6.1.4'
11
12
  gem 'rspec', '~> 3.12'
13
+ gem 'rspec-activemodel-mocks', '~> 1.1'
12
14
  gem 'rubocop', '~> 1.56.0'
13
15
  gem 'rubocop-performance', '~> 1.19'
14
16
  gem 'rubocop-rspec', '~> 2.23', '>= 2.23.2'
17
+ gem 'shoulda-matchers', '~> 5.3'
15
18
  gem 'simplecov', '~> 0.22.0'
data/Gemfile.lock CHANGED
@@ -1,36 +1,49 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- branch-name (3.10.4)
5
- activesupport (~> 7.0.8)
6
- colorize (>= 0.8.1, < 1.2.0)
7
- os (~> 1.1, >= 1.1.4)
8
- thor (~> 1.2, >= 1.2.2)
9
- thor_nested_subcommand (~> 1.0, >= 1.0.1)
4
+ branch-name (3.10.6)
5
+ activesupport (>= 7.0.8, < 8.0.0)
6
+ colorize (>= 1.1.0, < 2.0)
7
+ os (>= 1.1, < 2.0)
8
+ thor (>= 1.2, < 2.0)
9
+ thor_nested_subcommand (>= 1.0, < 2.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activesupport (7.0.8)
14
+ activemodel (7.1.2)
15
+ activesupport (= 7.1.2)
16
+ activesupport (7.1.2)
17
+ base64
18
+ bigdecimal
15
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
+ connection_pool (>= 2.2.5)
21
+ drb
16
22
  i18n (>= 1.6, < 2)
17
23
  minitest (>= 5.1)
24
+ mutex_m
18
25
  tzinfo (~> 2.0)
19
26
  ast (2.4.2)
20
27
  base64 (0.1.1)
28
+ bigdecimal (3.1.4)
21
29
  byebug (11.1.3)
22
30
  coderay (1.1.3)
23
31
  colorize (1.1.0)
24
32
  concurrent-ruby (1.2.2)
33
+ connection_pool (2.4.1)
25
34
  diff-lcs (1.5.0)
26
35
  docile (1.4.0)
36
+ dotenv (2.8.1)
37
+ drb (2.2.0)
38
+ ruby2_keywords
27
39
  i18n (1.14.1)
28
40
  concurrent-ruby (~> 1.0)
29
- json (2.6.3)
41
+ json (2.7.0)
30
42
  kwalify (0.7.2)
31
43
  language_server-protocol (3.17.0.3)
32
44
  method_source (1.0.0)
33
45
  minitest (5.20.0)
46
+ mutex_m (0.2.0)
34
47
  os (1.1.4)
35
48
  parallel (1.23.0)
36
49
  parser (3.2.2.4)
@@ -42,7 +55,7 @@ GEM
42
55
  pry-byebug (3.10.1)
43
56
  byebug (~> 11.0)
44
57
  pry (>= 0.13, < 0.15)
45
- racc (1.7.2)
58
+ racc (1.7.3)
46
59
  rainbow (3.1.1)
47
60
  rake (13.1.0)
48
61
  reek (6.1.4)
@@ -55,6 +68,10 @@ GEM
55
68
  rspec-core (~> 3.12.0)
56
69
  rspec-expectations (~> 3.12.0)
57
70
  rspec-mocks (~> 3.12.0)
71
+ rspec-activemodel-mocks (1.1.0)
72
+ activemodel (>= 3.0)
73
+ activesupport (>= 3.0)
74
+ rspec-mocks (>= 2.99, < 4.0)
58
75
  rspec-core (3.12.2)
59
76
  rspec-support (~> 3.12.0)
60
77
  rspec-expectations (3.12.3)
@@ -90,6 +107,9 @@ GEM
90
107
  rubocop-capybara (~> 2.17)
91
108
  rubocop-factory_bot (~> 2.22)
92
109
  ruby-progressbar (1.13.0)
110
+ ruby2_keywords (0.0.5)
111
+ shoulda-matchers (5.3.0)
112
+ activesupport (>= 5.2.0)
93
113
  simplecov (0.22.0)
94
114
  docile (~> 1.1)
95
115
  simplecov-html (~> 0.11)
@@ -97,7 +117,7 @@ GEM
97
117
  simplecov-html (0.12.3)
98
118
  simplecov_json_formatter (0.1.4)
99
119
  thor (1.3.0)
100
- thor_nested_subcommand (1.0.2)
120
+ thor_nested_subcommand (1.0.4)
101
121
  tzinfo (2.0.6)
102
122
  concurrent-ruby (~> 1.0)
103
123
  unicode-display_width (2.5.0)
@@ -109,13 +129,16 @@ PLATFORMS
109
129
 
110
130
  DEPENDENCIES
111
131
  branch-name!
132
+ dotenv (~> 2.8, >= 2.8.1)
112
133
  pry-byebug (~> 3.10, >= 3.10.1)
113
134
  rake (~> 13.0, >= 13.0.6)
114
135
  reek (~> 6.1, >= 6.1.4)
115
136
  rspec (~> 3.12)
137
+ rspec-activemodel-mocks (~> 1.1)
116
138
  rubocop (~> 1.56.0)
117
139
  rubocop-performance (~> 1.19)
118
140
  rubocop-rspec (~> 2.23, >= 2.23.2)
141
+ shoulda-matchers (~> 5.3)
119
142
  simplecov (~> 0.22.0)
120
143
 
121
144
  BUNDLED WITH
data/bin/console CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'pry-byebug'
5
4
  require 'bundler/setup'
6
5
  require 'branch/name/cli'
7
6
 
data/exe/branch-name CHANGED
@@ -6,6 +6,6 @@ require 'rubygems'
6
6
  lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
7
7
  $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
8
8
 
9
- require 'branch/name/cli'
9
+ require 'branch/name'
10
10
 
11
11
  Branch::Name::CLI.start
@@ -0,0 +1 @@
1
+ BRANCH_NAME_ENV=development
@@ -11,6 +11,7 @@ require_relative 'loadable'
11
11
  require_relative 'locatable'
12
12
  require_relative 'normalizable'
13
13
  require_relative 'projectable'
14
+ require_relative 'services/branch_name_service'
14
15
  require_relative 'subcommands/config'
15
16
  require_relative 'task_defaultable'
16
17
  require_relative 'version'
@@ -25,10 +26,15 @@ module Branch
25
26
  include Exitable
26
27
  include Loadable
27
28
  include Locatable
28
- include Normalizable
29
29
  include Projectable
30
30
  include TaskDefaultable
31
31
 
32
+ class << self
33
+ def exit_on_failure?
34
+ true
35
+ end
36
+ end
37
+
32
38
  class_option :debug, type: :boolean, default: false
33
39
  class_option :verbose, type: :boolean, default: false
34
40
 
@@ -93,11 +99,9 @@ module Branch
93
99
  method_option :interactive, type: :boolean, optional: true, aliases: '-i'
94
100
 
95
101
  def create(ticket_description, ticket = nil)
96
- validate_ticket_description! ticket_description
97
102
  original_options, altered_options = init_options_for! command: :create
98
103
  self.options = altered_options
99
-
100
- branch_name = validate_and_normalize_branch_name(ticket_description, ticket)
104
+ branch_name = BranchNameService.new(description: ticket_description, ticket: ticket, options: options).call
101
105
  say "Branch name: \"#{branch_name}\"", :cyan
102
106
  say "Branch name \"#{branch_name}\" has been copied to the clipboard!", SUCCESS if copy_to_clipboard branch_name
103
107
  if original_options[:interactive] && !options[:project]
@@ -121,6 +125,9 @@ module Branch
121
125
  say "Project folder name: \"#{project_folder_name}\"", :cyan
122
126
  create_project!(project_folder_name)
123
127
  end
128
+ rescue ArgumentError => e
129
+ say_error e.message, ERROR
130
+ exit 1
124
131
  end
125
132
 
126
133
  desc 'config SUBCOMMAND', 'Manages config files for this gem'
@@ -133,20 +140,6 @@ module Branch
133
140
 
134
141
  private
135
142
 
136
- def validate_ticket_description!(ticket_description)
137
- return unless ticket_description.blank?
138
-
139
- say_error 'description is required', ERROR
140
- exit 1
141
- end
142
-
143
- def validate_and_normalize_branch_name(ticket_description, ticket)
144
- normalize_branch_name(ticket_description, ticket) do |error|
145
- say_error error.message
146
- exit 1
147
- end
148
- end
149
-
150
143
  def validate_and_create_project_folder_name_from!(branch_name)
151
144
  project_folder_name_from(branch_name) do |error|
152
145
  say_error error.message
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model'
4
+
5
+ module Branch
6
+ module Name
7
+ module Models
8
+ attr_reader :description, :ticket
9
+
10
+ class Branch
11
+ include ActiveModel::Model
12
+
13
+ attr_accessor :description, :ticket
14
+
15
+ validates :description, presence: true
16
+
17
+ def initialize(description:, ticket: nil, options: {})
18
+ @description = description
19
+ @ticket = ticket
20
+ @options = options
21
+
22
+ super(description: description, ticket: ticket)
23
+ end
24
+
25
+ def branch_name
26
+ ''
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../colorizable'
4
+ require_relative '../normalizable'
5
+
6
+ module Branch
7
+ module Name
8
+ class BranchNameService
9
+ include Colorizable
10
+ include Normalizable
11
+
12
+ def initialize(description:, ticket: nil, options: {})
13
+ @description = description
14
+ @ticket = ticket
15
+ @options = options
16
+ end
17
+
18
+ def call
19
+ validate_description!
20
+ @branch_name = normalize_branch_name!
21
+ validate_banch_name!
22
+ @branch_name
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :options
28
+
29
+ def normalize_branch_name!
30
+ normalize_branch_name(@description, @ticket) do |error|
31
+ raise ArgumentError, error.message
32
+ end
33
+ end
34
+
35
+ def validate_description!
36
+ return unless @description.blank?
37
+
38
+ raise ArgumentError, 'description is required'
39
+ end
40
+
41
+ def validate_banch_name!
42
+ return unless @branch_name.blank?
43
+
44
+ raise ArgumentError, invalid_branch_name_message
45
+ end
46
+
47
+ def invalid_branch_name_message
48
+ 'the combination of description/ticket resulted in an empty branch name'
49
+ end
50
+ end
51
+ end
52
+ end
@@ -3,6 +3,6 @@
3
3
  module Branch
4
4
  module Name
5
5
  # branch-name version
6
- VERSION = '3.10.4'
6
+ VERSION = '3.10.6'
7
7
  end
8
8
  end
data/lib/branch/name.rb CHANGED
@@ -1,3 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'name/version'
3
+ require 'active_support/core_ext/object/blank'
4
+
5
+ if File.exist?("#{__dir__}/lib/.env.development")
6
+ # This loads our development environment when running dev.
7
+ require 'dotenv'
8
+ Dotenv.load('.env.development')
9
+ end
10
+
11
+ require 'pry-byebug' if ENV['BRANCH_NAME_ENV'] == 'development'
12
+
13
+ Dir.glob("#{__dir__}/name/**/*.rb").each do |file|
14
+ require file
15
+ end
metadata CHANGED
@@ -1,109 +1,115 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: branch-name
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.4
4
+ version: 3.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene M. Angelo, Jr.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-01 00:00:00.000000000 Z
11
+ date: 2023-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 7.0.8
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 8.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 7.0.8
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 8.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: colorize
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: 0.8.1
39
+ version: 1.1.0
34
40
  - - "<"
35
41
  - !ruby/object:Gem::Version
36
- version: 1.2.0
42
+ version: '2.0'
37
43
  type: :runtime
38
44
  prerelease: false
39
45
  version_requirements: !ruby/object:Gem::Requirement
40
46
  requirements:
41
47
  - - ">="
42
48
  - !ruby/object:Gem::Version
43
- version: 0.8.1
49
+ version: 1.1.0
44
50
  - - "<"
45
51
  - !ruby/object:Gem::Version
46
- version: 1.2.0
52
+ version: '2.0'
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: os
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
- - - "~>"
57
+ - - ">="
52
58
  - !ruby/object:Gem::Version
53
59
  version: '1.1'
54
- - - ">="
60
+ - - "<"
55
61
  - !ruby/object:Gem::Version
56
- version: 1.1.4
62
+ version: '2.0'
57
63
  type: :runtime
58
64
  prerelease: false
59
65
  version_requirements: !ruby/object:Gem::Requirement
60
66
  requirements:
61
- - - "~>"
67
+ - - ">="
62
68
  - !ruby/object:Gem::Version
63
69
  version: '1.1'
64
- - - ">="
70
+ - - "<"
65
71
  - !ruby/object:Gem::Version
66
- version: 1.1.4
72
+ version: '2.0'
67
73
  - !ruby/object:Gem::Dependency
68
74
  name: thor
69
75
  requirement: !ruby/object:Gem::Requirement
70
76
  requirements:
71
- - - "~>"
77
+ - - ">="
72
78
  - !ruby/object:Gem::Version
73
79
  version: '1.2'
74
- - - ">="
80
+ - - "<"
75
81
  - !ruby/object:Gem::Version
76
- version: 1.2.2
82
+ version: '2.0'
77
83
  type: :runtime
78
84
  prerelease: false
79
85
  version_requirements: !ruby/object:Gem::Requirement
80
86
  requirements:
81
- - - "~>"
87
+ - - ">="
82
88
  - !ruby/object:Gem::Version
83
89
  version: '1.2'
84
- - - ">="
90
+ - - "<"
85
91
  - !ruby/object:Gem::Version
86
- version: 1.2.2
92
+ version: '2.0'
87
93
  - !ruby/object:Gem::Dependency
88
94
  name: thor_nested_subcommand
89
95
  requirement: !ruby/object:Gem::Requirement
90
96
  requirements:
91
- - - "~>"
97
+ - - ">="
92
98
  - !ruby/object:Gem::Version
93
99
  version: '1.0'
94
- - - ">="
100
+ - - "<"
95
101
  - !ruby/object:Gem::Version
96
- version: 1.0.1
102
+ version: '2.0'
97
103
  type: :runtime
98
104
  prerelease: false
99
105
  version_requirements: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - "~>"
107
+ - - ">="
102
108
  - !ruby/object:Gem::Version
103
109
  version: '1.0'
104
- - - ">="
110
+ - - "<"
105
111
  - !ruby/object:Gem::Version
106
- version: 1.0.1
112
+ version: '2.0'
107
113
  description: |2
108
114
  branch-name is a gem that provides a command-line interface that allows you to accomplish several tasks, tasks I personally find myself having to carry out every time I work on a feature branch. I created this gem for myself; however, you are free to use it yourself, if any of these tasks fits into your personal routine:
109
115
 
@@ -130,6 +136,7 @@ files:
130
136
  - bin/console
131
137
  - bin/setup
132
138
  - exe/branch-name
139
+ - lib/.env.development
133
140
  - lib/branch/name.rb
134
141
  - lib/branch/name/cli.rb
135
142
  - lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
@@ -139,9 +146,11 @@ files:
139
146
  - lib/branch/name/exitable.rb
140
147
  - lib/branch/name/loadable.rb
141
148
  - lib/branch/name/locatable.rb
149
+ - lib/branch/name/models/branch.rb
142
150
  - lib/branch/name/normalizable.rb
143
151
  - lib/branch/name/option_error.rb
144
152
  - lib/branch/name/projectable.rb
153
+ - lib/branch/name/services/branch_name_service.rb
145
154
  - lib/branch/name/subcommands/config.rb
146
155
  - lib/branch/name/subcommands/delete.rb
147
156
  - lib/branch/name/subcommands/init.rb