Skip to content

Commit

Permalink
chore: add Error suffix to the Reader error classes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosgz committed Nov 23, 2024
1 parent 357b7a0 commit 8c3c801
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
site_maps (0.0.1.beta2)
site_maps (0.0.1.beta3)
builder (~> 3.0)
concurrent-ruby (>= 1.1)
rack (>= 2.0)
Expand Down
10 changes: 5 additions & 5 deletions lib/site_maps/sitemap_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
module SiteMaps
class SitemapReader
Error = Class.new(SiteMaps::Error)
FileNotFound = Class.new(Error)
MalformedFile = Class.new(Error)
FileNotFoundError = Class.new(Error)
MalformedFileError = Class.new(Error)

def initialize(location)
@location = Pathname.new(location)
Expand All @@ -19,7 +19,7 @@ def read
read_file.read
end
rescue Zlib::GzipFile::Error => _e
raise MalformedFile.new("The file #{@location} is not a valid Gzip file")
raise MalformedFileError.new("The file #{@location} is not a valid Gzip file")
end

def to_doc
Expand All @@ -40,9 +40,9 @@ def read_file
::File.open(@location, "r")
end
rescue Errno::ENOENT
raise FileNotFound.new("The file #{@location} does not exist")
raise FileNotFoundError.new("The file #{@location} does not exist")
rescue OpenURI::HTTPError
raise FileNotFound.new("The file #{@location} could not be opened")
raise FileNotFoundError.new("The file #{@location} could not be opened")
end

def compressed?
Expand Down
2 changes: 1 addition & 1 deletion lib/site_maps/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SiteMaps
VERSION = "0.0.1.beta2"
VERSION = "0.0.1.beta3"
end
2 changes: 1 addition & 1 deletion site_maps.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |spec|

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["bug_tracker_uri"] = "https://github.com/marcosgz/site_maps/issues"
spec.metadata["documentation_uri"] = "https://github.com/marcosgz/site_mapsg"
spec.metadata["documentation_uri"] = "https://github.com/marcosgz/site_maps"
spec.metadata["source_code_uri"] = "https://github.com/marcosgz/site_maps"

# Specify which files should be added to the gem when it is released.
Expand Down
10 changes: 5 additions & 5 deletions spec/site_maps/sitemap_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
it "raises an error if the file does not exist" do
reader = described_class.new("unknown.xml")

expect { reader.read }.to raise_error(SiteMaps::SitemapReader::FileNotFound)
expect { reader.read }.to raise_error(SiteMaps::SitemapReader::FileNotFoundError)
end
end

Expand All @@ -32,7 +32,7 @@
it "raises an error if the file does not exist" do
reader = described_class.new("unknown.xml.gz")

expect { reader.read }.to raise_error(SiteMaps::SitemapReader::FileNotFound)
expect { reader.read }.to raise_error(SiteMaps::SitemapReader::FileNotFoundError)
end
end

Expand All @@ -50,7 +50,7 @@
it "raises an error if the file does not exist" do
stub_request(:get, location).to_return(status: 404)

expect { reader.read }.to raise_error(SiteMaps::SitemapReader::FileNotFound)
expect { reader.read }.to raise_error(SiteMaps::SitemapReader::FileNotFoundError)
end
end

Expand All @@ -68,7 +68,7 @@
it "raises an error if the file does not exist" do
stub_request(:get, location).to_return(status: 404)

expect { reader.read }.to raise_error(SiteMaps::SitemapReader::FileNotFound)
expect { reader.read }.to raise_error(SiteMaps::SitemapReader::FileNotFoundError)
end
end
end
Expand All @@ -85,7 +85,7 @@
it "raises an error if the file does not exist" do
reader = described_class.new("unknown.xml")

expect { reader.to_doc }.to raise_error(SiteMaps::SitemapReader::FileNotFound)
expect { reader.to_doc }.to raise_error(SiteMaps::SitemapReader::FileNotFoundError)
end
end
end

0 comments on commit 8c3c801

Please sign in to comment.