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



426
427
428
429
430
# File 'lib/svn_command_helper.rb', line 426

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

Instance Attribute Details

#fileString

file basename



418
419
420
# File 'lib/svn_command_helper.rb', line 418

def file
  @file
end

#from_baseString

from base uri



418
419
420
# File 'lib/svn_command_helper.rb', line 418

def from_base
  @from_base
end

#to_baseString

to base uri



418
419
420
# File 'lib/svn_command_helper.rb', line 418

def to_base
  @to_base
end

Instance Method Details

#fromString

from uri



434
435
436
# File 'lib/svn_command_helper.rb', line 434

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

#from_exist?Boolean

from uri exists?



455
456
457
# File 'lib/svn_command_helper.rb', line 455

def from_exist?
  Svn.exist_file?(from)
end

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

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



447
448
449
450
451
# File 'lib/svn_command_helper.rb', line 447

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

#relative_from(path) ⇒ String

relative from path from given base uri



479
480
481
# File 'lib/svn_command_helper.rb', line 479

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



467
468
469
# File 'lib/svn_command_helper.rb', line 467

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



485
486
487
# File 'lib/svn_command_helper.rb', line 485

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



473
474
475
# File 'lib/svn_command_helper.rb', line 473

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

#toString

to uri



440
441
442
# File 'lib/svn_command_helper.rb', line 440

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

#to_exist?Boolean

to uri exists?



461
462
463
# File 'lib/svn_command_helper.rb', line 461

def to_exist?
  Svn.exist_file?(to)
end