Module: JamfRubyExtensions::Pathname::Utils

Included in:
Pathname
Defined in:
lib/jamf/ruby_extensions/pathname/utils.rb

Instance Method Summary collapse

Instance Method Details

#j_append(content) ⇒ Object

Append some string content to a file.

Simpler than always using an open(‘a’) block



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

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

#j_chown(usr, grp) ⇒ Object

Pathname should use FileUtils.chown, not File.chown



67
68
69
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 67

def j_chown(usr, grp)
  FileUtils.chown usr, grp, @path
end

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

Copy a path to a destination

See Also:

  • FileUtils.cp


32
33
34
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 32

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

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

Recursively copy this path to a destination

See Also:

  • FileUtils.cp_r


38
39
40
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 38

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

#j_save(content) ⇒ Object

Write some string content to a file.

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



47
48
49
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 47

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

#j_touchObject

Touching can sometimes be good

See Also:

  • FileUtils.touch


62
63
64
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 62

def j_touch
  FileUtils.touch @path
end