github-username-regex-ruby 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/build.yml +41 -0
- data/.github/workflows/codeql-analysis.yml +36 -0
- data/.github/workflows/lint.yml +28 -0
- data/.github/workflows/release.yml +60 -0
- data/.github/workflows/test.yml +31 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +16 -0
- data/.ruby-version +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +103 -0
- data/LICENSE +21 -0
- data/README.md +5 -0
- data/github-username-regex-ruby.gemspec +26 -0
- data/lib/github_username_regex_ruby.rb +20 -0
- data/lib/version.rb +7 -0
- data/script/bootstrap +32 -0
- data/script/test +90 -0
- data/vendor/cache/activesupport-7.0.5.gem +0 -0
- data/vendor/cache/ast-2.4.2.gem +0 -0
- data/vendor/cache/concurrent-ruby-1.2.2.gem +0 -0
- data/vendor/cache/diff-lcs-1.5.0.gem +0 -0
- data/vendor/cache/docile-1.4.0.gem +0 -0
- data/vendor/cache/i18n-1.14.1.gem +0 -0
- data/vendor/cache/json-2.6.3.gem +0 -0
- data/vendor/cache/language_server-protocol-3.17.0.3.gem +0 -0
- data/vendor/cache/minitest-5.18.1.gem +0 -0
- data/vendor/cache/parallel-1.23.0.gem +0 -0
- data/vendor/cache/parser-3.2.2.3.gem +0 -0
- data/vendor/cache/racc-1.7.1.gem +0 -0
- data/vendor/cache/rack-3.0.8.gem +0 -0
- data/vendor/cache/rainbow-3.1.1.gem +0 -0
- data/vendor/cache/regexp_parser-2.8.1.gem +0 -0
- data/vendor/cache/rexml-3.2.5.gem +0 -0
- data/vendor/cache/rspec-3.12.0.gem +0 -0
- data/vendor/cache/rspec-core-3.12.2.gem +0 -0
- data/vendor/cache/rspec-expectations-3.12.3.gem +0 -0
- data/vendor/cache/rspec-mocks-3.12.5.gem +0 -0
- data/vendor/cache/rspec-support-3.12.0.gem +0 -0
- data/vendor/cache/rubocop-1.53.0.gem +0 -0
- data/vendor/cache/rubocop-ast-1.29.0.gem +0 -0
- data/vendor/cache/rubocop-capybara-2.18.0.gem +0 -0
- data/vendor/cache/rubocop-factory_bot-2.23.1.gem +0 -0
- data/vendor/cache/rubocop-github-0.20.0.gem +0 -0
- data/vendor/cache/rubocop-performance-1.18.0.gem +0 -0
- data/vendor/cache/rubocop-rails-2.20.2.gem +0 -0
- data/vendor/cache/rubocop-rspec-2.22.0.gem +0 -0
- data/vendor/cache/ruby-progressbar-1.13.0.gem +0 -0
- data/vendor/cache/simplecov-0.22.0.gem +0 -0
- data/vendor/cache/simplecov-erb-1.0.1.gem +0 -0
- data/vendor/cache/simplecov-html-0.12.3.gem +0 -0
- data/vendor/cache/simplecov_json_formatter-0.1.4.gem +0 -0
- data/vendor/cache/tzinfo-2.0.6.gem +0 -0
- data/vendor/cache/unicode-display_width-2.4.2.gem +0 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ecaa641e240d055c758ab25a733d6960a3c9e5fe789dc25dbdc91509a5bf78c0
|
4
|
+
data.tar.gz: 4059af471d1cc7c0be0bef27a0aa9e5107b0241b09fda5e77ab1c909b1e09a5f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c616a04a2ee6dc2deae653c678be4526d8368ffe59d24a7f2ad92f16acbbd55238f1230a80ec8b51118fac01fa420fb5fc18d269572f5e3e9213b8068e83f29
|
7
|
+
data.tar.gz: 1c8b655fe43fa96aafe1fe10f90b569321625599fb96cdbaea7085fd12fe92668c727fb9653ea872f536c8d969140c29575ee2b4cd9217bab97064b2bb13ee83
|
@@ -0,0 +1,41 @@
|
|
1
|
+
name: build
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- main
|
10
|
+
workflow_call:
|
11
|
+
|
12
|
+
permissions:
|
13
|
+
contents: read
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
build:
|
17
|
+
name: build
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- name: checkout
|
22
|
+
uses: actions/checkout@v3
|
23
|
+
|
24
|
+
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0
|
25
|
+
with:
|
26
|
+
bundler-cache: true
|
27
|
+
|
28
|
+
- name: bootstrap
|
29
|
+
run: script/bootstrap
|
30
|
+
|
31
|
+
- name: build
|
32
|
+
run: |
|
33
|
+
GEM_NAME=$(ls | grep gemspec | cut -d. -f1)
|
34
|
+
echo "Attempting to build gem $GEM_NAME..."
|
35
|
+
gem build $GEM_NAME
|
36
|
+
if [ $? -eq 0 ]; then
|
37
|
+
echo "Gem built successfully!"
|
38
|
+
else
|
39
|
+
echo "Gem build failed!"
|
40
|
+
exit 1
|
41
|
+
fi
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: CodeQL
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
analyze:
|
11
|
+
name: Analyze
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
permissions:
|
14
|
+
actions: read
|
15
|
+
contents: read
|
16
|
+
security-events: write
|
17
|
+
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
language: [ 'ruby' ]
|
22
|
+
|
23
|
+
steps:
|
24
|
+
- name: Checkout repository
|
25
|
+
uses: actions/checkout@v3
|
26
|
+
|
27
|
+
- name: Initialize CodeQL
|
28
|
+
uses: github/codeql-action/init@v2
|
29
|
+
with:
|
30
|
+
languages: ${{ matrix.language }}
|
31
|
+
|
32
|
+
- name: Autobuild
|
33
|
+
uses: github/codeql-action/autobuild@v2
|
34
|
+
|
35
|
+
- name: Perform CodeQL Analysis
|
36
|
+
uses: github/codeql-action/analyze@v2
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: lint
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- main
|
10
|
+
|
11
|
+
permissions:
|
12
|
+
contents: read
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
lint:
|
16
|
+
name: lint
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- name: checkout
|
21
|
+
uses: actions/checkout@v3
|
22
|
+
|
23
|
+
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0
|
24
|
+
with:
|
25
|
+
bundler-cache: true
|
26
|
+
|
27
|
+
- name: lint
|
28
|
+
run: bundle exec rubocop -c .rubocop.yml lib/ spec/
|
@@ -0,0 +1,60 @@
|
|
1
|
+
name: release
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- main
|
8
|
+
paths:
|
9
|
+
- lib/version.rb
|
10
|
+
|
11
|
+
permissions:
|
12
|
+
contents: write
|
13
|
+
packages: write
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
release:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- name: checkout
|
21
|
+
uses: actions/checkout@v3
|
22
|
+
|
23
|
+
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0
|
24
|
+
with:
|
25
|
+
bundler-cache: true
|
26
|
+
|
27
|
+
- name: bootstrap
|
28
|
+
run: script/bootstrap
|
29
|
+
|
30
|
+
- name: lint
|
31
|
+
run: bundle exec rubocop -c .rubocop.yml lib/ spec/
|
32
|
+
|
33
|
+
- name: test
|
34
|
+
run: script/test
|
35
|
+
|
36
|
+
- name: set GEM_NAME from gemspec
|
37
|
+
run: echo "GEM_NAME=$(ls | grep gemspec | cut -d. -f1)" >> $GITHUB_ENV
|
38
|
+
# builds the gem and saves the version to GITHUB_ENV
|
39
|
+
- name: build
|
40
|
+
run: echo "GEM_VERSION=$(gem build ${{ env.GEM_NAME }}.gemspec 2>&1 | grep Version | cut -d':' -f 2 | tr -d " \t\n\r")" >> $GITHUB_ENV
|
41
|
+
|
42
|
+
- name: publish to GitHub packages
|
43
|
+
run: |
|
44
|
+
export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 )
|
45
|
+
GEM_HOST_API_KEY=${{ secrets.GITHUB_TOKEN }} gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem
|
46
|
+
|
47
|
+
- name: release
|
48
|
+
uses: ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e # pin@v1.12.0
|
49
|
+
with:
|
50
|
+
artifacts: "${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem"
|
51
|
+
tag: "v${{ env.GEM_VERSION }}"
|
52
|
+
generateReleaseNotes: true
|
53
|
+
|
54
|
+
- name: publish to RubyGems
|
55
|
+
run: |
|
56
|
+
mkdir -p ~/.gem
|
57
|
+
echo -e "---\n:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials
|
58
|
+
chmod 0600 ~/.gem/credentials
|
59
|
+
gem push ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem
|
60
|
+
rm ~/.gem/credentials
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- main
|
10
|
+
|
11
|
+
permissions:
|
12
|
+
contents: read
|
13
|
+
|
14
|
+
jobs:
|
15
|
+
test:
|
16
|
+
name: test
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- name: checkout
|
21
|
+
uses: actions/checkout@v3
|
22
|
+
|
23
|
+
- uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0
|
24
|
+
with:
|
25
|
+
bundler-cache: true
|
26
|
+
|
27
|
+
- name: bootstrap
|
28
|
+
run: script/bootstrap
|
29
|
+
|
30
|
+
- name: test
|
31
|
+
run: script/test -k
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-github:
|
3
|
+
- config/default.yml
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
NewCops: enable
|
7
|
+
SuggestExtensions: false
|
8
|
+
DisplayCopNames: true
|
9
|
+
TargetRubyVersion: 3.2
|
10
|
+
Exclude:
|
11
|
+
- "bin/*"
|
12
|
+
- "vendor/**/*"
|
13
|
+
- ".github/**/*"
|
14
|
+
|
15
|
+
Style/HashSyntax:
|
16
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem "rspec", "~> 3.12"
|
7
|
+
gem "rubocop", "~> 1.48"
|
8
|
+
gem "rubocop-github", "~> 0.20"
|
9
|
+
gem "rubocop-performance", "~> 1.16"
|
10
|
+
gem "rubocop-rspec", "~> 2.22"
|
11
|
+
gem "simplecov", "~> 0.22"
|
12
|
+
gem "simplecov-erb", "~> 1.0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (7.0.5)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (>= 1.6, < 2)
|
7
|
+
minitest (>= 5.1)
|
8
|
+
tzinfo (~> 2.0)
|
9
|
+
ast (2.4.2)
|
10
|
+
concurrent-ruby (1.2.2)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
docile (1.4.0)
|
13
|
+
i18n (1.14.1)
|
14
|
+
concurrent-ruby (~> 1.0)
|
15
|
+
json (2.6.3)
|
16
|
+
language_server-protocol (3.17.0.3)
|
17
|
+
minitest (5.18.1)
|
18
|
+
parallel (1.23.0)
|
19
|
+
parser (3.2.2.3)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
racc
|
22
|
+
racc (1.7.1)
|
23
|
+
rack (3.0.8)
|
24
|
+
rainbow (3.1.1)
|
25
|
+
regexp_parser (2.8.1)
|
26
|
+
rexml (3.2.5)
|
27
|
+
rspec (3.12.0)
|
28
|
+
rspec-core (~> 3.12.0)
|
29
|
+
rspec-expectations (~> 3.12.0)
|
30
|
+
rspec-mocks (~> 3.12.0)
|
31
|
+
rspec-core (3.12.2)
|
32
|
+
rspec-support (~> 3.12.0)
|
33
|
+
rspec-expectations (3.12.3)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.12.0)
|
36
|
+
rspec-mocks (3.12.5)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.12.0)
|
39
|
+
rspec-support (3.12.0)
|
40
|
+
rubocop (1.53.0)
|
41
|
+
json (~> 2.3)
|
42
|
+
language_server-protocol (>= 3.17.0)
|
43
|
+
parallel (~> 1.10)
|
44
|
+
parser (>= 3.2.2.3)
|
45
|
+
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
regexp_parser (>= 1.8, < 3.0)
|
47
|
+
rexml (>= 3.2.5, < 4.0)
|
48
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
49
|
+
ruby-progressbar (~> 1.7)
|
50
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
51
|
+
rubocop-ast (1.29.0)
|
52
|
+
parser (>= 3.2.1.0)
|
53
|
+
rubocop-capybara (2.18.0)
|
54
|
+
rubocop (~> 1.41)
|
55
|
+
rubocop-factory_bot (2.23.1)
|
56
|
+
rubocop (~> 1.33)
|
57
|
+
rubocop-github (0.20.0)
|
58
|
+
rubocop (>= 1.37)
|
59
|
+
rubocop-performance (>= 1.15)
|
60
|
+
rubocop-rails (>= 2.17)
|
61
|
+
rubocop-performance (1.18.0)
|
62
|
+
rubocop (>= 1.7.0, < 2.0)
|
63
|
+
rubocop-ast (>= 0.4.0)
|
64
|
+
rubocop-rails (2.20.2)
|
65
|
+
activesupport (>= 4.2.0)
|
66
|
+
rack (>= 1.1)
|
67
|
+
rubocop (>= 1.33.0, < 2.0)
|
68
|
+
rubocop-rspec (2.22.0)
|
69
|
+
rubocop (~> 1.33)
|
70
|
+
rubocop-capybara (~> 2.17)
|
71
|
+
rubocop-factory_bot (~> 2.22)
|
72
|
+
ruby-progressbar (1.13.0)
|
73
|
+
simplecov (0.22.0)
|
74
|
+
docile (~> 1.1)
|
75
|
+
simplecov-html (~> 0.11)
|
76
|
+
simplecov_json_formatter (~> 0.1)
|
77
|
+
simplecov-erb (1.0.1)
|
78
|
+
simplecov (< 1.0)
|
79
|
+
simplecov-html (0.12.3)
|
80
|
+
simplecov_json_formatter (0.1.4)
|
81
|
+
tzinfo (2.0.6)
|
82
|
+
concurrent-ruby (~> 1.0)
|
83
|
+
unicode-display_width (2.4.2)
|
84
|
+
|
85
|
+
PLATFORMS
|
86
|
+
arm64-darwin-21
|
87
|
+
ruby
|
88
|
+
x86_64-darwin-19
|
89
|
+
x86_64-darwin-20
|
90
|
+
x86_64-darwin-21
|
91
|
+
x86_64-linux
|
92
|
+
|
93
|
+
DEPENDENCIES
|
94
|
+
rspec (~> 3.12)
|
95
|
+
rubocop (~> 1.48)
|
96
|
+
rubocop-github (~> 0.20)
|
97
|
+
rubocop-performance (~> 1.16)
|
98
|
+
rubocop-rspec (~> 2.22)
|
99
|
+
simplecov (~> 0.22)
|
100
|
+
simplecov-erb (~> 1.0)
|
101
|
+
|
102
|
+
BUNDLED WITH
|
103
|
+
2.4.10
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 Grant Birkinbine
|
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 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,
|
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
# github-username-regex-ruby
|
2
|
+
|
3
|
+
[![test](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/test.yml/badge.svg)](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/test.yml) [![lint](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/lint.yml/badge.svg)](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/lint.yml) [![build](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/build.yml) [![release](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/release.yml/badge.svg)](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/release.yml) [![CodeQL](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/GrantBirki/github-username-regex-ruby/actions/workflows/codeql-analysis.yml)
|
4
|
+
|
5
|
+
A lightweight Ruby Gem to check if a GitHub username / handle is valid
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "github-username-regex-ruby"
|
7
|
+
spec.version = GitHubUsernameRegex::Version::VERSION
|
8
|
+
spec.authors = ["Grant Birkinbine"]
|
9
|
+
spec.email = "grant.birkinbine@gmail.com"
|
10
|
+
spec.license = "MIT"
|
11
|
+
|
12
|
+
spec.summary = "A lightweight Ruby Gem to check if a GitHub username / handle is valid"
|
13
|
+
spec.description = <<~SPEC_DESC
|
14
|
+
A lightweight Ruby Gem to check if a GitHub username / handle is valid using regex
|
15
|
+
SPEC_DESC
|
16
|
+
|
17
|
+
spec.homepage = "https://github.com/grantbirki/github-username-regex-ruby"
|
18
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GitHubUsernameRegex
|
4
|
+
|
5
|
+
# check if a GitHub username is valid
|
6
|
+
# :param username: the username to check (String)
|
7
|
+
# :return: true if the username is valid, false if it is invalid (Boolean)
|
8
|
+
def self.check(username)
|
9
|
+
# if the username is valid, return true
|
10
|
+
if username.match(/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i)
|
11
|
+
return true
|
12
|
+
# if the username is invalid, return false
|
13
|
+
else
|
14
|
+
return false
|
15
|
+
end
|
16
|
+
# if an error occurs, return false
|
17
|
+
rescue StandardError => _e
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
end
|
data/lib/version.rb
ADDED
data/script/bootstrap
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#! /usr/bin/env bash
|
2
|
+
|
3
|
+
# COLORS
|
4
|
+
OFF='\033[0m'
|
5
|
+
RED='\033[0;31m'
|
6
|
+
GREEN='\033[0;32m'
|
7
|
+
BLUE='\033[0;34m'
|
8
|
+
|
9
|
+
set -e # Prevent any kind of script failures
|
10
|
+
|
11
|
+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
|
12
|
+
[ -z "$RBENV_VERSION" ] && export RBENV_VERSION=$(cat "$DIR/.ruby-version")
|
13
|
+
[ -z "$APP_ENV" ] && export APP_ENV="development"
|
14
|
+
[ -d "/usr/share/rbenv/shims" ] && export PATH=/usr/share/rbenv/shims:$PATH
|
15
|
+
|
16
|
+
TRASHDIR=$(mktemp -d /tmp/bootstrap.XXXXXXXXXXXXXXXXX)
|
17
|
+
cleanup() {
|
18
|
+
rm -rf "$TRASHDIR"
|
19
|
+
# Remove empty directory
|
20
|
+
rmdir "$DIR/vendor/cache" 2>/dev/null || true
|
21
|
+
}
|
22
|
+
trap cleanup EXIT
|
23
|
+
|
24
|
+
# Bootstrap gem dependencies.
|
25
|
+
echo -e "💎 ${BLUE}Installing Gems...${OFF}"
|
26
|
+
if [ "$APP_ENV" == "production" ]; then
|
27
|
+
bundle install --path vendor/gems --local --without development
|
28
|
+
bundle binstubs --all
|
29
|
+
else
|
30
|
+
bundle install --path vendor/gems --local --with development
|
31
|
+
bundle binstubs --all
|
32
|
+
fi
|
data/script/test
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
#! /usr/bin/env bash
|
2
|
+
|
3
|
+
# run script/test -h for help
|
4
|
+
|
5
|
+
# COLORS
|
6
|
+
OFF='\033[0m'
|
7
|
+
RED='\033[0;31m'
|
8
|
+
GREEN='\033[0;32m'
|
9
|
+
BLUE='\033[0;34m'
|
10
|
+
|
11
|
+
set -e
|
12
|
+
|
13
|
+
function usage()
|
14
|
+
{
|
15
|
+
echo -e "\t ================== script/test usage =================="
|
16
|
+
echo -e "\t-h --help : displays help message"
|
17
|
+
echo -e "\t-k --no-linter : disables linting tests"
|
18
|
+
echo -e "\n\t Suggested flags for development: script/test"
|
19
|
+
}
|
20
|
+
|
21
|
+
while [ "$1" != "" ]; do
|
22
|
+
PARAM=`echo $1 | awk -F= '{print $1}'`
|
23
|
+
VALUE=`echo $1 | awk -F= '{print $2}'`
|
24
|
+
case $PARAM in
|
25
|
+
-h | --help)
|
26
|
+
usage
|
27
|
+
exit
|
28
|
+
;;
|
29
|
+
-k | --no-linter)
|
30
|
+
no_linter=1
|
31
|
+
;;
|
32
|
+
*)
|
33
|
+
echo "ERROR: unknown parameter \"$PARAM\""
|
34
|
+
usage
|
35
|
+
exit 1
|
36
|
+
;;
|
37
|
+
esac
|
38
|
+
shift
|
39
|
+
done
|
40
|
+
|
41
|
+
# setup
|
42
|
+
export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
|
43
|
+
[ -z "$RBENV_VERSION" ] && export RBENV_VERSION=$(cat "$DIR/.ruby-version")
|
44
|
+
|
45
|
+
# Run Rubocop
|
46
|
+
if [[ -z $no_linter ]]; then
|
47
|
+
echo -e "\n🤖 ${BLUE}Running Rubocop: $(date "+%H:%M:%S")${OFF}\n"
|
48
|
+
bundle exec bin/rubocop
|
49
|
+
else
|
50
|
+
echo -e "\n⏩ ${BLUE}Skipping Rubocop${OFF}"
|
51
|
+
fi
|
52
|
+
|
53
|
+
# run tests
|
54
|
+
echo -e "\n🧪 ${BLUE}Running tests: $(date "+%H:%M:%S")${OFF}\n"
|
55
|
+
cd "$(dirname $0)/.."
|
56
|
+
|
57
|
+
bundle exec bin/rspec spec && rspec_exit=$? || rspec_exit=$?
|
58
|
+
|
59
|
+
total_coverage=$(cat "$DIR/coverage/total-coverage.txt")
|
60
|
+
|
61
|
+
if grep -q "100.0" "$DIR/coverage/total-coverage.txt"; then
|
62
|
+
cov_exit=0
|
63
|
+
echo -e "\n✅ Total Coverage: ${GREEN}$total_coverage${OFF}"
|
64
|
+
else
|
65
|
+
cov_exit=1
|
66
|
+
echo -e "\n❌ Total Coverage: ${RED}$total_coverage${OFF}"
|
67
|
+
fi
|
68
|
+
|
69
|
+
echo ""
|
70
|
+
echo "---------------------------------------"
|
71
|
+
echo "📊 Summary Results"
|
72
|
+
echo "---------------------------------------"
|
73
|
+
echo ""
|
74
|
+
|
75
|
+
if [[ $rspec_exit == 0 ]]; then
|
76
|
+
echo -e "✅ ${GREEN}rspec: exitcode=${rspec_exit}${OFF}"
|
77
|
+
else
|
78
|
+
echo -e "❌ ${RED}rspec: exitcode=${rspec_exit}${OFF}"
|
79
|
+
fi
|
80
|
+
|
81
|
+
if [[ $cov_exit == 0 ]]; then
|
82
|
+
echo -e "✅ \033[0;32mcoverage: exitcode=${cov_exit}\033[0m"
|
83
|
+
else
|
84
|
+
echo -e "❌ \033[0;31mcoverage: exitcode=${cov_exit}\033[0m"
|
85
|
+
fi
|
86
|
+
|
87
|
+
[ $rspec_exit -gt 0 ] && exit 1
|
88
|
+
[ $cov_exit -gt 0 ] && exit 1
|
89
|
+
|
90
|
+
exit 0
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github-username-regex-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Grant Birkinbine
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: 'A lightweight Ruby Gem to check if a GitHub username / handle is valid
|
14
|
+
using regex
|
15
|
+
|
16
|
+
'
|
17
|
+
email: grant.birkinbine@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- ".github/workflows/build.yml"
|
23
|
+
- ".github/workflows/codeql-analysis.yml"
|
24
|
+
- ".github/workflows/lint.yml"
|
25
|
+
- ".github/workflows/release.yml"
|
26
|
+
- ".github/workflows/test.yml"
|
27
|
+
- ".gitignore"
|
28
|
+
- ".rubocop.yml"
|
29
|
+
- ".ruby-version"
|
30
|
+
- Gemfile
|
31
|
+
- Gemfile.lock
|
32
|
+
- LICENSE
|
33
|
+
- README.md
|
34
|
+
- github-username-regex-ruby.gemspec
|
35
|
+
- lib/github_username_regex_ruby.rb
|
36
|
+
- lib/version.rb
|
37
|
+
- script/bootstrap
|
38
|
+
- script/test
|
39
|
+
- vendor/cache/activesupport-7.0.5.gem
|
40
|
+
- vendor/cache/ast-2.4.2.gem
|
41
|
+
- vendor/cache/concurrent-ruby-1.2.2.gem
|
42
|
+
- vendor/cache/diff-lcs-1.5.0.gem
|
43
|
+
- vendor/cache/docile-1.4.0.gem
|
44
|
+
- vendor/cache/i18n-1.14.1.gem
|
45
|
+
- vendor/cache/json-2.6.3.gem
|
46
|
+
- vendor/cache/language_server-protocol-3.17.0.3.gem
|
47
|
+
- vendor/cache/minitest-5.18.1.gem
|
48
|
+
- vendor/cache/parallel-1.23.0.gem
|
49
|
+
- vendor/cache/parser-3.2.2.3.gem
|
50
|
+
- vendor/cache/racc-1.7.1.gem
|
51
|
+
- vendor/cache/rack-3.0.8.gem
|
52
|
+
- vendor/cache/rainbow-3.1.1.gem
|
53
|
+
- vendor/cache/regexp_parser-2.8.1.gem
|
54
|
+
- vendor/cache/rexml-3.2.5.gem
|
55
|
+
- vendor/cache/rspec-3.12.0.gem
|
56
|
+
- vendor/cache/rspec-core-3.12.2.gem
|
57
|
+
- vendor/cache/rspec-expectations-3.12.3.gem
|
58
|
+
- vendor/cache/rspec-mocks-3.12.5.gem
|
59
|
+
- vendor/cache/rspec-support-3.12.0.gem
|
60
|
+
- vendor/cache/rubocop-1.53.0.gem
|
61
|
+
- vendor/cache/rubocop-ast-1.29.0.gem
|
62
|
+
- vendor/cache/rubocop-capybara-2.18.0.gem
|
63
|
+
- vendor/cache/rubocop-factory_bot-2.23.1.gem
|
64
|
+
- vendor/cache/rubocop-github-0.20.0.gem
|
65
|
+
- vendor/cache/rubocop-performance-1.18.0.gem
|
66
|
+
- vendor/cache/rubocop-rails-2.20.2.gem
|
67
|
+
- vendor/cache/rubocop-rspec-2.22.0.gem
|
68
|
+
- vendor/cache/ruby-progressbar-1.13.0.gem
|
69
|
+
- vendor/cache/simplecov-0.22.0.gem
|
70
|
+
- vendor/cache/simplecov-erb-1.0.1.gem
|
71
|
+
- vendor/cache/simplecov-html-0.12.3.gem
|
72
|
+
- vendor/cache/simplecov_json_formatter-0.1.4.gem
|
73
|
+
- vendor/cache/tzinfo-2.0.6.gem
|
74
|
+
- vendor/cache/unicode-display_width-2.4.2.gem
|
75
|
+
homepage: https://github.com/grantbirki/github-username-regex-ruby
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 3.1.0
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubygems_version: 3.4.10
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: A lightweight Ruby Gem to check if a GitHub username / handle is valid
|
98
|
+
test_files: []
|