Sha256: 6bb5bc3576e5ef959efad83a60fb771115976e13a873e5fe9b851666f5413e9b

Contents?: true

Size: 834 Bytes

Versions: 9

Compression:

Stored size: 834 Bytes

Contents

require 'itamae'

module Itamae
  module Resource
    class Link < Base
      define_attribute :action, default: :create
      define_attribute :link, type: String, default_name: true
      define_attribute :to, type: String, required: true

      def pre_action
        case action
        when :create
          @attributes[:exist?] = true
        end
      end

      def set_current_attributes
        @current_attributes[:exist?] = (run_command(["test", "-L", link], error: false).exit_status == 0)

        if @current_attributes[:exist?]
          @current_attributes[:to] = run_command(["readlink", "-f", link]).stdout.strip
        end
      end

      def create_action
        unless run_specinfra(:check_file_is_linked_to, link, to)
          run_specinfra(:link_file_to, link, to)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
itamae-1.0.0.beta29 lib/itamae/resource/link.rb
itamae-1.0.0.beta28 lib/itamae/resource/link.rb
itamae-1.0.0.beta27 lib/itamae/resource/link.rb
itamae-1.0.0.beta26 lib/itamae/resource/link.rb
itamae-1.0.0.beta25 lib/itamae/resource/link.rb
itamae-1.0.0.beta24 lib/itamae/resource/link.rb
itamae-1.0.0.beta23 lib/itamae/resource/link.rb
itamae-1.0.0.beta22 lib/itamae/resource/link.rb
itamae-1.0.0.beta21 lib/itamae/resource/link.rb