lex-http 0.1.3 → 0.2.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/.github/workflows/ci.yml +16 -0
- data/.rubocop.yml +39 -13
- data/CHANGELOG.md +20 -0
- data/CLAUDE.md +79 -0
- data/Dockerfile +1 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +103 -0
- data/README.md +44 -45
- data/docker_deploy.rb +7 -12
- data/lex-http.gemspec +5 -3
- data/lib/legion/extensions/http/client.rb +29 -0
- data/lib/legion/extensions/http/helpers/client.rb +23 -0
- data/lib/legion/extensions/http/runners/http.rb +2 -1
- data/lib/legion/extensions/http/version.rb +3 -1
- data/lib/legion/extensions/http.rb +6 -1
- metadata +13 -26
- data/.github/workflows/rspec.yml +0 -69
- data/.github/workflows/rubocop.yml +0 -28
- data/CODE_OF_CONDUCT.md +0 -74
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b21fcb6617fd52576b22e111705979bc7a4c00ee26afe63b70cb0abd622b34fe
|
|
4
|
+
data.tar.gz: 4a65e3f26e588d3f759dca7ec5062c5634011192e527baaac3c9331fc23260ed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 681d1d7f2a3443cd2b57859a3dfe9b5a8ef9b443e96cbbb97ecc313ab75dda881b27aa029a6a659b9f7ad162f2cd8d5620f5afb95678817037c3430b6470922f
|
|
7
|
+
data.tar.gz: 34bd60d5e53244785d8bf35a78f915fcf1135c8615b48cc066f0507a2510d406df3e6c9cc70b76a671cadb6cca357fab3b9b8a3c8c5052aadb7a6251160b9659
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
ci:
|
|
9
|
+
uses: LegionIO/.github/.github/workflows/ci.yml@main
|
|
10
|
+
|
|
11
|
+
release:
|
|
12
|
+
needs: ci
|
|
13
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
14
|
+
uses: LegionIO/.github/.github/workflows/release.yml@main
|
|
15
|
+
secrets:
|
|
16
|
+
rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.rubocop.yml
CHANGED
|
@@ -1,24 +1,50 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.4
|
|
3
|
+
NewCops: enable
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
|
|
1
6
|
Layout/LineLength:
|
|
2
|
-
Max:
|
|
7
|
+
Max: 160
|
|
8
|
+
|
|
9
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
10
|
+
EnforcedStyle: space
|
|
11
|
+
|
|
12
|
+
Layout/HashAlignment:
|
|
13
|
+
EnforcedHashRocketStyle: table
|
|
14
|
+
EnforcedColonStyle: table
|
|
15
|
+
|
|
3
16
|
Metrics/MethodLength:
|
|
4
|
-
Max:
|
|
17
|
+
Max: 50
|
|
18
|
+
|
|
5
19
|
Metrics/ClassLength:
|
|
6
20
|
Max: 1500
|
|
7
|
-
|
|
8
|
-
Max: 50
|
|
21
|
+
|
|
9
22
|
Metrics/ModuleLength:
|
|
10
|
-
Max:
|
|
23
|
+
Max: 1500
|
|
24
|
+
|
|
25
|
+
Metrics/BlockLength:
|
|
26
|
+
Max: 40
|
|
27
|
+
Exclude:
|
|
28
|
+
- 'spec/**/*'
|
|
29
|
+
|
|
11
30
|
Metrics/AbcSize:
|
|
12
|
-
Max:
|
|
31
|
+
Max: 60
|
|
32
|
+
|
|
33
|
+
Metrics/CyclomaticComplexity:
|
|
34
|
+
Max: 15
|
|
35
|
+
|
|
36
|
+
Metrics/PerceivedComplexity:
|
|
37
|
+
Max: 17
|
|
38
|
+
|
|
13
39
|
Style/Documentation:
|
|
14
40
|
Enabled: false
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
41
|
+
|
|
42
|
+
Style/SymbolArray:
|
|
43
|
+
Enabled: true
|
|
44
|
+
|
|
19
45
|
Style/FrozenStringLiteralComment:
|
|
20
|
-
Enabled:
|
|
46
|
+
Enabled: true
|
|
47
|
+
EnforcedStyle: always
|
|
48
|
+
|
|
21
49
|
Naming/FileName:
|
|
22
50
|
Enabled: false
|
|
23
|
-
Style/ClassAndModuleChildren:
|
|
24
|
-
Enabled: false
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [0.2.0] - 2026-03-15
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `Helpers::Client` module for building Faraday connections with configurable timeouts
|
|
9
|
+
- Standalone `Client` class including all runner modules
|
|
10
|
+
- `Client#initialize` accepts `open_timeout:`, `read_timeout:`, `timeout:`, `port:` stored as defaults
|
|
11
|
+
- `Client#settings` exposes stored options for runner compatibility without the full framework
|
|
12
|
+
- Specs for `Client`: initialize defaults, custom options, `#connection`, `#settings`, runner method availability
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- `lib/legion/extensions/http.rb` now requires `helpers/client`, `runners/http`, and `client`
|
|
16
|
+
|
|
17
|
+
## [0.1.3] - 2026-03-13
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- Initial release
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# lex-http: HTTP Client Extension for LegionIO
|
|
2
|
+
|
|
3
|
+
**Repository Level 3 Documentation**
|
|
4
|
+
- **Parent (Level 2)**: `/Users/miverso2/rubymine/legion/extensions/CLAUDE.md`
|
|
5
|
+
- **Parent (Level 1)**: `/Users/miverso2/rubymine/legion/CLAUDE.md`
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
Legion Extension that connects LegionIO to any HTTP source. Provides runners for making HTTP requests with support for multiple content types (JSON, XML) via Faraday.
|
|
10
|
+
|
|
11
|
+
**Version**: 0.2.0
|
|
12
|
+
**GitHub**: https://github.com/LegionIO/lex-http
|
|
13
|
+
**License**: MIT
|
|
14
|
+
|
|
15
|
+
## Architecture
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
Legion::Extensions::Http
|
|
19
|
+
├── Runners/
|
|
20
|
+
│ └── Http # HTTP request execution (GET, POST, etc.)
|
|
21
|
+
├── Helpers/
|
|
22
|
+
│ └── Client # Faraday connection builder with timeout defaults
|
|
23
|
+
└── Client # Standalone client class (includes all runners)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Key Files
|
|
27
|
+
|
|
28
|
+
| Path | Purpose |
|
|
29
|
+
|------|---------|
|
|
30
|
+
| `lib/legion/extensions/http.rb` | Entry point, extension registration, `default_settings` |
|
|
31
|
+
| `lib/legion/extensions/http/runners/http.rb` | HTTP request logic (all verbs) |
|
|
32
|
+
| `lib/legion/extensions/http/helpers/client.rb` | Faraday connection builder with timeout defaults |
|
|
33
|
+
| `lib/legion/extensions/http/client.rb` | Standalone `Client` class for use outside Legion framework |
|
|
34
|
+
|
|
35
|
+
## Runner Methods
|
|
36
|
+
|
|
37
|
+
All methods are in `Runners::Http` and accept `host:` (required), `uri:`, `port:`, `params:`, `body:` as keyword args. Timeouts are read from `settings[:options]` populated by `default_settings`.
|
|
38
|
+
|
|
39
|
+
| Method | Notes |
|
|
40
|
+
|--------|-------|
|
|
41
|
+
| `get` | |
|
|
42
|
+
| `post` | |
|
|
43
|
+
| `put` | |
|
|
44
|
+
| `patch` | |
|
|
45
|
+
| `delete` | |
|
|
46
|
+
| `head` | |
|
|
47
|
+
| `options` | |
|
|
48
|
+
| `status` | Smoke-test; returns `{ test: true }` |
|
|
49
|
+
|
|
50
|
+
Response parsing is automatic: JSON content types parse to Hash, XML content types parse to Hash via `multi_xml`. Return value is the Faraday response as a hash (`response.to_hash`).
|
|
51
|
+
|
|
52
|
+
## Notes
|
|
53
|
+
|
|
54
|
+
- `default_settings` defines `open_timeout: 5`, `read_timeout: 10`, `timeout: 10`
|
|
55
|
+
- `Helpers::Client` builds a Faraday connection with those timeout defaults; runners use it rather than constructing Faraday inline
|
|
56
|
+
- The standalone `Client` class wraps `Helpers::Client` and includes all runners, enabling use outside the full LegionIO framework
|
|
57
|
+
- `faraday_middleware` is NOT a declared dependency; response parsing is handled by Faraday's built-in middleware (`c.response :json` / `c.response :xml`)
|
|
58
|
+
|
|
59
|
+
## Dependencies
|
|
60
|
+
|
|
61
|
+
| Gem | Purpose |
|
|
62
|
+
|-----|---------|
|
|
63
|
+
| `faraday` | HTTP client (includes built-in JSON/XML response middleware) |
|
|
64
|
+
| `multi_json` | JSON parser abstraction |
|
|
65
|
+
| `multi_xml` | XML parser abstraction |
|
|
66
|
+
|
|
67
|
+
## Testing
|
|
68
|
+
|
|
69
|
+
55 specs total (45 existing + 10 in `spec/legion/extensions/http/client_spec.rb`).
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
bundle install
|
|
73
|
+
bundle exec rspec
|
|
74
|
+
bundle exec rubocop
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
**Maintained By**: Matthew Iverson (@Esity)
|
data/Dockerfile
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
lex-http (0.2.0)
|
|
5
|
+
faraday (>= 2.0)
|
|
6
|
+
multi_json
|
|
7
|
+
multi_xml
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: https://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
addressable (2.8.9)
|
|
13
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
14
|
+
ast (2.4.3)
|
|
15
|
+
bigdecimal (4.0.1)
|
|
16
|
+
diff-lcs (1.6.2)
|
|
17
|
+
docile (1.4.1)
|
|
18
|
+
faraday (2.14.1)
|
|
19
|
+
faraday-net_http (>= 2.0, < 3.5)
|
|
20
|
+
json
|
|
21
|
+
logger
|
|
22
|
+
faraday-net_http (3.4.2)
|
|
23
|
+
net-http (~> 0.5)
|
|
24
|
+
json (2.19.1)
|
|
25
|
+
json-schema (6.2.0)
|
|
26
|
+
addressable (~> 2.8)
|
|
27
|
+
bigdecimal (>= 3.1, < 5)
|
|
28
|
+
language_server-protocol (3.17.0.5)
|
|
29
|
+
lint_roller (1.1.0)
|
|
30
|
+
logger (1.7.0)
|
|
31
|
+
mcp (0.8.0)
|
|
32
|
+
json-schema (>= 4.1)
|
|
33
|
+
multi_json (1.19.1)
|
|
34
|
+
multi_xml (0.8.1)
|
|
35
|
+
bigdecimal (>= 3.1, < 5)
|
|
36
|
+
net-http (0.9.1)
|
|
37
|
+
uri (>= 0.11.1)
|
|
38
|
+
parallel (1.27.0)
|
|
39
|
+
parser (3.3.10.2)
|
|
40
|
+
ast (~> 2.4.1)
|
|
41
|
+
racc
|
|
42
|
+
prism (1.9.0)
|
|
43
|
+
public_suffix (7.0.5)
|
|
44
|
+
racc (1.8.1)
|
|
45
|
+
rainbow (3.1.1)
|
|
46
|
+
rake (13.3.1)
|
|
47
|
+
regexp_parser (2.11.3)
|
|
48
|
+
rspec (3.13.2)
|
|
49
|
+
rspec-core (~> 3.13.0)
|
|
50
|
+
rspec-expectations (~> 3.13.0)
|
|
51
|
+
rspec-mocks (~> 3.13.0)
|
|
52
|
+
rspec-core (3.13.6)
|
|
53
|
+
rspec-support (~> 3.13.0)
|
|
54
|
+
rspec-expectations (3.13.5)
|
|
55
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
56
|
+
rspec-support (~> 3.13.0)
|
|
57
|
+
rspec-mocks (3.13.8)
|
|
58
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
59
|
+
rspec-support (~> 3.13.0)
|
|
60
|
+
rspec-support (3.13.7)
|
|
61
|
+
rspec_junit_formatter (0.6.0)
|
|
62
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
|
63
|
+
rubocop (1.85.1)
|
|
64
|
+
json (~> 2.3)
|
|
65
|
+
language_server-protocol (~> 3.17.0.2)
|
|
66
|
+
lint_roller (~> 1.1.0)
|
|
67
|
+
mcp (~> 0.6)
|
|
68
|
+
parallel (~> 1.10)
|
|
69
|
+
parser (>= 3.3.0.2)
|
|
70
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
71
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
72
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
73
|
+
ruby-progressbar (~> 1.7)
|
|
74
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
75
|
+
rubocop-ast (1.49.1)
|
|
76
|
+
parser (>= 3.3.7.2)
|
|
77
|
+
prism (~> 1.7)
|
|
78
|
+
ruby-progressbar (1.13.0)
|
|
79
|
+
simplecov (0.22.0)
|
|
80
|
+
docile (~> 1.1)
|
|
81
|
+
simplecov-html (~> 0.11)
|
|
82
|
+
simplecov_json_formatter (~> 0.1)
|
|
83
|
+
simplecov-html (0.13.2)
|
|
84
|
+
simplecov_json_formatter (0.1.4)
|
|
85
|
+
unicode-display_width (3.2.0)
|
|
86
|
+
unicode-emoji (~> 4.1)
|
|
87
|
+
unicode-emoji (4.2.0)
|
|
88
|
+
uri (1.1.1)
|
|
89
|
+
|
|
90
|
+
PLATFORMS
|
|
91
|
+
arm64-darwin-25
|
|
92
|
+
ruby
|
|
93
|
+
|
|
94
|
+
DEPENDENCIES
|
|
95
|
+
lex-http!
|
|
96
|
+
rake
|
|
97
|
+
rspec
|
|
98
|
+
rspec_junit_formatter
|
|
99
|
+
rubocop
|
|
100
|
+
simplecov
|
|
101
|
+
|
|
102
|
+
BUNDLED WITH
|
|
103
|
+
2.6.9
|
data/README.md
CHANGED
|
@@ -1,70 +1,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# lex-http
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
HTTP client extension for [LegionIO](https://github.com/LegionIO/LegionIO). Makes HTTP requests with support for JSON and XML content types via Faraday. Responses are automatically parsed based on the `Content-Type` header.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```ruby
|
|
10
|
-
gem 'lex-http'
|
|
7
|
+
```bash
|
|
8
|
+
gem install lex-http
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
## Functions
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
All functions are in the `Http` runner and accept the following parameters:
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
| Function | Required | Optional |
|
|
16
|
+
|----------|----------|---------|
|
|
17
|
+
| `get` | `host` | `uri`, `port`, `params`, `body` |
|
|
18
|
+
| `post` | `host` | `uri`, `port`, `params`, `body` |
|
|
19
|
+
| `put` | `host` | `uri`, `port`, `params`, `body` |
|
|
20
|
+
| `patch` | `host` | `uri`, `port`, `params`, `body` |
|
|
21
|
+
| `delete` | `host` | `uri`, `port`, `params`, `body` |
|
|
22
|
+
| `head` | `host` | `uri`, `port`, `params`, `body` |
|
|
23
|
+
| `options` | `host` | `uri`, `port`, `params`, `body` |
|
|
24
|
+
| `status` | (none) | - |
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
**Parameters:**
|
|
27
|
+
- `host` - Full base URL (e.g. `https://api.example.com`)
|
|
28
|
+
- `uri` - Path component (default: `''`)
|
|
29
|
+
- `port` - Override port (default: `80`)
|
|
30
|
+
- `params` - Query string parameters as a hash
|
|
31
|
+
- `body` - Request body
|
|
20
32
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"enabled": true, "workers": 1
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
```
|
|
33
|
+
**Default timeouts** (configured via `default_settings`):
|
|
34
|
+
- `open_timeout`: 5 seconds
|
|
35
|
+
- `read_timeout`: 10 seconds
|
|
36
|
+
- `timeout`: 10 seconds
|
|
37
|
+
|
|
38
|
+
### Example Task Payloads
|
|
32
39
|
|
|
33
|
-
## Usage
|
|
34
|
-
|
|
35
|
-
There is only a single runner in this LEX. It can make the following calls
|
|
36
|
-
##### Functions
|
|
37
|
-
|function|open_timeout|timeout|Port|Params|Body|Host|URI|
|
|
38
|
-
|---|---|---|---|---|---|---|---|
|
|
39
|
-
|get |Optional|Optional|80|Optional|Optional|Required|\|
|
|
40
|
-
|post |Optional|Optional|80|Optional|Optional|Required|\|
|
|
41
|
-
|patch |Optional|Optional|80|Optional|Optional|Required|\|
|
|
42
|
-
|put |Optional|Optional|80|Optional|Optional|Required|\|
|
|
43
|
-
|delete |Optional|Optional|80|Optional|Optional|Required|\|
|
|
44
|
-
|options|Optional|Optional|80|Optional|Optional|Required|\|
|
|
45
|
-
|head |Optional|Optional|80|Optional|Optional|Required|\|
|
|
46
|
-
|
|
47
|
-
#### Example Payloads
|
|
48
40
|
```json
|
|
49
|
-
{"host": "https://
|
|
41
|
+
{"host": "https://api.example.com"}
|
|
50
42
|
```
|
|
51
43
|
|
|
52
44
|
```json
|
|
53
|
-
{"host": "
|
|
45
|
+
{"host": "http://192.168.1.1", "uri": "/api/v1/status", "port": 8080, "params": {"format": "json"}}
|
|
54
46
|
```
|
|
55
47
|
|
|
56
48
|
```json
|
|
57
|
-
{"host": "
|
|
49
|
+
{"host": "https://api.example.com", "uri": "/users", "body": {"name": "Alice"}}
|
|
58
50
|
```
|
|
59
51
|
|
|
60
|
-
##
|
|
61
|
-
|
|
52
|
+
## Standalone Client
|
|
53
|
+
|
|
54
|
+
Use `Legion::Extensions::Http::Client` outside the full LegionIO framework. The client stores timeout defaults; each request specifies its own host.
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
require 'legion/extensions/http'
|
|
58
|
+
client = Legion::Extensions::Http::Client.new(open_timeout: 5, read_timeout: 10)
|
|
59
|
+
response = client.get(host: 'https://api.example.com', uri: '/status')
|
|
60
|
+
```
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
## Requirements
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
- Ruby >= 3.4
|
|
65
|
+
- [LegionIO](https://github.com/LegionIO/LegionIO) framework
|
|
67
66
|
|
|
68
67
|
## License
|
|
69
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
70
68
|
|
|
69
|
+
MIT
|
data/docker_deploy.rb
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
long_name = 'lex-http'
|
|
4
4
|
name = 'http'
|
|
5
5
|
require "./lib/legion/extensions/#{name}/version"
|
|
6
6
|
version = Legion::Extensions::Http::VERSION
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
system("
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# system("docker build --tag legionio/lex-#{name}:v#{version} .")
|
|
15
|
-
# puts 'Pushing to hub.docker.com'
|
|
16
|
-
# system("docker push legionio/lex-#{name}:v#{version}")
|
|
17
|
-
# system("docker push legionio/lex-#{name}:latest")
|
|
18
|
-
# puts 'completed'
|
|
8
|
+
puts "Building docker image for Legion v#{version}"
|
|
9
|
+
system("docker build --tag legionio/lex-#{name}:v#{version} .")
|
|
10
|
+
puts 'Pushing to hub.docker.com'
|
|
11
|
+
system("docker push legionio/lex-#{name}:v#{version}")
|
|
12
|
+
system("docker push legionio/lex-#{name}:latest")
|
|
13
|
+
puts 'completed'
|
data/lex-http.gemspec
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require_relative 'lib/legion/extensions/http/version'
|
|
2
4
|
|
|
3
5
|
Gem::Specification.new do |spec|
|
|
@@ -10,21 +12,21 @@ Gem::Specification.new do |spec|
|
|
|
10
12
|
spec.description = 'Connections LegionIO to any HTTP source'
|
|
11
13
|
spec.homepage = 'https://github.com/LegionIO/lex-http'
|
|
12
14
|
spec.license = 'MIT'
|
|
13
|
-
spec.required_ruby_version =
|
|
15
|
+
spec.required_ruby_version = '>= 3.4'
|
|
14
16
|
|
|
15
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
|
16
18
|
spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-http'
|
|
17
19
|
spec.metadata['documentation_uri'] = 'https://github.com/LegionIO/lex-http'
|
|
18
20
|
spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-http'
|
|
19
21
|
spec.metadata['bug_tracker_uri'] = 'https://github.com/LegionIO/lex-http/issues'
|
|
22
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
20
23
|
|
|
21
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
22
25
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
23
26
|
end
|
|
24
27
|
spec.require_paths = ['lib']
|
|
25
28
|
|
|
26
|
-
spec.add_dependency 'faraday'
|
|
27
|
-
spec.add_dependency 'faraday_middleware'
|
|
29
|
+
spec.add_dependency 'faraday', '>= 2.0'
|
|
28
30
|
spec.add_dependency 'multi_json'
|
|
29
31
|
spec.add_dependency 'multi_xml'
|
|
30
32
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'helpers/client'
|
|
4
|
+
require_relative 'runners/http'
|
|
5
|
+
|
|
6
|
+
module Legion
|
|
7
|
+
module Extensions
|
|
8
|
+
module Http
|
|
9
|
+
class Client
|
|
10
|
+
include Helpers::Client
|
|
11
|
+
include Runners::Http
|
|
12
|
+
|
|
13
|
+
attr_reader :opts
|
|
14
|
+
|
|
15
|
+
def initialize(open_timeout: 5, read_timeout: 10, timeout: 10, port: 80, **extra)
|
|
16
|
+
@opts = { open_timeout: open_timeout, read_timeout: read_timeout, timeout: timeout, port: port, **extra }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def connection(**override)
|
|
20
|
+
super(**@opts.merge(override))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def settings
|
|
24
|
+
{ options: @opts }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Http
|
|
8
|
+
module Helpers
|
|
9
|
+
module Client
|
|
10
|
+
def connection(host:, port: 80, **opts)
|
|
11
|
+
Faraday.new("#{host}:#{port}") do |conn|
|
|
12
|
+
conn.options.open_timeout = opts.fetch(:open_timeout, 5)
|
|
13
|
+
conn.options.read_timeout = opts.fetch(:read_timeout, 10)
|
|
14
|
+
conn.options.timeout = opts.fetch(:timeout, 10)
|
|
15
|
+
conn.response :json, content_type: /\bjson$/
|
|
16
|
+
conn.adapter Faraday.default_adapter
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'legion/extensions/http/version'
|
|
4
|
+
require 'legion/extensions/http/helpers/client'
|
|
5
|
+
require 'legion/extensions/http/runners/http'
|
|
6
|
+
require 'legion/extensions/http/client'
|
|
2
7
|
|
|
3
8
|
module Legion
|
|
4
9
|
module Extensions
|
|
@@ -10,7 +15,7 @@ module Legion
|
|
|
10
15
|
options: {
|
|
11
16
|
open_timeout: 5,
|
|
12
17
|
read_timeout: 10,
|
|
13
|
-
timeout:
|
|
18
|
+
timeout: 10
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lex-http
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -16,28 +15,14 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
18
|
+
version: '2.0'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: faraday_middleware
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
25
|
+
version: '2.0'
|
|
41
26
|
- !ruby/object:Gem::Dependency
|
|
42
27
|
name: multi_json
|
|
43
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -73,19 +58,22 @@ executables: []
|
|
|
73
58
|
extensions: []
|
|
74
59
|
extra_rdoc_files: []
|
|
75
60
|
files:
|
|
76
|
-
- ".github/workflows/
|
|
77
|
-
- ".github/workflows/rubocop.yml"
|
|
61
|
+
- ".github/workflows/ci.yml"
|
|
78
62
|
- ".gitignore"
|
|
79
63
|
- ".rspec"
|
|
80
64
|
- ".rubocop.yml"
|
|
81
|
-
-
|
|
65
|
+
- CHANGELOG.md
|
|
66
|
+
- CLAUDE.md
|
|
82
67
|
- Dockerfile
|
|
83
68
|
- Gemfile
|
|
69
|
+
- Gemfile.lock
|
|
84
70
|
- LICENSE
|
|
85
71
|
- README.md
|
|
86
72
|
- docker_deploy.rb
|
|
87
73
|
- lex-http.gemspec
|
|
88
74
|
- lib/legion/extensions/http.rb
|
|
75
|
+
- lib/legion/extensions/http/client.rb
|
|
76
|
+
- lib/legion/extensions/http/helpers/client.rb
|
|
89
77
|
- lib/legion/extensions/http/runners/http.rb
|
|
90
78
|
- lib/legion/extensions/http/version.rb
|
|
91
79
|
homepage: https://github.com/LegionIO/lex-http
|
|
@@ -97,7 +85,7 @@ metadata:
|
|
|
97
85
|
documentation_uri: https://github.com/LegionIO/lex-http
|
|
98
86
|
changelog_uri: https://github.com/LegionIO/lex-http
|
|
99
87
|
bug_tracker_uri: https://github.com/LegionIO/lex-http/issues
|
|
100
|
-
|
|
88
|
+
rubygems_mfa_required: 'true'
|
|
101
89
|
rdoc_options: []
|
|
102
90
|
require_paths:
|
|
103
91
|
- lib
|
|
@@ -105,15 +93,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
105
93
|
requirements:
|
|
106
94
|
- - ">="
|
|
107
95
|
- !ruby/object:Gem::Version
|
|
108
|
-
version:
|
|
96
|
+
version: '3.4'
|
|
109
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
98
|
requirements:
|
|
111
99
|
- - ">="
|
|
112
100
|
- !ruby/object:Gem::Version
|
|
113
101
|
version: '0'
|
|
114
102
|
requirements: []
|
|
115
|
-
rubygems_version: 3.
|
|
116
|
-
signing_key:
|
|
103
|
+
rubygems_version: 3.6.9
|
|
117
104
|
specification_version: 4
|
|
118
105
|
summary: LEX HTTP
|
|
119
106
|
test_files: []
|
data/.github/workflows/rspec.yml
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
name: RSpec
|
|
2
|
-
on: [push, pull_request]
|
|
3
|
-
|
|
4
|
-
jobs:
|
|
5
|
-
rspec:
|
|
6
|
-
strategy:
|
|
7
|
-
fail-fast: false
|
|
8
|
-
matrix:
|
|
9
|
-
os: [ubuntu-latest]
|
|
10
|
-
ruby: [2.7]
|
|
11
|
-
runs-on: ${{ matrix.os }}
|
|
12
|
-
steps:
|
|
13
|
-
- uses: actions/checkout@v2
|
|
14
|
-
- uses: ruby/setup-ruby@v1
|
|
15
|
-
with:
|
|
16
|
-
ruby-version: ${{ matrix.ruby }}
|
|
17
|
-
bundler-cache: true
|
|
18
|
-
- name: RSpec run
|
|
19
|
-
run: |
|
|
20
|
-
bash -c "
|
|
21
|
-
bundle exec rspec
|
|
22
|
-
[[ $? -ne 2 ]]
|
|
23
|
-
"
|
|
24
|
-
rspec-mri:
|
|
25
|
-
needs: rspec
|
|
26
|
-
strategy:
|
|
27
|
-
fail-fast: false
|
|
28
|
-
matrix:
|
|
29
|
-
os: [ ubuntu-latest ]
|
|
30
|
-
ruby: [2.5, 2.6, '3.0', head]
|
|
31
|
-
runs-on: ${{ matrix.os }}
|
|
32
|
-
steps:
|
|
33
|
-
- uses: actions/checkout@v2
|
|
34
|
-
- uses: ruby/setup-ruby@v1
|
|
35
|
-
with:
|
|
36
|
-
ruby-version: ${{ matrix.ruby }}
|
|
37
|
-
bundler-cache: true
|
|
38
|
-
- run: bundle exec rspec
|
|
39
|
-
rspec-jruby:
|
|
40
|
-
needs: rspec
|
|
41
|
-
strategy:
|
|
42
|
-
fail-fast: false
|
|
43
|
-
matrix:
|
|
44
|
-
os: [ ubuntu-latest ]
|
|
45
|
-
ruby: [ jruby, jruby-head]
|
|
46
|
-
runs-on: ${{ matrix.os }}
|
|
47
|
-
steps:
|
|
48
|
-
- uses: actions/checkout@v2
|
|
49
|
-
- uses: ruby/setup-ruby@v1
|
|
50
|
-
with:
|
|
51
|
-
ruby-version: ${{ matrix.ruby }}
|
|
52
|
-
bundler-cache: true
|
|
53
|
-
- run: JRUBY_OPTS="--debug" bundle exec rspec
|
|
54
|
-
rspec-truffleruby:
|
|
55
|
-
needs: rspec
|
|
56
|
-
strategy:
|
|
57
|
-
fail-fast: false
|
|
58
|
-
matrix:
|
|
59
|
-
os: [ ubuntu-latest ]
|
|
60
|
-
ruby: [truffleruby]
|
|
61
|
-
runs-on: ${{ matrix.os }}
|
|
62
|
-
steps:
|
|
63
|
-
- uses: actions/checkout@v2
|
|
64
|
-
- uses: ruby/setup-ruby@v1
|
|
65
|
-
with:
|
|
66
|
-
ruby-version: ${{ matrix.ruby }}
|
|
67
|
-
bundler-cache: true
|
|
68
|
-
- run: bundle exec rspec
|
|
69
|
-
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
name: Rubocop
|
|
2
|
-
on: [push, pull_request]
|
|
3
|
-
jobs:
|
|
4
|
-
rubocop:
|
|
5
|
-
strategy:
|
|
6
|
-
fail-fast: false
|
|
7
|
-
matrix:
|
|
8
|
-
os: [ubuntu-latest]
|
|
9
|
-
ruby: [2.7]
|
|
10
|
-
runs-on: ${{ matrix.os }}
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v2
|
|
13
|
-
- uses: ruby/setup-ruby@v1
|
|
14
|
-
with:
|
|
15
|
-
ruby-version: ${{ matrix.ruby }}
|
|
16
|
-
bundler-cache: true
|
|
17
|
-
- name: Install Rubocop
|
|
18
|
-
run: gem install rubocop code-scanning-rubocop
|
|
19
|
-
- name: Rubocop run --no-doc
|
|
20
|
-
run: |
|
|
21
|
-
bash -c "
|
|
22
|
-
rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
|
|
23
|
-
[[ $? -ne 2 ]]
|
|
24
|
-
"
|
|
25
|
-
- name: Upload Sarif output
|
|
26
|
-
uses: github/codeql-action/upload-sarif@v1
|
|
27
|
-
with:
|
|
28
|
-
sarif_file: rubocop.sarif
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
-
orientation.
|
|
11
|
-
|
|
12
|
-
## Our Standards
|
|
13
|
-
|
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
|
15
|
-
include:
|
|
16
|
-
|
|
17
|
-
* Using welcoming and inclusive language
|
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
|
19
|
-
* Gracefully accepting constructive criticism
|
|
20
|
-
* Focusing on what is best for the community
|
|
21
|
-
* Showing empathy towards other community members
|
|
22
|
-
|
|
23
|
-
Examples of unacceptable behavior by participants include:
|
|
24
|
-
|
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
-
advances
|
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
-
* Public or private harassment
|
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
|
30
|
-
address, without explicit permission
|
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
-
professional setting
|
|
33
|
-
|
|
34
|
-
## Our Responsibilities
|
|
35
|
-
|
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
-
response to any instances of unacceptable behavior.
|
|
39
|
-
|
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
-
threatening, offensive, or harmful.
|
|
45
|
-
|
|
46
|
-
## Scope
|
|
47
|
-
|
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
-
when an individual is representing the project or its community. Examples of
|
|
50
|
-
representing a project or community include using an official project e-mail
|
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
|
53
|
-
further defined and clarified by project maintainers.
|
|
54
|
-
|
|
55
|
-
## Enforcement
|
|
56
|
-
|
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
-
reported by contacting the project team at matthewdiverson@gmail.com. All
|
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
|
63
|
-
|
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
-
members of the project's leadership.
|
|
67
|
-
|
|
68
|
-
## Attribution
|
|
69
|
-
|
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
-
available at [https://contributor-covenant.org/version/1/4][version]
|
|
72
|
-
|
|
73
|
-
[homepage]: https://contributor-covenant.org
|
|
74
|
-
[version]: https://contributor-covenant.org/version/1/4/
|