devpack 0.1.1 → 0.3.0

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: 4e0060c2ad41fd138a702fdd931eafdd5798940ea173e6a2aa30cb638a9975ee
4
- data.tar.gz: 79d3b3d0c6de5c4dfc3795d6bdb6a58d5e0316e95dd85d609a1bcb6f3172f39e
3
+ metadata.gz: 9d17e8b2f27d6bf6dc15ff37e549e3f97a3550339daa6fba5db14174483c2197
4
+ data.tar.gz: e85c8dc654ae6fdf89c24ebaff90f0a14d2ae67b802b33a25430dde625c72a4b
5
5
  SHA512:
6
- metadata.gz: c78cedc44a1fdab0fd5086776e9b6bb9a96c8ccffd34d83cf62e9b1b48da9fb3ae28161bacb048de8fbfc8c438c4c9bb4bcb63a5a56548e437facc6f3d7de042
7
- data.tar.gz: e32424c2f6d7cc63fadbff9542c0980469837d0821378987e82830db4262e1c323b62e69c49188b9acf44a2823c78a262697ee383e2887ec748f78bbaee90f28
6
+ metadata.gz: 6095f9fe4d862df8a9a50ceccc1de6415f95a3e7a6749fd10076ff05e22244f343364e23231bb0270af7a1d0b9c02b5e627b82f49775c1cfa95cea10dc3f3c58
7
+ data.tar.gz: 79363c38a26853e07ef07ae3675ab867ce1d16bc52f1e31f6489ab1fd33e7cc09a45121a588c0b645a72a93c0adf1a0e5dfceb34424f0f1e5398d628e79f879e
@@ -34,3 +34,21 @@ Style/RedundantRegexpEscape:
34
34
  Enabled: true
35
35
  Style/SlicingWithRange:
36
36
  Enabled: true
37
+ Lint/DuplicateElsifCondition:
38
+ Enabled: true
39
+ Style/AccessorGrouping:
40
+ Enabled: true
41
+ Style/ArrayCoercion:
42
+ Enabled: true
43
+ Style/BisectedAttrAccessor:
44
+ Enabled: true
45
+ Style/CaseLikeIf:
46
+ Enabled: true
47
+ Style/HashAsLastArrayItem:
48
+ Enabled: true
49
+ Style/HashLikeCase:
50
+ Enabled: true
51
+ Style/RedundantAssignment:
52
+ Enabled: true
53
+ Style/RedundantFileExtensionInRequire:
54
+ Enabled: true
@@ -15,3 +15,27 @@ Load latest version of gem by default. Allow specifying version with rubygems sy
15
15
  Permit comments in config file.
16
16
 
17
17
  Use `Gem::Specification` to load "rendered" gemspec (i.e. the file created by rubygems when the gem is installed). This version of the gemspec will load very quickly so no need to do custom gemspec parsing any more. This also accounts for "missing" gemspecs.
18
+
19
+ ## 0.1.2
20
+
21
+ Recursively include gem dependencies in `$LOAD_PATH` rather than assuming that any dependencies are already loaded.
22
+
23
+ Include original error message when warning that a gem was unable to be loaded.
24
+
25
+ ## 0.1.3
26
+
27
+ Use a more appropriate method of identifying the latest version of a gem (use `Gem::Version` to sort matched gem paths).
28
+
29
+ Fix edge case where e.g. `pry-rails-0.1.0` was matching for `pry` due to naive match logic. Split on last dash instead of first (i.e. don't assume gems will not have a dash in their name; last dash separates gem name from version in directory name).
30
+
31
+ ## 0.2.0
32
+
33
+ Add support for initializers. Files located in a `.devpack_initializers` directory will be loaded after gems configured in `.devpack` have been loaded. When using _Rails_ these files will be loaded using the `after_initialize` hook. Thanks to @joshmn for this idea: https://github.com/bobf/devpack/issues/1
34
+
35
+ Show full tracebacks of load errors when `DEVPACK_DEBUG` is set in environment.
36
+
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/Makefile CHANGED
@@ -3,3 +3,7 @@ test:
3
3
  bundle exec rspec
4
4
  bundle exec rubocop
5
5
  bundle exec strong_versions
6
+
7
+ .PHONY: build
8
+ build: test
9
+ bundle exec gem build devpack.gemspec
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.1.1'
11
+ gem 'devpack', '~> 0.3.0'
12
12
  end
13
13
  ```
14
14
 
@@ -32,19 +32,61 @@ better_errors
32
32
  pry:0.13.1
33
33
  ```
34
34
 
35
- All listed gems will be automatically required at launch. Any gems that fail to load will generate a warning.
35
+ All listed gems will be automatically required when _Devpack_ is loaded.
36
+
37
+ If your gems are not auto-loaded (e.g. by _Rails_) then you must require the gem:
38
+ ```ruby
39
+ require 'devpack'
40
+ ```
41
+
42
+ Any gems that fail to load (due to `LoadError`) will generate a warning.
43
+
44
+ All dependencies are recursively verified for compatibily before loading. If no compatible version can be located then the gem will not be loaded.
36
45
 
37
46
  It is recommended that `.devpack` is added to your `.gitignore`.
38
47
 
48
+ ### Initializers
49
+
50
+ Custom initializers can be loaded by creating a directory named `.devpack_initializers` containing a set of `.rb` files.
51
+
52
+ Initializers will be loaded in alphabetical order after all gems listed in the `.devpack` configuration file have been loaded.
53
+
54
+ Initializers that fail to load (for any reason) will generate a warning.
55
+
56
+ ```ruby
57
+ # .devpack_initializers/pry.rb
58
+
59
+ Pry.config.pager = false
60
+ ```
61
+
62
+ #### Rails
63
+
64
+ If _Rails_ is detected then files in the `.devpack_initializers` directory will be loaded using the _Rails_ `after_initialize` hook (i.e. after all other frameworks have been initialized).
65
+
66
+ ```ruby
67
+ # .devpack_initializers/bullet.rb
68
+
69
+ Bullet.enable = true
70
+ ```
71
+
39
72
  ### Global Configuration
40
73
 
41
74
  To configure globally simply save your `.devpack` configuration file to any parent directory of your project directory, e.g. `~/.devpack`.
42
75
 
76
+ This strategy also applies to `.devpack_initializers`.
77
+
43
78
  ### Disabling
44
79
 
45
- To disable _Devpack_ set the environment variable `DISABLE_DEVPACK` to any value:
80
+ To disable _Devpack_ set the environment variable `DEVPACK_DISABLE` to any value:
81
+ ```bash
82
+ DEVPACK_DISABLE=1 bundle exec ruby myapp.rb
83
+ ```
84
+
85
+ ### Debugging
86
+
87
+ To see the full traceback of any errors encountered at load time set the environment variable `DEVPACK_DEBUG` to any value:
46
88
  ```bash
47
- DISABLE_DEVPACK=1 bundle exec ruby myapp.rb
89
+ DEVPACK_DEBUG=1 bundle exec ruby myapp.rb
48
90
  ```
49
91
 
50
92
  ## License
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'byebug', '~> 11.1'
29
29
  spec.add_development_dependency 'rspec', '~> 3.9'
30
30
  spec.add_development_dependency 'rspec-its', '~> 1.3'
31
- spec.add_development_dependency 'rubocop', '~> 0.86.0'
31
+ spec.add_development_dependency 'rubocop', '~> 0.88.0'
32
32
  spec.add_development_dependency 'strong_versions', '~> 0.4.4'
33
33
  end
@@ -2,19 +2,48 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'pathname'
5
+ require 'set'
5
6
 
7
+ require 'devpack/timeable'
6
8
  require 'devpack/config'
7
9
  require 'devpack/gems'
8
10
  require 'devpack/gem_glob'
9
- require 'devpack/gem_path'
11
+ require 'devpack/gem_spec'
12
+ require 'devpack/initializers'
10
13
  require 'devpack/messages'
11
14
  require 'devpack/version'
12
15
 
16
+ # Provides helper method for writing warning messages.
13
17
  module Devpack
14
18
  class Error < StandardError; end
19
+
20
+ class << self
21
+ def warn(message)
22
+ prefixed = message.split("\n").map { |line| "[devpack] #{line}" }.join("\n")
23
+ Kernel.warn(prefixed)
24
+ end
25
+
26
+ def debug?
27
+ ENV.key?('DEVPACK_DEBUG')
28
+ end
29
+
30
+ def disabled?
31
+ ENV.key?('DEVPACK_DISABLE')
32
+ end
33
+
34
+ def rails?
35
+ defined?(Rails::Railtie)
36
+ end
37
+
38
+ def config
39
+ @config ||= Devpack::Config.new(Dir.pwd)
40
+ end
41
+ end
15
42
  end
16
43
 
17
- unless ENV.key?('DISABLE_DEVPACK')
18
- config = Devpack::Config.new(Dir.pwd)
19
- Devpack::Gems.new(config).load
44
+ unless Devpack.disabled?
45
+ require 'devpack/railtie' if Devpack.rails?
46
+
47
+ Devpack::Gems.new(Devpack.config).load
48
+ Devpack::Initializers.new(Devpack.config).load unless Devpack.rails?
20
49
  end
@@ -4,6 +4,7 @@ module Devpack
4
4
  # Locates and parses .devpack config file
5
5
  class Config
6
6
  FILENAME = '.devpack'
7
+ INITIALIZERS_DIRECTORY_NAME = '.devpack_initializers'
7
8
  MAX_PARENTS = 100 # Avoid infinite loops (symlinks/weird file systems)
8
9
 
9
10
  def initialize(pwd)
@@ -19,18 +20,26 @@ module Devpack
19
20
  end
20
21
 
21
22
  def devpack_path
22
- @devpack_path ||= located_config_path(@pwd)
23
+ @devpack_path ||= located_path(@pwd, FILENAME, :file)
24
+ end
25
+
26
+ def devpack_initializers_path
27
+ @devpack_initializers_path ||= located_path(@pwd, INITIALIZERS_DIRECTORY_NAME, :directory)
28
+ end
29
+
30
+ def devpack_initializer_paths
31
+ devpack_initializers_path&.glob(File.join('**', '*.rb'))&.map(&:to_s)&.sort || []
23
32
  end
24
33
 
25
34
  private
26
35
 
27
- def located_config_path(next_parent)
36
+ def located_path(next_parent, filename, type)
28
37
  loop.with_index(1) do |_, index|
29
38
  return nil if index > MAX_PARENTS
30
39
 
31
- path = next_parent.join(FILENAME)
40
+ path = next_parent.join(filename)
32
41
  next_parent = next_parent.parent
33
- next unless File.exist?(path)
42
+ next unless File.exist?(path) && File.public_send("#{type}?", path)
34
43
 
35
44
  return path
36
45
  end
@@ -4,13 +4,9 @@ module Devpack
4
4
  # Locates gems by searching in paths listed in GEM_PATH
5
5
  class GemGlob
6
6
  def find(name)
7
- glob.select do |path|
8
- pathname = Pathname.new(path)
9
- next unless pathname.directory?
10
-
11
- basename = pathname.basename.to_s
12
- match?(name, basename)
13
- end.max # FIXME: Quick-and-dirty way to get latest version - will have many edge cases.
7
+ matched_paths(name)
8
+ .sort { |a, b| version(a) <=> version(b) }
9
+ .reverse
14
10
  end
15
11
 
16
12
  private
@@ -27,10 +23,24 @@ module Devpack
27
23
 
28
24
  def match?(name_with_version, basename)
29
25
  name, _, version = name_with_version.partition(':')
30
- return true if version.empty? && basename.start_with?("#{name}-")
26
+ return true if version.empty? && basename.rpartition('-').first == name
31
27
  return true if !version.empty? && basename == "#{name}-#{version}"
32
28
 
33
29
  false
34
30
  end
31
+
32
+ def matched_paths(name)
33
+ glob.select do |path|
34
+ pathname = Pathname.new(path)
35
+ next unless pathname.directory?
36
+
37
+ basename = pathname.basename.to_s
38
+ match?(name, basename)
39
+ end
40
+ end
41
+
42
+ def version(path)
43
+ Gem::Version.new(File.split(path).last.rpartition('-').last)
44
+ end
35
45
  end
36
46
  end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Devpack
4
+ # Locates relevant gemspec for a given gem and provides a full list of paths
5
+ # for all `require_paths` listed in gemspec.
6
+ class GemSpec
7
+ def initialize(glob, name, requirement)
8
+ @name = name
9
+ @glob = glob
10
+ @requirement = requirement
11
+ @dependency = Gem::Dependency.new(@name, @requirement)
12
+ end
13
+
14
+ def require_paths(visited = Set.new)
15
+ raise LoadError, Messages.no_compatible_version(@dependency) if gemspec.nil?
16
+
17
+ (immediate_require_paths + dependency_require_paths(visited)).compact.flatten.uniq
18
+ end
19
+
20
+ def gemspec
21
+ @gemspec ||= gemspecs.find do |spec|
22
+ next false if spec.nil?
23
+
24
+ @dependency.requirement.satisfied_by?(spec.version) && compatible?(spec)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def compatible?(spec)
31
+ return false if spec.nil?
32
+ return false if incompatible_version_loaded?(spec)
33
+
34
+ compatible_specs?(Gem.loaded_specs.values, [@dependency] + spec.runtime_dependencies)
35
+ end
36
+
37
+ def incompatible_version_loaded?(spec)
38
+ matched = Gem.loaded_specs[spec.name]
39
+ return false if matched.nil?
40
+
41
+ matched.version != spec.version
42
+ end
43
+
44
+ def compatible_specs?(specs, dependencies)
45
+ specs.all? { |spec| compatible_dependencies?(dependencies, spec) }
46
+ end
47
+
48
+ def compatible_dependencies?(dependencies, spec)
49
+ dependencies.all? { |dependency| compatible_dependency?(dependency, spec) }
50
+ end
51
+
52
+ def compatible_dependency?(dependency, spec)
53
+ return false if spec.nil?
54
+ return true unless dependency.name == spec.name
55
+
56
+ dependency.requirement.satisfied_by?(spec.version)
57
+ end
58
+
59
+ def gemspecs
60
+ @gemspecs ||= gemspec_paths.map { |path| Gem::Specification.load(path.to_s) }
61
+ end
62
+
63
+ def dependency_require_paths(visited)
64
+ dependencies.map do |dependency|
65
+ next nil if visited.include?(dependency)
66
+
67
+ visited << dependency
68
+ GemSpec.new(@glob, dependency.name, dependency.requirement).require_paths(visited)
69
+ end
70
+ end
71
+
72
+ def dependencies
73
+ gemspec.runtime_dependencies
74
+ end
75
+
76
+ def gem_paths
77
+ return nil if candidates.empty?
78
+
79
+ candidates.map { |candidate| Pathname.new(candidate) }
80
+ end
81
+
82
+ def gemspec_paths
83
+ return [] if gem_paths.nil?
84
+
85
+ gem_paths.map do |path|
86
+ path.join('..', '..', 'specifications', "#{path.basename}.gemspec").expand_path
87
+ end
88
+ end
89
+
90
+ def immediate_require_paths
91
+ gemspec
92
+ .require_paths
93
+ .map { |path| File.join(gemspec.full_gem_path, path) }
94
+ end
95
+
96
+ def candidates
97
+ @candidates ||= @glob.find(@name)
98
+ end
99
+ end
100
+ end
@@ -3,8 +3,11 @@
3
3
  module Devpack
4
4
  # Loads requested gems from configuration
5
5
  class Gems
6
- def initialize(config)
6
+ include Timeable
7
+
8
+ def initialize(config, glob = GemGlob.new)
7
9
  @config = config
10
+ @gem_glob = glob
8
11
  end
9
12
 
10
13
  def load
@@ -12,40 +15,48 @@ module Devpack
12
15
 
13
16
  gems, time = timed { load_devpack }
14
17
  names = gems.map(&:first)
15
- warn(Messages.loaded_message(@config.devpack_path, gems, time.round(2)))
18
+ warn(Messages.loaded(@config.devpack_path, gems, time.round(2)))
16
19
  names
17
20
  end
18
21
 
19
22
  private
20
23
 
21
- def timed
22
- start = Time.now.utc
23
- result = yield
24
- [result, Time.now.utc - start]
25
- end
26
-
27
24
  def load_devpack
28
- @config.requested_gems.map { |name| load_gem(name) }.compact
25
+ @config.requested_gems.map do |requested|
26
+ name, _, version = requested.partition(':')
27
+ load_gem(name, version.empty? ? nil : Gem::Requirement.new("= #{version}"))
28
+ end.compact
29
29
  end
30
30
 
31
- def load_gem(name)
32
- update_load_path(name)
33
- [name, Kernel.require(name)]
34
- rescue LoadError
35
- warn(Messages.failure_message(name))
31
+ def load_gem(name, requirement)
32
+ [name, activate(name, requirement)]
33
+ rescue LoadError => e
34
+ warn(Messages.failure(name, load_error_message(e)))
36
35
  nil
37
36
  end
38
37
 
38
+ def activate(name, version)
39
+ spec = GemSpec.new(@gem_glob, name, version)
40
+ update_load_path(spec.require_paths)
41
+ loaded = Kernel.require(name)
42
+ Gem.loaded_specs[name] = spec.gemspec
43
+ spec.gemspec&.activated = true
44
+ spec.gemspec&.instance_variable_set(:@loaded, true)
45
+ loaded
46
+ end
47
+
39
48
  def warn(message)
40
- Kernel.warn("[devpack] #{message}")
49
+ Devpack.warn(message)
41
50
  end
42
51
 
43
- def gem_glob
44
- @gem_glob ||= GemGlob.new
52
+ def load_error_message(error)
53
+ return "(#{error.message})" unless Devpack.debug?
54
+
55
+ %[(#{error.message})\n#{error.backtrace.join("\n")}]
45
56
  end
46
57
 
47
- def update_load_path(name)
48
- $LOAD_PATH.concat(GemPath.new(gem_glob, name).require_paths)
58
+ def update_load_path(paths)
59
+ $LOAD_PATH.concat(paths)
49
60
  end
50
61
  end
51
62
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Devpack
4
+ # Loads requested initializers from configuration
5
+ class Initializers
6
+ include Timeable
7
+
8
+ def initialize(config)
9
+ @config = config
10
+ end
11
+
12
+ def load
13
+ initializers, time = timed { load_initializers }
14
+ path = @config.devpack_initializers_path
15
+ return if path.nil?
16
+
17
+ args = path, initializers, time.round(2)
18
+ Devpack.warn(Messages.loaded_initializers(*args))
19
+ end
20
+
21
+ private
22
+
23
+ def load_initializers
24
+ @config.devpack_initializer_paths.map { |path| load_initializer(path) }
25
+ end
26
+
27
+ def load_initializer(path)
28
+ require path
29
+ rescue ScriptError, StandardError => e
30
+ Devpack.warn(Messages.initializer_failure(path, message(e)))
31
+ nil
32
+ end
33
+
34
+ def message(error)
35
+ return "(#{error.class.name} - #{error.message&.split("\n")&.first})" unless Devpack.debug?
36
+
37
+ %[(#{error.class.name})\n#{error.message}\n#{error.backtrace.join("\n")}]
38
+ end
39
+ end
40
+ end
@@ -3,18 +3,37 @@
3
3
  module Devpack
4
4
  # Generates output messages.
5
5
  class Messages
6
- def self.failure_message(name)
7
- base = "Failed to load `#{name}`"
8
- install = "bundle exec gem install #{name}"
9
- "#{base}. Try `#{install}`"
10
- end
6
+ class << self
7
+ def failure(name, error_message)
8
+ base = "Failed to load `#{name}`"
9
+ "#{base}. #{error_message}"
10
+ end
11
+
12
+ def initializer_failure(path, error_message)
13
+ "Failed to load initializer `#{path}`: #{error_message}"
14
+ end
15
+
16
+ def loaded(path, gems, time)
17
+ already_loaded = gems.size - gems.reject { |_, loaded| loaded }.size
18
+ base = "Loaded #{already_loaded} development gem(s) from '#{path}' in #{time} seconds"
19
+ return "#{base}." if already_loaded == gems.size
20
+
21
+ "#{base} (#{gems.size - already_loaded} gem(s) were already loaded by environment)."
22
+ end
23
+
24
+ def loaded_initializers(path, initializers, time)
25
+ "Loaded #{initializers.compact.size} initializer(s) from '#{path}' in #{time} seconds"
26
+ end
27
+
28
+ def no_compatible_version(dependency)
29
+ "No compatible version found for `#{dependency.requirement}`"
30
+ end
11
31
 
12
- def self.loaded_message(path, gems, time)
13
- already_loaded = gems.size - gems.reject { |_, loaded| loaded }.size
14
- base = "Loaded #{already_loaded} development gem(s) from '#{path}' in #{time} seconds"
15
- return "#{base}." if already_loaded == gems.size
32
+ private
16
33
 
17
- "#{base} (#{gems.size - already_loaded} gem(s) were already loaded by environment)."
34
+ def indented(message)
35
+ message.split("\n").map { |line| " #{line}" }.join("\n")
36
+ end
18
37
  end
19
38
  end
20
39
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Devpack
4
+ # Loads Devpack initializers after standard Rails initializers have been loaded.
5
+ class Railtie < Rails::Railtie
6
+ config.after_initialize { Devpack::Initializers.new(Devpack.config).load }
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Provides result and run time of a given block.
4
+ module Timeable
5
+ def timed
6
+ start = Time.now.utc
7
+ result = yield
8
+ [result, Time.now.utc - start]
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Devpack
4
- VERSION = '0.1.1'
4
+ VERSION = '0.3.0'
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.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-05 00:00:00.000000000 Z
11
+ date: 2020-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.86.0
61
+ version: 0.88.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.86.0
68
+ version: 0.88.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: strong_versions
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -103,9 +103,12 @@ 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
+ - lib/devpack/initializers.rb
108
109
  - lib/devpack/messages.rb
110
+ - lib/devpack/railtie.rb
111
+ - lib/devpack/timeable.rb
109
112
  - lib/devpack/version.rb
110
113
  homepage: https://github.com/bobf/devpack
111
114
  licenses:
@@ -114,7 +117,7 @@ metadata:
114
117
  homepage_uri: https://github.com/bobf/devpack
115
118
  source_code_uri: https://github.com/bobf/devpack
116
119
  changelog_uri: https://github.com/bobf/devpack/blob/master/CHANGELOG.md
117
- post_install_message:
120
+ post_install_message:
118
121
  rdoc_options: []
119
122
  require_paths:
120
123
  - lib
@@ -130,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
133
  version: '0'
131
134
  requirements: []
132
135
  rubygems_version: 3.1.2
133
- signing_key:
136
+ signing_key:
134
137
  specification_version: 4
135
138
  summary: Conveniently tailor your development environment
136
139
  test_files: []
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Devpack
4
- # Locates relevant gemspec for a given gem and provides a full list of paths
5
- # for all `require_paths` listed in gemspec.
6
- class GemPath
7
- def initialize(glob, name)
8
- @name = name
9
- @glob = glob
10
- end
11
-
12
- def require_paths
13
- return [] unless gemspec_path&.exist? && gem_path&.exist?
14
-
15
- Gem::Specification
16
- .load(gemspec_path.to_s)
17
- .require_paths
18
- .map { |path| gem_path.join(path).to_s }
19
- end
20
-
21
- private
22
-
23
- def gem_path
24
- return nil if located_gem.nil?
25
-
26
- Pathname.new(located_gem)
27
- end
28
-
29
- def gemspec_path
30
- return nil if gem_path.nil?
31
-
32
- gem_path.join('..', '..', 'specifications', "#{gem_path.basename}.gemspec")
33
- .expand_path
34
- end
35
-
36
- def located_gem
37
- @located_gem ||= @glob.find(@name)
38
- end
39
- end
40
- end