mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
ruby: change value of 'readonly' drive toption to Boolean in doc/example/test
Seeing `g.add_drive_opt :readonly => 1` allows one to imply that ensuring writable access to drive should happen via `g.add_drive_opt :readonly => 0`. However, the passed option value gets passed down to C according to Ruby Boolean semantics, that is, any value apart from `false` and `nil` will be true (see RTEST in Ruby C API). So its more idiomatic and provides a better hint if we use `g.add_drive_opt :readonly => true` in Ruby samples.
This commit is contained in:
committed by
Richard W.M. Jones
parent
b68a67e1a9
commit
83474887ed
@@ -7,7 +7,7 @@ guestfs-ruby - How to use libguestfs from Ruby
|
||||
require 'guestfs'
|
||||
g = Guestfs::Guestfs.new()
|
||||
g.add_drive_opts("disk.img",
|
||||
:readonly => 1, :format => "raw")
|
||||
:readonly => true, :format => "raw")
|
||||
g.launch()
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
@@ -11,7 +11,7 @@ disk = ARGV[0]
|
||||
g = Guestfs::Guestfs.new()
|
||||
|
||||
# Attach the disk image read-only to libguestfs.
|
||||
g.add_drive_opts(disk, :readonly => 1)
|
||||
g.add_drive_opts(disk, :readonly => true)
|
||||
|
||||
# Run the libguestfs back-end.
|
||||
g.launch()
|
||||
|
||||
@@ -22,9 +22,9 @@ class Test070Optargs < MiniTest::Unit::TestCase
|
||||
g = Guestfs::Guestfs.new()
|
||||
|
||||
g.add_drive("/dev/null", {})
|
||||
g.add_drive("/dev/null", :readonly => 1)
|
||||
g.add_drive("/dev/null", :readonly => 1, :iface => "virtio")
|
||||
g.add_drive("/dev/null", :readonly => true)
|
||||
g.add_drive("/dev/null", :readonly => true, :iface => "virtio")
|
||||
g.add_drive("/dev/null",
|
||||
:readonly => 1, :iface => "virtio", :format => "raw")
|
||||
:readonly => true, :iface => "virtio", :format => "raw")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user