Permalink
Browse files

changed 'source' to be a hash not a string

  • Loading branch information...
1 parent 851b39d commit 0e6271d317209cb1373a4b56a62fd14a4ccb3552 @barbie committed Jul 4, 2010
@@ -32,7 +32,6 @@ sub get_info {
for my $cmd (keys %commands) {
$self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
- $self->{info}{source} .= "$commands{$cmd}\n$self->{cmds}{$cmd}\n";
$self->{cmds}{$cmd} =~ s/\s+$//s;
$self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
}
@@ -47,6 +46,7 @@ sub get_info {
$self->{info}{is32bit} = $self->{info}{kname} !~ /64/ ? 1 : 0;
$self->{info}{is64bit} = $self->{info}{kname} =~ /64/ ? 1 : 0;
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
return $self->{info};
}
@@ -35,7 +35,6 @@ sub get_info {
for my $cmd (keys %commands) {
$self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
- $self->{info}{source} .= "$commands{$cmd}\n$self->{cmds}{$cmd}\n";
$self->{cmds}{$cmd} =~ s/\s+$//s;
$self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
}
@@ -48,6 +47,7 @@ sub get_info {
$self->{info}{is32bit} = $self->{info}{kname} !~ /64/ ? 1 : 0;
$self->{info}{is64bit} = $self->{info}{kname} =~ /64/ ? 1 : 0;
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
return $self->{info};
}
@@ -185,7 +185,6 @@ sub get_info {
for my $cmd (keys %commands) {
$self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
- $self->{info}{source} .= "$commands{$cmd}\n$self->{cmds}{$cmd}\n";
$self->{cmds}{$cmd} =~ s/\s+$//s;
$self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
}
@@ -204,6 +203,7 @@ sub get_info {
$self->_release_version();
}
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
return $self->{info};
}
@@ -241,7 +241,8 @@ sub _release_version {
$self->{info}{oslabel} = $oslabel;
$self->{info}{osvers} = $version;
- $self->{info}{source} .= "cat $file\n$line\n";
+ $commands{'_cat'} = "cat $file";
+ $self->{cmds}{'_cat'} = $line;
for my $vers (keys %{ $distributions{$label}->{codenames} }) {
if($version =~ /^$vers\b/) {
@@ -62,10 +62,7 @@ sub _command {
my $command = shift;
my $result = `$command`;
- $self->{info}{source} .= $command;
- $self->{info}{source} .= "\n";
- $self->{info}{source} .= $result;
- $self->{info}{source} .= "\n";
+ $self->{info}{source}{$command} = $result;
chomp $result;
return $result;
@@ -85,7 +82,6 @@ sub _macos_versions {
};
}
-
#-------------------------------------------------------------------------------
1;
@@ -48,21 +48,22 @@ sub get_info {
my $self = shift;
for my $cmd (keys %commands) {
- $self->{info}{$cmd} = `$commands{$cmd}`;
- $self->{info}{source} .= "$commands{$cmd}\n$self->{info}{$cmd}\n";
- $self->{info}{$cmd} =~ s/\s+$//s;
+ $self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
+ $self->{cmds}{$cmd} =~ s/\s+$//s;
+ $self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
}
$self->{info}{osflag} = $^O;
$self->{info}{osname} = 'SCO';
$self->{info}{kernel} = lc($self->{info}{kname}) . '-' . $self->{info}{kvers};
- ($self->{info}{osvers}) = $self->{info}{'_lsb'} =~ /Release\s*=\s*(.*?)\n/s;
+ ($self->{info}{osvers}) = $self->{cmds}{'_lsb'} =~ /Release\s*=\s*(.*?)\n/s;
($self->{info}{oslabel}) = $releases{ $self->{info}{osvers} }->{oslabel};
($self->{info}{codename}) = $releases{ $self->{info}{osvers} }->{codename};
$self->{info}{is32bit} = $self->{info}{archname} !~ /_(64)$/ ? 1 : 0;
$self->{info}{is64bit} = $self->{info}{archname} =~ /_(64)$/ ? 1 : 0;
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
return $self->{info};
}
@@ -33,7 +33,6 @@ sub get_info {
for my $cmd (keys %commands) {
$self->{cmds}{$cmd} = `$commands{$cmd} 2>/dev/null`;
- $self->{info}{source} .= "$commands{$cmd}\n$self->{cmds}{$cmd}\n";
$self->{cmds}{$cmd} =~ s/\s+$//s;
$self->{info}{$cmd} = $self->{cmds}{$cmd} if($cmd =~ /^[^_]/);
}
@@ -51,6 +50,7 @@ sub get_info {
# Question: Anyone know how to get the real version number for OpenSolaris?
# i.e. "2008.05" or "2009.06"
+ $self->{info}{source}{$commands{$_}} = $self->{cmds}{$_} for(keys %commands);
return $self->{info};
}
View
@@ -10,7 +10,11 @@ my $data = $info->get_info();
isnt($data,undef);
diag("OS: $^O");
+
if($data) {
- diag(".. $_ => " . (defined $data->{$_} ? $data->{$_} : '')) for(keys %$data);
+ diag('.. source => ');
+ diag(" .. $_ => " . (defined $data->{source}{$_} ? $data->{source}{$_} : '')) for(sort keys %{$data->{source}});
+
+ diag(".. $_ => " . (defined $data->{$_} ? $data->{$_} : '')) for(grep {!/source/} keys %$data);
}

0 comments on commit 0e6271d

Please sign in to comment.