Class: Jenkins::FilePath
- Inherits:
-
Object
- Object
- Jenkins::FilePath
- Defined in:
- lib/jenkins/filepath.rb
Defined Under Namespace
Classes: Stat
Instance Attribute Summary collapse
-
#natvie ⇒ Object
readonly
Returns the value of attribute natvie.
Instance Method Summary collapse
-
#+(name) ⇒ Object
Ruby’s Pathname internace.
-
#basename ⇒ Object
TODO: utime.
- #chmod(mask) ⇒ Object
- #delete ⇒ Object (also: #unlink)
- #directory? ⇒ Boolean
-
#each_entry(&block) ⇒ Object
TODO: rmdir TODO: opendir.
- #entries ⇒ Object
-
#exist? ⇒ Boolean
TODO: dirname TODO: extname.
- #file? ⇒ Boolean
-
#initialize(native) ⇒ FilePath
constructor
A new instance of FilePath.
- #join(*names) ⇒ Object
- #mkdir ⇒ Object
-
#mtime ⇒ Object
TODO: atime jnr-posix? TODO: ctime jnr-posix?.
-
#parent ⇒ Object
TODO: hudson.FilePath does not handle FilePath(“.”).parent since it scans the last “/” for file, the 2nd last “/” for directory.
- #read(*args) ⇒ Object
- #realpath ⇒ Object
- #remote? ⇒ Boolean
-
#rename(to) ⇒ Object
TODO: chown TODO: open.
- #rmtree ⇒ Object
- #size ⇒ Object
- #stat ⇒ Object
- #to_s ⇒ Object
-
#touch(time) ⇒ Object
Original interface.
Constructor Details
#initialize(native) ⇒ FilePath
Returns a new instance of FilePath.
9 10 11 |
# File 'lib/jenkins/filepath.rb', line 9 def initialize(native) @native = native end |
Instance Attribute Details
#natvie ⇒ Object (readonly)
Returns the value of attribute natvie.
7 8 9 |
# File 'lib/jenkins/filepath.rb', line 7 def natvie @natvie end |
Instance Method Details
#+(name) ⇒ Object
Ruby’s Pathname internace
15 16 17 |
# File 'lib/jenkins/filepath.rb', line 15 def +(name) FilePath.new(@native.child(name)) end |
#basename ⇒ Object
TODO: utime
59 60 61 |
# File 'lib/jenkins/filepath.rb', line 59 def basename FilePath.new(create_filepath(@native.getName())) end |
#chmod(mask) ⇒ Object
42 43 44 |
# File 'lib/jenkins/filepath.rb', line 42 def chmod(mask) @native.chmod(mask) end |
#delete ⇒ Object Also known as: unlink
101 102 103 |
# File 'lib/jenkins/filepath.rb', line 101 def delete @native.delete() end |
#directory? ⇒ Boolean
70 71 72 |
# File 'lib/jenkins/filepath.rb', line 70 def directory? @native.isDirectory() end |
#each_entry(&block) ⇒ Object
TODO: rmdir TODO: opendir
95 96 97 98 99 |
# File 'lib/jenkins/filepath.rb', line 95 def each_entry(&block) entries.each do |child| yield child end end |
#entries ⇒ Object
82 83 84 85 86 |
# File 'lib/jenkins/filepath.rb', line 82 def entries @native.list().map { |native| FilePath.new(native) } end |
#exist? ⇒ Boolean
TODO: dirname TODO: extname
66 67 68 |
# File 'lib/jenkins/filepath.rb', line 66 def exist? @native.exists() end |
#file? ⇒ Boolean
74 75 76 |
# File 'lib/jenkins/filepath.rb', line 74 def file? !directory? end |
#join(*names) ⇒ Object
19 20 21 |
# File 'lib/jenkins/filepath.rb', line 19 def join(*names) FilePath.new names.inject(@native) {|native, name| native.child(name) } end |
#mkdir ⇒ Object
88 89 90 |
# File 'lib/jenkins/filepath.rb', line 88 def mkdir @native.mkdirs end |
#mtime ⇒ Object
TODO: atime jnr-posix? TODO: ctime jnr-posix?
38 39 40 |
# File 'lib/jenkins/filepath.rb', line 38 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?
113 114 115 116 |
# File 'lib/jenkins/filepath.rb', line 113 def parent parent = Pathname.new(to_s).parent.to_s FilePath.new(Java.hudson.FilePath.new(@native.getChannel(), parent)) end |
#read(*args) ⇒ Object
31 32 33 |
# File 'lib/jenkins/filepath.rb', line 31 def read(*args) @native.read.to_io.read(*args) end |
#realpath ⇒ Object
27 28 29 |
# File 'lib/jenkins/filepath.rb', line 27 def realpath @native.absolutize().getRemote() end |
#remote? ⇒ Boolean
124 125 126 |
# File 'lib/jenkins/filepath.rb', line 124 def remote? @native.isRemote() end |
#rename(to) ⇒ Object
TODO: chown TODO: open
49 50 51 |
# File 'lib/jenkins/filepath.rb', line 49 def rename(to) @native.renameTo(create_filepath(to)) end |
#rmtree ⇒ Object
106 107 108 |
# File 'lib/jenkins/filepath.rb', line 106 def rmtree @native.deleteRecursive() end |
#size ⇒ Object
78 79 80 |
# File 'lib/jenkins/filepath.rb', line 78 def size @native.length() end |
#stat ⇒ Object
53 54 55 |
# File 'lib/jenkins/filepath.rb', line 53 def stat Stat.new(size, @native.mode(), mtime) end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/jenkins/filepath.rb', line 23 def to_s @native.getRemote() end |
#touch(time) ⇒ Object
Original interface
120 121 122 |
# File 'lib/jenkins/filepath.rb', line 120 def touch(time) @native.touch(time.to_i * 1000) end |