branch-name 0.1.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d882d8879ddec14bdc35c55ef3dbe8248f8015354fc2f80e9facd910340422b5
4
+ data.tar.gz: f55756f320579898d41e13a9f27200886a4ed2715eabdf5aa80929ff79637d33
5
+ SHA512:
6
+ metadata.gz: d3e87289c12232e36def910161ed1fe58f6129bf780a18bc4a6e65210fc1169f8f448aef6217b67fa51ab1e30fafb19c02721d6d17528d63f2b470a401e6a352
7
+ data.tar.gz: fb33ef5ca18c7c55ceb31d5f7bf32c1159093c590d715b35763eb4331cd3de7fa4a4bea1c88476810dd9bc7eac32ff2d8c96fc8f869f37a33cb054c73f4a6203
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,186 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 3.0
7
+ NewCops: enable
8
+ Exclude:
9
+ - '.git/**/*'
10
+ - '.idea/**/*'
11
+ - 'init/*'
12
+ - 'Rakefile'
13
+ - 'vendor/**/*'
14
+ - 'scratch*.rb'
15
+
16
+ # Align the elements of a hash literal if they span more than one line.
17
+ Layout/HashAlignment:
18
+ EnforcedLastArgumentHashStyle: always_ignore
19
+
20
+ # Alignment of parameters in multi-line method definition.
21
+ # The `with_fixed_indentation` style aligns the following lines with one
22
+ # level of indentation relative to the start of the line with the method
23
+ # definition.
24
+ #
25
+ # def my_method(a,
26
+ # b)
27
+ Layout/ParameterAlignment:
28
+ EnforcedStyle: with_fixed_indentation
29
+
30
+ # Alignment of parameters in multi-line method call.
31
+ # The `with_fixed_indentation` style aligns the following lines with one
32
+ # level of indentation relative to the start of the line with the method call.
33
+ #
34
+ # my_method(a,
35
+ # b)
36
+ Layout/ArgumentAlignment:
37
+ EnforcedStyle: with_fixed_indentation
38
+
39
+ # a = case n
40
+ # when 0
41
+ # x * 2
42
+ # else
43
+ # y / 3
44
+ # end
45
+ Layout/CaseIndentation:
46
+ EnforcedStyle: end
47
+
48
+ # Enforces a configured order of definitions within a class body
49
+ Layout/ClassStructure:
50
+ Enabled: true
51
+
52
+ # Align `end` with the matching keyword or starting expression except for
53
+ # assignments, where it should be aligned with the LHS.
54
+ Layout/EndAlignment:
55
+ EnforcedStyleAlignWith: variable
56
+ AutoCorrect: true
57
+
58
+ # The `consistent` style enforces that the first element in an array
59
+ # literal where the opening bracket and the first element are on
60
+ # seprate lines is indented the same as an array literal which is not
61
+ # defined inside a method call.
62
+ Layout/FirstArrayElementIndentation:
63
+ EnforcedStyle: consistent
64
+
65
+ # The `consistent` style enforces that the first key in a hash
66
+ # literal where the opening brace and the first key are on
67
+ # seprate lines is indented the same as a hash literal which is not
68
+ # defined inside a method call.
69
+ Layout/FirstHashElementIndentation:
70
+ EnforcedStyle: consistent
71
+
72
+ # Indent multi-line methods instead of aligning with periods
73
+ Layout/MultilineMethodCallIndentation:
74
+ EnforcedStyle: indented
75
+
76
+ # Allow `debug` in tasks for now
77
+ Lint/Debugger:
78
+ Exclude:
79
+ - 'RakeFile'
80
+
81
+ # A calculated magnitude based on number of assignments, branches, and
82
+ # conditions.
83
+ # NOTE: This is temporarily disabled until we can eliminate existing Rubocop
84
+ # complaints
85
+ Metrics/AbcSize:
86
+ Enabled: false
87
+
88
+ # Avoid long blocks with many lines.
89
+ Metrics/BlockLength:
90
+ Exclude:
91
+ - 'RakeFile'
92
+ - 'db/seeds.rb'
93
+ - 'spec/**/*.rb'
94
+
95
+ # Avoid classes longer than 100 lines of code.
96
+ # NOTE: This is temporarily disabled until we can eliminate existing Rubocop
97
+ # complaints
98
+ Metrics/ClassLength:
99
+ Max: 200
100
+ Exclude:
101
+ - 'spec/**/*.rb'
102
+
103
+ # A complexity metric that is strongly correlated to the number of test cases
104
+ # needed to validate a method.
105
+ Metrics/CyclomaticComplexity:
106
+ Max: 9
107
+
108
+ # Limit lines to 80 characters
109
+ Layout/LineLength:
110
+ Exclude:
111
+ - 'RakeFile'
112
+ - 'spec/**/*.rb'
113
+
114
+ # Avoid methods longer than 15 lines of code.
115
+ Metrics/MethodLength:
116
+ Max: 20
117
+ AllowedMethods:
118
+ - swagger_path
119
+ - operation
120
+
121
+
122
+ # A complexity metric geared towards measuring complexity for a human reader.
123
+ Metrics/PerceivedComplexity:
124
+ Max: 10
125
+
126
+ # Naming/FileName:
127
+ # Exclude:
128
+ # - 'lib/file.rb'
129
+
130
+ # Allow `downcase == ` instead of forcing `casecmp`
131
+ Performance/Casecmp:
132
+ Enabled: false
133
+
134
+ # Require children definitions to be nested or compact in classes and modules
135
+ Style/ClassAndModuleChildren:
136
+ Enabled: false
137
+
138
+ # Document classes and non-namespace modules.
139
+ # (Disabled for now, may revisit later)
140
+ Style/Documentation:
141
+ Enabled: false
142
+
143
+ # Checks the formatting of empty method definitions.
144
+ Style/EmptyMethod:
145
+ EnforcedStyle: expanded
146
+
147
+ # Add the frozen_string_literal comment to the top of files to help transition
148
+ # to frozen string literals by default.
149
+ Style/FrozenStringLiteralComment:
150
+ EnforcedStyle: always
151
+
152
+ # Check for conditionals that can be replaced with guard clauses
153
+ Style/GuardClause:
154
+ Enabled: false
155
+
156
+ Style/MixinUsage:
157
+ Exclude:
158
+ - 'RakeFile'
159
+
160
+ # Avoid multi-line method signatures.
161
+ Style/MultilineMethodSignature:
162
+ Enabled: true
163
+
164
+ # Don't use option hashes when you can use keyword arguments.
165
+ Style/OptionHash:
166
+ Enabled: true
167
+
168
+ # Use return instead of return nil.
169
+ Style/ReturnNil:
170
+ Enabled: true
171
+
172
+ # Allow code like `return x, y` as it's occasionally handy.
173
+ Style/RedundantReturn:
174
+ AllowMultipleReturnValues: true
175
+
176
+ # Prefer symbols instead of strings as hash keys.
177
+ Style/StringHashKeys:
178
+ Enabled: true
179
+
180
+ # Checks if configured preferred methods are used over non-preferred.
181
+ Style/StringMethods:
182
+ Enabled: true
183
+
184
+ # Checks for use of parentheses around ternary conditions.
185
+ Style/TernaryParentheses:
186
+ EnforcedStyle: require_parentheses_when_complex
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-09-15
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at web.gma@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in branch-name.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop', '~> 0.81.0'
11
+
12
+ gem 'pry-byebug', '~> 3.9'
13
+ gem 'reek', '~> 6.1', '>= 6.1.1'
14
+ # spec.add_development_dependency 'rubocop', '~> 1.35'
15
+ # spec.add_development_dependency 'rubocop-performance', '~> 1.14', '>= 1.14.3'
16
+ # spec.add_development_dependency 'rubocop-rspec', '~> 2.12', '>= 2.12.1'
17
+ gem 'simplecov', '~> 0.21.2'
data/Gemfile.lock ADDED
@@ -0,0 +1,92 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ branch-name (0.1.0.pre.alpha)
5
+ activesupport (~> 7.0, >= 7.0.4)
6
+ colorize (~> 0.8.1)
7
+ thor (~> 1.2, >= 1.2.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (7.0.4)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ ast (2.4.2)
18
+ byebug (11.1.3)
19
+ coderay (1.1.3)
20
+ colorize (0.8.1)
21
+ concurrent-ruby (1.1.10)
22
+ diff-lcs (1.5.0)
23
+ docile (1.4.0)
24
+ i18n (1.12.0)
25
+ concurrent-ruby (~> 1.0)
26
+ jaro_winkler (1.5.4)
27
+ kwalify (0.7.2)
28
+ method_source (1.0.0)
29
+ minitest (5.16.3)
30
+ parallel (1.22.1)
31
+ parser (3.1.2.1)
32
+ ast (~> 2.4.1)
33
+ pry (0.14.1)
34
+ coderay (~> 1.1)
35
+ method_source (~> 1.0)
36
+ pry-byebug (3.10.1)
37
+ byebug (~> 11.0)
38
+ pry (>= 0.13, < 0.15)
39
+ rainbow (3.1.1)
40
+ rake (13.0.6)
41
+ reek (6.1.1)
42
+ kwalify (~> 0.7.0)
43
+ parser (~> 3.1.0)
44
+ rainbow (>= 2.0, < 4.0)
45
+ rexml (3.2.5)
46
+ rspec (3.11.0)
47
+ rspec-core (~> 3.11.0)
48
+ rspec-expectations (~> 3.11.0)
49
+ rspec-mocks (~> 3.11.0)
50
+ rspec-core (3.11.0)
51
+ rspec-support (~> 3.11.0)
52
+ rspec-expectations (3.11.1)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.11.0)
55
+ rspec-mocks (3.11.1)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.11.0)
58
+ rspec-support (3.11.1)
59
+ rubocop (0.81.0)
60
+ jaro_winkler (~> 1.5.1)
61
+ parallel (~> 1.10)
62
+ parser (>= 2.7.0.1)
63
+ rainbow (>= 2.2.2, < 4.0)
64
+ rexml
65
+ ruby-progressbar (~> 1.7)
66
+ unicode-display_width (>= 1.4.0, < 2.0)
67
+ ruby-progressbar (1.11.0)
68
+ simplecov (0.21.2)
69
+ docile (~> 1.1)
70
+ simplecov-html (~> 0.11)
71
+ simplecov_json_formatter (~> 0.1)
72
+ simplecov-html (0.12.3)
73
+ simplecov_json_formatter (0.1.4)
74
+ thor (1.2.1)
75
+ tzinfo (2.0.5)
76
+ concurrent-ruby (~> 1.0)
77
+ unicode-display_width (1.8.0)
78
+
79
+ PLATFORMS
80
+ x86_64-darwin-19
81
+
82
+ DEPENDENCIES
83
+ branch-name!
84
+ pry-byebug (~> 3.9)
85
+ rake (~> 13.0)
86
+ reek (~> 6.1, >= 6.1.1)
87
+ rspec (~> 3.0)
88
+ rubocop (~> 0.81.0)
89
+ simplecov (~> 0.21.2)
90
+
91
+ BUNDLED WITH
92
+ 2.3.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 gangelo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Branch::Name
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/branch/name`. 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
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'branch-name'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install branch-name
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
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.
30
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/branch-name. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/branch-name/blob/main/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Branch::Name project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/branch-name/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'branch/name'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/branch/name/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'branch-name'
7
+ spec.version = Branch::Name::VERSION
8
+ spec.authors = ['Gene M. Angelo, Jr.']
9
+ spec.email = ['public.gma@gmail.com']
10
+
11
+ spec.summary = 'Generates a branch name based on a JIRA card/ticket number.'
12
+ spec.description = 'Generates a branch name based on a JIRA card/ticket number.'
13
+ spec.homepage = 'https://github.com/gangelo/branch_name'
14
+ spec.license = 'MIT'
15
+
16
+ spec.required_ruby_version = '>= 3.0.1'
17
+
18
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
19
+
20
+ spec.metadata['homepage_uri'] = spec.homepage
21
+ spec.metadata['source_code_uri'] = 'https://github.com/gangelo/branch-name'
22
+ spec.metadata['changelog_uri'] = 'https://github.com/gangelo/branch-name/CHANGELOG.md'
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
+ `git ls-files -z`.split("\x0").reject do |f|
28
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
29
+ end
30
+ end
31
+ spec.bindir = 'exe'
32
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ['lib']
34
+
35
+ spec.add_dependency 'activesupport', '~> 7.0', '>= 7.0.4'
36
+ spec.add_dependency 'colorize', '~> 0.8.1'
37
+ spec.add_dependency 'thor', '~> 1.2', '>= 1.2.1'
38
+
39
+ # Remove this for now.
40
+ # spec.metadata['rubygems_mfa_required'] = 'true'
41
+ end
data/exe/branch-name ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'rubygems'
5
+
6
+ lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
8
+
9
+ require 'branch/name/cli'
10
+
11
+ Branch::Name::CLI.start
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Lifted from:
4
+ # https://github.com/rubysec/bundler-audit/blob/master/lib/bundler/audit/cli/thor_ext/shell/basic/say_error.rb
5
+ require 'English'
6
+ class Thor
7
+ module Shell
8
+ class Basic
9
+ #
10
+ # Prints an error message to `stderr`.
11
+ #
12
+ # @param [String] message
13
+ # The message to print to `stderr`.
14
+ #
15
+ # @param [Symbol, nil] color
16
+ # Optional ANSI color.
17
+ #
18
+ # @param [Boolean] force_new_line
19
+ # Controls whether a newline character will be appended to the output.
20
+ #
21
+ def say_error(message, color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
22
+ return if quiet?
23
+
24
+ buffer = prepare_message(message, *color)
25
+ buffer << $INPUT_RECORD_SEPARATOR if force_new_line && !message.to_s.end_with?($INPUT_RECORD_SEPARATOR)
26
+
27
+ stderr.print(buffer)
28
+ stderr.flush
29
+ end
30
+ end
31
+
32
+ module_eval <<-METHOD, __FILE__, __LINE__ + 1
33
+ def say_error(*args,&block)
34
+ shell.say_error(*args,&block)
35
+ end
36
+ METHOD
37
+ end
38
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+ require 'active_support/core_ext/object/blank'
5
+ require 'bundler'
6
+ require 'colorize'
7
+ require 'thor'
8
+ require_relative 'configurable'
9
+ require_relative 'exitable'
10
+ require_relative 'locatable'
11
+ require_relative 'subcommands/config'
12
+ require_relative 'subcommands/init'
13
+ require_relative 'version'
14
+
15
+ module Branch
16
+ module Name
17
+ #
18
+ # The `branch-name` command.
19
+ #
20
+ class CLI < ::Thor
21
+ include Locatable
22
+ include Exitable
23
+
24
+ default_task :create
25
+ map %w[--version -v] => :version
26
+
27
+ desc 'create [OPTIONS] TICKET [DESCRIPTION]', 'Formulate a branch name based on a ticket and optional description'
28
+ long_desc <<-LONG_DESC
29
+ NAME
30
+ \x5
31
+ `branch-name create` -- will formulate a Git branch name based on the TICKET and optional DECRIPTION provided.
32
+
33
+ SYNOPSIS
34
+ \x5
35
+ branch-name create [-dsp] TICKET [DESCRIPTION]
36
+
37
+ \x5
38
+ The following options are available:
39
+
40
+ \x5 -d: Forces the branch name to lower case.
41
+ The default is --no-downcase
42
+
43
+ \x5\x5 -s DELIMITER: Indicates the DELIMITER that will be used to delimit tokens in the branch name.
44
+ The default DELIMITER is the '_' (underscore) character.
45
+
46
+ \x5\x5 -p LOCATION: Indicates that a project should be created.
47
+ A "project" is a folder that is created in the LOCATION specified
48
+ whose name is equivalent to the branch name that is formulated.
49
+ The default LOCATION is #{Locatable.project_folder(options: options)}.
50
+
51
+ \x5 -f: Used with the -p option. If -f is specified, scratch.rb and readme.txt files
52
+ will be created in the project folder created.
53
+ The default is --project-files
54
+ LONG_DESC
55
+ method_option :downcase, type: :boolean, aliases: '-d'
56
+ method_option :separator, type: :string, aliases: '-s', default: '_'
57
+ method_option :project, type: :string, aliases: '-p', default: "#{Locatable.project_folder(options: options)}"
58
+ method_option :project_files, type: :boolean, aliases: '-f', default: true
59
+
60
+ def create(ticket, ticket_description = nil)
61
+ if ticket.blank? && ticket_description.blank?
62
+ say_error 'ticket and/or ticket_description is required', :red
63
+ exit 1
64
+ end
65
+
66
+ branch_name = "#{ticket} #{ticket_description}".strip
67
+ branch_name = branch_name.split.join options[:separator]
68
+ branch_name = branch_name.downcase if options[:downcase]
69
+ branch_name = branch_name.tr('_', '-') if options[:separator] == '-'
70
+ branch_name = branch_name.tr('-', '_') if options[:separator] == '_'
71
+ branch_name = branch_name.squeeze('-') if options[:separator] == '-'
72
+ branch_name = branch_name.squeeze('_') if options[:separator] == '_'
73
+
74
+ say "Branch name: #{branch_name}", :cyan
75
+
76
+ if /darwin/ =~ RUBY_PLATFORM
77
+ IO.popen('pbcopy', 'w') { |pipe| pipe.puts branch_name }
78
+ say "\"#{branch_name}\" has been copied to the clipboard!", :green
79
+ end
80
+ end
81
+
82
+ desc 'init SUBCOMMAND', 'Sets up config files for this gem'
83
+ subcommand :init, Branch::Name::Subcommands::Init
84
+
85
+ desc 'config SUBCOMMAND', 'Manages config files for this gem'
86
+ subcommand :config, Branch::Name::Subcommands::Config
87
+
88
+ desc '--version, -v', 'Displays this gem version'
89
+ def version
90
+ puts Branch::Name::VERSION
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+ require_relative 'locatable'
5
+
6
+ module Branch
7
+ module Name
8
+ module Configurable
9
+ include Locatable
10
+
11
+ CONFIG_FILENAME = '.branch-nameconfig'
12
+
13
+ module_function
14
+
15
+ def global_config_file
16
+ File.join(global_folder, CONFIG_FILENAME)
17
+ end
18
+
19
+ def local_config_file
20
+ File.join(local_folder, CONFIG_FILENAME)
21
+ end
22
+
23
+ def system_config_file
24
+ File.join(system_folder, CONFIG_FILENAME)
25
+ end
26
+
27
+ def global_config_file?
28
+ Dir.exist? global_config_file
29
+ end
30
+
31
+ def local_config_file?
32
+ Dir.exist? local_config_file
33
+ end
34
+
35
+ def system_config_file?
36
+ Dir.exist? system_config_file
37
+ end
38
+
39
+ def create_global_config_file!
40
+ return false if Dir.exist? global_config_file
41
+
42
+ Dir.mkdir(global_config_file) == 0
43
+ end
44
+
45
+ def create_local_config_file!
46
+ return false if Dir.exist? local_config_file
47
+
48
+ Dir.mkdir(local_config_file) == 0
49
+ end
50
+
51
+ def create_system_config_file!
52
+ return false if Dir.exist? system_config_file
53
+
54
+ Dir.mkdir(system_config_file) == 0
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,15 @@
1
+ module Branch
2
+ module Name
3
+ module Exitable
4
+ def included(base)
5
+ base.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ def exit_on_failure?
10
+ false
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+ require 'pathname'
5
+
6
+ module Branch
7
+ module Name
8
+ module Locatable
9
+ module_function
10
+
11
+ def home_folder
12
+ Dir.home
13
+ end
14
+ alias_method :global_folder, :home_folder
15
+ singleton_class.alias_method :global_folder, :home_folder
16
+
17
+ def local_folder
18
+ Dir.pwd
19
+ end
20
+
21
+ def system_folder
22
+ system_folder = Pathname.new('/')
23
+ unless system_folder.exist? && system_folder.directory?
24
+ puts "WARNING: system folder #{system_folder} does not exist, " \
25
+ "using global folder instead (#{global_folder})".red
26
+
27
+ return global_folder
28
+ end
29
+ system_folder.to_s
30
+ end
31
+
32
+ def project_folder(options: {})
33
+ return home_folder if options.blank?
34
+
35
+ home_folder
36
+ end
37
+
38
+ def system_folder_equals_global_folder?
39
+ syetem_folder == global_folder
40
+ end
41
+
42
+ def temp_folder
43
+ Dir.tmpdir
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+ require 'thor'
5
+ require_relative '../configurable'
6
+ require_relative '../exitable'
7
+
8
+ module Branch
9
+ module Name
10
+ module Subcommands
11
+ class Config < ::Thor
12
+ include Configurable
13
+ include Exitable
14
+
15
+ default_task :info
16
+
17
+ desc 'info', 'Displays information about this gem configuration'
18
+ long_desc <<-LONG_DESC
19
+ NAME
20
+ \x5
21
+ `branch-name config info` -- Displays information about this gem configuration.
22
+
23
+ SYNOPSIS
24
+ \x5
25
+ branch-name config info
26
+ LONG_DESC
27
+ def info
28
+ if global_config_file?
29
+ say "Global config file exists: \"#{global_config_file}\"", :green
30
+ else
31
+ say "Global config file does not exist at: \"#{global_folder}\"", :yellow
32
+ end
33
+
34
+ if local_config_file?
35
+ say "Local config file exists: \"#{local_config_file}\"", :green
36
+ else
37
+ say "Local config file does not exist at: \"#{local_folder}\"", :yellow
38
+ end
39
+
40
+ if system_config_file?
41
+ say "System config file exists: \"#{system_config_file}\"", :green
42
+ else
43
+ say "System config file does not exist at: \"#{system_folder}\"", :yellow
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+ require 'thor'
5
+ require_relative '../configurable'
6
+ require_relative '../exitable'
7
+
8
+ module Branch
9
+ module Name
10
+ module Subcommands
11
+ # https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config
12
+ class Init < ::Thor
13
+ include Configurable
14
+ include Exitable
15
+
16
+ default_task :global
17
+
18
+ desc 'global', 'Creates and initializes a .branch-nameconfig file in the global folder'
19
+ long_desc <<-LONG_DESC
20
+ NAME
21
+ \x5
22
+ `branch-name init global` -- will create and initialize a .branch-nameconfig file
23
+ in the "#{Locatable.global_folder}" folder.
24
+
25
+ SYNOPSIS
26
+ \x5
27
+ branch-name init global
28
+ LONG_DESC
29
+ def global
30
+ if create_global_config_file!
31
+ say "Global config file created \"#{global_config_file}\"", :green
32
+ else
33
+ say "Global config file already exists \"#{global_config_file}\"", :yellow
34
+ end
35
+ end
36
+
37
+ desc 'local', 'Creates and initializes a .branch-nameconfig file in the local folder'
38
+ long_desc <<-LONG_DESC
39
+ NAME
40
+ \x5
41
+ `branch-name init local` -- will create and initialize a .branch-nameconfig file
42
+ in the "#{Locatable.local_folder}" folder.
43
+
44
+ SYNOPSIS
45
+ \x5
46
+ branch-name init local
47
+ LONG_DESC
48
+ def local
49
+ if create_local_config_file!
50
+ say "Local config file created \"#{local_config_file}\"", :green
51
+ else
52
+ say "Local config file already exists \"#{local_config_file}\"", :yellow
53
+ end
54
+ end
55
+
56
+ desc 'system', 'Creates and initializes a .branch-nameconfig file in the system folder'
57
+ long_desc <<-LONG_DESC
58
+ NAME
59
+ \x5
60
+ `branch-name init system` -- will create and initialize a .branch-nameconfig file
61
+ in the "#{Locatable.system_folder}" folder.
62
+
63
+ SYNOPSIS
64
+ \x5
65
+ branch-name init system
66
+ LONG_DESC
67
+ def system
68
+ # if create_system_config_file!
69
+ # say "System config file created \"#{system_config_file}\"", :green
70
+ # else
71
+ # say "System config file already exists \"#{system_config_file}\"", :yellow
72
+ # end
73
+ say_error 'System initialization is not available at this time', :red
74
+ exit 1
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Branch
4
+ module Name
5
+ # branch-name version
6
+ VERSION = '0.1.0-alpha'
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'name/version'
@@ -0,0 +1,6 @@
1
+ module Branch
2
+ module Name
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: branch-name
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre.alpha
5
+ platform: ruby
6
+ authors:
7
+ - Gene M. Angelo, Jr.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-09-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '7.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.4
33
+ - !ruby/object:Gem::Dependency
34
+ name: colorize
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.8.1
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.8.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: thor
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.2'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.2.1
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.2'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.2.1
67
+ description: Generates a branch name based on a JIRA card/ticket number.
68
+ email:
69
+ - public.gma@gmail.com
70
+ executables:
71
+ - branch-name
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".rspec"
76
+ - ".rubocop.yml"
77
+ - ".ruby-version"
78
+ - CHANGELOG.md
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - branch-name.gemspec
88
+ - exe/branch-name
89
+ - lib/branch/name.rb
90
+ - lib/branch/name/cli.rb
91
+ - lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
92
+ - lib/branch/name/configurable.rb
93
+ - lib/branch/name/exitable.rb
94
+ - lib/branch/name/locatable.rb
95
+ - lib/branch/name/subcommands/config.rb
96
+ - lib/branch/name/subcommands/init.rb
97
+ - lib/branch/name/version.rb
98
+ - sig/branch/name.rbs
99
+ homepage: https://github.com/gangelo/branch_name
100
+ licenses:
101
+ - MIT
102
+ metadata:
103
+ homepage_uri: https://github.com/gangelo/branch_name
104
+ source_code_uri: https://github.com/gangelo/branch-name
105
+ changelog_uri: https://github.com/gangelo/branch-name/CHANGELOG.md
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: 3.0.1
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">"
118
+ - !ruby/object:Gem::Version
119
+ version: 1.3.1
120
+ requirements: []
121
+ rubygems_version: 3.3.22
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Generates a branch name based on a JIRA card/ticket number.
125
+ test_files: []