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 Also known as: jss_append

Append some string content to a file.

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



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

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

#j_chown(usr, grp) ⇒ Object Also known as: jss_chown

Pathname should use FileUtils.chown, not File.chown



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

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

#j_cp(dest, **options) ⇒ Object Also known as: jss_cp

Copy a path to a destination

See Also:

  • FileUtils.cp


14
15
16
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 14

def j_cp(dest, **options)
  FileUtils.cp @path, dest.to_s, **options
end

#j_cp_r(dest, **options) ⇒ Object Also known as: jss_cp_r

Recursively copy this path to a destination

See Also:

  • FileUtils.cp_r


21
22
23
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 21

def j_cp_r(dest, **options)
  FileUtils.cp_r @path, dest.to_s, **options
end

#j_save(content) ⇒ Object Also known as: jss_save

Write some string content to a file.

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



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

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

#j_touchObject Also known as: jss_touch

Touching can sometimes be good

See Also:

  • FileUtils.touch


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

def j_touch
  FileUtils.touch @path
end