Sha256: 96f40310c5280845707867871a1f5e0ce31c76192d33ba962938b9bf3a975386

Contents?: true

Size: 920 Bytes

Versions: 30

Compression:

Stored size: 920 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
      define_attribute :force, default: false

      def pre_action
        case @current_action
        when :create
          attributes.exist = true
        end
      end

      def set_current_attributes
        current.exist = run_specinfra(:check_file_is_link, attributes.link)

        if current.exist
          current.to = run_specinfra(:get_file_link_target, attributes.link).stdout.strip
        end
      end

      def action_create(options)
        unless run_specinfra(:check_file_is_linked_to, attributes.link, attributes.to)
          run_specinfra(:link_file_to, attributes.link, attributes.to, force: attributes.force)
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
itamae-1.9.1 lib/itamae/resource/link.rb
itamae-1.9.0 lib/itamae/resource/link.rb
itamae-1.8.0 lib/itamae/resource/link.rb
itamae-1.7.0 lib/itamae/resource/link.rb
itamae-1.7.0.pre lib/itamae/resource/link.rb
itamae-1.6.3 lib/itamae/resource/link.rb
itamae-1.6.2 lib/itamae/resource/link.rb
itamae-1.6.1 lib/itamae/resource/link.rb
itamae-1.6.0 lib/itamae/resource/link.rb
itamae-1.5.2 lib/itamae/resource/link.rb
itamae-1.5.1 lib/itamae/resource/link.rb
itamae-1.5.0 lib/itamae/resource/link.rb
itamae-1.4.5 lib/itamae/resource/link.rb
itamae-1.4.4 lib/itamae/resource/link.rb
itamae-1.4.3 lib/itamae/resource/link.rb
itamae-1.4.2 lib/itamae/resource/link.rb
itamae-1.4.1 lib/itamae/resource/link.rb
itamae-1.4.0 lib/itamae/resource/link.rb
itamae-1.3.6 lib/itamae/resource/link.rb
itamae-1.3.5 lib/itamae/resource/link.rb