Sha256: 71ac9718efbbeef89c280caa2d060fbae140ed6d7e8d20da0ccf5d652dc7081c

Contents?: true

Size: 968 Bytes

Versions: 90

Compression:

Stored size: 968 Bytes

Contents

require 'itamae-mitsurin'

module ItamaeMitsurin
  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, type: [TrueClass, FalseClass], 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

90 entries across 47 versions & 1 rubygems

Version Path
itamae-mitsurin-1.0.3 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-1.0.2 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-1.0.1 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-1.0.0 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-0.50 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-0.50 test/test_itamae-mitsurin/resource/test_link.rb
itamae-mitsurin-0.49 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-0.49 test/test_itamae-mitsurin/resource/test_link.rb
itamae-mitsurin-0.48 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-0.48 test/test_itamae-mitsurin/resource/test_link.rb
itamae-mitsurin-0.47 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-0.47 test/test_itamae-mitsurin/resource/test_link.rb
itamae-mitsurin-0.46 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-0.46 test/test_itamae-mitsurin/resource/test_link.rb
itamae-mitsurin-0.45 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-0.45 test/test_itamae-mitsurin/resource/test_link.rb
itamae-mitsurin-0.44 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-0.44 test/test_itamae-mitsurin/resource/test_link.rb
itamae-mitsurin-0.43 lib/itamae-mitsurin/resource/link.rb
itamae-mitsurin-0.43 test/test_itamae-mitsurin/resource/test_link.rb