lib/iev/db_cache.rb in iev-0.2.4 vs lib/iev/db_cache.rb in iev-0.2.5
- old
+ new
@@ -8,11 +8,12 @@
# @param dir [String] DB directory
def initialize(dir)
@dir = dir
FileUtils::mkdir_p @dir
file_version = "#{@dir}/version"
- File.write file_version, VERSION, encoding: "utf-8" unless File.exist? file_version
+ File.exist? file_version or
+ File.write file_version, VERSION, encoding: "utf-8"
end
# Save item
# @param key [String]
# @param value [String] Bibitem xml serialization
@@ -65,18 +66,18 @@
end
# Check if version of the DB match to the gem version.
# @return [TrueClass, FalseClass]
def check_version?
- v = File.read @dir + "/version", encoding: "utf-8"
+ v = File.read "#{@dir}/version", encoding: "utf-8"
v == VERSION
end
# Set version of the DB to the gem version.
# @return [Iev::DbCache]
def set_version
- File.write @dir + "/version", VERSION, encoding: "utf-8"
+ File.write "#{@dir}/version", VERSION, encoding: "utf-8"
self
end
# if cached reference is undated, expire it after 60 days
# @param key [String]
@@ -108,9 +109,9 @@
# @return [String]
def prefix(key)
# @registry.processors.detect do |_n, p|
# /^#{p.prefix}/.match(key) || processor.defaultprefix.match(key)
# end[1].prefix.downcase
- key.downcase.match(/^[^\(]+(?=\()/).to_s
+ key.downcase.match(/^[^(]+(?=\()/).to_s
end
end
end