branch-name 3.10.4 → 3.10.5

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: a7a0395786139641cf06c3d89663980e7b9d1e04add54f5140101255a7fce6f9
4
+ data.tar.gz: 1a6ab663fea24b03573c152247ca0c1b6a681c5de64ac64223edcf2f90e03f67
5
5
  SHA512:
6
- metadata.gz: 1641bc9f6cd8d9b98a0fd80d910af2c59f332dcd2df6d1bc87b8f2dbde98d9aedf810a4cdea0d53982789afd20a242c8ef5c7c7c7b3aa4911876f1872560cd4b
7
- data.tar.gz: 858eb02458c7324a8c9020e7dd8dfe0236e6c865dee2c5577c35fdeb20feb5cde0c8ae4b70e09aa9368d7d6aa2e3581a92a29130d75a534f164e711cf69711e1
6
+ metadata.gz: 8e5869f8ab9afb59269db6a5453cbee596a5a61c6822c30f8aa8441634822e4d9c23182f8dde495f583b072da903d5139f9c755670122a3ae1d80744c3b23d3e
7
+ data.tar.gz: a3eda29aedcbf7a574c6c622905b62c7166c02508d7e0796ee041e47841e10f36dfff4f406c99b2bfa85b2bf72cda98aa77957a93019c893c062218dd9bcd85b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## ['3.10.5'] - 2023-11-03
2
+
3
+ Changes
4
+
5
+ - Various code refactors.
6
+ - Update gems.
7
+
1
8
  ## ['3.10.4'] - 2023-11-01
2
9
 
3
10
  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,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- branch-name (3.10.4)
4
+ branch-name (3.10.5)
5
5
  activesupport (~> 7.0.8)
6
6
  colorize (>= 0.8.1, < 1.2.0)
7
7
  os (~> 1.1, >= 1.1.4)
@@ -11,6 +11,8 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
+ activemodel (7.0.8)
15
+ activesupport (= 7.0.8)
14
16
  activesupport (7.0.8)
15
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
18
  i18n (>= 1.6, < 2)
@@ -24,6 +26,7 @@ GEM
24
26
  concurrent-ruby (1.2.2)
25
27
  diff-lcs (1.5.0)
26
28
  docile (1.4.0)
29
+ dotenv (2.8.1)
27
30
  i18n (1.14.1)
28
31
  concurrent-ruby (~> 1.0)
29
32
  json (2.6.3)
@@ -55,6 +58,10 @@ GEM
55
58
  rspec-core (~> 3.12.0)
56
59
  rspec-expectations (~> 3.12.0)
57
60
  rspec-mocks (~> 3.12.0)
61
+ rspec-activemodel-mocks (1.1.0)
62
+ activemodel (>= 3.0)
63
+ activesupport (>= 3.0)
64
+ rspec-mocks (>= 2.99, < 4.0)
58
65
  rspec-core (3.12.2)
59
66
  rspec-support (~> 3.12.0)
60
67
  rspec-expectations (3.12.3)
@@ -90,6 +97,8 @@ GEM
90
97
  rubocop-capybara (~> 2.17)
91
98
  rubocop-factory_bot (~> 2.22)
92
99
  ruby-progressbar (1.13.0)
100
+ shoulda-matchers (5.3.0)
101
+ activesupport (>= 5.2.0)
93
102
  simplecov (0.22.0)
94
103
  docile (~> 1.1)
95
104
  simplecov-html (~> 0.11)
@@ -109,13 +118,16 @@ PLATFORMS
109
118
 
110
119
  DEPENDENCIES
111
120
  branch-name!
121
+ dotenv (~> 2.8, >= 2.8.1)
112
122
  pry-byebug (~> 3.10, >= 3.10.1)
113
123
  rake (~> 13.0, >= 13.0.6)
114
124
  reek (~> 6.1, >= 6.1.4)
115
125
  rspec (~> 3.12)
126
+ rspec-activemodel-mocks (~> 1.1)
116
127
  rubocop (~> 1.56.0)
117
128
  rubocop-performance (~> 1.19)
118
129
  rubocop-rspec (~> 2.23, >= 2.23.2)
130
+ shoulda-matchers (~> 5.3)
119
131
  simplecov (~> 0.22.0)
120
132
 
121
133
  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.5'
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,14 +1,14 @@
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.5
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-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -130,6 +130,7 @@ files:
130
130
  - bin/console
131
131
  - bin/setup
132
132
  - exe/branch-name
133
+ - lib/.env.development
133
134
  - lib/branch/name.rb
134
135
  - lib/branch/name/cli.rb
135
136
  - lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
@@ -139,9 +140,11 @@ files:
139
140
  - lib/branch/name/exitable.rb
140
141
  - lib/branch/name/loadable.rb
141
142
  - lib/branch/name/locatable.rb
143
+ - lib/branch/name/models/branch.rb
142
144
  - lib/branch/name/normalizable.rb
143
145
  - lib/branch/name/option_error.rb
144
146
  - lib/branch/name/projectable.rb
147
+ - lib/branch/name/services/branch_name_service.rb
145
148
  - lib/branch/name/subcommands/config.rb
146
149
  - lib/branch/name/subcommands/delete.rb
147
150
  - lib/branch/name/subcommands/init.rb