code-ruby 1.7.3 → 1.7.4
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/AGENTS.md +6 -1
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/code/object/html.rb +0 -14
- data/lib/code/object/http.rb +2 -6
- data/lib/code-ruby.rb +1 -1
- data/spec/code_spec.rb +0 -3
- data/spec/spec_helper.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd10d6e30e6104bd4502576334f3c8a4a7c35ccb96f9d88d8915bb750988b93c
|
|
4
|
+
data.tar.gz: ea0dd0d3511cc147ac64d67ddf152e30fba5e0bcc1b4f03e9cef5bfd3bdad206
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48c33e339f68db73623f6bf43332f09b57454563903b9e9e8942a8d148d650e789b0b0e66ab9a7a0d68c340588ee896b3214891eab2785ee368c3caf3fc5bbec
|
|
7
|
+
data.tar.gz: 7f386fee01ca28936281aa5c4e7e34296107f39fcaa34d96ad2cd803a88a8215555d2cefe6027703d9a56be5ebb2dc6fe0afa97ef769b145b671200601d2851c
|
data/AGENTS.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Repository Guidelines
|
|
2
2
|
|
|
3
3
|
## Project Structure & Module Organization
|
|
4
|
+
|
|
4
5
|
- `lib/` — Core source. Classes live under the `Code` namespace and mirror paths (e.g., `lib/code/object/http.rb` → `Code::Object::Http`). Entry files: `lib/code.rb`, `lib/code-ruby.rb`.
|
|
5
6
|
- `bin/` — Executables and tooling shims: `bin/code` (CLI), `bin/rspec`, `bin/rubocop`, `bin/bundle`, `bin/bundler-audit`.
|
|
6
7
|
- `spec/` — RSpec tests. Shared setup in `spec/spec_helper.rb` (WebMock + Sinatra test app). File names end with `_spec.rb`.
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
- Root — `Gemfile`, `code-ruby.gemspec`, `Rakefile` (RSpec default), `.rubocop.yml`, `VERSION`.
|
|
9
10
|
|
|
10
11
|
## Build, Test, and Development Commands
|
|
12
|
+
|
|
11
13
|
- Install: `bundle install`
|
|
12
14
|
- Run all tests: `bundle exec rake` or `bin/rspec`
|
|
13
15
|
- Run one file/example: `bin/rspec spec/code_spec.rb:42`
|
|
@@ -17,22 +19,25 @@
|
|
|
17
19
|
- CLI examples: `bin/code -h`, `bin/code -p '1+2'`, `bin/code -t 2 'loop { }'`
|
|
18
20
|
|
|
19
21
|
## Coding Style & Naming Conventions
|
|
22
|
+
|
|
20
23
|
- Ruby 3.4.5; 2-space indentation; keep `# frozen_string_literal: true`.
|
|
21
24
|
- Follow `.rubocop.yml`; prefer small, single-responsibility classes under `lib/code/...` reflecting their constants.
|
|
22
25
|
- File names: snake_case; tests mirror source paths under `spec/` with `_spec.rb` suffix.
|
|
23
26
|
|
|
24
27
|
## Testing Guidelines
|
|
28
|
+
|
|
25
29
|
- Framework: RSpec. Network calls are disabled via WebMock; use the provided `FakeHttpBin` rack app for HTTP behavior.
|
|
26
30
|
- Add focused specs near the feature (e.g., parser under `spec/code/parser/*`, objects under `spec/code/object/*`).
|
|
27
31
|
- For language-level behaviors, extend `spec/code_spec.rb` with input → output examples.
|
|
28
32
|
- Ensure new behavior has at least one positive and one edge/failure case.
|
|
29
33
|
|
|
30
34
|
## Commit & Pull Request Guidelines
|
|
35
|
+
|
|
31
36
|
- Commits: short, imperative subjects (e.g., "fix parser whitespace"). Version bumps (`VERSION`, `vX.Y.Z`) are handled by maintainers.
|
|
32
37
|
- PRs: include a clear description, reproduction or CLI examples, and links to issues. Update docs in `docs/` when grammar/precedence changes.
|
|
33
38
|
- Keep diffs minimal and focused; include tests and run `bin/rubocop` before submitting.
|
|
34
39
|
|
|
35
40
|
## Security & Configuration Tips
|
|
41
|
+
|
|
36
42
|
- Tooling versions: see `.tool-versions`, `.ruby-version`, `.node-version`, `.npm-version`.
|
|
37
43
|
- Tests must not reach the network; rely on stubs/fixtures. Prefer timeouts (`-t/--timeout`) when evaluating untrusted input with `bin/code`.
|
|
38
|
-
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.7.
|
|
1
|
+
1.7.4
|
data/lib/code/object/html.rb
CHANGED
|
@@ -20,9 +20,6 @@ class Code
|
|
|
20
20
|
code_arguments = args.fetch(:arguments, []).to_code
|
|
21
21
|
|
|
22
22
|
case code_operator.to_s
|
|
23
|
-
when "link_to"
|
|
24
|
-
sig(args) { [Object.maybe, Object.maybe] }
|
|
25
|
-
code_link_to(*code_arguments.raw)
|
|
26
23
|
when "escape"
|
|
27
24
|
sig(args) { Object.maybe }
|
|
28
25
|
code_escape(*code_arguments.raw)
|
|
@@ -31,17 +28,6 @@ class Code
|
|
|
31
28
|
end
|
|
32
29
|
end
|
|
33
30
|
|
|
34
|
-
def self.code_link_to(text = nil, href = nil)
|
|
35
|
-
code_text = text.to_code
|
|
36
|
-
code_href = href.to_code
|
|
37
|
-
|
|
38
|
-
String.new(<<~LINK.strip)
|
|
39
|
-
<a
|
|
40
|
-
href="#{CGI.escapeHTML(code_href.to_s)}"
|
|
41
|
-
>#{CGI.escapeHTML(code_text.to_s)}</a>
|
|
42
|
-
LINK
|
|
43
|
-
end
|
|
44
|
-
|
|
45
31
|
def self.code_escape(string = nil)
|
|
46
32
|
code_string = string.to_code
|
|
47
33
|
|
data/lib/code/object/http.rb
CHANGED
|
@@ -204,18 +204,14 @@ class Code
|
|
|
204
204
|
code = response.code.to_i
|
|
205
205
|
location = response["location"].to_s
|
|
206
206
|
|
|
207
|
-
if (300..399).cover?(code) && location.present? && redirects
|
|
207
|
+
if (300..399).cover?(code) && location.present? && redirects.positive?
|
|
208
208
|
new_uri = ::URI.join(uri, location)
|
|
209
209
|
|
|
210
210
|
if new_uri.host == uri.host
|
|
211
211
|
code_fetch(
|
|
212
212
|
"get",
|
|
213
213
|
new_uri.to_s,
|
|
214
|
-
{
|
|
215
|
-
username: username,
|
|
216
|
-
password: password,
|
|
217
|
-
headers: headers
|
|
218
|
-
},
|
|
214
|
+
{ username: username, password: password, headers: headers },
|
|
219
215
|
redirects: redirects - 1
|
|
220
216
|
)
|
|
221
217
|
else
|
data/lib/code-ruby.rb
CHANGED
|
@@ -4,6 +4,7 @@ require "active_support/all"
|
|
|
4
4
|
require "base64"
|
|
5
5
|
require "bigdecimal"
|
|
6
6
|
require "bigdecimal/util"
|
|
7
|
+
require "date"
|
|
7
8
|
require "did_you_mean"
|
|
8
9
|
require "json"
|
|
9
10
|
require "language-ruby"
|
|
@@ -14,7 +15,6 @@ require "stringio"
|
|
|
14
15
|
require "timeout"
|
|
15
16
|
require "uri"
|
|
16
17
|
require "zeitwerk"
|
|
17
|
-
require "date"
|
|
18
18
|
|
|
19
19
|
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
|
|
20
20
|
loader.ignore("#{__dir__}/code-ruby.rb")
|
data/spec/code_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
|
@@ -7,7 +7,7 @@ require "webmock/rspec"
|
|
|
7
7
|
class FakeHttpBin < Sinatra::Base
|
|
8
8
|
set :host_authorization, { permitted_hosts: ["httpbin.org"] }
|
|
9
9
|
|
|
10
|
-
%w[GET HEAD POST PUT DELETE
|
|
10
|
+
%w[GET HEAD POST PUT DELETE OPTIONS TRACE PATCH].each do |verb|
|
|
11
11
|
route verb, "/status/:status" do
|
|
12
12
|
status params[:status].to_i
|
|
13
13
|
end
|