bun 1.1.0 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2768a6afdab33b24df8ec9dcb95bb8764bf3c0098dc7008769d3f61b187fba91
4
- data.tar.gz: b2f875654ae2db8746064d8f5aebbc2618d7cfedef486f0120600cd0fec422c6
3
+ metadata.gz: ee1b4b5d7a749db8a2b3ab21198d3c6976c43238396191f1ab1bc825bfff6176
4
+ data.tar.gz: 1580273ec6395600642231b0363ff8702c7bbf2793fb3ab5ca05d0b0074c1f85
5
5
  SHA512:
6
- metadata.gz: f2f4c416129ba3d8bd4e4c7166c5d8171fda830eeb5cfa6bcad55b0928eb1c177ea9d05bca8d89dfc854f9ca22b42d365b32221638969f0fc14559937004b71d
7
- data.tar.gz: e0c913a084c34304c7ed4f1d89413dd8c25e0059bc6b2429328fecc5c97ba0c34927bfb7cf1368dc09bbb58ff6c0cbf0403ac29c1504bf972102fb5a2d791f4e
6
+ metadata.gz: 2fff2b557d0b84693aa4b687792828f2d942d3e7c1537cacc4d6137d663949d5613b80630a2be6e65d333628b9bc8c185e7d128e6f17d4ce4de70484a2940f69
7
+ data.tar.gz: 147c1eb63f8a4e55858ab6691c64d81e1faf7afac90f57491a0bbc6a1a90699b452b4c680922dae8daf403276684375b0905a9e0db2a6337dda2625ba2007419
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bun (1.0.2)
4
+ bun (1.1.0)
5
5
  bundler (~> 1.16)
6
6
  paint (~> 2.0)
7
7
  tty-spinner (~> 0.8)
@@ -74,6 +74,7 @@ module Bun
74
74
  def with_exception_handling
75
75
  yield
76
76
  rescue Errors::DuplicateGemError, Errors::GemNotFoundError => ex
77
+ puts
77
78
  puts Paint[ex.message, :red, :bright]
78
79
  exit(1)
79
80
  end
@@ -1,3 +1,3 @@
1
1
  module Bun
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -4,7 +4,7 @@ require "tty/spinner"
4
4
 
5
5
  module Bun
6
6
  class VersionFetcher
7
- RUBYGEMS_SEARCH_URL = "https://rubygems.org/api/v1/search.json"
7
+ RUBYGEMS_GEM_URL = "https://rubygems.org/api/v1/gems"
8
8
 
9
9
  def initialize(gem, arguments)
10
10
  @gem = gem
@@ -15,16 +15,8 @@ module Bun
15
15
  version = nil
16
16
 
17
17
  with_optional_spinner do
18
- response = open("#{RUBYGEMS_SEARCH_URL}?query=#{gem}").read
19
- json_response = JSON.parse(response)
20
- latest_gem_attributes = json_response.
21
- find {|attributes| attributes["name"] == gem }
22
-
23
- unless latest_gem_attributes
24
- raise ::Bun::Errors::GemNotFoundError.new("Aborting. Gem not found: #{gem}")
25
- end
26
-
27
- version = latest_gem_attributes["version"]
18
+ json_response = JSON.parse(fetch)
19
+ version = json_response["version"]
28
20
  end
29
21
 
30
22
  version
@@ -43,6 +35,12 @@ module Bun
43
35
 
44
36
  private
45
37
 
38
+ def fetch
39
+ open("#{RUBYGEMS_GEM_URL}/#{gem}.json").read
40
+ rescue OpenURI::HTTPError
41
+ raise ::Bun::Errors::GemNotFoundError.new("Aborting. Gem not found: #{gem}")
42
+ end
43
+
46
44
  attr :gem
47
45
  attr :arguments
48
46
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bun
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hrvoje Šimić