Class: SvnCommandHelper::SvnFileCopyTransaction

Inherits:
Object
  • Object
show all
Defined in:
lib/svn_command_helper.rb

Overview

svn file copy transaction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_base:, to_base:, file:) ⇒ SvnFileCopyTransaction

Returns a new instance of SvnFileCopyTransaction.

Parameters:

  • from_base (String)

    from base uri

  • to_base (String)

    to base uri

  • file (String)

    file basename



355
356
357
358
359
# File 'lib/svn_command_helper.rb', line 355

def initialize(from_base:, to_base:, file:)
  @from_base = from_base
  @to_base = to_base
  @file = file
end

Instance Attribute Details

#fileString

file basename

Returns:

  • (String)

    the current value of file



347
348
349
# File 'lib/svn_command_helper.rb', line 347

def file
  @file
end

#from_baseString

from base uri

Returns:

  • (String)

    the current value of from_base



347
348
349
# File 'lib/svn_command_helper.rb', line 347

def from_base
  @from_base
end

#to_baseString

to base uri

Returns:

  • (String)

    the current value of to_base



347
348
349
# File 'lib/svn_command_helper.rb', line 347

def to_base
  @to_base
end

Instance Method Details

#fromString

from uri

Returns:

  • (String)

    from uri



363
364
365
# File 'lib/svn_command_helper.rb', line 363

def from
  File.join(@from_base, @file)
end

#from_exist?Boolean

from uri exists?

Returns:

  • (Boolean)


384
385
386
# File 'lib/svn_command_helper.rb', line 384

def from_exist?
  Svn.exist_file?(from)
end

#glob_transactions(recursive = false) ⇒ Array<SvnFileCopyTransaction>

filename glob (like “hoge*”) to each single file transaction

Parameters:

  • recursive (Boolean) (defaults to: false)

    list –recursive

Returns:



376
377
378
379
380
# File 'lib/svn_command_helper.rb', line 376

def glob_transactions(recursive = false)
  Svn.list_files(@from_base, recursive)
    .select{|_file| File.fnmatch(@file, _file)}
    .map{|_file| SvnFileCopyTransaction.new(from_base: @from_base, to_base: @to_base, file: _file)}
end

#relative_from(path) ⇒ String

relative from path from given base uri

Returns:

  • (String)

    relative from path



408
409
410
# File 'lib/svn_command_helper.rb', line 408

def relative_from(path)
  File.join(relative_from_base(path), @file)
end

#relative_from_base(path) ⇒ String

relative from base path from given base uri

Returns:

  • (String)

    relative from base path



396
397
398
# File 'lib/svn_command_helper.rb', line 396

def relative_from_base(path)
  Pathname.new(@from_base).relative_path_from(Pathname.new(path)).to_s
end

#relative_to(path) ⇒ String

relative to path from given base uri

Returns:

  • (String)

    relative to path



414
415
416
# File 'lib/svn_command_helper.rb', line 414

def relative_to(path)
  File.join(relative_to_base(path), @file)
end

#relative_to_base(path) ⇒ String

relative to base path from given base uri

Returns:

  • (String)

    relative to base path



402
403
404
# File 'lib/svn_command_helper.rb', line 402

def relative_to_base(path)
  Pathname.new(@to_base).relative_path_from(Pathname.new(path)).to_s
end

#toString

to uri

Returns:

  • (String)

    to uri



369
370
371
# File 'lib/svn_command_helper.rb', line 369

def to
  File.join(@to_base, @file)
end

#to_exist?Boolean

to uri exists?

Returns:

  • (Boolean)


390
391
392
# File 'lib/svn_command_helper.rb', line 390

def to_exist?
  Svn.exist_file?(to)
end