ivar 0.2.0 → 0.4.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/.augment-guidelines +5 -3
- data/.devcontainer/devcontainer.json +28 -20
- data/.devcontainer/post-create.sh +18 -0
- data/.editorconfig +35 -0
- data/.rubocop.yml +6 -0
- data/.standard.yml +1 -1
- data/.vscode/extensions.json +3 -1
- data/.vscode/launch.json +25 -0
- data/.vscode/settings.json +38 -2
- data/CHANGELOG.md +83 -1
- data/README.md +272 -207
- data/Rakefile +1 -1
- data/VERSION.md +44 -0
- data/examples/check_all_block_example.rb +84 -0
- data/examples/check_all_example.rb +42 -0
- data/examples/inheritance_with_kwarg_init.rb +156 -0
- data/examples/inheritance_with_positional_init.rb +142 -0
- data/examples/mixed_positional_and_kwarg_init.rb +125 -0
- data/examples/require_check_all_example.rb +23 -0
- data/examples/sandwich_inheritance.rb +1 -1
- data/examples/sandwich_with_accessors.rb +78 -0
- data/examples/sandwich_with_block_values.rb +54 -0
- data/examples/sandwich_with_checked.rb +0 -1
- data/examples/sandwich_with_checked_once.rb +0 -1
- data/examples/sandwich_with_initial_values.rb +52 -0
- data/examples/sandwich_with_ivar_block.rb +6 -9
- data/examples/sandwich_with_ivar_macro.rb +4 -4
- data/examples/sandwich_with_kwarg_init.rb +78 -0
- data/examples/sandwich_with_positional_init.rb +50 -0
- data/examples/sandwich_with_shared_values.rb +54 -0
- data/hooks/README.md +42 -0
- data/hooks/install.sh +12 -0
- data/hooks/pre-commit +54 -0
- data/ivar.gemspec +5 -4
- data/lib/ivar/check_all.rb +7 -0
- data/lib/ivar/check_all_manager.rb +72 -0
- data/lib/ivar/check_policy.rb +29 -0
- data/lib/ivar/checked/class_methods.rb +19 -0
- data/lib/ivar/checked/instance_methods.rb +35 -0
- data/lib/ivar/checked.rb +17 -24
- data/lib/ivar/declaration.rb +30 -0
- data/lib/ivar/explicit_declaration.rb +56 -0
- data/lib/ivar/explicit_keyword_declaration.rb +24 -0
- data/lib/ivar/explicit_positional_declaration.rb +19 -0
- data/lib/ivar/macros.rb +48 -111
- data/lib/ivar/manifest.rb +124 -0
- data/lib/ivar/policies.rb +13 -1
- data/lib/ivar/project_root.rb +59 -0
- data/lib/ivar/targeted_prism_analysis.rb +144 -0
- data/lib/ivar/validation.rb +6 -29
- data/lib/ivar/version.rb +1 -1
- data/lib/ivar.rb +141 -9
- data/script/console +11 -0
- data/script/de-lint +2 -0
- data/script/de-lint-unsafe +2 -0
- data/script/lint +2 -0
- data/script/release +134 -0
- data/script/setup +8 -0
- data/script/test +2 -0
- metadata +41 -5
- data/examples/sandwich_with_kwarg.rb +0 -45
- data/lib/ivar/auto_check.rb +0 -77
- data/lib/ivar/prism_analysis.rb +0 -102
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fab4b673955331785324df9526d8c6cbefc2fb2bfd5268364fabea167842deaa
|
4
|
+
data.tar.gz: 4a39dc2f3530e7292e613b9140cb668ee1755a55cf4da8676c6bc74da159a20d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e15519f99aa5c24bec436bc1365d5640eb64f31b91c901442105cd62da045b44d55a6537b73b8c8d405318afc430ce9cfa9060e99beb72368643f25933043327
|
7
|
+
data.tar.gz: 7f717746c49f99ee91757429bc0dfe0c568c9e4684bcb219a11224457b06fc3aac4dc59d40e3109b600b4bd0729c58c070bee874a25787f5802afdbb13cb5cf8
|
data/.augment-guidelines
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
- use modern Ruby 3.4 style and features, including pattern-matching, endless methods, etc., where appropriate.
|
3
3
|
- avoid over-engineering. Prefer basic Ruby data types to building new abstractions. (But extract abstractions when I tell you to.)
|
4
4
|
- avoid inline comments. Prefer "explaining variables", intention-revealing method names, and the "composed method" pattern where appropriate. Class, module, and method-documenting comments are fine.
|
5
|
-
-
|
6
|
-
- Run all tests and fix failures before committing.
|
5
|
+
- Code style is managed with standardrb. Run it (with script/de-lint) before committing. Manually fix the rest. script/lint can be used to check for issues without updating the code.
|
6
|
+
- Run all tests and fix failures before committing.
|
7
7
|
- Never "cheat" by making implementation code test-aware. But it is fine to make interactions with the world dependency-injectable for testing purposes.
|
8
8
|
- Include a quote of my instruction that led to the commit in the commit message
|
9
9
|
- Sign your commit messages with "-- Auggie".
|
10
|
-
-
|
10
|
+
- Update the CHANGELOG.md unreleased section as appropriate
|
11
|
+
- Commit and push after making successful changes.
|
12
|
+
- In methods that get information and where mutation is not the goal, prefer a concise, functional-transformation style leveraging Enumerable methods over imperative approaches.
|
@@ -1,22 +1,30 @@
|
|
1
1
|
// See https://containers.dev/implementors/json_reference/ for configuration reference
|
2
2
|
{
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
3
|
+
"name": "ivar",
|
4
|
+
"build": {
|
5
|
+
"dockerfile": "Dockerfile"
|
6
|
+
},
|
7
|
+
"remoteUser": "devcontainer",
|
8
|
+
"features": {
|
9
|
+
"ghcr.io/devcontainers/features/github-cli:1": {},
|
10
|
+
"ghcr.io/jungaretti/features/ripgrep:1": {}
|
11
|
+
},
|
12
|
+
"customizations": {
|
13
|
+
"vscode": {
|
14
|
+
"extensions": [
|
15
|
+
"connorshea.vscode-ruby-test-adapter",
|
16
|
+
"stripe.endsmart",
|
17
|
+
"testdouble.vscode-standard-ruby",
|
18
|
+
"castwide.solargraph",
|
19
|
+
"github.vscode-github-actions",
|
20
|
+
"Shopify.ruby-lsp",
|
21
|
+
"EditorConfig.EditorConfig"
|
22
|
+
],
|
23
|
+
"settings": {
|
24
|
+
"standardRuby.commandPath": "/usr/local/bundle/bin/standardrb",
|
25
|
+
"solargraph.bundlerPath": "/usr/local/bin/bundle"
|
26
|
+
}
|
27
|
+
}
|
28
|
+
},
|
29
|
+
"postCreateCommand": "bash .devcontainer/post-create.sh"
|
30
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
echo "Running post-create setup script..."
|
5
|
+
|
6
|
+
# Install Ruby dependencies
|
7
|
+
echo "Installing Ruby dependencies with bundle install..."
|
8
|
+
bundle install
|
9
|
+
|
10
|
+
# Install Git hooks
|
11
|
+
echo "Installing Git hooks..."
|
12
|
+
if [ -f "hooks/install.sh" ]; then
|
13
|
+
./hooks/install.sh
|
14
|
+
else
|
15
|
+
echo "Hooks installation script not found. Skipping."
|
16
|
+
fi
|
17
|
+
|
18
|
+
echo "Post-create setup completed successfully!"
|
data/.editorconfig
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# EditorConfig is awesome: https://EditorConfig.org
|
2
|
+
|
3
|
+
# top-most EditorConfig file
|
4
|
+
root = true
|
5
|
+
|
6
|
+
# Unix-style newlines with a newline ending every file
|
7
|
+
[*]
|
8
|
+
end_of_line = lf
|
9
|
+
insert_final_newline = true
|
10
|
+
trim_trailing_whitespace = true
|
11
|
+
charset = utf-8
|
12
|
+
|
13
|
+
# 2 space indentation for Ruby files
|
14
|
+
[*.rb]
|
15
|
+
indent_style = space
|
16
|
+
indent_size = 2
|
17
|
+
|
18
|
+
# 2 space indentation for YAML files
|
19
|
+
[*.{yml,yaml}]
|
20
|
+
indent_style = space
|
21
|
+
indent_size = 2
|
22
|
+
|
23
|
+
# 2 space indentation for JSON files
|
24
|
+
[*.json]
|
25
|
+
indent_style = space
|
26
|
+
indent_size = 2
|
27
|
+
|
28
|
+
# 2 space indentation for Gemfile and Rakefile
|
29
|
+
[{Gemfile,Rakefile}]
|
30
|
+
indent_style = space
|
31
|
+
indent_size = 2
|
32
|
+
|
33
|
+
# Markdown files
|
34
|
+
[*.md]
|
35
|
+
trim_trailing_whitespace = false
|
data/.rubocop.yml
ADDED
data/.standard.yml
CHANGED
data/.vscode/extensions.json
CHANGED
data/.vscode/launch.json
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
3
|
+
// Hover to view descriptions of existing attributes.
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
5
|
+
"version": "0.2.0",
|
6
|
+
"configurations": [
|
7
|
+
{
|
8
|
+
"type": "ruby_lsp",
|
9
|
+
"name": "Debug script",
|
10
|
+
"request": "launch",
|
11
|
+
"program": "ruby ${file}"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"type": "ruby_lsp",
|
15
|
+
"name": "Debug test",
|
16
|
+
"request": "launch",
|
17
|
+
"program": "ruby -Itest ${relativeFile}"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"type": "ruby_lsp",
|
21
|
+
"name": "Attach debugger",
|
22
|
+
"request": "attach"
|
23
|
+
}
|
24
|
+
]
|
25
|
+
}
|
data/.vscode/settings.json
CHANGED
@@ -2,13 +2,49 @@
|
|
2
2
|
"rubyTestExplorer.testFramework": "minitest",
|
3
3
|
"[ruby]": {
|
4
4
|
"editor.formatOnType": true,
|
5
|
+
"editor.defaultFormatter": "Shopify.ruby-lsp",
|
6
|
+
"editor.formatOnSave": true
|
5
7
|
},
|
6
8
|
"editor.formatOnSave": true,
|
7
9
|
"standardRuby.mode": "enableUnconditionally",
|
8
10
|
"solargraph.diagnostics": true,
|
9
11
|
"solargraph.formatting": true,
|
10
12
|
"solargraph.useBundler": true,
|
11
|
-
"standardRuby.commandPath": "/usr/local/bundle/bin/standardrb",
|
12
13
|
"rubyLsp.formatter": "standard",
|
13
14
|
"standardRuby.autofix": true,
|
14
|
-
|
15
|
+
"rubyLsp.enabledFeatures": {
|
16
|
+
"diagnostics": true,
|
17
|
+
"documentHighlights": true,
|
18
|
+
"documentLink": true,
|
19
|
+
"documentSymbols": true,
|
20
|
+
"foldingRanges": true,
|
21
|
+
"formatting": true,
|
22
|
+
"hover": true,
|
23
|
+
"inlayHint": true,
|
24
|
+
"onTypeFormatting": true,
|
25
|
+
"selectionRanges": true,
|
26
|
+
"semanticHighlighting": true,
|
27
|
+
"completion": true,
|
28
|
+
"codeLens": true,
|
29
|
+
"definition": true,
|
30
|
+
"workspaceSymbol": true,
|
31
|
+
},
|
32
|
+
"rubyLsp.rubyVersionManager": {
|
33
|
+
"identifier": "auto"
|
34
|
+
},
|
35
|
+
"rubyLsp.addonSettings": {
|
36
|
+
"rubocop": {
|
37
|
+
"command": "standardrb",
|
38
|
+
"except": []
|
39
|
+
}
|
40
|
+
},
|
41
|
+
"editor.detectIndentation": true,
|
42
|
+
"editor.insertFinalNewline": true,
|
43
|
+
"files.insertFinalNewline": true,
|
44
|
+
"files.trimTrailingWhitespace": true,
|
45
|
+
"editor.trimAutoWhitespace": true,
|
46
|
+
"files.eol": "\n",
|
47
|
+
"editor.codeActionsOnSave": {
|
48
|
+
"source.fixAll": "explicit"
|
49
|
+
}
|
50
|
+
}
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,91 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
1
8
|
## [Unreleased]
|
2
9
|
|
10
|
+
### Fixed
|
11
|
+
- Fixed GitHub Actions workflow to prevent "frozen Gemfile.lock" errors during gem publishing
|
12
|
+
|
13
|
+
## [0.4.0] - 2025-05-07
|
14
|
+
|
15
|
+
### Added
|
16
|
+
- Support for initializing instance variables from keyword arguments using `ivar :@foo, init: :kwarg` or `ivar :@foo, init: :keyword`
|
17
|
+
- Proper inheritance handling for keyword argument initialization, with child class declarations taking precedence over parent class declarations
|
18
|
+
- Added Ivar::Manifest class to formalize tracking of instance variables
|
19
|
+
- Added ExplicitDeclaration and ImplicitDeclaration classes to represent different types of variable declarations
|
20
|
+
- Added callbacks for declarations: on_declare and before_init
|
21
|
+
- Added CheckPolicy module to handle class-level check policy configuration
|
22
|
+
- Added support for policy inheritance in subclasses
|
23
|
+
- Added method stash abstraction with `stash_method`, `get_method_stash`, and `get_stashed_method` on the Ivar module
|
24
|
+
- Added `get_or_create_manifest` method to make it clearer when a manifest may be created
|
25
|
+
|
26
|
+
### Changed
|
27
|
+
- Split declaration classes into separate files for better organization:
|
28
|
+
- `Declaration` → `lib/ivar/declaration.rb`
|
29
|
+
- `ExplicitDeclaration` → `lib/ivar/explicit_declaration.rb`
|
30
|
+
- `ExplicitKeywordDeclaration` → `lib/ivar/explicit_keyword_declaration.rb`
|
31
|
+
- `ExplicitPositionalDeclaration` → `lib/ivar/explicit_positional_declaration.rb`
|
32
|
+
- Centralized handling of internal variables (those starting with `@__ivar_`) to avoid explicit declarations
|
33
|
+
- Improved filtering of internal variables during analysis phase rather than validation phase
|
34
|
+
- Refactored internal variable tracking to use the Manifest system
|
35
|
+
- Removed backwards compatibility variables (@__ivar_declared_ivars, @__ivar_initial_values, @__ivar_init_methods)
|
36
|
+
- Improved manifest ancestry handling to walk the entire ancestor chain instead of just the direct parent
|
37
|
+
- Enhanced declaration inheritance to properly handle overrides from modules and included mixins
|
38
|
+
- Optimized manifest ancestry to avoid creating unnecessary manifests for classes/modules that don't declare anything
|
39
|
+
- Simplified Manifest class to use a single declarations hash instead of separate explicit and implicit declarations
|
40
|
+
- Improved Manifest API with clearer separation between declarations (array of values) and declarations_by_name (hash)
|
41
|
+
- Simplified initialization process by combining keyword argument handling into the before_init callback
|
42
|
+
- Refactored Checked module to use the CheckPolicy module for policy configuration
|
43
|
+
- Changed default policy for Checked module from :warn_once to :warn
|
44
|
+
- Enhanced initialization process in Checked module to properly handle manifest processing
|
45
|
+
- Simplified external-process tests to directly check for warnings in stderr instead of using custom capture logic
|
46
|
+
- Updated TargetedPrismAnalysis and Checked::InstanceMethods to use the new method stash abstraction
|
47
|
+
- Extracted modules from auto_check.rb into their own files and removed auto_check.rb
|
48
|
+
- Removed PrismAnalysis class as it has been superseded by TargetedPrismAnalysis
|
49
|
+
|
50
|
+
### Documentation
|
51
|
+
- Improved documentation for the CheckPolicy module explaining its purpose and inheritance behavior
|
52
|
+
- Enhanced documentation for the Checked module detailing its functionality and initialization process
|
53
|
+
- Added comprehensive documentation for the Manifest#add_implicits method explaining its role in tracking instance variables
|
54
|
+
- Added documentation for the new method stash abstraction methods
|
55
|
+
|
56
|
+
## [0.3.2] - 2025-05-05
|
57
|
+
|
58
|
+
## [0.3.1] - 2025-05-05
|
59
|
+
|
60
|
+
## [0.3.0] - 2025-05-05
|
61
|
+
|
62
|
+
### Added
|
63
|
+
- Support for initializing multiple instance variables to the same value using `ivar :@foo, :@bar, value: 123`
|
64
|
+
- Support for ivar declarations with a block that generates default values based on the variable name
|
65
|
+
- Support for reader, writer, and accessor keyword arguments to automatically generate attr methods
|
66
|
+
|
67
|
+
### Changed
|
68
|
+
- Extracted check_all functionality to its own class (CheckAllManager) for better organization
|
69
|
+
- Converted module instance variables to constants where appropriate
|
70
|
+
- Moved scripts from bin/ to script/ directory for better organization
|
71
|
+
- Improved development environment with consistent line endings and editor configuration
|
72
|
+
|
73
|
+
### Fixed
|
74
|
+
- Fixed missing trailing newlines in files
|
75
|
+
- Fixed Gemfile.lock version synchronization
|
76
|
+
- Fixed release script to use $stdin.gets instead of gets
|
77
|
+
|
78
|
+
## [0.2.1] - 2025-05-05
|
79
|
+
|
80
|
+
### Added
|
81
|
+
- Release automation via GitHub Actions
|
82
|
+
|
3
83
|
## [0.2.0] - 2025-05-01
|
4
84
|
|
5
|
-
|
85
|
+
### Added
|
86
|
+
- CheckDynamic module that overrides instance_variable_get/set to check against a list of allowed variables saved at the end of initialization
|
6
87
|
|
7
88
|
## [0.1.0] - 2025-04-29
|
8
89
|
|
90
|
+
### Added
|
9
91
|
- Initial release
|