named_imports 0.2.1 → 0.2.2
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/README.md +1 -1
- data/lib/named_imports.rb +6 -1
- data/lib/named_imports/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc3b22fb97762b6e36a0ad8edc65dff545c472d9f30258bf9789dab0e177084d
|
|
4
|
+
data.tar.gz: a74b0a5948bd4d8d4250f10e2d0637257e37d1ac73d950b518ea109b0f687216
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 55bae01c3d5a7e94a8d37eba48cf3235ee9048962b03f4810c34a9a28c175d12320c7f44c94a1d856ebb0f43412323a6ebfd3991ac14eb5844e5b5b21900e8b7
|
|
7
|
+
data.tar.gz: be98ddd0ef26712eda2d5781f78aedaf88ecd2a05b09c878fac6463e2287162552186520451df39554130285247d4c11d567609bcd6f1e5f66bf47a8a8857aeb
|
data/README.md
CHANGED
|
@@ -124,7 +124,7 @@ Bop.some_hash
|
|
|
124
124
|
- [x] namespace should not be polluted with non-specified constants (before the specified import is referenced/used)
|
|
125
125
|
- [x] namespace should not be polluted with non-specified constants (after the specified import is referenced/used)
|
|
126
126
|
- [ ] namespace of child imports should not be polluted with constants from the parent's scope
|
|
127
|
-
- [
|
|
127
|
+
- [x] cached imports so constants are always reused (as opposed to being redefined in a new anonymous module)
|
|
128
128
|
|
|
129
129
|
## Development
|
|
130
130
|
|
data/lib/named_imports.rb
CHANGED
|
@@ -4,6 +4,8 @@ require_relative "named_imports/version"
|
|
|
4
4
|
require_relative "named_imports/error"
|
|
5
5
|
|
|
6
6
|
module NamedImports
|
|
7
|
+
@@sandboxes = {}
|
|
8
|
+
|
|
7
9
|
class << self
|
|
8
10
|
def from(raw_path, constant_names, context = Object)
|
|
9
11
|
into_path, import_line = caller_path_and_line
|
|
@@ -78,7 +80,10 @@ module NamedImports
|
|
|
78
80
|
end
|
|
79
81
|
|
|
80
82
|
def sandbox_eval(file_path:)
|
|
81
|
-
|
|
83
|
+
return @@sandboxes[file_path] if @@sandboxes[file_path]
|
|
84
|
+
|
|
85
|
+
@@sandboxes[file_path] = Module.new
|
|
86
|
+
sandbox_module = @@sandboxes[file_path]
|
|
82
87
|
make_named_imports_available(in_context: sandbox_module)
|
|
83
88
|
ruby_code = read_content(file_path: file_path)
|
|
84
89
|
sandbox_module.class_eval(ruby_code, file_path)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: named_imports
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Keegan Leitz
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-04-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|