Class: Jenkins::FilePath
Defined Under Namespace
Classes: Stat
Instance Attribute Summary
#native
Instance Method Summary
collapse
#initialize
extended, #implemented, #included
#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
|
#basename ⇒ Object
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
|
#delete ⇒ Object
Also known as:
unlink
96
97
98
|
# File 'lib/jenkins/filepath.rb', line 96
def delete
@native.delete()
end
|
#directory? ⇒ 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
|
#entries ⇒ Object
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
61
62
63
|
# File 'lib/jenkins/filepath.rb', line 61
def exist?
@native.exists()
end
|
#file? ⇒ 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
|
#mkdir ⇒ Object
83
84
85
|
# File 'lib/jenkins/filepath.rb', line 83
def mkdir
@native.mkdirs
end
|
#mtime ⇒ Object
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
|
#parent ⇒ Object
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
|
#realpath ⇒ Object
22
23
24
|
# File 'lib/jenkins/filepath.rb', line 22
def realpath
@native.absolutize().getRemote()
end
|
#remote? ⇒ Boolean
119
120
121
|
# File 'lib/jenkins/filepath.rb', line 119
def remote?
@native.isRemote()
end
|
#rename(to) ⇒ Object
44
45
46
|
# File 'lib/jenkins/filepath.rb', line 44
def rename(to)
@native.renameTo(create_filepath(to))
end
|
#rmtree ⇒ Object
101
102
103
|
# File 'lib/jenkins/filepath.rb', line 101
def rmtree
@native.deleteRecursive()
end
|
#size ⇒ Object
73
74
75
|
# File 'lib/jenkins/filepath.rb', line 73
def size
@native.length()
end
|
#stat ⇒ Object
48
49
50
|
# File 'lib/jenkins/filepath.rb', line 48
def stat
Stat.new(size, @native.mode(), mtime)
end
|
#to_s ⇒ Object
18
19
20
|
# File 'lib/jenkins/filepath.rb', line 18
def to_s
@native.getRemote()
end
|
#touch(time) ⇒ Object
115
116
117
|
# File 'lib/jenkins/filepath.rb', line 115
def touch(time)
@native.touch(time.to_i * 1000)
end
|