Class: Jenkins::FilePath

Inherits:
Object
  • Object
show all
Includes:
Plugin::Wrapper
Defined in:
lib/jenkins/filepath.rb

Defined Under Namespace

Classes: Stat

Instance Attribute Summary

Attributes included from Plugin::Wrapper

#native

Instance Method Summary collapse

Methods included from Plugin::Wrapper

#initialize

Methods included from Plugin::Behavior

extended, #implemented, #included

Methods included from Plugin::Behavior::BehavesAs

#behaves_as

Instance Method Details

#+(name) ⇒ Object

Ruby’s Pathname internace



10
11
12
# File 'lib/jenkins/filepath.rb', line 10

def +(name)
  FilePath.new(@native.child(name))
end

#basenameObject

TODO: utime



54
55
56
# File 'lib/jenkins/filepath.rb', line 54

def basename
  FilePath.new(create_filepath(@native.getName()))
end

#chmod(mask) ⇒ Object



37
38
39
# File 'lib/jenkins/filepath.rb', line 37

def chmod(mask)
  @native.chmod(mask)
end

#create_launcher(listener) ⇒ Object

TODO: createTempDir TODO: createTempFile



126
127
128
# File 'lib/jenkins/filepath.rb', line 126

def create_launcher(listener)
  Launcher.new(@native.createLauncher(listener.native))
end

#deleteObject Also known as: unlink



96
97
98
# File 'lib/jenkins/filepath.rb', line 96

def delete
  @native.delete()
end

#directory?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/jenkins/filepath.rb', line 65

def directory?
  @native.isDirectory()
end

#each_entry(&block) ⇒ Object

TODO: rmdir TODO: opendir



90
91
92
93
94
# File 'lib/jenkins/filepath.rb', line 90

def each_entry(&block)
  entries.each do |child|
    yield child
  end
end

#entriesObject



77
78
79
80
81
# File 'lib/jenkins/filepath.rb', line 77

def entries
  @native.list().map { |native|
    FilePath.new(native)
  }
end

#exist?Boolean

TODO: dirname TODO: extname

Returns:

  • (Boolean)


61
62
63
# File 'lib/jenkins/filepath.rb', line 61

def exist?
  @native.exists()
end

#file?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/jenkins/filepath.rb', line 69

def file?
  !directory?
end

#join(*names) ⇒ Object



14
15
16
# File 'lib/jenkins/filepath.rb', line 14

def join(*names)
  FilePath.new names.inject(@native) {|native, name| native.child(name) }
end

#mkdirObject



83
84
85
# File 'lib/jenkins/filepath.rb', line 83

def mkdir
  @native.mkdirs
end

#mtimeObject

TODO: atime jnr-posix? TODO: ctime jnr-posix?



33
34
35
# File 'lib/jenkins/filepath.rb', line 33

def mtime
  Time.at(@native.lastModified().to_f / 1000)
end

#parentObject

TODO: hudson.FilePath does not handle FilePath(“.”).parent since it scans the last “/” for file, the 2nd last “/” for directory. Can Jenkins handle new FilePatn(ch, “../..”) correctly?



108
109
110
111
# File 'lib/jenkins/filepath.rb', line 108

def parent
  parent = Pathname.new(to_s).parent.to_s
  FilePath.new(Java.hudson.FilePath.new(@native.getChannel(), parent))
end

#read(*args) ⇒ Object



26
27
28
# File 'lib/jenkins/filepath.rb', line 26

def read(*args)
  @native.read.to_io.read(*args)
end

#realpathObject



22
23
24
# File 'lib/jenkins/filepath.rb', line 22

def realpath
  @native.absolutize().getRemote()
end

#remote?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/jenkins/filepath.rb', line 119

def remote?
  @native.isRemote()
end

#rename(to) ⇒ Object

TODO: chown TODO: open



44
45
46
# File 'lib/jenkins/filepath.rb', line 44

def rename(to)
  @native.renameTo(create_filepath(to))
end

#rmtreeObject



101
102
103
# File 'lib/jenkins/filepath.rb', line 101

def rmtree
  @native.deleteRecursive()
end

#sizeObject



73
74
75
# File 'lib/jenkins/filepath.rb', line 73

def size
  @native.length()
end

#statObject



48
49
50
# File 'lib/jenkins/filepath.rb', line 48

def stat
  Stat.new(size, @native.mode(), mtime)
end

#to_sObject



18
19
20
# File 'lib/jenkins/filepath.rb', line 18

def to_s
  @native.getRemote()
end

#touch(time) ⇒ Object

Original interface



115
116
117
# File 'lib/jenkins/filepath.rb', line 115

def touch(time)
  @native.touch(time.to_i * 1000)
end