lex-http 0.1.2 → 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 -18
- data/CHANGELOG.md +20 -0
- data/CLAUDE.md +79 -0
- data/Dockerfile +2 -3
- data/Gemfile +10 -2
- data/Gemfile.lock +103 -0
- data/README.md +44 -45
- data/docker_deploy.rb +3 -2
- data/lex-http.gemspec +11 -11
- 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 +10 -2
- data/lib/legion/extensions/http/version.rb +3 -1
- data/lib/legion/extensions/http.rb +5 -0
- metadata +21 -74
- data/CODE_OF_CONDUCT.md +0 -74
- data/Rakefile +0 -6
- data/bitbucket-pipelines.yml +0 -21
- /data/{LICENSE.txt → LICENSE} +0 -0
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,29 +1,50 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.4
|
|
3
|
+
NewCops: enable
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
|
|
1
6
|
Layout/LineLength:
|
|
2
|
-
Max:
|
|
3
|
-
|
|
4
|
-
Max: 30
|
|
5
|
-
Metrics/ClassLength:
|
|
6
|
-
Max: 1500
|
|
7
|
-
Metrics/BlockLength:
|
|
8
|
-
Max: 50
|
|
9
|
-
Metrics/AbcSize:
|
|
10
|
-
Max: 30
|
|
7
|
+
Max: 160
|
|
8
|
+
|
|
11
9
|
Layout/SpaceAroundEqualsInParameterDefault:
|
|
12
10
|
EnforcedStyle: space
|
|
13
|
-
|
|
14
|
-
Enabled: true
|
|
11
|
+
|
|
15
12
|
Layout/HashAlignment:
|
|
16
13
|
EnforcedHashRocketStyle: table
|
|
17
14
|
EnforcedColonStyle: table
|
|
15
|
+
|
|
16
|
+
Metrics/MethodLength:
|
|
17
|
+
Max: 50
|
|
18
|
+
|
|
19
|
+
Metrics/ClassLength:
|
|
20
|
+
Max: 1500
|
|
21
|
+
|
|
22
|
+
Metrics/ModuleLength:
|
|
23
|
+
Max: 1500
|
|
24
|
+
|
|
25
|
+
Metrics/BlockLength:
|
|
26
|
+
Max: 40
|
|
27
|
+
Exclude:
|
|
28
|
+
- 'spec/**/*'
|
|
29
|
+
|
|
30
|
+
Metrics/AbcSize:
|
|
31
|
+
Max: 60
|
|
32
|
+
|
|
33
|
+
Metrics/CyclomaticComplexity:
|
|
34
|
+
Max: 15
|
|
35
|
+
|
|
36
|
+
Metrics/PerceivedComplexity:
|
|
37
|
+
Max: 17
|
|
38
|
+
|
|
18
39
|
Style/Documentation:
|
|
19
40
|
Enabled: false
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
41
|
+
|
|
42
|
+
Style/SymbolArray:
|
|
43
|
+
Enabled: true
|
|
44
|
+
|
|
24
45
|
Style/FrozenStringLiteralComment:
|
|
25
|
-
Enabled:
|
|
46
|
+
Enabled: true
|
|
47
|
+
EnforcedStyle: always
|
|
48
|
+
|
|
26
49
|
Naming/FileName:
|
|
27
50
|
Enabled: false
|
|
28
|
-
Style/ClassAndModuleChildren:
|
|
29
|
-
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
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
FROM
|
|
1
|
+
FROM legionio/legion:latest
|
|
2
2
|
LABEL maintainer="Matthew Iverson <matthewdiverson@gmail.com>"
|
|
3
3
|
|
|
4
4
|
RUN mkdir /etc/legionio
|
|
5
5
|
RUN apk update && apk add build-base tzdata gcc git
|
|
6
6
|
|
|
7
7
|
COPY . ./
|
|
8
|
-
RUN gem install legionio tzinfo-data tzinfo --no-document --no-prerelease
|
|
9
8
|
RUN gem install lex-http --no-document --no-prerelease
|
|
10
|
-
CMD legionio
|
|
9
|
+
CMD ruby --yjit $(which legionio)
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
|
5
|
+
|
|
6
|
+
group :test do
|
|
7
|
+
gem 'rake'
|
|
8
|
+
gem 'rspec'
|
|
9
|
+
gem 'rspec_junit_formatter'
|
|
10
|
+
gem 'rubocop'
|
|
11
|
+
gem 'simplecov'
|
|
12
|
+
end
|
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,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
version = Legion::Extensions::Http::VERSION
|
|
4
4
|
name = 'http'
|
|
5
|
-
|
|
6
5
|
require "./lib/legion/extensions/#{name}/version"
|
|
6
|
+
version = Legion::Extensions::Http::VERSION
|
|
7
|
+
|
|
7
8
|
puts "Building docker image for Legion v#{version}"
|
|
8
9
|
system("docker build --tag legionio/lex-#{name}:v#{version} .")
|
|
9
10
|
puts 'Pushing to hub.docker.com'
|
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|
|
|
@@ -7,26 +9,24 @@ Gem::Specification.new do |spec|
|
|
|
7
9
|
spec.email = ['matthewdiverson@gmail.com']
|
|
8
10
|
|
|
9
11
|
spec.summary = 'LEX HTTP'
|
|
10
|
-
spec.description = 'Connections
|
|
11
|
-
spec.homepage = 'https://
|
|
12
|
+
spec.description = 'Connections LegionIO to any HTTP source'
|
|
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
|
-
spec.metadata['source_code_uri'] = 'https://
|
|
17
|
-
spec.metadata['
|
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-http'
|
|
19
|
+
spec.metadata['documentation_uri'] = 'https://github.com/LegionIO/lex-http'
|
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-http'
|
|
21
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/LegionIO/lex-http/issues'
|
|
22
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
18
23
|
|
|
19
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
20
25
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
21
26
|
end
|
|
22
27
|
spec.require_paths = ['lib']
|
|
23
28
|
|
|
24
|
-
spec.
|
|
25
|
-
spec.add_development_dependency 'rspec'
|
|
26
|
-
spec.add_development_dependency 'rubocop'
|
|
27
|
-
|
|
28
|
-
spec.add_dependency 'faraday'
|
|
29
|
-
spec.add_dependency 'faraday_middleware'
|
|
29
|
+
spec.add_dependency 'faraday', '>= 2.0'
|
|
30
30
|
spec.add_dependency 'multi_json'
|
|
31
31
|
spec.add_dependency 'multi_xml'
|
|
32
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,11 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
require 'faraday_middleware'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
3
|
+
require 'faraday'
|
|
4
|
+
# excon 174m
|
|
5
|
+
# net-http-persistent 42m
|
|
6
|
+
# HTTPClient 131m
|
|
7
|
+
#
|
|
4
8
|
module Legion
|
|
5
9
|
module Extensions
|
|
6
10
|
module Http
|
|
7
11
|
module Runners
|
|
8
12
|
module Http
|
|
13
|
+
def status(**_opts)
|
|
14
|
+
{ test: true }
|
|
15
|
+
end
|
|
16
|
+
|
|
9
17
|
def get(host:, uri: '', port: 80, **opts)
|
|
10
18
|
conn = Faraday.new(host) do |c|
|
|
11
19
|
c.options[:open_timeout] = settings[:options][:open_timeout]
|
metadata
CHANGED
|
@@ -1,85 +1,28 @@
|
|
|
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
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: rake
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rspec
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rubocop
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
12
|
- !ruby/object:Gem::Dependency
|
|
56
13
|
name: faraday
|
|
57
14
|
requirement: !ruby/object:Gem::Requirement
|
|
58
15
|
requirements:
|
|
59
16
|
- - ">="
|
|
60
17
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
18
|
+
version: '2.0'
|
|
62
19
|
type: :runtime
|
|
63
20
|
prerelease: false
|
|
64
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
22
|
requirements:
|
|
66
23
|
- - ">="
|
|
67
24
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: faraday_middleware
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - ">="
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0'
|
|
76
|
-
type: :runtime
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - ">="
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0'
|
|
25
|
+
version: '2.0'
|
|
83
26
|
- !ruby/object:Gem::Dependency
|
|
84
27
|
name: multi_json
|
|
85
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -108,36 +51,41 @@ dependencies:
|
|
|
108
51
|
- - ">="
|
|
109
52
|
- !ruby/object:Gem::Version
|
|
110
53
|
version: '0'
|
|
111
|
-
description: Connections
|
|
54
|
+
description: Connections LegionIO to any HTTP source
|
|
112
55
|
email:
|
|
113
56
|
- matthewdiverson@gmail.com
|
|
114
57
|
executables: []
|
|
115
58
|
extensions: []
|
|
116
59
|
extra_rdoc_files: []
|
|
117
60
|
files:
|
|
61
|
+
- ".github/workflows/ci.yml"
|
|
118
62
|
- ".gitignore"
|
|
119
63
|
- ".rspec"
|
|
120
64
|
- ".rubocop.yml"
|
|
121
|
-
-
|
|
65
|
+
- CHANGELOG.md
|
|
66
|
+
- CLAUDE.md
|
|
122
67
|
- Dockerfile
|
|
123
68
|
- Gemfile
|
|
124
|
-
-
|
|
69
|
+
- Gemfile.lock
|
|
70
|
+
- LICENSE
|
|
125
71
|
- README.md
|
|
126
|
-
- Rakefile
|
|
127
|
-
- bitbucket-pipelines.yml
|
|
128
72
|
- docker_deploy.rb
|
|
129
73
|
- lex-http.gemspec
|
|
130
74
|
- lib/legion/extensions/http.rb
|
|
75
|
+
- lib/legion/extensions/http/client.rb
|
|
76
|
+
- lib/legion/extensions/http/helpers/client.rb
|
|
131
77
|
- lib/legion/extensions/http/runners/http.rb
|
|
132
78
|
- lib/legion/extensions/http/version.rb
|
|
133
|
-
homepage: https://
|
|
79
|
+
homepage: https://github.com/LegionIO/lex-http
|
|
134
80
|
licenses:
|
|
135
81
|
- MIT
|
|
136
82
|
metadata:
|
|
137
|
-
homepage_uri: https://
|
|
138
|
-
source_code_uri: https://
|
|
139
|
-
|
|
140
|
-
|
|
83
|
+
homepage_uri: https://github.com/LegionIO/lex-http
|
|
84
|
+
source_code_uri: https://github.com/LegionIO/lex-http
|
|
85
|
+
documentation_uri: https://github.com/LegionIO/lex-http
|
|
86
|
+
changelog_uri: https://github.com/LegionIO/lex-http
|
|
87
|
+
bug_tracker_uri: https://github.com/LegionIO/lex-http/issues
|
|
88
|
+
rubygems_mfa_required: 'true'
|
|
141
89
|
rdoc_options: []
|
|
142
90
|
require_paths:
|
|
143
91
|
- lib
|
|
@@ -145,15 +93,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
145
93
|
requirements:
|
|
146
94
|
- - ">="
|
|
147
95
|
- !ruby/object:Gem::Version
|
|
148
|
-
version:
|
|
96
|
+
version: '3.4'
|
|
149
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
98
|
requirements:
|
|
151
99
|
- - ">="
|
|
152
100
|
- !ruby/object:Gem::Version
|
|
153
101
|
version: '0'
|
|
154
102
|
requirements: []
|
|
155
|
-
rubygems_version: 3.
|
|
156
|
-
signing_key:
|
|
103
|
+
rubygems_version: 3.6.9
|
|
157
104
|
specification_version: 4
|
|
158
105
|
summary: LEX HTTP
|
|
159
106
|
test_files: []
|
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/
|
data/Rakefile
DELETED
data/bitbucket-pipelines.yml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
image: ruby:2.7
|
|
2
|
-
|
|
3
|
-
pipelines:
|
|
4
|
-
tags:
|
|
5
|
-
"v*":
|
|
6
|
-
- step:
|
|
7
|
-
name: Push to RubyGems
|
|
8
|
-
deployment: RubyGems
|
|
9
|
-
script:
|
|
10
|
-
- gem install gem-release
|
|
11
|
-
- (umask 077 ; echo $gem_creds | base64 --decode > ~/.gem/credentials)
|
|
12
|
-
- gem release
|
|
13
|
-
artifacts:
|
|
14
|
-
- pkg/**
|
|
15
|
-
- step:
|
|
16
|
-
name: Push to Docker
|
|
17
|
-
deployment: Docker
|
|
18
|
-
script:
|
|
19
|
-
- 'apt-get update'
|
|
20
|
-
- 'apt-get install -y docker-ce'
|
|
21
|
-
- './docker_deploy.rb'
|
/data/{LICENSE.txt → LICENSE}
RENAMED
|
File without changes
|