Class: Pathname

Inherits:
Object show all
Includes:
JamfRubyExtensions::Pathname::Predicates, JamfRubyExtensions::Pathname::Utils
Defined in:
lib/jss/ruby_extensions/pathname.rb,
lib/jamf/ruby_extensions/pathname.rb

Overview

include the modules loaded above

Instance Method Summary collapse

Instance Method Details

#j_append(content) ⇒ Object Originally defined in module JamfRubyExtensions::Pathname::Utils

Append some string content to a file.

Simpler than always using an open('a') block

#j_chown(usr, grp) ⇒ Object Originally defined in module JamfRubyExtensions::Pathname::Utils

Pathname should use FileUtils.chown, not File.chown

#j_cp(dest, options = {}) ⇒ Object Originally defined in module JamfRubyExtensions::Pathname::Utils

Copy a path to a destination

See Also:

  • FileUtils.cp

#j_cp_r(dest, options = {}) ⇒ Object Originally defined in module JamfRubyExtensions::Pathname::Utils

Recursively copy this path to a destination

See Also:

  • FileUtils.cp_r

#j_include?(other) ⇒ Boolean Originally defined in module JamfRubyExtensions::Pathname::Predicates

does a path include another? i.e. is 'other' a descendant of self ?

Returns:

  • (Boolean)

#j_real_file?Boolean Originally defined in module JamfRubyExtensions::Pathname::Predicates

Is this a real file rather than a symlink?

Returns:

  • (Boolean)

See Also:

  • FileTest.real_file

#j_save(content) ⇒ Object Originally defined in module JamfRubyExtensions::Pathname::Utils

Write some string content to a file.

Simpler than always using an open('w') block CAUTION this overwrites files!

#j_touchObject Originally defined in module JamfRubyExtensions::Pathname::Utils

Touching can sometimes be good

See Also:

  • FileUtils.touch

#jss_append(content) ⇒ Object

Append some string content to a file.

Simpler than always using an open('a') block



63
64
65
# File 'lib/jss/ruby_extensions/pathname.rb', line 63

def jss_append(content)
  self.open('a'){|f| f.write content.to_s}
end

#jss_chown(u, g) ⇒ Object

Pathname should use FileUtils.chown, not File.chown



75
76
77
# File 'lib/jss/ruby_extensions/pathname.rb', line 75

def jss_chown(u,g)
  FileUtils.chown u, g, @path
end

#jss_cp(dest, options = {}) ⇒ Object

Copy a path to a destination

See Also:

  • FileUtils.cp


40
41
42
# File 'lib/jss/ruby_extensions/pathname.rb', line 40

def jss_cp(dest, options = {})
  FileUtils.cp @path, dest.to_s, options
end

#jss_cp_r(dest, options = {}) ⇒ Object

Recursively copy this path to a destination

See Also:

  • FileUtils.cp_r


46
47
48
# File 'lib/jss/ruby_extensions/pathname.rb', line 46

def jss_cp_r(dest, options = {})
  FileUtils.cp_r @path, dest.to_s, options
end

#jss_real_file?Boolean

Is this a real file rather than a symlink?

Returns:

  • (Boolean)

See Also:

  • FileTest.real_file


34
35
36
# File 'lib/jss/ruby_extensions/pathname.rb', line 34

def jss_real_file?
  FileTest.jss_real_file? self 
end

#jss_save(content) ⇒ Object

Write some string content to a file.

Simpler than always using an open('w') block CAUTION this overwrites files!



55
56
57
# File 'lib/jss/ruby_extensions/pathname.rb', line 55

def jss_save(content)
  self.open('w'){|f| f.write content.to_s}
end

#jss_touchObject

Touching can be good

See Also:

  • FileUtils.touch


70
71
72
# File 'lib/jss/ruby_extensions/pathname.rb', line 70

def jss_touch
  FileUtils.touch @path
end