sinclair 3.1.0 → 3.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/.circleci/config.yml +4 -5
- data/.claude/agents/architect.md +53 -0
- data/.claude/agents/docs.md +34 -0
- data/.claude/agents/ruby.md +44 -0
- data/.claude/agents/security.md +27 -0
- data/.claude/configuration/arcanum-repo-config.json +8 -0
- data/.claude/configuration/auto-fix-all.json +3 -0
- data/.claude/scripts/check_ruby.sh +7 -0
- data/.claude/settings.json +10 -0
- data/.github/commit_message_template-2.0.md +32 -0
- data/.github/commit_message_template.md +8 -0
- data/.github/copilot-instructions.md +1 -66
- data/.github/pull_request_template.md +17 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/AGENTS.md +111 -0
- data/CLAUDE.md +1 -0
- data/Dockerfile +3 -2
- data/Dockerfile.circleci +6 -11
- data/Gemfile +10 -9
- data/README.md +2 -2
- data/config/yardstick.yml +6 -0
- data/docs/agents/arcanum-split-issue.md +9 -0
- data/docs/agents/architecture.md +96 -0
- data/docs/agents/contributing.md +201 -0
- data/docs/agents/flow.md +5 -0
- data/docs/agents/folder-structure.md +44 -0
- data/docs/agents/issue-enhancement.md +10 -0
- data/docs/agents/issues/.gitkeep +1 -0
- data/docs/agents/plans/.gitkeep +1 -0
- data/docs/guides/sinclair/caster.md +33 -0
- data/docs/guides/sinclair/comparable.md +26 -0
- data/docs/guides/sinclair/complete-example.md +43 -0
- data/docs/guides/sinclair/configurable.md +55 -0
- data/docs/guides/sinclair/env-settable.md +41 -0
- data/docs/guides/sinclair/installation.md +17 -0
- data/docs/guides/sinclair/matchers.md +52 -0
- data/docs/guides/sinclair/method-builder.md +104 -0
- data/docs/guides/sinclair/model.md +75 -0
- data/docs/guides/sinclair/options.md +33 -0
- data/docs/guides/sinclair-usage.md +39 -0
- data/lib/sinclair/caster.rb +1 -1
- data/lib/sinclair/core_ext/object.rb +2 -2
- data/lib/sinclair/version.rb +1 -1
- data/scripts/bump_version.sh +62 -0
- data/sinclair.gemspec +1 -1
- data/spec/integration/yard/sinclair/caster/cast_spec.rb +1 -1
- data/spec/lib/sinclair/config_factory_spec.rb +5 -10
- data/spec/lib/sinclair/configurable_spec.rb +3 -6
- data/spec/lib/sinclair/method_definition/stringifier_spec.rb +1 -1
- data/spec/lib/sinclair/options_parser_spec.rb +1 -1
- data/spec/support/models/hash_app_client.rb +1 -2
- metadata +37 -8
- data/.github/sinclair-usage.md +0 -492
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Sinclair – Dynamic Method Builder
|
|
2
|
+
|
|
3
|
+
`Sinclair` lets you add instance and class methods to any class at runtime.
|
|
4
|
+
Methods are queued with `add_method` / `add_class_method` and created only
|
|
5
|
+
when `build` is called.
|
|
6
|
+
|
|
7
|
+
### Stand-alone usage
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
class Clazz; end
|
|
11
|
+
|
|
12
|
+
builder = Sinclair.new(Clazz)
|
|
13
|
+
builder.add_method(:twenty, '10 + 10') # string-based
|
|
14
|
+
builder.add_method(:eighty) { 4 * twenty } # block-based
|
|
15
|
+
builder.add_class_method(:one_hundred) { 100 }
|
|
16
|
+
builder.build
|
|
17
|
+
|
|
18
|
+
instance = Clazz.new
|
|
19
|
+
instance.twenty # => 20
|
|
20
|
+
instance.eighty # => 80
|
|
21
|
+
Clazz.one_hundred # => 100
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Block DSL (`Sinclair.build`)
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
Sinclair.build(MyClass) do
|
|
28
|
+
add_method(:random_number) { Random.rand(10..20) }
|
|
29
|
+
add_class_method(:static_value) { 42 }
|
|
30
|
+
end
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### String method with parameters
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
Sinclair.build(MyClass) do
|
|
37
|
+
add_class_method(
|
|
38
|
+
:power, 'a ** b + c',
|
|
39
|
+
parameters: [:a],
|
|
40
|
+
named_parameters: [:b, { c: 15 }]
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
MyClass.power(10, b: 2) # => 115
|
|
45
|
+
MyClass.power(10, b: 2, c: 0) # => 100
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Call-based method (delegates to the class itself)
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
builder = Sinclair.new(MyClass)
|
|
52
|
+
builder.add_class_method(:attr_accessor, :number, type: :call)
|
|
53
|
+
builder.build
|
|
54
|
+
|
|
55
|
+
MyClass.number # => nil
|
|
56
|
+
MyClass.number = 10
|
|
57
|
+
MyClass.number # => 10
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Caching results
|
|
61
|
+
|
|
62
|
+
```ruby
|
|
63
|
+
builder.add_method(:expensive, cached: true) { slow_computation }
|
|
64
|
+
# equivalent to: @expensive ||= slow_computation
|
|
65
|
+
|
|
66
|
+
builder.add_method(:nullable, cached: :full) { may_return_nil }
|
|
67
|
+
# caches even nil / false values
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Extending the builder
|
|
71
|
+
|
|
72
|
+
Subclass `Sinclair` to create domain-specific builders:
|
|
73
|
+
|
|
74
|
+
```ruby
|
|
75
|
+
class ValidationBuilder < Sinclair
|
|
76
|
+
delegate :expected, to: :options_object
|
|
77
|
+
|
|
78
|
+
def add_validation(field)
|
|
79
|
+
add_method("#{field}_valid?", "#{field}.is_a?(#{expected})")
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
module Validatable
|
|
84
|
+
extend ActiveSupport::Concern
|
|
85
|
+
|
|
86
|
+
class_methods do
|
|
87
|
+
def validate(*fields, expected_class)
|
|
88
|
+
builder = ValidationBuilder.new(self, expected: expected_class)
|
|
89
|
+
fields.each { |f| builder.add_validation(f) }
|
|
90
|
+
builder.build
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class MyModel
|
|
96
|
+
include Validatable
|
|
97
|
+
validate :name, String
|
|
98
|
+
validate :age, Integer
|
|
99
|
+
end
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
[Back to index](../sinclair-usage.md)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Sinclair::Model – Quick Plain-Ruby Models
|
|
2
|
+
|
|
3
|
+
`Sinclair::Model` generates reader/writer methods, a keyword-argument
|
|
4
|
+
initializer, and equality (via `Sinclair::Comparable`) in one call.
|
|
5
|
+
|
|
6
|
+
There are two ways to define a model:
|
|
7
|
+
|
|
8
|
+
- **`initialize_with`** – called inside the class body; adds methods to the current class.
|
|
9
|
+
- **`.for`** – class method that returns a new anonymous subclass; useful when inheriting inline.
|
|
10
|
+
|
|
11
|
+
### Basic model (initialize_with)
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
class Human < Sinclair::Model
|
|
15
|
+
initialize_with :name, :age, { gender: :undefined }, **{}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
h1 = Human.new(name: 'John', age: 22)
|
|
19
|
+
h2 = Human.new(name: 'John', age: 22)
|
|
20
|
+
|
|
21
|
+
h1.name # => 'John'
|
|
22
|
+
h1.gender # => :undefined
|
|
23
|
+
h1 == h2 # => true
|
|
24
|
+
|
|
25
|
+
h1.name = 'Jane' # setter generated by default
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Disabling writers or equality (initialize_with)
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
class Tv < Sinclair::Model
|
|
32
|
+
initialize_with :brand, :model, writter: false, comparable: false
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
tv1 = Tv.new(brand: 'Sony', model: 'X90L')
|
|
36
|
+
tv2 = Tv.new(brand: 'Sony', model: 'X90L')
|
|
37
|
+
|
|
38
|
+
tv1 == tv2 # => false (comparable disabled)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Using .for (inline subclassing)
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
class Car < Sinclair::Model.for(:brand, :model, writter: false)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
car = Car.new(brand: :ford, model: :T)
|
|
48
|
+
|
|
49
|
+
car.brand # => :ford
|
|
50
|
+
car.model # => :T
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Using .for with default values
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
class Job < Sinclair::Model.for({ state: :starting }, writter: true)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
job = Job.new
|
|
60
|
+
|
|
61
|
+
job.state # => :starting
|
|
62
|
+
job.state = :done
|
|
63
|
+
job.state # => :done
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Options accepted by both `initialize_with` and `.for`:
|
|
67
|
+
|
|
68
|
+
| Option | Default | Description |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `writter:` | `true` | Generate setter methods |
|
|
71
|
+
| `comparable:` | `true` | Include field in `==` comparison |
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
[Back to index](../sinclair-usage.md)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Sinclair::Options – Validated Option Objects
|
|
2
|
+
|
|
3
|
+
`Sinclair::Options` creates structured option/parameter value objects with
|
|
4
|
+
defaults and validation against unknown keys.
|
|
5
|
+
|
|
6
|
+
```ruby
|
|
7
|
+
class ConnectionOptions < Sinclair::Options
|
|
8
|
+
with_options :timeout, :retries, port: 443, protocol: 'https'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
opts = ConnectionOptions.new(timeout: 30, protocol: 'http')
|
|
12
|
+
opts.timeout # => 30
|
|
13
|
+
opts.retries # => nil
|
|
14
|
+
opts.port # => 443 (default)
|
|
15
|
+
opts.protocol # => 'http'
|
|
16
|
+
opts.to_h # => { timeout: 30, retries: nil, port: 443, protocol: 'http' }
|
|
17
|
+
|
|
18
|
+
ConnectionOptions.new(unknown_key: 1)
|
|
19
|
+
# raises Sinclair::Exception::InvalidOptions
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Call `skip_validation` in the class body to allow unknown keys:
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
class LooseOptions < Sinclair::Options
|
|
26
|
+
with_options :name
|
|
27
|
+
skip_validation
|
|
28
|
+
end
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
[Back to index](../sinclair-usage.md)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Sinclair – Usage Guide for Dependent Projects
|
|
2
|
+
|
|
3
|
+
This document describes how to use the **sinclair** gem in your project.
|
|
4
|
+
Copy this file and the [`sinclair/`](sinclair/) directory into your project's
|
|
5
|
+
`docs/guides/` directory so that GitHub Copilot is aware of the patterns and
|
|
6
|
+
conventions Sinclair provides.
|
|
7
|
+
|
|
8
|
+
**Current release**: 3.1.0
|
|
9
|
+
**Docs**: <https://www.rubydoc.info/gems/sinclair/3.1.0>
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Guides
|
|
14
|
+
|
|
15
|
+
- [Installation](sinclair/installation.md)
|
|
16
|
+
- [Sinclair – Dynamic Method Builder](sinclair/method-builder.md)
|
|
17
|
+
- [Sinclair::Configurable – Application Configuration](sinclair/configurable.md)
|
|
18
|
+
- [Sinclair::Options – Validated Option Objects](sinclair/options.md)
|
|
19
|
+
- [Sinclair::EnvSettable – Environment Variable Access](sinclair/env-settable.md)
|
|
20
|
+
- [Sinclair::Comparable – Attribute-based Equality](sinclair/comparable.md)
|
|
21
|
+
- [Sinclair::Model – Quick Plain-Ruby Models](sinclair/model.md)
|
|
22
|
+
- [Sinclair::Caster – Type Casting](sinclair/caster.md)
|
|
23
|
+
- [Sinclair::Matchers – RSpec Matchers](sinclair/matchers.md)
|
|
24
|
+
- [Complete Example](sinclair/complete-example.md)
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Features Overview
|
|
29
|
+
|
|
30
|
+
| Feature | Class / Module | Purpose | Guide |
|
|
31
|
+
|---|---|---|---|
|
|
32
|
+
| Method builder | `Sinclair` | Add instance/class methods dynamically | [method-builder.md](sinclair/method-builder.md) |
|
|
33
|
+
| Configuration | `Sinclair::Configurable` + `Sinclair::Config` | Read-only config with defaults | [configurable.md](sinclair/configurable.md) |
|
|
34
|
+
| Options | `Sinclair::Options` | Validated parameter objects | [options.md](sinclair/options.md) |
|
|
35
|
+
| Env variables | `Sinclair::EnvSettable` | Read ENV vars via class methods | [env-settable.md](sinclair/env-settable.md) |
|
|
36
|
+
| Equality | `Sinclair::Comparable` | Attribute-based `==` | [comparable.md](sinclair/comparable.md) |
|
|
37
|
+
| Plain models | `Sinclair::Model` | Quick data-model classes | [model.md](sinclair/model.md) |
|
|
38
|
+
| Type casting | `Sinclair::Caster` | Extensible type transformations | [caster.md](sinclair/caster.md) |
|
|
39
|
+
| RSpec matchers | `Sinclair::Matchers` | Test method-builder behaviour | [matchers.md](sinclair/matchers.md) |
|
data/lib/sinclair/caster.rb
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#
|
|
6
6
|
# Extension to core class Object
|
|
7
7
|
class Object
|
|
8
|
-
# rubocop:disable Naming/
|
|
8
|
+
# rubocop:disable Naming/PredicatePrefix
|
|
9
9
|
|
|
10
10
|
# @api public
|
|
11
11
|
# Checks if an object is an instance of any of the given classes
|
|
@@ -22,7 +22,7 @@ class Object
|
|
|
22
22
|
def is_any?(*classes)
|
|
23
23
|
classes.any?(method(:is_a?))
|
|
24
24
|
end
|
|
25
|
-
# rubocop:enable Naming/
|
|
25
|
+
# rubocop:enable Naming/PredicatePrefix
|
|
26
26
|
|
|
27
27
|
# Maps the elements into a new value, returning only one
|
|
28
28
|
#
|
data/lib/sinclair/version.rb
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Usage: scripts/bump_version.sh [major|minor|patch|X.Y.Z]
|
|
3
|
+
# Without arguments, bumps the patch version of the current version.
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
ROOT="$(git rev-parse --show-toplevel)"
|
|
8
|
+
README="$ROOT/README.md"
|
|
9
|
+
VERSION_FILE="$ROOT/lib/sinclair/version.rb"
|
|
10
|
+
LOCKFILE="$ROOT/Gemfile.lock"
|
|
11
|
+
GEM="sinclair"
|
|
12
|
+
|
|
13
|
+
current=$(grep -oE "VERSION = '[0-9]+\.[0-9]+\.[0-9]+'" "$VERSION_FILE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
|
14
|
+
IFS='.' read -r cmajor cminor cpatch <<< "$current"
|
|
15
|
+
|
|
16
|
+
arg="${1:-patch}"
|
|
17
|
+
|
|
18
|
+
case "$arg" in
|
|
19
|
+
major) new_version="$((cmajor + 1)).0.0" ;;
|
|
20
|
+
minor) new_version="${cmajor}.$((cminor + 1)).0" ;;
|
|
21
|
+
patch) new_version="${cmajor}.${cminor}.$((cpatch + 1))" ;;
|
|
22
|
+
*) new_version="$arg" ;;
|
|
23
|
+
esac
|
|
24
|
+
|
|
25
|
+
# Validate semver format
|
|
26
|
+
if ! echo "$new_version" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
|
27
|
+
echo "Error: version must be major, minor, patch or X.Y.Z" >&2
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Next release: following minor
|
|
32
|
+
IFS='.' read -r major minor _patch <<< "$new_version"
|
|
33
|
+
next_release="${major}.$((minor + 1)).0"
|
|
34
|
+
|
|
35
|
+
echo "Current version: $current"
|
|
36
|
+
echo "New version: $new_version"
|
|
37
|
+
echo "Next release: $next_release"
|
|
38
|
+
|
|
39
|
+
# version.rb
|
|
40
|
+
sed -i '' "s|VERSION = '[0-9.]*'|VERSION = '${new_version}'|" "$VERSION_FILE"
|
|
41
|
+
|
|
42
|
+
# README: YARD docs link
|
|
43
|
+
sed -i '' \
|
|
44
|
+
"s|rubydoc.info/gems/${GEM}/[0-9.]*|rubydoc.info/gems/${GEM}/${new_version}|g" \
|
|
45
|
+
"$README"
|
|
46
|
+
|
|
47
|
+
# README: Current Release line
|
|
48
|
+
sed -i '' \
|
|
49
|
+
"s|\*\*Current Release\*\*: \[[0-9.]*\](https://github.com/darthjee/sinclair/tree/[0-9.]*)|**Current Release**: [${new_version}](https://github.com/darthjee/sinclair/tree/${new_version})|" \
|
|
50
|
+
"$README"
|
|
51
|
+
|
|
52
|
+
# README: Next release line
|
|
53
|
+
sed -i '' \
|
|
54
|
+
"s|\*\*Next release\*\*: \[[0-9.]*\](https://github.com/darthjee/sinclair/compare/[0-9.]*\.\.\.main)|**Next release**: [${next_release}](https://github.com/darthjee/sinclair/compare/${new_version}...main)|" \
|
|
55
|
+
"$README"
|
|
56
|
+
|
|
57
|
+
# Gemfile.lock
|
|
58
|
+
if [ -f "$LOCKFILE" ]; then
|
|
59
|
+
sed -i '' "s|^\( *${GEM} (\)[0-9.]*)|\1${new_version})|" "$LOCKFILE"
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
echo "Done."
|
data/sinclair.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
|
12
12
|
gem.homepage = 'https://github.com/darthjee/sinclair'
|
|
13
13
|
gem.description = 'Gem for easy concern creation'
|
|
14
14
|
gem.summary = gem.description
|
|
15
|
-
gem.required_ruby_version = '>= 3.
|
|
15
|
+
gem.required_ruby_version = '>= 3.4.0'
|
|
16
16
|
|
|
17
17
|
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
18
18
|
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
@@ -47,25 +47,23 @@ describe Sinclair::ConfigFactory do
|
|
|
47
47
|
context 'when initializing with custom config class that does not extend config_class' do
|
|
48
48
|
subject(:factory) { described_class.new(config_class: DummyConfig) }
|
|
49
49
|
|
|
50
|
-
# rubocop:disable RSpec/AnyInstance
|
|
50
|
+
# rubocop:disable-next RSpec/AnyInstance
|
|
51
51
|
before do
|
|
52
52
|
allow_any_instance_of(described_class)
|
|
53
53
|
.to receive(:warn)
|
|
54
54
|
end
|
|
55
|
-
# rubocop:enable RSpec/AnyInstance
|
|
56
55
|
|
|
57
56
|
it do
|
|
58
57
|
expect(factory.config).to be_a(DummyConfig)
|
|
59
58
|
end
|
|
60
59
|
|
|
61
|
-
# rubocop:disable RSpec/SubjectStub
|
|
60
|
+
# rubocop:disable-next RSpec/SubjectStub
|
|
62
61
|
it 'warns about class use' do
|
|
63
62
|
factory.config
|
|
64
63
|
|
|
65
64
|
expect(factory).to have_received(:warn)
|
|
66
65
|
.with described_class::CONFIG_CLASS_WARNING
|
|
67
66
|
end
|
|
68
|
-
# rubocop:enable RSpec/SubjectStub
|
|
69
67
|
|
|
70
68
|
context 'when calling after reset_config' do
|
|
71
69
|
before { factory.reset_config }
|
|
@@ -157,12 +155,11 @@ describe Sinclair::ConfigFactory do
|
|
|
157
155
|
|
|
158
156
|
let(:config_class) { Class.new }
|
|
159
157
|
|
|
160
|
-
# rubocop:disable RSpec/AnyInstance
|
|
158
|
+
# rubocop:disable-next RSpec/AnyInstance
|
|
161
159
|
before do
|
|
162
160
|
allow_any_instance_of(described_class)
|
|
163
161
|
.to receive(:warn)
|
|
164
162
|
end
|
|
165
|
-
# rubocop:enable RSpec/AnyInstance
|
|
166
163
|
|
|
167
164
|
it_behaves_like 'a config factory adding config' do
|
|
168
165
|
let(:method_call) { proc { add_configs(:name) } }
|
|
@@ -173,14 +170,13 @@ describe Sinclair::ConfigFactory do
|
|
|
173
170
|
expect(factory.config.name).to be_nil
|
|
174
171
|
end
|
|
175
172
|
|
|
176
|
-
# rubocop:disable RSpec/SubjectStub
|
|
173
|
+
# rubocop:disable-next RSpec/SubjectStub
|
|
177
174
|
it 'warns about class use' do
|
|
178
175
|
code_block.call
|
|
179
176
|
|
|
180
177
|
expect(factory).to have_received(:warn)
|
|
181
178
|
.with described_class::CONFIG_CLASS_WARNING
|
|
182
179
|
end
|
|
183
|
-
# rubocop:enable RSpec/SubjectStub
|
|
184
180
|
end
|
|
185
181
|
|
|
186
182
|
context 'when passing a hash' do
|
|
@@ -193,14 +189,13 @@ describe Sinclair::ConfigFactory do
|
|
|
193
189
|
expect(factory.config.name).to eq('Bobby')
|
|
194
190
|
end
|
|
195
191
|
|
|
196
|
-
# rubocop:disable RSpec/SubjectStub
|
|
192
|
+
# rubocop:disable-next RSpec/SubjectStub
|
|
197
193
|
it 'warns about class use' do
|
|
198
194
|
code_block.call
|
|
199
195
|
|
|
200
196
|
expect(factory).to have_received(:warn)
|
|
201
197
|
.with described_class::CONFIG_CLASS_WARNING
|
|
202
198
|
end
|
|
203
|
-
# rubocop:enable RSpec/SubjectStub
|
|
204
199
|
end
|
|
205
200
|
end
|
|
206
201
|
end
|
|
@@ -123,13 +123,12 @@ describe Sinclair::Configurable do
|
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
-
# rubocop:disable RSpec/SubjectStub
|
|
126
|
+
# rubocop:disable-next RSpec/SubjectStub
|
|
127
127
|
before do
|
|
128
128
|
allow(configurable)
|
|
129
129
|
.to receive(:warn)
|
|
130
130
|
.with(described_class::CONFIG_CLASS_WARNING)
|
|
131
131
|
end
|
|
132
|
-
# rubocop:enable RSpec/SubjectStub
|
|
133
132
|
|
|
134
133
|
it 'does not add symbol methods config object' do
|
|
135
134
|
expect(&block)
|
|
@@ -141,12 +140,11 @@ describe Sinclair::Configurable do
|
|
|
141
140
|
.not_to add_method(:port).to(configurable.config)
|
|
142
141
|
end
|
|
143
142
|
|
|
144
|
-
# rubocop:disable RSpec/SubjectStub
|
|
143
|
+
# rubocop:disable-next RSpec/SubjectStub
|
|
145
144
|
it 'sends deprecation warning' do
|
|
146
145
|
block.call
|
|
147
146
|
expect(configurable).to have_received(:warn)
|
|
148
147
|
end
|
|
149
|
-
# rubocop:enable RSpec/SubjectStub
|
|
150
148
|
|
|
151
149
|
it 'does not raises error on configuration of given symbol attributes' do
|
|
152
150
|
block.call
|
|
@@ -217,11 +215,10 @@ describe Sinclair::Configurable do
|
|
|
217
215
|
let(:config_class) { ServerConfig }
|
|
218
216
|
|
|
219
217
|
before do
|
|
220
|
-
# rubocop:disable RSpec/SubjectStub
|
|
218
|
+
# rubocop:disable-next RSpec/SubjectStub
|
|
221
219
|
allow(configurable)
|
|
222
220
|
.to receive(:warn)
|
|
223
221
|
.with(described_class::CONFIG_CLASS_WARNING)
|
|
224
|
-
# rubocop:enable RSpec/SubjectStub
|
|
225
222
|
|
|
226
223
|
configurable.send(
|
|
227
224
|
:configurable_by, config_class, with: [:host, 'port']
|
|
@@ -55,7 +55,7 @@ describe Sinclair::MethodDefinition::Stringifier do
|
|
|
55
55
|
context 'when value is a hash' do
|
|
56
56
|
it 'returns string representing a Hash' do
|
|
57
57
|
expect(described_class.value_string({ a: 10, 'b' => 'value' }))
|
|
58
|
-
.to eq('{:
|
|
58
|
+
.to eq('{a: 10, "b" => "value"}')
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
@@ -5,9 +5,8 @@ require './spec/support/models/hash_settable'
|
|
|
5
5
|
class HashAppClient
|
|
6
6
|
extend HashSettable
|
|
7
7
|
|
|
8
|
-
# rubocop:disable Style/MutableConstant
|
|
8
|
+
# rubocop:disable-next Style/MutableConstant
|
|
9
9
|
HASH = {}
|
|
10
|
-
# rubocop:enable Style/MutableConstant
|
|
11
10
|
|
|
12
11
|
with_settings :username, :password, host: 'my-host.com'
|
|
13
12
|
setting_with_options :port, type: :integer
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sinclair
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DarthJee
|
|
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: activesupport
|
|
@@ -32,12 +31,24 @@ extensions: []
|
|
|
32
31
|
extra_rdoc_files: []
|
|
33
32
|
files:
|
|
34
33
|
- ".circleci/config.yml"
|
|
34
|
+
- ".claude/agents/architect.md"
|
|
35
|
+
- ".claude/agents/docs.md"
|
|
36
|
+
- ".claude/agents/ruby.md"
|
|
37
|
+
- ".claude/agents/security.md"
|
|
38
|
+
- ".claude/configuration/arcanum-repo-config.json"
|
|
39
|
+
- ".claude/configuration/auto-fix-all.json"
|
|
40
|
+
- ".claude/scripts/check_ruby.sh"
|
|
41
|
+
- ".claude/settings.json"
|
|
42
|
+
- ".github/commit_message_template-2.0.md"
|
|
43
|
+
- ".github/commit_message_template.md"
|
|
35
44
|
- ".github/copilot-instructions.md"
|
|
36
|
-
- ".github/
|
|
45
|
+
- ".github/pull_request_template.md"
|
|
37
46
|
- ".gitignore"
|
|
38
47
|
- ".rspec"
|
|
39
48
|
- ".rubocop.yml"
|
|
40
49
|
- ".rubocop_todo.yml"
|
|
50
|
+
- AGENTS.md
|
|
51
|
+
- CLAUDE.md
|
|
41
52
|
- Dockerfile
|
|
42
53
|
- Dockerfile.circleci
|
|
43
54
|
- Gemfile
|
|
@@ -51,6 +62,25 @@ files:
|
|
|
51
62
|
- config/yardstick.rb
|
|
52
63
|
- config/yardstick.yml
|
|
53
64
|
- docker-compose.yml
|
|
65
|
+
- docs/agents/arcanum-split-issue.md
|
|
66
|
+
- docs/agents/architecture.md
|
|
67
|
+
- docs/agents/contributing.md
|
|
68
|
+
- docs/agents/flow.md
|
|
69
|
+
- docs/agents/folder-structure.md
|
|
70
|
+
- docs/agents/issue-enhancement.md
|
|
71
|
+
- docs/agents/issues/.gitkeep
|
|
72
|
+
- docs/agents/plans/.gitkeep
|
|
73
|
+
- docs/guides/sinclair-usage.md
|
|
74
|
+
- docs/guides/sinclair/caster.md
|
|
75
|
+
- docs/guides/sinclair/comparable.md
|
|
76
|
+
- docs/guides/sinclair/complete-example.md
|
|
77
|
+
- docs/guides/sinclair/configurable.md
|
|
78
|
+
- docs/guides/sinclair/env-settable.md
|
|
79
|
+
- docs/guides/sinclair/installation.md
|
|
80
|
+
- docs/guides/sinclair/matchers.md
|
|
81
|
+
- docs/guides/sinclair/method-builder.md
|
|
82
|
+
- docs/guides/sinclair/model.md
|
|
83
|
+
- docs/guides/sinclair/options.md
|
|
54
84
|
- lib/sinclair.rb
|
|
55
85
|
- lib/sinclair/caster.rb
|
|
56
86
|
- lib/sinclair/caster/class_methods.rb
|
|
@@ -110,6 +140,7 @@ files:
|
|
|
110
140
|
- lib/sinclair/settable/caster.rb
|
|
111
141
|
- lib/sinclair/settable/class_methods.rb
|
|
112
142
|
- lib/sinclair/version.rb
|
|
143
|
+
- scripts/bump_version.sh
|
|
113
144
|
- sinclair.gemspec
|
|
114
145
|
- sinclair.png
|
|
115
146
|
- spec/integration/readme/my_class_spec.rb
|
|
@@ -273,7 +304,6 @@ homepage: https://github.com/darthjee/sinclair
|
|
|
273
304
|
licenses: []
|
|
274
305
|
metadata:
|
|
275
306
|
rubygems_mfa_required: 'false'
|
|
276
|
-
post_install_message:
|
|
277
307
|
rdoc_options: []
|
|
278
308
|
require_paths:
|
|
279
309
|
- lib
|
|
@@ -281,15 +311,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
281
311
|
requirements:
|
|
282
312
|
- - ">="
|
|
283
313
|
- !ruby/object:Gem::Version
|
|
284
|
-
version: 3.
|
|
314
|
+
version: 3.4.0
|
|
285
315
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
286
316
|
requirements:
|
|
287
317
|
- - ">="
|
|
288
318
|
- !ruby/object:Gem::Version
|
|
289
319
|
version: '0'
|
|
290
320
|
requirements: []
|
|
291
|
-
rubygems_version:
|
|
292
|
-
signing_key:
|
|
321
|
+
rubygems_version: 4.0.23
|
|
293
322
|
specification_version: 4
|
|
294
323
|
summary: Gem for easy concern creation
|
|
295
324
|
test_files: []
|