Module: JamfRubyExtensions::Pathname::Utils
- Included in:
- Pathname
- Defined in:
- lib/jamf/ruby_extensions/pathname/utils.rb
Instance Method Summary collapse
-
#j_append(content) ⇒ Object
(also: #jss_append)
Append some string content to a file.
-
#j_chown(usr, grp) ⇒ Object
(also: #jss_chown)
Pathname should use FileUtils.chown, not File.chown.
-
#j_cp(dest, **options) ⇒ Object
(also: #jss_cp)
Copy a path to a destination.
-
#j_cp_r(dest, **options) ⇒ Object
(also: #jss_cp_r)
Recursively copy this path to a destination.
-
#j_save(content) ⇒ Object
(also: #jss_save)
Write some string content to a file.
-
#j_touch ⇒ Object
(also: #jss_touch)
Touching can sometimes be good.
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
58 59 60 |
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 58 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
72 73 74 |
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 72 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
32 33 34 |
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 32 def j_cp(dest, **) FileUtils.cp @path, dest.to_s, ** end |
#j_cp_r(dest, **options) ⇒ Object Also known as: jss_cp_r
Recursively copy this path to a destination
39 40 41 |
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 39 def j_cp_r(dest, **) FileUtils.cp_r @path, dest.to_s, ** 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!
49 50 51 |
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 49 def j_save(content) self.open('w') { |f| f.write content.to_s } end |
#j_touch ⇒ Object Also known as: jss_touch
Touching can sometimes be good
66 67 68 |
# File 'lib/jamf/ruby_extensions/pathname/utils.rb', line 66 def j_touch FileUtils.touch @path end |