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


200
201
202
203
204
# File 'lib/svn_command_helper.rb', line 200

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


192
193
194
# File 'lib/svn_command_helper.rb', line 192

def file
  @file
end

#from_baseString

from base uri

Returns:

  • (String)

    the current value of from_base


192
193
194
# File 'lib/svn_command_helper.rb', line 192

def from_base
  @from_base
end

#to_baseString

to base uri

Returns:

  • (String)

    the current value of to_base


192
193
194
# File 'lib/svn_command_helper.rb', line 192

def to_base
  @to_base
end

Instance Method Details

#fromString

from uri

Returns:

  • (String)

    from uri


208
209
210
# File 'lib/svn_command_helper.rb', line 208

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

#from_exist?Boolean

from uri exists?

Returns:

  • (Boolean)

228
229
230
# File 'lib/svn_command_helper.rb', line 228

def from_exist?
  Svn.list_files(@from_base).find{|_file| File.fnmatch(@file, _file)}
end

#glob_transactionsArray<SvnFileCopyTransaction>

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

Returns:


220
221
222
223
224
# File 'lib/svn_command_helper.rb', line 220

def glob_transactions
  Svn.list_files(@from_base)
    .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


252
253
254
# File 'lib/svn_command_helper.rb', line 252

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


240
241
242
# File 'lib/svn_command_helper.rb', line 240

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


258
259
260
# File 'lib/svn_command_helper.rb', line 258

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

#relative_to_base(path) ⇒ String

relative to base path from given base uri

Returns:

  • (String)

    relative to base path


246
247
248
# File 'lib/svn_command_helper.rb', line 246

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


214
215
216
# File 'lib/svn_command_helper.rb', line 214

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

#to_exist?Boolean

to uri exists?

Returns:

  • (Boolean)

234
235
236
# File 'lib/svn_command_helper.rb', line 234

def to_exist?
  Svn.list_files(@to_base).find{|_file| File.fnmatch(@file, _file)}
end