Sha256: 39bf0c0e46643f770bd11262e9620bd29094deaee297ab482340192991e1fc23

Contents?: true

Size: 958 Bytes

Versions: 18

Compression:

Stored size: 958 Bytes

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
      puts `ln -s #{relative_path} #{@context['name']}`
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
docman-0.0.23 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.22 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.21 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.20 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.19 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.18 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.17 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.16 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.15 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.14 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.13 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.12 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.11 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.10 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.9 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.8 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.7 lib/docman/commands/create_symlink_cmd.rb
docman-0.0.6 lib/docman/commands/create_symlink_cmd.rb