ratalada 0.2.0 → 1.0.0
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/README.md +42 -5
- data/lib/ratalada/version.rb +1 -1
- metadata +1 -37
- data/.envrc +0 -1
- data/.gitignore +0 -11
- data/Gemfile +0 -5
- data/Gemfile.lock +0 -125
- data/Rakefile +0 -11
- data/bin/console +0 -8
- data/bin/increment-version +0 -44
- data/bin/release-gem +0 -32
- data/bin/setup +0 -10
- data/bin/tag-version +0 -19
- data/bin/test +0 -14
- data/examples/README.md +0 -56
- data/examples/brute.rb +0 -28
- data/examples/falcon.rb +0 -16
- data/examples/puma.rb +0 -16
- data/examples/sinatra.rb +0 -23
- data/flake.lock +0 -61
- data/flake.nix +0 -38
- data/lib/ratalada/sinatra.rb +0 -20
- data/lib/ratalada/version.rb.erb +0 -5
- data/ratalada.gemspec +0 -38
- data/ratalada.gemspec.erb +0 -34
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73ea752f5d6ce4bf6e29adbf7ffd4bf0e4268b5b101f0b598c85139d3c2d950d
|
|
4
|
+
data.tar.gz: 2302c8c9e7eebb884c61ec45bd8c1be23af6085af5a14fe694969f47d70b971c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06f563d4c1de92706df455f2b7eb39d5ca59d1c4709b2ffe07d222f43b6101b4cfcb68493ad492341d8bd75d63d930d1f70c9d79d9fac1e62535f5882be1b335
|
|
7
|
+
data.tar.gz: 6484687565f459c17b9a06463b14a74b7df4285f69ab64ee108c5b2253cc86879646972e95a44be4811d92c511a7df6c52261df2fa44634c15fdea81065049eb
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# ratalada
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
A DSL for running Rack servers as easily as you can in JavaScript.
|
|
4
6
|
|
|
5
7
|
```ruby
|
|
@@ -17,11 +19,26 @@ That's a whole app. Run the file, and it's listening on `http://127.0.0.1:9292`.
|
|
|
17
19
|
## Installation
|
|
18
20
|
|
|
19
21
|
```bash
|
|
20
|
-
gem install ratalada
|
|
22
|
+
gem install ratalada puma # core + a server to run on
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The core `ratalada` gem is the router, the backends, and the DSL. It has no
|
|
26
|
+
runtime dependencies of its own — install whichever server you run on (`puma`
|
|
27
|
+
or `falcon`).
|
|
28
|
+
|
|
29
|
+
The Sinatra and Grape DSLs are optional add-ons, each its own gem:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
gem install ratalada-sinatra # enables require "ratalada/sinatra"
|
|
33
|
+
gem install ratalada-grape # enables require "ratalada/grape"
|
|
21
34
|
```
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
They ship separately because their dependencies conflict (Grape needs
|
|
37
|
+
`mustermann` 4, Sinatra needs `mustermann` 3), so bundling both into `ratalada`
|
|
38
|
+
would force you to pick one. **The require path is the same either way**:
|
|
39
|
+
install `ratalada-grape`, then `require "ratalada/grape"`. The adapter file
|
|
40
|
+
lives under the shared `ratalada/` namespace on the load path, so the `require`
|
|
41
|
+
never names the gem — only the file you want.
|
|
25
42
|
|
|
26
43
|
## Usage
|
|
27
44
|
|
|
@@ -54,8 +71,8 @@ Server.run do |request|
|
|
|
54
71
|
end
|
|
55
72
|
```
|
|
56
73
|
|
|
57
|
-
Prefer Sinatra's routing?
|
|
58
|
-
required:
|
|
74
|
+
Prefer Sinatra's routing? Install `ratalada-sinatra`, then swap the frontend
|
|
75
|
+
and keep whichever backend you required:
|
|
59
76
|
|
|
60
77
|
```ruby
|
|
61
78
|
require "ratalada/falcon"
|
|
@@ -68,6 +85,26 @@ Server.run do
|
|
|
68
85
|
end
|
|
69
86
|
```
|
|
70
87
|
|
|
88
|
+
Or Grape, from `ratalada-grape`:
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
require "ratalada/falcon"
|
|
92
|
+
require "ratalada/grape"
|
|
93
|
+
|
|
94
|
+
Server.run do
|
|
95
|
+
format :txt
|
|
96
|
+
|
|
97
|
+
get "/" do
|
|
98
|
+
"hello\n"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Requiring a frontend only changes how the block builds the app, not which
|
|
104
|
+
server runs it. Each of these adapters is a separate gem (`ratalada-sinatra`,
|
|
105
|
+
`ratalada-grape`), but the `require "ratalada/<name>"` line is all your code
|
|
106
|
+
ever sees.
|
|
107
|
+
|
|
71
108
|
The host and port default to `127.0.0.1:9292`, configurable via the `HOST` and
|
|
72
109
|
`PORT` environment variables or explicitly:
|
|
73
110
|
|
data/lib/ratalada/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ratalada
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan K
|
|
@@ -65,20 +65,6 @@ dependencies:
|
|
|
65
65
|
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
67
|
version: '0'
|
|
68
|
-
- !ruby/object:Gem::Dependency
|
|
69
|
-
name: sinatra
|
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - ">="
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: '0'
|
|
75
|
-
type: :development
|
|
76
|
-
prerelease: false
|
|
77
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - ">="
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: '0'
|
|
82
68
|
description: 'DSL for running rack servers as easily as you can in javasript.
|
|
83
69
|
|
|
84
70
|
'
|
|
@@ -89,35 +75,13 @@ executables:
|
|
|
89
75
|
extensions: []
|
|
90
76
|
extra_rdoc_files: []
|
|
91
77
|
files:
|
|
92
|
-
- ".envrc"
|
|
93
|
-
- ".gitignore"
|
|
94
|
-
- Gemfile
|
|
95
|
-
- Gemfile.lock
|
|
96
78
|
- LICENSE
|
|
97
79
|
- README.md
|
|
98
|
-
- Rakefile
|
|
99
|
-
- bin/console
|
|
100
|
-
- bin/increment-version
|
|
101
|
-
- bin/release-gem
|
|
102
|
-
- bin/setup
|
|
103
|
-
- bin/tag-version
|
|
104
|
-
- bin/test
|
|
105
|
-
- examples/README.md
|
|
106
|
-
- examples/brute.rb
|
|
107
|
-
- examples/falcon.rb
|
|
108
|
-
- examples/puma.rb
|
|
109
|
-
- examples/sinatra.rb
|
|
110
80
|
- exe/ratalada
|
|
111
|
-
- flake.lock
|
|
112
|
-
- flake.nix
|
|
113
81
|
- lib/ratalada.rb
|
|
114
82
|
- lib/ratalada/falcon.rb
|
|
115
83
|
- lib/ratalada/puma.rb
|
|
116
|
-
- lib/ratalada/sinatra.rb
|
|
117
84
|
- lib/ratalada/version.rb
|
|
118
|
-
- lib/ratalada/version.rb.erb
|
|
119
|
-
- ratalada.gemspec
|
|
120
|
-
- ratalada.gemspec.erb
|
|
121
85
|
homepage: https://github.com/n-at-han-k/ratalada
|
|
122
86
|
licenses:
|
|
123
87
|
- MIT
|
data/.envrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
use flake
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
ratalada (0.1.1)
|
|
5
|
-
|
|
6
|
-
GEM
|
|
7
|
-
remote: https://rubygems.org/
|
|
8
|
-
specs:
|
|
9
|
-
async (2.42.0)
|
|
10
|
-
console (~> 1.29)
|
|
11
|
-
fiber-annotation
|
|
12
|
-
io-event (~> 1.11)
|
|
13
|
-
metrics (~> 0.12)
|
|
14
|
-
traces (~> 0.18)
|
|
15
|
-
async-container (0.37.0)
|
|
16
|
-
async (~> 2.22)
|
|
17
|
-
async-http (0.95.1)
|
|
18
|
-
async (>= 2.10.2)
|
|
19
|
-
async-pool (~> 0.11)
|
|
20
|
-
io-endpoint (~> 0.14)
|
|
21
|
-
io-stream (~> 0.6)
|
|
22
|
-
metrics (~> 0.12)
|
|
23
|
-
protocol-http (~> 0.62)
|
|
24
|
-
protocol-http1 (~> 0.39)
|
|
25
|
-
protocol-http2 (~> 0.26)
|
|
26
|
-
protocol-url (~> 0.2)
|
|
27
|
-
traces (~> 0.10)
|
|
28
|
-
async-http-cache (0.4.6)
|
|
29
|
-
async-http (~> 0.56)
|
|
30
|
-
async-pool (0.11.2)
|
|
31
|
-
async (>= 2.0)
|
|
32
|
-
async-service (0.24.1)
|
|
33
|
-
async
|
|
34
|
-
async-container (~> 0.34)
|
|
35
|
-
string-format (~> 0.2)
|
|
36
|
-
async-utilization (0.4.0)
|
|
37
|
-
console (~> 1.0)
|
|
38
|
-
bake (0.25.0)
|
|
39
|
-
bigdecimal
|
|
40
|
-
samovar (~> 2.1)
|
|
41
|
-
base64 (0.3.0)
|
|
42
|
-
bigdecimal (4.1.2)
|
|
43
|
-
console (1.36.0)
|
|
44
|
-
fiber-annotation
|
|
45
|
-
fiber-local (~> 1.1)
|
|
46
|
-
json
|
|
47
|
-
falcon (0.55.5)
|
|
48
|
-
async
|
|
49
|
-
async-container (~> 0.20)
|
|
50
|
-
async-http (~> 0.75)
|
|
51
|
-
async-http-cache (~> 0.4)
|
|
52
|
-
async-service (~> 0.19)
|
|
53
|
-
async-utilization (~> 0.3)
|
|
54
|
-
bundler
|
|
55
|
-
localhost (~> 1.1)
|
|
56
|
-
openssl (>= 3.0)
|
|
57
|
-
protocol-http (~> 0.31)
|
|
58
|
-
protocol-rack (~> 0.7)
|
|
59
|
-
samovar (~> 2.3)
|
|
60
|
-
fiber-annotation (0.2.0)
|
|
61
|
-
fiber-local (1.1.0)
|
|
62
|
-
fiber-storage
|
|
63
|
-
fiber-storage (1.0.1)
|
|
64
|
-
io-endpoint (0.17.2)
|
|
65
|
-
io-event (1.19.1)
|
|
66
|
-
io-stream (0.13.1)
|
|
67
|
-
json (2.20.0)
|
|
68
|
-
localhost (1.8.0)
|
|
69
|
-
bake
|
|
70
|
-
logger (1.7.0)
|
|
71
|
-
metrics (0.15.0)
|
|
72
|
-
minitest (5.27.0)
|
|
73
|
-
mustermann (3.1.1)
|
|
74
|
-
nio4r (2.7.5)
|
|
75
|
-
openssl (4.0.2)
|
|
76
|
-
protocol-hpack (1.5.1)
|
|
77
|
-
protocol-http (0.62.2)
|
|
78
|
-
protocol-http1 (0.39.0)
|
|
79
|
-
protocol-http (~> 0.62)
|
|
80
|
-
protocol-http2 (0.26.0)
|
|
81
|
-
protocol-hpack (~> 1.4)
|
|
82
|
-
protocol-http (~> 0.62)
|
|
83
|
-
protocol-rack (0.22.1)
|
|
84
|
-
io-stream (>= 0.10)
|
|
85
|
-
protocol-http (~> 0.58)
|
|
86
|
-
rack (>= 1.0)
|
|
87
|
-
protocol-url (0.4.0)
|
|
88
|
-
puma (8.0.2)
|
|
89
|
-
nio4r (~> 2.0)
|
|
90
|
-
rack (3.2.6)
|
|
91
|
-
rack-protection (4.2.1)
|
|
92
|
-
base64 (>= 0.1.0)
|
|
93
|
-
logger (>= 1.6.0)
|
|
94
|
-
rack (>= 3.0.0, < 4)
|
|
95
|
-
rack-session (2.1.2)
|
|
96
|
-
base64 (>= 0.1.0)
|
|
97
|
-
rack (>= 3.0.0)
|
|
98
|
-
rake (13.4.2)
|
|
99
|
-
samovar (2.5.1)
|
|
100
|
-
console (~> 1.0)
|
|
101
|
-
sinatra (4.2.1)
|
|
102
|
-
logger (>= 1.6.0)
|
|
103
|
-
mustermann (~> 3.0)
|
|
104
|
-
rack (>= 3.0.0, < 4)
|
|
105
|
-
rack-protection (= 4.2.1)
|
|
106
|
-
rack-session (>= 2.0.0, < 3)
|
|
107
|
-
tilt (~> 2.0)
|
|
108
|
-
string-format (0.2.0)
|
|
109
|
-
tilt (2.8.0)
|
|
110
|
-
traces (0.18.2)
|
|
111
|
-
|
|
112
|
-
PLATFORMS
|
|
113
|
-
ruby
|
|
114
|
-
x86_64-linux
|
|
115
|
-
|
|
116
|
-
DEPENDENCIES
|
|
117
|
-
falcon
|
|
118
|
-
minitest (~> 5.0)
|
|
119
|
-
puma
|
|
120
|
-
rake (~> 13.0)
|
|
121
|
-
ratalada!
|
|
122
|
-
sinatra
|
|
123
|
-
|
|
124
|
-
BUNDLED WITH
|
|
125
|
-
2.6.9
|
data/Rakefile
DELETED
data/bin/console
DELETED
data/bin/increment-version
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "erb"
|
|
5
|
-
require_relative "../lib/ratalada/version"
|
|
6
|
-
|
|
7
|
-
USAGE = <<~TEXT
|
|
8
|
-
Usage: bin/increment-version <major|minor|patch>
|
|
9
|
-
TEXT
|
|
10
|
-
|
|
11
|
-
segment = ARGV[0]
|
|
12
|
-
|
|
13
|
-
unless %w[major minor patch].include?(segment)
|
|
14
|
-
warn USAGE
|
|
15
|
-
exit 1
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
current = Ratalada::VERSION
|
|
19
|
-
major, minor, patch = current.split(".").map(&:to_i)
|
|
20
|
-
|
|
21
|
-
case segment
|
|
22
|
-
when "major"
|
|
23
|
-
major += 1
|
|
24
|
-
minor = 0
|
|
25
|
-
patch = 0
|
|
26
|
-
when "minor"
|
|
27
|
-
minor += 1
|
|
28
|
-
patch = 0
|
|
29
|
-
when "patch"
|
|
30
|
-
patch += 1
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
version = "#{major}.#{minor}.#{patch}"
|
|
34
|
-
|
|
35
|
-
template_path = File.expand_path("../lib/ratalada/version.rb.erb", __dir__)
|
|
36
|
-
output_path = File.expand_path("../lib/ratalada/version.rb", __dir__)
|
|
37
|
-
|
|
38
|
-
template = ERB.new(File.read(template_path))
|
|
39
|
-
result = template.result(binding)
|
|
40
|
-
|
|
41
|
-
File.write(output_path, result)
|
|
42
|
-
|
|
43
|
-
puts "#{current} -> #{version}"
|
|
44
|
-
|
data/bin/release-gem
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative "../lib/ratalada/version"
|
|
5
|
-
|
|
6
|
-
local_version = Ratalada::VERSION
|
|
7
|
-
gem_name = "ratalada"
|
|
8
|
-
gemspec = "ratalada.gemspec"
|
|
9
|
-
|
|
10
|
-
puts "Local version: #{local_version}"
|
|
11
|
-
|
|
12
|
-
remote_output = `gem specification #{gem_name} version --remote 2>&1`
|
|
13
|
-
|
|
14
|
-
if $?.success?
|
|
15
|
-
remote_version = remote_output[/version: (.+)/, 1]&.strip
|
|
16
|
-
puts "Remote version: #{remote_version}"
|
|
17
|
-
|
|
18
|
-
if Gem::Version.new(local_version) <= Gem::Version.new(remote_version)
|
|
19
|
-
abort "ERROR: Local version (#{local_version}) has not been incremented past remote (#{remote_version})"
|
|
20
|
-
end
|
|
21
|
-
else
|
|
22
|
-
puts "Gem not yet published remotely, proceeding with first release"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
puts "Building #{gemspec}..."
|
|
26
|
-
system("gem build #{gemspec}") || abort("ERROR: gem build failed")
|
|
27
|
-
|
|
28
|
-
gem_file = "#{gem_name}-#{local_version}.gem"
|
|
29
|
-
puts "Pushing #{gem_file}..."
|
|
30
|
-
system("gem push #{gem_file}") || abort("ERROR: gem push failed")
|
|
31
|
-
|
|
32
|
-
puts "Released #{gem_name} #{local_version}"
|
data/bin/setup
DELETED
data/bin/tag-version
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require_relative "../lib/ratalada/version"
|
|
5
|
-
|
|
6
|
-
version = Ratalada::VERSION
|
|
7
|
-
tag = "v#{version}"
|
|
8
|
-
|
|
9
|
-
existing = `git tag -l #{tag}`.strip
|
|
10
|
-
unless existing.empty?
|
|
11
|
-
abort "ERROR: Tag #{tag} already exists"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
system("git tag #{tag}") || abort("ERROR: Failed to create tag #{tag}")
|
|
15
|
-
|
|
16
|
-
puts "Tagged #{tag}"
|
|
17
|
-
puts ""
|
|
18
|
-
puts "To push the tag, run:"
|
|
19
|
-
puts " git push --tags"
|
data/bin/test
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
$LOAD_PATH.unshift File.expand_path("../test", __dir__)
|
|
5
|
-
|
|
6
|
-
require "bundler/setup"
|
|
7
|
-
|
|
8
|
-
Dir.chdir(File.expand_path("..", __dir__))
|
|
9
|
-
|
|
10
|
-
if ARGV.empty?
|
|
11
|
-
Dir.glob("test/**/*_test.rb").sort.each { |f| require_relative "../#{f}" }
|
|
12
|
-
else
|
|
13
|
-
ARGV.each { |f| require_relative "../#{f}" }
|
|
14
|
-
end
|
data/examples/README.md
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# Examples
|
|
2
|
-
|
|
3
|
-
Each example is a complete server. From the repo root:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
bundle install
|
|
7
|
-
bundle exec ruby examples/puma.rb # built-in router on puma
|
|
8
|
-
bundle exec ruby examples/falcon.rb # built-in router on falcon
|
|
9
|
-
bundle exec ruby examples/sinatra.rb # sinatra DSL on falcon
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
One example brings its own dependencies (via an inline gemfile) instead of
|
|
13
|
-
the repo bundle — run it with plain `ruby`:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
ruby examples/brute.rb # a brute coding agent served over HTTP
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
It expects a [brute](https://github.com/general-intelligence-systems/brute) checkout at
|
|
20
|
-
`~/brute/brute` (override with `BRUTE_PATH`) and an LLM — a local Ollama by
|
|
21
|
-
default (`BRUTE_PROVIDER` / `BRUTE_MODEL` to change). Ask it things:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
curl -d 'What files are in the current directory?' http://localhost:9292/ask
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
All of them listen on `http://127.0.0.1:9292` (override with `HOST`/`PORT`
|
|
28
|
-
env vars, or `Server.run(host:, port:)`).
|
|
29
|
-
|
|
30
|
-
## How it works
|
|
31
|
-
|
|
32
|
-
`require "ratalada/puma"` or `require "ratalada/falcon"` picks the server
|
|
33
|
-
backend and defines the top-level `Server` constant.
|
|
34
|
-
|
|
35
|
-
With the built-in router, the `Server.run` block receives each request and
|
|
36
|
-
returns a handler for it. A request pattern-matches as `[verb, path]`, and a
|
|
37
|
-
handler can be:
|
|
38
|
-
|
|
39
|
-
- a `String` — sent as a `200 text/plain` response
|
|
40
|
-
- a callable — called with the request, its result handled the same way
|
|
41
|
-
- a `[status, headers, body]` triplet — used as-is
|
|
42
|
-
- nothing (`nil` or a fall-through `case ... in`) — a `404`
|
|
43
|
-
|
|
44
|
-
```ruby
|
|
45
|
-
require "ratalada/puma"
|
|
46
|
-
|
|
47
|
-
Server.run do |request|
|
|
48
|
-
case request
|
|
49
|
-
in ["GET", "/"] then "ok"
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
`require "ratalada/sinatra"` swaps the block DSL for Sinatra: the block is
|
|
55
|
-
class-evaluated into an anonymous Sinatra app, running on whichever backend
|
|
56
|
-
you required.
|
data/examples/brute.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Serve a brute agent over HTTP.
|
|
4
|
-
#
|
|
5
|
-
# curl -d 'Say hi' http://localhost:9292/ask
|
|
6
|
-
|
|
7
|
-
require "ratalada/falcon"
|
|
8
|
-
require "ratalada/sinatra"
|
|
9
|
-
require "brute"
|
|
10
|
-
require "ruby_llm"
|
|
11
|
-
|
|
12
|
-
RubyLLM.configure do |config|
|
|
13
|
-
config.ollama_api_base = "http://localhost:11434/v1"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
Server.run do
|
|
17
|
-
get "/ask" do
|
|
18
|
-
Brute.agent.run do |env|
|
|
19
|
-
RubyLLM.chat(model: "llama3.2", provider: :ollama).then do |chat|
|
|
20
|
-
chat.ask(env[:messages].last.content).content.then do |response|
|
|
21
|
-
env[:messages].assistant(response)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end.then do |agent|
|
|
25
|
-
agent.start(request.body.read)[:messages].last.content
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
data/examples/falcon.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Run: bundle exec ruby examples/falcon.rb
|
|
4
|
-
# Try: curl http://localhost:9292/
|
|
5
|
-
# curl http://localhost:9292/up
|
|
6
|
-
# curl "http://localhost:9292/greet?name=world"
|
|
7
|
-
|
|
8
|
-
require "ratalada/falcon"
|
|
9
|
-
|
|
10
|
-
Server.run do |request|
|
|
11
|
-
case request
|
|
12
|
-
in ["GET", "/"] then "hello from falcon\n"
|
|
13
|
-
in ["GET", "/up"] then "ok\n"
|
|
14
|
-
in ["GET", "/greet"] then ->(req) { "hello #{req.query.delete_prefix("name=")}\n" }
|
|
15
|
-
end
|
|
16
|
-
end
|
data/examples/puma.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Run: bundle exec ruby examples/puma.rb
|
|
4
|
-
# Try: curl http://localhost:9292/
|
|
5
|
-
# curl http://localhost:9292/up
|
|
6
|
-
# curl -d "hello" http://localhost:9292/echo
|
|
7
|
-
|
|
8
|
-
require "ratalada/puma"
|
|
9
|
-
|
|
10
|
-
Server.run do |request|
|
|
11
|
-
case request
|
|
12
|
-
in ["GET", "/"] then "hello from puma\n"
|
|
13
|
-
in ["GET", "/up"] then "ok\n"
|
|
14
|
-
in ["POST", "/echo"] then ->(req) { [200, { "content-type" => "text/plain" }, req.body] }
|
|
15
|
-
end
|
|
16
|
-
end
|
data/examples/sinatra.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Run: bundle exec ruby examples/sinatra.rb
|
|
4
|
-
# Try: curl http://localhost:9292/
|
|
5
|
-
# curl http://localhost:9292/up
|
|
6
|
-
# curl http://localhost:9292/greet/world
|
|
7
|
-
|
|
8
|
-
require "ratalada/falcon"
|
|
9
|
-
require "ratalada/sinatra"
|
|
10
|
-
|
|
11
|
-
Server.run do
|
|
12
|
-
get "/" do
|
|
13
|
-
"hello from sinatra on falcon\n"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
get "/up" do
|
|
17
|
-
"ok\n"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
get "/greet/:name" do
|
|
21
|
-
"hello #{params[:name]}\n"
|
|
22
|
-
end
|
|
23
|
-
end
|
data/flake.lock
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"nodes": {
|
|
3
|
-
"nixpkgs": {
|
|
4
|
-
"locked": {
|
|
5
|
-
"lastModified": 1781577229,
|
|
6
|
-
"narHash": "sha256-lrp67w8AulE9Ks53n27I45ADSzbOCn4H+CNW1Ck8B+8=",
|
|
7
|
-
"owner": "NixOS",
|
|
8
|
-
"repo": "nixpkgs",
|
|
9
|
-
"rev": "567a49d1913ce81ac6e9582e3553dd90a955875f",
|
|
10
|
-
"type": "github"
|
|
11
|
-
},
|
|
12
|
-
"original": {
|
|
13
|
-
"owner": "NixOS",
|
|
14
|
-
"ref": "nixos-unstable",
|
|
15
|
-
"repo": "nixpkgs",
|
|
16
|
-
"type": "github"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"root": {
|
|
20
|
-
"inputs": {
|
|
21
|
-
"nixpkgs": "nixpkgs",
|
|
22
|
-
"utils": "utils"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"systems": {
|
|
26
|
-
"locked": {
|
|
27
|
-
"lastModified": 1681028828,
|
|
28
|
-
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
29
|
-
"owner": "nix-systems",
|
|
30
|
-
"repo": "default",
|
|
31
|
-
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
32
|
-
"type": "github"
|
|
33
|
-
},
|
|
34
|
-
"original": {
|
|
35
|
-
"owner": "nix-systems",
|
|
36
|
-
"repo": "default",
|
|
37
|
-
"type": "github"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"utils": {
|
|
41
|
-
"inputs": {
|
|
42
|
-
"systems": "systems"
|
|
43
|
-
},
|
|
44
|
-
"locked": {
|
|
45
|
-
"lastModified": 1731533236,
|
|
46
|
-
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
47
|
-
"owner": "numtide",
|
|
48
|
-
"repo": "flake-utils",
|
|
49
|
-
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
50
|
-
"type": "github"
|
|
51
|
-
},
|
|
52
|
-
"original": {
|
|
53
|
-
"owner": "numtide",
|
|
54
|
-
"repo": "flake-utils",
|
|
55
|
-
"type": "github"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
"root": "root",
|
|
60
|
-
"version": 7
|
|
61
|
-
}
|
data/flake.nix
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
description = "Ruby gem flake";
|
|
3
|
-
|
|
4
|
-
inputs = {
|
|
5
|
-
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
6
|
-
utils.url = "github:numtide/flake-utils";
|
|
7
|
-
};
|
|
8
|
-
outputs = { self, nixpkgs, utils }:
|
|
9
|
-
utils.lib.eachDefaultSystem (system:
|
|
10
|
-
let
|
|
11
|
-
pkgs = nixpkgs.legacyPackages.${system};
|
|
12
|
-
ruby = pkgs.ruby_3_4; # Specify version
|
|
13
|
-
in
|
|
14
|
-
{
|
|
15
|
-
devShells.default = pkgs.mkShell {
|
|
16
|
-
nativeBuildInputs = [
|
|
17
|
-
pkgs.pkg-config # native extension discovery
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
buildInputs = [
|
|
21
|
-
ruby
|
|
22
|
-
pkgs.libyaml # psych gem
|
|
23
|
-
pkgs.openssl # openssl gem
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
shellHook = ''
|
|
27
|
-
export GEM_HOME="$HOME/.gem-${ruby.version}"
|
|
28
|
-
export GEM_PATH="$GEM_HOME"
|
|
29
|
-
export PATH="$GEM_HOME/bin:$PATH"
|
|
30
|
-
export BUNDLE_GEMFILE="$PWD/Gemfile"
|
|
31
|
-
export BUNDLE_PATH="$GEM_HOME"
|
|
32
|
-
export BUNDLE_BIN="$GEM_HOME/bin"
|
|
33
|
-
'';
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
data/lib/ratalada/sinatra.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "sinatra/base"
|
|
4
|
-
require_relative "../ratalada"
|
|
5
|
-
|
|
6
|
-
module Ratalada
|
|
7
|
-
module Frontends
|
|
8
|
-
# Sinatra-flavoured DSL: the Server.run block is class-evaluated into an
|
|
9
|
-
# anonymous Sinatra application, so `get "/" do ... end` etc. all work.
|
|
10
|
-
module Sinatra
|
|
11
|
-
def self.build(block)
|
|
12
|
-
app = Class.new(::Sinatra::Base)
|
|
13
|
-
app.class_eval(&block)
|
|
14
|
-
app.new
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
self.frontend = Frontends::Sinatra
|
|
20
|
-
end
|
data/lib/ratalada/version.rb.erb
DELETED
data/ratalada.gemspec
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "lib/ratalada/version"
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name = "ratalada"
|
|
7
|
-
spec.version = Ratalada::VERSION
|
|
8
|
-
spec.authors = ["Nathan K"]
|
|
9
|
-
spec.email = ["nathankidd@hey.com"]
|
|
10
|
-
|
|
11
|
-
spec.summary = "DSL for running rack servers as easily as you can in javascript."
|
|
12
|
-
|
|
13
|
-
spec.description = <<~DESC
|
|
14
|
-
DSL for running rack servers as easily as you can in javasript.
|
|
15
|
-
DESC
|
|
16
|
-
|
|
17
|
-
spec.homepage = "https://github.com/n-at-han-k/ratalada"
|
|
18
|
-
spec.license = "MIT"
|
|
19
|
-
spec.required_ruby_version = ">= 3.2.0"
|
|
20
|
-
|
|
21
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
|
22
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
|
23
|
-
spec.metadata["documentation_uri"] = spec.homepage
|
|
24
|
-
spec.metadata["rubygems_mfa_required"] = "true"
|
|
25
|
-
|
|
26
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|data|docs|\.github)/}) }
|
|
27
|
-
spec.bindir = "exe"
|
|
28
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
29
|
-
spec.require_paths = ["lib"]
|
|
30
|
-
|
|
31
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
|
32
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
|
33
|
-
|
|
34
|
-
# Servers and frameworks the adapters wrap; users install whichever they require.
|
|
35
|
-
spec.add_development_dependency "falcon"
|
|
36
|
-
spec.add_development_dependency "puma"
|
|
37
|
-
spec.add_development_dependency "sinatra"
|
|
38
|
-
end
|
data/ratalada.gemspec.erb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "lib/ratalada/version"
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name = "<%= gem_name %>"
|
|
7
|
-
spec.version = Ratalada::VERSION
|
|
8
|
-
spec.authors = [<%= authors.map { |a| %("#{a}") }.join(", ") %>]
|
|
9
|
-
spec.email = [<%= emails.map { |e| %("#{e}") }.join(", ") %>]
|
|
10
|
-
|
|
11
|
-
spec.summary = "<%= summary %>"
|
|
12
|
-
|
|
13
|
-
spec.description = <<~DESC
|
|
14
|
-
<%= description %>
|
|
15
|
-
DESC
|
|
16
|
-
|
|
17
|
-
spec.homepage = "<%= homepage %>"
|
|
18
|
-
spec.license = "<%= license %>"
|
|
19
|
-
spec.required_ruby_version = ">= <%= ruby_version %>"
|
|
20
|
-
|
|
21
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
|
22
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
|
23
|
-
spec.metadata["documentation_uri"] = spec.homepage
|
|
24
|
-
spec.metadata["rubygems_mfa_required"] = "true"
|
|
25
|
-
|
|
26
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|data)/}) }
|
|
27
|
-
spec.bindir = "exe"
|
|
28
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
29
|
-
spec.require_paths = ["lib"]
|
|
30
|
-
|
|
31
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
|
32
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
|
33
|
-
spec.add_development_dependency "rubocop", "~> 1.21"
|
|
34
|
-
end
|