Skip to content

Commit

Permalink
Merge pull request #61 from alexeyschepin/feature/ignore-not-found-gems
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmeurer authored Jan 19, 2021
2 parents 747d965 + 3d12f77 commit d8d3c04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/services/gemmies/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Gemmies
class Create < Services::Base
class AlreadyExists < Error
class BaseError < StandardError
attr_reader :gemmy

def initialize(gemmy)
Expand All @@ -12,6 +12,14 @@ def initialize(gemmy)
end
end

class AlreadyExists < BaseError; end

class NotFound < BaseError
def message
"Gem '#{@gemmy.name}' does not exist."
end
end

def call(name)
if name.blank?
raise Error, 'Please enter a name.'
Expand All @@ -24,7 +32,7 @@ def call(name)
begin
Gems.info name
rescue Gems::NotFound
raise Error, %(Gem "#{name}" does not exist.)
raise NotFound.new(Gemmy.new(name: name))
end

gemmy = Gemmy.create!(name: name)
Expand Down
2 changes: 2 additions & 0 deletions app/services/lockfiles/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def call(content)
gem_names.each do |gem_name|
gemmy = Gemmy.find_by(name: gem_name) || Gemmies::Create.call(gem_name)
lockfile.gemmies << gemmy
rescue Gemmies::Create::NotFound
next
end
end

Expand Down

0 comments on commit d8d3c04

Please sign in to comment.