lib/self_data.rb in self_data-1.0.0 vs lib/self_data.rb in self_data-1.1.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require "yaml"
require "json"
require "active_support/core_ext/module/delegation.rb"
require "active_support/core_ext/class/attribute.rb"
@@ -28,28 +30,28 @@
def load(*formats, **options)
formats = default_formats if formats.empty?
options = default_options if options.empty?
formats.reduce(read) do |data, format|
- fail ConverterNotFound, format unless converters[format]
+ raise ConverterNotFound, format unless converters[format]
begin
converters[format].call(data, options)
rescue => e
raise ConversionError.new(format, e)
end
end
end
def read
- IO.read(file).scan(/\n__END__\n(.*)/m).flatten.first or fail NoDataFound, file
+ IO.read(file).scan(/\n__END__\n(.*)/m).flatten.first or raise NoDataFound, file
end
private
def caller_file
calls = caller.lazy
- .map { |call_string| call_string.split(':').first }
- .select { |file| file != __FILE__ }
+ .map { |call_string| call_string.split(":").first }
+ .reject { |file| file == __FILE__ }
.select(&File.method(:exist?))
filters.each do |filter|
calls = calls.select(&filter.method(:call))
end