devpack 0.2.0 → 0.2.1

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: a6ef12d9845a34ffde013cc03cc66f0d23a6d6b8dd65a0073c39ff89e2a58d1e
4
- data.tar.gz: 1de91a3b2aa5c0ff8dda1a77887d02cf1a4d2b36608db6285863b05c5c4d1663
3
+ metadata.gz: 9502f5bb5412be236b272450cf30b9410a37676ce9a8ff7a769e01e08ebedc0f
4
+ data.tar.gz: f96bfcfbd97d530ee6a93ff54a8fef02066e5206c468d50d0ef0e4e8501055bc
5
5
  SHA512:
6
- metadata.gz: 8c55a6febb5a5c1d7986f151e2849442d05799889d500fd72d7ea3713b9ef9b64b549c275dc134b357cd160f2b2dcb803f0b2ab8945d21635fd2c545d9ecb9e6
7
- data.tar.gz: facb20fb48d76ec0bef375a09dc09b144b59ed773baf3720bfa5c955e01849c71d94a4d8c920bee35d5a8733f737cb8e1a8e396061e44ea2974f9786a3efe5dc
6
+ metadata.gz: b94fee5740d2a0a57db65fdb9533d63397f0a1200babc95ea48104789084eab958570d0e659ba76cae1bbfc65e00839ab822ba9ebe300e8edc66d7490d28f266
7
+ data.tar.gz: 8d05d1b3839e26b658357613fa6f5a3f2c2251aa939aa6ac68b509cc9733530dddf21024933c11b84e52894bd48c7290fc713307b1e1882c04bd1d0b477d7eb6
@@ -35,3 +35,7 @@ Add support for initializers. Files located in a `.devpack_initializers` directo
35
35
  Show full tracebacks of load errors when `DEVPACK_DEBUG` is set in environment.
36
36
 
37
37
  Rename `DISABLE_DEVPACK` environment variable to `DEVPACK_DISABLE` for consistency.
38
+
39
+ ## 0.2.1
40
+
41
+ Fully activate gem on load: add gem spec to `Gem.loaded_specs` and set instance variables `@loaded` and `@activated` to `true`. This mimics `Gem::Specification#activate` to ensure that anything that depends on these characteristics will function as normal.
data/README.md CHANGED
@@ -8,7 +8,7 @@ Add the gem to your `Gemfile`:
8
8
 
9
9
  ```ruby
10
10
  group :development, :test do
11
- gem 'devpack', '~> 0.2.0'
11
+ gem 'devpack', '~> 0.2.1'
12
12
  end
13
13
  ```
14
14
 
@@ -7,7 +7,7 @@ require 'devpack/timeable'
7
7
  require 'devpack/config'
8
8
  require 'devpack/gems'
9
9
  require 'devpack/gem_glob'
10
- require 'devpack/gem_path'
10
+ require 'devpack/gem_spec'
11
11
  require 'devpack/initializers'
12
12
  require 'devpack/messages'
13
13
  require 'devpack/version'
@@ -3,7 +3,7 @@
3
3
  module Devpack
4
4
  # Locates relevant gemspec for a given gem and provides a full list of paths
5
5
  # for all `require_paths` listed in gemspec.
6
- class GemPath
6
+ class GemSpec
7
7
  def initialize(glob, name)
8
8
  @name = name
9
9
  @glob = glob
@@ -16,6 +16,10 @@ module Devpack
16
16
  .compact.flatten.uniq
17
17
  end
18
18
 
19
+ def gemspec
20
+ @gemspec ||= Gem::Specification.load(gemspec_path.to_s)
21
+ end
22
+
19
23
  private
20
24
 
21
25
  def dependency_require_paths(visited)
@@ -23,7 +27,7 @@ module Devpack
23
27
  next nil if visited.include?(dependency)
24
28
 
25
29
  visited << dependency
26
- GemPath.new(@glob, name_with_version(dependency)).require_paths(visited)
30
+ GemSpec.new(@glob, name_with_version(dependency)).require_paths(visited)
27
31
  end
28
32
  end
29
33
 
@@ -44,10 +48,6 @@ module Devpack
44
48
  .expand_path
45
49
  end
46
50
 
47
- def gemspec
48
- @gemspec ||= Gem::Specification.load(gemspec_path.to_s)
49
- end
50
-
51
51
  def immediate_require_paths
52
52
  gemspec
53
53
  .require_paths
@@ -25,13 +25,22 @@ module Devpack
25
25
  end
26
26
 
27
27
  def load_gem(name)
28
- update_load_path(name)
29
- [name, Kernel.require(name)]
28
+ [name, activate(name)]
30
29
  rescue LoadError => e
31
30
  warn(Messages.failure(name, load_error_message(e)))
32
31
  nil
33
32
  end
34
33
 
34
+ def activate(name)
35
+ spec = GemSpec.new(gem_glob, name)
36
+ update_load_path(spec.require_paths)
37
+ loaded = Kernel.require(name)
38
+ Gem.loaded_specs[name] = spec.gemspec
39
+ spec.gemspec&.activated = true
40
+ spec.gemspec&.instance_variable_set(:@loaded, true)
41
+ loaded
42
+ end
43
+
35
44
  def warn(message)
36
45
  Devpack.warn(message)
37
46
  end
@@ -46,8 +55,8 @@ module Devpack
46
55
  @gem_glob ||= GemGlob.new
47
56
  end
48
57
 
49
- def update_load_path(name)
50
- $LOAD_PATH.concat(GemPath.new(gem_glob, name).require_paths)
58
+ def update_load_path(paths)
59
+ $LOAD_PATH.concat(paths)
51
60
  end
52
61
  end
53
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Devpack
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-01 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -103,7 +103,7 @@ files:
103
103
  - lib/devpack.rb
104
104
  - lib/devpack/config.rb
105
105
  - lib/devpack/gem_glob.rb
106
- - lib/devpack/gem_path.rb
106
+ - lib/devpack/gem_spec.rb
107
107
  - lib/devpack/gems.rb
108
108
  - lib/devpack/initializers.rb
109
109
  - lib/devpack/messages.rb