Sha256: 8150a3ef8002ae1500243a4400b133b4a7cf6cd6f2af0ab032e1f08a1ecf2fbb

Contents?: true

Size: 1.01 KB

Versions: 82

Compression:

Stored size: 1.01 KB

Contents

require 'pathname'

module Docman
  class CreateSymlinkCmd < Docman::Command

    register_command :create_symlink

    def validate_command
      raise "Please provide 'target_dir' param" if self['target_dir'].nil?
      raise "Please provide 'context'" if @context.nil?
      raise "Context should be of type 'Info'" unless @context.is_a? Docman::Info
      raise "Directory #{File.join(@context['docroot_config'].docroot_dir, self['target_dir'])} not exists" unless File.directory? File.join(@context['docroot_config'].docroot_dir, self['target_dir'])
    end

    def execute
      source_path = File.join(@context['docroot_config'].docroot_dir, self['target_dir'])
      Dir.chdir source_path
      source_pathname = Pathname.new source_path
      target_pathname = Pathname.new @context['full_build_path']
      relative_path = target_pathname.relative_path_from source_pathname
      `ln -f -s #{relative_path} .`
      log "Created symlink in #{source_path} dir: '#{@context['name']}' to '#{relative_path}'"
    end
  end
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
docman-0.0.107 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.106 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.105 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.104 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.103 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.102 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.101 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.100 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.99 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.98 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.97 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.96 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.95 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.94 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.93 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.92 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.91 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.90 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.89 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.88 lib/docman/commands/create_symlink_cmd.rb