J
James F. Hranicky
It seems that when I do a YPATH select on a node that
contains an integer, I get nothing in return. However,
when the node is a string, the select works.
Here's the YAML file:
---------- x.yaml ------------
Domains :
my.domain.com :
Networks :
192.168.0.0-24 :
Hosts :
0 :
Name : net192-168
Ether : NONE
1 :
Name : route192-168
Ether : 00:00:00:00:00:01
Arch : gateway
x2 :
Name : myserv
Ether : 00:00:00:00:00:02
Arch : x86
OS : linux
---------- x.yaml ------------
Here's the ruby script
---------- x.rb ------------
y = File.open(ARGV.shift).read
node = ARGV.shift
p YAML.parse(y).select("/Domains/*/Networks/*/Hosts/#{node}").transform
---------- x.rb ------------
Here's the output:
% ruby /tmp/x.rb /tmp/x.yaml 1
[]
% ruby /tmp/x.rb /tmp/x.yaml x2
[{"Name"=>"myserv", "Arch"=>"x86", "OS"=>"linux", "Ether"=>2}]
Is there any way to get the select to work without changing the 1
to "1" or using !str every time?
Jim
contains an integer, I get nothing in return. However,
when the node is a string, the select works.
Here's the YAML file:
---------- x.yaml ------------
Domains :
my.domain.com :
Networks :
192.168.0.0-24 :
Hosts :
0 :
Name : net192-168
Ether : NONE
1 :
Name : route192-168
Ether : 00:00:00:00:00:01
Arch : gateway
x2 :
Name : myserv
Ether : 00:00:00:00:00:02
Arch : x86
OS : linux
---------- x.yaml ------------
Here's the ruby script
---------- x.rb ------------
y = File.open(ARGV.shift).read
node = ARGV.shift
p YAML.parse(y).select("/Domains/*/Networks/*/Hosts/#{node}").transform
---------- x.rb ------------
Here's the output:
% ruby /tmp/x.rb /tmp/x.yaml 1
[]
% ruby /tmp/x.rb /tmp/x.yaml x2
[{"Name"=>"myserv", "Arch"=>"x86", "OS"=>"linux", "Ether"=>2}]
Is there any way to get the select to work without changing the 1
to "1" or using !str every time?
Jim