lib/stashify/file.rb in stashify-1.0.5 vs lib/stashify/file.rb in stashify-2.0.0

- old
+ new

@@ -2,15 +2,17 @@ require "stashify" module Stashify class File - attr_reader :name, :contents + attr_reader :name, :path, :contents - def initialize(name:, contents: "") - raise Stashify::InvalidFile, "Name '#{name}' contains a /" if name =~ %r{/} + def initialize(name: nil, path: nil, contents: "") + raise StandardError, "name or path must be defined" unless name || path + raise Stashify::InvalidFile, "Name '#{name}' contains a /" if name && name =~ %r{/} - @name = name + @path = path + @name = name || ::File.basename(path) @contents = contents end def ==(other) name == other.name && contents == other.contents