lib/wright/resource/file.rb in wright-0.2.0 vs lib/wright/resource/file.rb in wright-0.3.0

- old
+ new

@@ -1,46 +1,50 @@ +require 'forwardable' + require 'wright/resource' require 'wright/dsl' +require 'wright/util/file_owner' module Wright class Resource # Symlink resource, represents a symlink. # # @example # file = Wright::Resource::File.new('/tmp/foo') # file.content = 'bar' # file.create class File < Wright::Resource + extend Forwardable + # @return [String] the file's intended content attr_accessor :content - # @return [String] the file's intended group - attr_accessor :group - # @return [String, Integer] the file's intended mode attr_accessor :mode - # @return [String] the file's intended owner - attr_reader :owner + # @!attribute owner + # @return [String, Integer] the directory's intended owner + # @!method owner= + # @see #owner + def_delegator :@owner, :user_and_group=, :owner= + def_delegator :@owner, :user, :owner + # @!attribute group + # @return [String, Integer] the directory's intended group + # @!method group= + # @see #group + def_delegator :@owner, :group= + def_delegator :@owner, :group + # Initializes a File. # # @param name [String] the file's name def initialize(name) super @content = nil @mode = nil - @owner = nil - @group = nil + @owner = Wright::Util::FileOwner.new @action = :create - end - - # Sets the file's owner. - def owner=(owner) - target_owner, target_group = - Wright::Util::User.owner_to_owner_group(owner) - @owner = target_owner unless target_owner.nil? - @group = target_group unless target_group.nil? end # Creates or updates the file. # # @return [Bool] true if the file was updated and false