liberty 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.qlty/.gitignore +7 -0
- data/.qlty/qlty.toml +81 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +22 -1
- data/lib/liberty/adapters/request.rb +4 -0
- data/lib/liberty/adapters/response.rb +9 -1
- data/lib/liberty/router.rb +16 -2
- data/lib/liberty/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44e1f59a2b827b9bda2ec873fca9e2592db73e23d9ad946ee673be3cca0c8d37
|
|
4
|
+
data.tar.gz: 8ed828dddae3cc7fbce9957bce6d66a11801f13499761728ca03befd954655cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 77a90f8920aef4886192435fecc60c46bdb317405ff447db995b9fd264136bd996c6b3b1123c502b7ad375addc8c2756a6dcecfeccdd3bf573b67b54e4d62703
|
|
7
|
+
data.tar.gz: 7891e701f9c931e6e43488e2b45bdd47eb0790e4b8fd098aeb7870386460db43d36357768f1010bac54e819530bdad99dc7e26147e92e351af24a0cbb7b2ad84
|
data/.qlty/.gitignore
ADDED
data/.qlty/qlty.toml
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# This file was automatically generated by `qlty init`.
|
|
2
|
+
# You can modify it to suit your needs.
|
|
3
|
+
# We recommend you to commit this file to your repository.
|
|
4
|
+
#
|
|
5
|
+
# This configuration is used by both Qlty CLI and Qlty Cloud.
|
|
6
|
+
#
|
|
7
|
+
# Qlty CLI -- Code quality toolkit for developers
|
|
8
|
+
# Qlty Cloud -- Fully automated Code Health Platform
|
|
9
|
+
#
|
|
10
|
+
# Try Qlty Cloud: https://qlty.sh
|
|
11
|
+
#
|
|
12
|
+
# For a guide to configuration, visit https://qlty.sh/d/config
|
|
13
|
+
# Or for a full reference, visit https://qlty.sh/d/qlty-toml
|
|
14
|
+
config_version = "0"
|
|
15
|
+
|
|
16
|
+
exclude_patterns = [
|
|
17
|
+
"*_min.*",
|
|
18
|
+
"*-min.*",
|
|
19
|
+
"*.min.*",
|
|
20
|
+
"**/.yarn/**",
|
|
21
|
+
"**/*.d.ts",
|
|
22
|
+
"**/assets/**",
|
|
23
|
+
"**/bower_components/**",
|
|
24
|
+
"**/build/**",
|
|
25
|
+
"**/cache/**",
|
|
26
|
+
"**/config/**",
|
|
27
|
+
"**/db/**",
|
|
28
|
+
"**/deps/**",
|
|
29
|
+
"**/dist/**",
|
|
30
|
+
"**/extern/**",
|
|
31
|
+
"**/external/**",
|
|
32
|
+
"**/generated/**",
|
|
33
|
+
"**/Godeps/**",
|
|
34
|
+
"**/gradlew/**",
|
|
35
|
+
"**/mvnw/**",
|
|
36
|
+
"**/node_modules/**",
|
|
37
|
+
"**/protos/**",
|
|
38
|
+
"**/seed/**",
|
|
39
|
+
"**/target/**",
|
|
40
|
+
"**/templates/**",
|
|
41
|
+
"**/testdata/**",
|
|
42
|
+
"**/vendor/**",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
test_patterns = [
|
|
46
|
+
"**/test/**",
|
|
47
|
+
"**/spec/**",
|
|
48
|
+
"**/*.test.*",
|
|
49
|
+
"**/*.spec.*",
|
|
50
|
+
"**/*_test.*",
|
|
51
|
+
"**/*_spec.*",
|
|
52
|
+
"**/test_*.*",
|
|
53
|
+
"**/spec_*.*",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[smells]
|
|
57
|
+
mode = "comment"
|
|
58
|
+
|
|
59
|
+
[[source]]
|
|
60
|
+
name = "default"
|
|
61
|
+
default = true
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
[[plugin]]
|
|
65
|
+
name = "actionlint"
|
|
66
|
+
|
|
67
|
+
[[plugin]]
|
|
68
|
+
name = "osv-scanner"
|
|
69
|
+
|
|
70
|
+
[[plugin]]
|
|
71
|
+
name = "ripgrep"
|
|
72
|
+
mode = "comment"
|
|
73
|
+
|
|
74
|
+
[[plugin]]
|
|
75
|
+
name = "standardrb"
|
|
76
|
+
|
|
77
|
+
[[plugin]]
|
|
78
|
+
name = "trufflehog"
|
|
79
|
+
|
|
80
|
+
[[plugin]]
|
|
81
|
+
name = "zizmor"
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [0.3.1] - 2026-09-07
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
- Responds to `HEAD` requests with an empty body, as the Rack specification requires. Status and headers, including `content-length`, still describe what the matching `GET` would return.
|
|
6
|
+
- Responds to `HEAD` requests for unknown routes with a 404 and an empty body.
|
|
7
|
+
- Builds the 404 response per request instead of reusing a frozen constant, which Rack::Lint rejects.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Adds `qlty` and `flog` tasks to the default Rake task, alongside `spec` and `standard`.
|
|
12
|
+
|
|
1
13
|
## [0.3.0] - 2026-09-06
|
|
2
14
|
|
|
3
15
|
### Breaking changes
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
|
@@ -7,4 +7,25 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
7
7
|
|
|
8
8
|
require "standard/rake"
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
FLOG_LIMIT = 10.0
|
|
11
|
+
|
|
12
|
+
def qlty_bin
|
|
13
|
+
installed = File.expand_path("~/.qlty/bin/qlty")
|
|
14
|
+
ENV.fetch("QLTY_BIN") { File.exist?(installed) ? installed : "qlty" }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Run qlty lint checks and report code smells"
|
|
18
|
+
task :qlty do
|
|
19
|
+
sh qlty_bin, "check", "--all", "--no-progress"
|
|
20
|
+
sh qlty_bin, "smells", "--all", "--quiet"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "Fail when the average flog score per method reaches #{FLOG_LIMIT}"
|
|
24
|
+
task :flog do
|
|
25
|
+
report = `bundle exec flog -m lib`
|
|
26
|
+
puts report
|
|
27
|
+
average = report[/^\s*([\d.]+): flog\/method average/, 1].to_f
|
|
28
|
+
abort("Quality gate failed: average flog #{average} is #{FLOG_LIMIT} or higher") if average >= FLOG_LIMIT
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
task default: %i[spec standard qlty flog]
|
|
@@ -17,7 +17,7 @@ module Liberty
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def to_rack_response
|
|
20
|
-
[status, headers,
|
|
20
|
+
[status, headers, rack_body]
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
private
|
|
@@ -26,6 +26,14 @@ module Liberty
|
|
|
26
26
|
endpoint.status
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
def rack_body
|
|
30
|
+
head? ? [] : [content]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def head?
|
|
34
|
+
endpoint.request.head?
|
|
35
|
+
end
|
|
36
|
+
|
|
29
37
|
def headers
|
|
30
38
|
headers = {CONTENT_LENGTH => content_length}
|
|
31
39
|
headers[CONTENT_TYPE] = content_type if content_type
|
data/lib/liberty/router.rb
CHANGED
|
@@ -15,7 +15,9 @@ module Liberty
|
|
|
15
15
|
PATH_INFO = "PATH_INFO"
|
|
16
16
|
ROUTER_PARAMS = "router.params"
|
|
17
17
|
DYNAMIC_PREFIX = /:/
|
|
18
|
-
|
|
18
|
+
NOT_FOUND_STATUS = 404
|
|
19
|
+
NOT_FOUND_BODY = "Not Found"
|
|
20
|
+
CONTENT_LENGTH = "content-length"
|
|
19
21
|
|
|
20
22
|
def initialize
|
|
21
23
|
@apps = {}
|
|
@@ -46,7 +48,7 @@ module Liberty
|
|
|
46
48
|
|
|
47
49
|
def call(env)
|
|
48
50
|
endpoint = find_endpoint(env[REQUEST_METHOD], env[PATH_INFO]) { |params| env[ROUTER_PARAMS] = params }
|
|
49
|
-
endpoint ? endpoint.call(env) :
|
|
51
|
+
endpoint ? endpoint.call(env) : not_found_response(env)
|
|
50
52
|
end
|
|
51
53
|
|
|
52
54
|
def print(stdout = $stdout)
|
|
@@ -55,6 +57,18 @@ module Liberty
|
|
|
55
57
|
|
|
56
58
|
private
|
|
57
59
|
|
|
60
|
+
def not_found_response(env)
|
|
61
|
+
[NOT_FOUND_STATUS, not_found_headers, not_found_body(env)]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def not_found_headers
|
|
65
|
+
{CONTENT_LENGTH => NOT_FOUND_BODY.bytesize.to_s}
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def not_found_body(env)
|
|
69
|
+
(env[REQUEST_METHOD] == HEAD) ? [] : [NOT_FOUND_BODY]
|
|
70
|
+
end
|
|
71
|
+
|
|
58
72
|
def register_route(verb, path, to)
|
|
59
73
|
dynamic?(path) ? register_dynamic_route(verb, path, to) : register_static_route(verb, path, to)
|
|
60
74
|
end
|
data/lib/liberty/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: liberty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alan Ridlehoover
|
|
@@ -102,6 +102,8 @@ executables: []
|
|
|
102
102
|
extensions: []
|
|
103
103
|
extra_rdoc_files: []
|
|
104
104
|
files:
|
|
105
|
+
- ".qlty/.gitignore"
|
|
106
|
+
- ".qlty/qlty.toml"
|
|
105
107
|
- ".rspec"
|
|
106
108
|
- ".ruby-version"
|
|
107
109
|
- ".standard.yml"
|