Skip to content

Commit cd69c45

Browse files
committed
Initial commit
0 parents  commit cd69c45

19 files changed

+1013
-0
lines changed

.github/workflows/ci.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
ruby-version: ["2.7", "3.0"]
15+
16+
env:
17+
RUBYOPT: "-W:no-experimental"
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: ${{ matrix.ruby-version }}
25+
bundler-cache: true
26+
- name: Run tests
27+
run: bundle exec rspec
28+
- name: Perform type check
29+
run: bundle exec steep check
30+
- name: Lint
31+
run: bundle exec rubocop
32+
- name: Check documentation coverage
33+
run: bundle exec yard stats --list-undoc

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/.bundle/
2+
/.vscode/
3+
/.yardoc
4+
/_yardoc/
5+
/coverage/
6+
/doc/
7+
/pkg/
8+
/spec/reports/
9+
/tmp/
10+
/vendor/
11+
12+
# rspec failure tracking
13+
.rspec_status

.rspec

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--format documentation
2+
--color
3+
--require spec_helper

.rubocop.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
AllCops:
2+
TargetRubyVersion: 2.7
3+
NewCops: enable
4+
Metrics/AbcSize:
5+
Enabled: false
6+
Metrics/BlockLength:
7+
Exclude:
8+
- "Rakefile"
9+
- "**/*.rake"
10+
- "spec/**/*.rb"
11+
Metrics/CyclomaticComplexity:
12+
Enabled: false
13+
Metrics/ClassLength:
14+
Max: 500
15+
Metrics/MethodLength:
16+
Max: 100
17+
Metrics/ParameterLists:
18+
Max: 7
19+
Metrics/PerceivedComplexity:
20+
Max: 15
21+
Style/ConditionalAssignment:
22+
Enabled: false

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0.1

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [v0.0.1] - 2021-12-09
11+
12+
Initial release.
13+
14+
[unreleased]: https://github.com/package-url/packageurl-ruby/releases/tag/v0.1.0...main
15+
[v0.1.0]: https://github.com/package-url/packageurl-ruby/releases/tag/v0.1.0

Gemfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
5+
gemspec
6+
7+
gem 'bundler', '~> 2.0'
8+
gem 'rake', '~> 13.0'
9+
gem 'rspec', '~> 3.0'
10+
gem 'rubocop', '~> 1.23.0'
11+
gem 'rubocop-rake', '~> 0.6.0'
12+
gem 'rubocop-rspec', '~> 2.6.0'
13+
gem 'steep', '~> 0.46.0'
14+
gem 'yard', '~> 0.9.0'

Gemfile.lock

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
PATH
2+
remote: .
3+
specs:
4+
packageurl-ruby (0.1.0)
5+
6+
GEM
7+
remote: https://rubygems.org/
8+
specs:
9+
activesupport (6.1.4.1)
10+
concurrent-ruby (~> 1.0, >= 1.0.2)
11+
i18n (>= 1.6, < 2)
12+
minitest (>= 5.1)
13+
tzinfo (~> 2.0)
14+
zeitwerk (~> 2.3)
15+
ast (2.4.2)
16+
concurrent-ruby (1.1.9)
17+
diff-lcs (1.4.4)
18+
ffi (1.15.4)
19+
i18n (1.8.11)
20+
concurrent-ruby (~> 1.0)
21+
language_server-protocol (3.16.0.3)
22+
listen (3.7.0)
23+
rb-fsevent (~> 0.10, >= 0.10.3)
24+
rb-inotify (~> 0.9, >= 0.9.10)
25+
minitest (5.14.4)
26+
parallel (1.21.0)
27+
parser (3.0.3.0)
28+
ast (~> 2.4.1)
29+
rainbow (3.0.0)
30+
rake (13.0.6)
31+
rb-fsevent (0.11.0)
32+
rb-inotify (0.10.1)
33+
ffi (~> 1.0)
34+
rbs (1.7.1)
35+
regexp_parser (2.1.1)
36+
rexml (3.2.5)
37+
rspec (3.10.0)
38+
rspec-core (~> 3.10.0)
39+
rspec-expectations (~> 3.10.0)
40+
rspec-mocks (~> 3.10.0)
41+
rspec-core (3.10.1)
42+
rspec-support (~> 3.10.0)
43+
rspec-expectations (3.10.1)
44+
diff-lcs (>= 1.2.0, < 2.0)
45+
rspec-support (~> 3.10.0)
46+
rspec-mocks (3.10.2)
47+
diff-lcs (>= 1.2.0, < 2.0)
48+
rspec-support (~> 3.10.0)
49+
rspec-support (3.10.3)
50+
rubocop (1.23.0)
51+
parallel (~> 1.10)
52+
parser (>= 3.0.0.0)
53+
rainbow (>= 2.2.2, < 4.0)
54+
regexp_parser (>= 1.8, < 3.0)
55+
rexml
56+
rubocop-ast (>= 1.12.0, < 2.0)
57+
ruby-progressbar (~> 1.7)
58+
unicode-display_width (>= 1.4.0, < 3.0)
59+
rubocop-ast (1.13.0)
60+
parser (>= 3.0.1.1)
61+
rubocop-rake (0.6.0)
62+
rubocop (~> 1.0)
63+
rubocop-rspec (2.6.0)
64+
rubocop (~> 1.19)
65+
ruby-progressbar (1.11.0)
66+
steep (0.46.0)
67+
activesupport (>= 5.1)
68+
language_server-protocol (>= 3.15, < 4.0)
69+
listen (~> 3.0)
70+
parallel (>= 1.0.0)
71+
parser (>= 3.0)
72+
rainbow (>= 2.2.2, < 4.0)
73+
rbs (>= 1.2.0)
74+
terminal-table (>= 2, < 4)
75+
terminal-table (3.0.2)
76+
unicode-display_width (>= 1.1.1, < 3)
77+
tzinfo (2.0.4)
78+
concurrent-ruby (~> 1.0)
79+
unicode-display_width (2.1.0)
80+
yard (0.9.26)
81+
zeitwerk (2.5.1)
82+
83+
PLATFORMS
84+
x86_64-darwin-19
85+
x86_64-darwin-20
86+
x86_64-linux
87+
88+
DEPENDENCIES
89+
bundler (~> 2.0)
90+
packageurl-ruby!
91+
rake (~> 13.0)
92+
rspec (~> 3.0)
93+
rubocop (~> 1.23.0)
94+
rubocop-rake (~> 0.6.0)
95+
rubocop-rspec (~> 2.6.0)
96+
steep (~> 0.46.0)
97+
yard (~> 0.9.0)
98+
99+
BUNDLED WITH
100+
2.2.32

README.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# packageurl-ruby
2+
3+
![CI][ci badge]
4+
5+
A Ruby implementation of the [package url specification][purl-spec].
6+
7+
## Requirements
8+
9+
- Ruby 2.7+
10+
11+
## Installation
12+
13+
Add this line to your application's Gemfile:
14+
15+
```ruby
16+
gem 'packageurl-ruby'
17+
```
18+
19+
And then execute:
20+
21+
```console
22+
$ bundle install
23+
```
24+
25+
Or install it yourself as:
26+
27+
```console
28+
$ gem install packageurl-ruby
29+
```
30+
31+
## Usage
32+
33+
```ruby
34+
require 'packageurl-ruby'
35+
36+
purl = PackageURL.parse("pkg:gem/[email protected]")
37+
purl.type # "gem"
38+
purl.name # "rails"
39+
purl.version # "6.1.4"
40+
41+
# supports pattern matching with hashes and arrays
42+
case purl
43+
in type: 'gem', name: 'rails'
44+
puts 'Yay! You’re on Rails!'
45+
in ['pkg', 'gem', *]
46+
puts '🦊🗯 "Ruby is easy to read"'
47+
end
48+
```
49+
50+
## Development
51+
52+
After checking out the repo, run `bin/setup` to install dependencies.
53+
Then, run `rake spec` to run the tests.
54+
You can also run `bin/console` for an interactive prompt
55+
that will allow you to experiment.
56+
57+
To install this gem onto your local machine,
58+
run `bundle exec rake install`.
59+
To release a new version,
60+
update the version number in `version.rb`,
61+
and then run `bundle exec rake release`,
62+
which will create a git tag for the version,
63+
push git commits and the created tag,
64+
and push the `.gem` file to [rubygems.org](https://rubygems.org).
65+
66+
[ci badge]: https://github.com/mattt/packageurl-ruby/workflows/CI/badge.svg
67+
[purl-spec]: https://github.com/package-url/purl-spec

Rakefile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
namespace :steep do
9+
task :check do
10+
system 'steep check'
11+
end
12+
end
13+
14+
task default: %i[spec steep:check]

Steepfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
target :lib do
4+
signature 'sig'
5+
6+
check 'lib'
7+
8+
library 'uri'
9+
10+
configure_code_diagnostics do |config|
11+
config[Steep::Diagnostic::Ruby::UnsupportedSyntax] = :hint
12+
config[Steep::Diagnostic::Ruby::MethodDefinitionMissing] = :hint
13+
end
14+
end
15+
16+
target :test do
17+
signature 'sig'
18+
19+
check 'test'
20+
21+
library 'uri'
22+
end

bin/console

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'bundler/setup'
5+
require 'package_url'
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__)

bin/setup

+8
Original file line numberDiff line numberDiff line change
@@ -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 commit comments

Comments
 (0)