devpack 0.1.2 → 0.1.3

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: 2ec75af91bddba1020bdc23508c881dfc9da92c5c0a69793935c1839d699139e
4
- data.tar.gz: 7751b678c8a59010a8a5160a108e3c0c672d37104ca44e41c8f4d0c2c6ec280c
3
+ metadata.gz: 57a7f13b41361d7f9c45a147a99221d6f88e3b8d0ee1ede4f59ccdaeb878c7e8
4
+ data.tar.gz: 5e631a6efa73d770ecafcb8b55278240f83f4ffb58702fbc7c6f48cd101e45ef
5
5
  SHA512:
6
- metadata.gz: '09208ee73b785fbf9c67ad5375ab672e15241bf561216e27cab3db7292d0e7f2ed198d0cf159f544acaef4cd6241f9ed1f0e9e44beb31b1fef236f8ccd47fe36'
7
- data.tar.gz: e4301ef053caf42a34463f9ffc1f816d6203144d36e9920c21895d92cbb17354c27b90716c1e5177b878d0d4cae73b6523a7e2e2f96db3643be6164144d68ccb
6
+ metadata.gz: 057fcdb72061f64c1fd330722e958eb2680936756b861fb1d6777878e860cda2a645d050721e2d29f9518a2057bfaaf386d5d166938c9c4de1cb498cee83dd1e
7
+ data.tar.gz: 5f145c0cac07ae44eb0375aa62d68cf12bf0d1966d353eed205857f5e9d5d69ebe13387df2c44fd0b8914fc7ab34bbe9572e1192908df5452d2337f75ff1aa09
@@ -21,3 +21,9 @@ Use `Gem::Specification` to load "rendered" gemspec (i.e. the file created by ru
21
21
  Recursively include gem dependencies in `$LOAD_PATH` rather than assuming that any dependencies are already loaded.
22
22
 
23
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).
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.2'
11
+ gem 'devpack', '~> 0.1.3'
12
12
  end
13
13
  ```
14
14
 
@@ -4,13 +4,7 @@ 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).max { |a, b| version(a) <=> version(b) }
14
8
  end
15
9
 
16
10
  private
@@ -27,10 +21,24 @@ module Devpack
27
21
 
28
22
  def match?(name_with_version, basename)
29
23
  name, _, version = name_with_version.partition(':')
30
- return true if version.empty? && basename.start_with?("#{name}-")
24
+ return true if version.empty? && basename.rpartition('-').first == name
31
25
  return true if !version.empty? && basename == "#{name}-#{version}"
32
26
 
33
27
  false
34
28
  end
29
+
30
+ def matched_paths(name)
31
+ glob.select do |path|
32
+ pathname = Pathname.new(path)
33
+ next unless pathname.directory?
34
+
35
+ basename = pathname.basename.to_s
36
+ match?(name, basename)
37
+ end
38
+ end
39
+
40
+ def version(path)
41
+ Gem::Version.new(File.split(path).last.rpartition('-').last)
42
+ end
35
43
  end
36
44
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Devpack
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
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.2
4
+ version: 0.1.3
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-07-20 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug