Class: Train::Extras::FileCommon
- Inherits:
-
Object
- Object
- Train::Extras::FileCommon
- Defined in:
- lib/train/extras/file_common.rb
Direct Known Subclasses
Instance Method Summary collapse
- #block_device? ⇒ Boolean
- #character_device? ⇒ Boolean
- #directory? ⇒ Boolean
-
#file? ⇒ Boolean
Additional methods for convenience.
- #grouped_into?(sth) ⇒ Boolean
- #linked_to?(dst) ⇒ Boolean
-
#md5sum ⇒ Object
The following methods can be overwritten by a derived class if desired, to e.g.
- #mode?(sth) ⇒ Boolean
- #mounted? ⇒ Boolean
- #owned_by?(sth) ⇒ Boolean
- #pipe? ⇒ Boolean
- #sha256sum ⇒ Object
- #socket? ⇒ Boolean
- #symlink? ⇒ Boolean
- #type ⇒ Object
- #unix_mode_mask(owner, type) ⇒ Object
- #version?(version) ⇒ Boolean
Instance Method Details
#block_device? ⇒ Boolean
50 51 52 |
# File 'lib/train/extras/file_common.rb', line 50 def block_device? target_type == :block_device end |
#character_device? ⇒ Boolean
54 55 56 |
# File 'lib/train/extras/file_common.rb', line 54 def character_device? target_type == :character_device end |
#directory? ⇒ Boolean
62 63 64 |
# File 'lib/train/extras/file_common.rb', line 62 def directory? target_type == :directory end |
#file? ⇒ Boolean
Additional methods for convenience
46 47 48 |
# File 'lib/train/extras/file_common.rb', line 46 def file? target_type == :file end |
#grouped_into?(sth) ⇒ Boolean
82 83 84 |
# File 'lib/train/extras/file_common.rb', line 82 def grouped_into?(sth) group == sth end |
#linked_to?(dst) ⇒ Boolean
86 87 88 |
# File 'lib/train/extras/file_common.rb', line 86 def linked_to?(dst) link_path == dst end |
#md5sum ⇒ Object
The following methods can be overwritten by a derived class if desired, to e.g. achieve optimizations.
28 29 30 31 32 33 34 |
# File 'lib/train/extras/file_common.rb', line 28 def md5sum res = Digest::MD5.new res.update(content) res.hexdigest rescue TypeError => _ nil end |
#mode?(sth) ⇒ Boolean
74 75 76 |
# File 'lib/train/extras/file_common.rb', line 74 def mode?(sth) mode == sth end |
#mounted? ⇒ Boolean
105 106 107 |
# File 'lib/train/extras/file_common.rb', line 105 def mounted? !mounted.nil? && !mounted.stdout.nil? && !mounted.stdout.empty? end |
#owned_by?(sth) ⇒ Boolean
78 79 80 |
# File 'lib/train/extras/file_common.rb', line 78 def owned_by?(sth) owner == sth end |
#pipe? ⇒ Boolean
70 71 72 |
# File 'lib/train/extras/file_common.rb', line 70 def pipe? target_type == :pipe end |
#sha256sum ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/train/extras/file_common.rb', line 36 def sha256sum res = Digest::SHA256.new res.update(content) res.hexdigest rescue TypeError => _ nil end |
#socket? ⇒ Boolean
58 59 60 |
# File 'lib/train/extras/file_common.rb', line 58 def socket? target_type == :socket end |
#symlink? ⇒ Boolean
66 67 68 |
# File 'lib/train/extras/file_common.rb', line 66 def symlink? type == :symlink end |
#type ⇒ Object
21 22 23 |
# File 'lib/train/extras/file_common.rb', line 21 def type :unknown end |
#unix_mode_mask(owner, type) ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/train/extras/file_common.rb', line 95 def unix_mode_mask(owner, type) o = UNIX_MODE_OWNERS[owner.to_sym] return nil if o.nil? t = UNIX_MODE_TYPES[type.to_sym] return nil if t.nil? t & o end |
#version?(version) ⇒ Boolean
90 91 92 93 |
# File 'lib/train/extras/file_common.rb', line 90 def version?(version) product_version == version or file_version == version end |