named_imports 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb15d783f22496923d8eb7770bc934347bbd84a0019fad85380e3e43a29361d7
4
- data.tar.gz: fb90680e03f17db882f40cd38e93e3d51c729177d90e67bc7b6f5d82fd99fe8d
3
+ metadata.gz: bc3b22fb97762b6e36a0ad8edc65dff545c472d9f30258bf9789dab0e177084d
4
+ data.tar.gz: a74b0a5948bd4d8d4250f10e2d0637257e37d1ac73d950b518ea109b0f687216
5
5
  SHA512:
6
- metadata.gz: 498ea8dd7a20b2e9a5070e2edfa97b31911b471fa93fe28800ad076f69b031b1132ea5bc65d12db206b52c5bb0dd1903dd41ff611fa1b637cb5aa16947bf0445
7
- data.tar.gz: 88c609ed4e0649b998752474c78d6496978b1adc5144fe294a0ed770561f0120668977c75885fe8e605748f22a137f08b3d2541becd23e8ab2a92d1c2a9db8f1
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
- - [ ] cached imports so constants are always reused (as opposed to being redefined in a new anonymous module)
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
- sandbox_module = Module.new
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NamedImports
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
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.1
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-03-24 00:00:00.000000000 Z
11
+ date: 2021-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler