Skip to content

Commit

Permalink
Merge pull request #44 from chef/chris-rock/mounted
Browse files Browse the repository at this point in the history
introduce `mounted` as a seperate method to retrieve the content
  • Loading branch information
arlimus committed Dec 31, 2015
2 parents d143c52 + 20dfc93 commit 46726ed
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/train/extras/aix_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def link_path
)
end

def mounted?
def mounted
@mounted ||= (
!@backend.run_command("lsfs -c #{@spath}").stdout.empty?
@backend.run_command("lsfs -c #{@spath}")
)
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/train/extras/file_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ def unix_mode_mask(owner, type)
t & o
end

def mounted?
!mounted.nil? && !mounted.stdout.nil? && !mounted.stdout.empty?
end

# helper methods provided to any implementing class

private
Expand Down
5 changes: 2 additions & 3 deletions lib/train/extras/linux_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ def link_path
)
end

def mounted?
def mounted
@mounted ||= (
!@backend.run_command("mount | grep -- ' on #{@spath}'")
.stdout.empty?
@backend.run_command("mount | grep -- ' on #{@spath}'")
)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/train/extras/windows_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def link_path
nil
end

def mounted?
def mounted
nil
end

Expand Down
12 changes: 9 additions & 3 deletions lib/train/transports/mock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,22 @@ class Train::Transports::Mock::Connection
class File < FileCommon
%w{
exist? mode owner group link_target link_path content mtime size
selinux_label product_version file_version path
type
selinux_label product_version file_version path type
}.each do |m|
attr_accessor m.tr('?', '').to_sym
end

def initialize(_runtime, path)
def initialize(runtime, path)
@path = path
@type = :unknown
@exist = false
@runtime = runtime
end

def mounted
@mounted ||= (
@runtime.run_command("mount | grep -- ' on #{@path}'")
)
end
end
end

0 comments on commit 46726ed

Please sign in to comment.