lib/cosing.rb in cosing-0.1.0 vs lib/cosing.rb in cosing-0.1.1
- old
+ new
@@ -11,16 +11,19 @@
require_relative "cosing/database"
module Cosing
module_function
+ GEM_ROOT = File.expand_path("..", __dir__)
+
class Error < StandardError; end
# Your code goes here...
def load
Database.new(Annex.load).tap do |database|
- ingredient_file = File.read("data/ingredients.csv").delete("\r")
+ path = gem_path("data/ingredients.csv")
+ ingredient_file = File.read(path).delete("\r")
CSV.parse(
ingredient_file,
headers: true,
liberal_parsing: true,
@@ -33,7 +36,11 @@
.transform_values(&:strip)
database.add_ingredient(row)
end
end
+ end
+
+ def gem_path(path)
+ Pathname.new(GEM_ROOT).join(path)
end
end