The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Build.PL 219
Changes 023
META.json 44
META.yml 1212
Makefile.PL 229
eg/votable 11
inc/Astro/SIMBAD/Client/Build.pm 11
inc/Astro/SIMBAD/Client/Test.pm 01
lib/Astro/SIMBAD/Client/WSQueryInterfaceService.pm 11
lib/Astro/SIMBAD/Client.pm 54165
t/simple.t 137
t/vo.t 059
t/yaml.t 036
13 files changed (This is a version diff) 117358
@@ -49,36 +49,23 @@ my %opt = $bldr->args();
 
 my (@exe_files, @clean_files);
 
-print <<eod;
+print <<EOD;
 
 The simbadc script is a simple wrapper for Astro::SIMBAD::Client, which
 may be used interactively or as a Unix filter.
 
->>>> NOTE <<<<\a\a\a
+>>>> NOTICE <<<<\a\a\a
 
-In the first release after September 1 2014 I intend to remove the
-interactive question about whether the simbadc script should be
-installed, and install it by default. The -y and -n command-line options
-will remain available.
+As of version 0.032_01 the simbadc script is installed by default. If
+you do not wish it installed. run this script with the -n option. The -y
+option is still accepted for backward compatibility.
 
-eod
+EOD
 
-if ($opt{n}) {
+if ( $opt{n} ) {
     print "Because you have asserted -n, simbadc will not be installed.\n";
-} elsif ($opt{y}) {
-    print "Because you have asserted -y, simbadc will be installed.\n";
-    push @exe_files, 'simbadc';
 } else {
-    print <<eod;
-To supress the following prompt, run Build.PL with the -y option to
-install the script, or with the -n option to not install the script.
-Setting environment variable PERL_MM_USE_DEFAULT true, or running non-
-interactively without data on STDIN will also cause the script not to
-be installed.
-
-eod
-    $bldr->prompt ("Do you want to install simbadc?", 'n') =~ m/^y/i
-	and push @exe_files, 'simbadc';
+    push @exe_files, 'simbadc';
 }
 
 if ($^O eq 'MSWin32') {
@@ -105,3 +92,4 @@ if ($^O eq 'MSWin32') {
 
 $bldr->create_build_script ();
 
+# ex: set textwidth=72 :
@@ -1,3 +1,26 @@
+0.033		2014-10-25	T. R. Wyant
+  No changes since 0.032_01.
+
+0.032_01	2014-10-18	T. R. Wyant
+  Remove installer question. The simbadc script is now installed by
+    default. If you do not want it, run the installer with the -n
+    option.
+  Restructure data retrieval code to facilitate debugging.
+
+0.032		2014-06-12	T. R. Wyant
+  No changes since version 0.031_01.
+
+0.031_01	2014-06-04	T. R. Wyant
+  Add attribute emulate_soap_queries. If true, this attribute causes the
+    query() method (and friends) to generate canned script queries
+    rather than SOAP queries. If we are not using SOAP, query() and
+    friends do not produce warnings.
+  Eliminate use of each() built-in.
+  Remove VO-format url_query test of MAIN_ID. A note from SIMBAD support
+    January 6 2014 says they do not support any way to change what is in
+    the MAIN_ID field in a url_query VO-format return. It _is_ supported
+    in the script queries.
+
 0.031		2014-02-05	T. R. Wyant
   Have installer scripts Build.PL and Makefile.PL notify of my intent to
     remove the 'install simbadc?' question and simply install it by
@@ -4,7 +4,7 @@
       "Tom Wyant (wyant at cpan dot org)"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "Module::Build version 0.4204",
+   "generated_by" : "Module::Build version 0.421",
    "license" : [
       "perl_5"
    ],
@@ -40,11 +40,11 @@
    "provides" : {
       "Astro::SIMBAD::Client" : {
          "file" : "lib/Astro/SIMBAD/Client.pm",
-         "version" : "0.031"
+         "version" : "0.033"
       },
       "Astro::SIMBAD::Client::WSQueryInterfaceService" : {
          "file" : "lib/Astro/SIMBAD/Client/WSQueryInterfaceService.pm",
-         "version" : "0.031"
+         "version" : "0.033"
       }
    },
    "release_status" : "stable",
@@ -56,5 +56,5 @@
          "http://dev.perl.org/licenses/"
       ]
    },
-   "version" : "0.031"
+   "version" : "0.033"
 }
@@ -3,13 +3,13 @@ abstract: 'Fetch astronomical data from SIMBAD 4.'
 author:
   - 'Tom Wyant (wyant at cpan dot org)'
 build_requires:
-  Test::More: 0.88
+  Test::More: '0.88'
 dynamic_config: 1
-generated_by: 'Module::Build version 0.4204, CPAN::Meta::Converter version 2.133380'
+generated_by: 'Module::Build version 0.421, CPAN::Meta::Converter version 2.142690'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
+  version: '1.4'
 name: Astro-SIMBAD-Client
 no_index:
   directory:
@@ -19,18 +19,18 @@ no_index:
 provides:
   Astro::SIMBAD::Client:
     file: lib/Astro/SIMBAD/Client.pm
-    version: 0.031
+    version: '0.033'
   Astro::SIMBAD::Client::WSQueryInterfaceService:
     file: lib/Astro/SIMBAD/Client/WSQueryInterfaceService.pm
-    version: 0.031
+    version: '0.033'
 requires:
-  HTTP::Request::Common: 0
-  LWP::UserAgent: 0
-  Scalar::Util: 1.01
-  URI::Escape: 0
-  XML::DoubleEncodedEntities: 1
-  perl: 5.008
+  HTTP::Request::Common: '0'
+  LWP::UserAgent: '0'
+  Scalar::Util: '1.01'
+  URI::Escape: '0'
+  XML::DoubleEncodedEntities: '1'
+  perl: '5.008'
 resources:
   bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Astro-SIMBAD-Client
   license: http://dev.perl.org/licenses/
-version: 0.031
+version: '0.033'
@@ -23,37 +23,23 @@ Astro::SIMBAD::Client::Recommend->recommend();
 
 my (@exe_files, @clean_files);
 
-print <<eod;
+print <<EOD;
 
 The simbadc script is a simple wrapper for Astro::SIMBAD::Client, which
 may be used interactively or as a Unix filter.
 
->>>> NOTE <<<<\a\a\a
+>>>> NOTICE <<<<\a\a\a
 
-In the first release after September 1 2014 I intend to remove the
-interactive question about whether the simbadc script should be
-installed, and install it by default. The -y and -n command-line options
-will remain available.
+As of version 0.032_01 the simbadc script is installed by default. If
+you do not wish it installed. run this script with the -n option. The -y
+option is still accepted for backward compatibility.
 
-eod
+EOD
 
-if ($opt{n}) {
+if ( $opt{n} ) {
     print "Because you have asserted -n, simbadc will not be installed.\n";
-} elsif ($opt{y}) {
-    print "Because you have asserted -y, simbadc will be installed.\n";
-    push @exe_files, 'simbadc';
 } else {
-    print <<eod;
-To supress the following prompt, run Makefile.PL with the -y option to
-install the script, or with the -n option not to install the script.
-Setting environment variable PERL_MM_USE_DEFAULT true, or running non-
-interactively without data on STDIN will also cause the script not to be
-installed.
-
-eod
-    
-    prompt ("Do you want to install simbadc?", 'n') =~ m/^y/i
-	and push @exe_files, 'simbadc';
+    push @exe_files, 'simbadc';
 }
 
 if ($^O eq 'MSWin32') {
@@ -115,3 +101,4 @@ $mmv >= 6.5501
 
 WriteMakefile (%attr);
 
+# ex: set textwidth=72 :
@@ -7,7 +7,7 @@ use Astro::SIMBAD::Client;
 use Getopt::Long 2.33;
 use Pod::Usage;
 
-our $VERSION = '0.031';
+our $VERSION = '0.033';
 
 my %opt;
 
@@ -5,7 +5,7 @@ use warnings;
 
 use base qw{ Module::Build };
 
-our $VERSION = '0.031';
+our $VERSION = '0.033';
 
 use Carp;
 
@@ -27,6 +27,7 @@ our @EXPORT_OK = qw{
     load_module
     load_module_or_skip_all
     module_loaded
+    note
     plan
     returned_value
     silent
@@ -9,7 +9,7 @@ package Astro::SIMBAD::Client::WSQueryInterfaceService;
 use strict;
 use warnings;
 
-our $VERSION = '0.031';
+our $VERSION = '0.033';
 ## TRW ^^^^
 
 my %methods = (
@@ -14,26 +14,30 @@ As of release 0.027_01 the SOAP interface is deprecated. The
 University of Strasbourg has announced that this interface will not be
 supported after April 1 2014.
 
-The deprecation schedule for this module is as follows:
-
-=over
-
-=item First release of 2014 (0.030)
-
-Every use of the SOAP interface will generate a warning.
-
-=item First release after April 1 2014
-
-Every use of the SOAP interface will generate a fatal error.
-
-=item First release after July 1 2014
-
-SOAP code will be removed.
-
-=back
-
-Also effective immediately, all tests of the SOAP interface are marked
-TODO.
+Because the SOAP interface is still sort of functional (except for
+VO-format queries) as of June 4 2014, I have revised the transition plan
+announced with the release of 0.027_01 on October 28 2014.
+
+What I have done as of version 0.031_01 is to add attribute
+C<emulate_soap_queries>. This is false by default. If this attribute is
+true, the C<query()> method and friends, instead of issuing a SOAP
+request to the SIMBAD server, will instead construct an equivalent
+script query, and issue that. The deprecation warning will not be issued
+if C<emulate_soap_queries> is true, since the SOAP interface is not
+being used.
+
+I intend to make the default value of C<emulate_soap_queries> true in
+the first release on or after October 1 2014, assuming SOAP queries work
+for that long.
+
+When the SOAP servers go out of service (and I notice) SOAP queries will
+become fatal, and the default value of C<emulate_soap_queries> will
+become true if it is not already.
+
+Eventually the SOAP code will be removed. In the meantime all tests are
+marked TODO, and support of SOAP by this module will be on a best-effort
+basis; that is, if I can make it work without a huge amount of work I
+will -- otherwise SOAP will become unsupported.
 
 =head1 DESCRIPTION
 
@@ -106,7 +110,7 @@ BEGIN {
 	|| sub { return $_[0] };
 }
 
-our $VERSION = '0.031';
+our $VERSION = '0.033';
 
 our @CARP_NOT = qw{Astro::SIMBAD::Client::WSQueryInterfaceService};
 
@@ -175,6 +179,7 @@ my %static = (
     autoload => 1,
     debug => 0,
     delay => 3,
+    emulate_soap_queries	=> 0,
     format => {
 	txt => FORMAT_TXT_YAML_BASIC,
 	vo => FORMAT_VO_BASIC,
@@ -575,20 +580,58 @@ C<Astro::SIMBAD::Client> is installed.
     );
 
     my %transform = (
-	txt => sub {local $_ = $_[0]; s/\n//gm; $_},
+	txt => sub {
+	    local $_ = $_[0];
+	    s/\n//gm;
+	    return $_
+	},
 	vo => sub {
 	    local $_ = ref $_[0] ? join (',', @{$_[0]}) : $_[0];
-	    s/\s+/,/gms;
-	    s/^,+//;
-	    s/,+$//;
-	    s/,+/,/g;
-	    $_
+	    if ( defined $_ ) {
+		s/\s+/,/gms;
+		s/^,+//;
+		s/,+$//;
+		s/,+/,/g;
+	    }
+	    return $_
 	},
     );
 
+    my %make_script = (
+	txt	=> sub {
+	    my ( $self, $query, @args ) = @_;
+	    return <<"EOD";
+format object "@{[ $transform{txt}->( $self->get( 'format' )->{txt} ) ]}"
+query $query @args
+EOD
+	},
+	vo	=> sub {
+	    my ( $self, $query, @args ) = @_;
+	    return <<"EOD";
+votable myvo {
+@{[ $transform{vo}->( $self->get( 'format' )->{vo} ) ]}
+}
+votable open myvo
+query $query @args
+votable close myvo
+EOD
+	},
+    );
 
     sub query {
-	my ($self, $query, @args) = @_;
+	my ( $self, $query, @args ) = @_;
+	if ( $self->get( 'emulate_soap_queries' ) ) {
+	    my $type = $self->get( 'type' );
+	    my $code = $make_script{$type} || sub {
+		my ( $self, $query, @args ) = @_;
+		return "query $query @args\n";
+	    };
+	    return $self->_script(
+		parser	=> $type,
+		script	=> $code->( $self, $query, @args ),
+		verbatim	=> 0,
+	    );
+	}
 	$self->_deprecation_notice( method => 'query', 'a non-SOAP method' );
 	eval { _load_module( 'SOAP::Lite' ); 1 }
 	    or croak 'Error - query() requires SOAP::Lite';
@@ -627,6 +670,7 @@ C<Astro::SIMBAD::Client> is installed.
 
 }	# End local symbol block.
 
+
 =item $value = $simbad->queryObjectByBib ($bibcode, $format, $type);
 
 This method is B<deprecated>, and will cease to work in April 2014.
@@ -760,31 +804,79 @@ to the caller.
 
 sub script {
     my ( $self, $script ) = @_;
-    my $server = $self->get ('server');
-
-    my $url = "http://$server/simbad/sim-script";
+    return $self->_script(
+	parser	=> 'script',
+	script	=> $script,
+	verbatim	=> $self->get( 'verbatim' ),
+    );
+}
 
-    my $resp = $self->_retrieve( $url, {
-	    submit	=> 'submit+script',
-	    script	=> $script,
+{
+    my %dflt = (
+	parser	=> sub { return 'script' },
+	script	=> sub {
+	    confess 'Programming error - script argument required';
+	},
+	verbatim	=> sub {
+	    my ( $self ) = @_;
+	    return $self->get( 'verbatim' );
 	},
     );
 
-    $resp->is_success or croak $resp->status_line;
+    sub _script {
+	my ( $self, %arg ) = @_;
 
-    my $rslt = $resp->content or return;
-    unless ($self->get ('verbatim')) {
-	$rslt =~ s/.*?::data:+\s*//sm or croak $rslt;
-    }
-    $rslt = XML::DoubleEncodedEntities::decode ($rslt);
-    if (my $parser = $self->_get_parser ('script')) {
-##	$rslt =~ s/.*?::data:+.?$//sm or croak $rslt;
-	my @rslt = $parser->($rslt);
-	return wantarray ? @rslt : \@rslt;
-    } else {
-	return $rslt;
-    }
+	foreach my $key ( keys %dflt ) {
+	    defined $arg{$key}
+		or $arg{$key} = $dflt{$key}->( $self );
+	}
+
+	my $debug = $self->get( 'debug' );
+
+	my $server = $self->get ('server');
+
+	my $url = "http://$server/simbad/sim-script";
+
+	$debug
+	    and warn "Debug - script\n$arg{script} ";
+
+	my $resp = $self->_retrieve( $url, {
+		submit	=> 'submit+script',
+		script	=> $arg{script},
+	    },
+	);
 
+	$resp->is_success
+	    or croak $resp->status_line;
+
+	my $rslt = $resp->content
+	    or return;
+
+	unless ( $arg{verbatim} ) {
+	    $rslt =~ s/.*?::data:+\s*//sm or croak $rslt;
+	}
+
+	$debug
+	    and warn "Debug - result:\n$rslt ";
+
+	$rslt = XML::DoubleEncodedEntities::decode( $rslt );
+	if ( my $parser = $self->_get_parser( $arg{parser} ) ) {
+	    $debug
+		and warn "Debug - Parser $arg{parser}";
+	    ## $rslt =~ s/.*?::data:+.?$//sm or croak $rslt;
+	    my @rslt = $parser->($rslt);
+	    $debug
+		and eval {	## no critic (RequireCheckingReturnValueOfEval)
+		require YAML;
+		warn "Debug - Parsed to:\n", YAML::Dump( \@rslt ), ' ';
+	    };
+	    return wantarray ? @rslt : \@rslt;
+	} else {
+	    $debug
+		and warn "Debug - No parser for $arg{parser}";
+	    return $rslt;
+	}
+    }
 }
 
 
@@ -977,10 +1069,7 @@ onto the end of the URL and a GET is done.
 	txt	=> 'ASCII',
 	vo	=> 'VOTable',
     );
-    my %type_unmap;
-    while (my ($key, $value) = each %type_map) {
-	$type_unmap{$value} = $key;
-    }
+    my %type_unmap = reverse %type_map;
 
     # Perl::Critic objects to the use of @_ (rather than values 
     # unpacked from it) but the parity check lets me give a less
@@ -1239,11 +1328,12 @@ sub _retrieve {
     my $debug = $self->get ('debug');
     my $ua = _get_user_agent ();
     $self->_delay ();
+    my $resp;
     if (eval {$url->isa('HTTP::Request')}) {
 	$debug
 	    and print 'Debug ', _callers_caller(), 'executing ',
 		$url->as_string, "\n";
-	return $ua->request ($url);
+	$resp = $ua->request ($url);
     } elsif ($self->get ('post') && %$args) {
 	if ($debug) {
 	    print 'Debug ', _callers_caller(), " posting to $url\n";
@@ -1251,7 +1341,7 @@ sub _retrieve {
 		print "    $key => $args->{$key}\n";
 	    }
 	}
-	return $ua->post ($url, $args);
+	$resp = $ua->post ($url, $args);
     } else {
 	my $join = '?';
 	foreach my $key (sort keys %$args) {
@@ -1261,8 +1351,11 @@ sub _retrieve {
 	}
 	$debug
 	    and print 'Debug ', _callers_caller(), " getting from $url\n";
-	return $ua->get( $url );
+	$resp = $ua->get( $url );
     }
+    $debug
+	and print 'Debug - request: ', $resp->request()->as_string(), "\n";
+    return $resp;
 }
 
 1;
@@ -1322,6 +1415,8 @@ that the author makes no claim what will happen if it is non-zero.
 
 The default value is 0.
 
+=for html <a name="delay"></a>
+
 =item delay (integer)
 
 This attribute sets the minimum delay in seconds between requests, so as
@@ -1335,6 +1430,22 @@ negative number.
 
 The default is 3.
 
+=for html <a name="emulate_soap_queries">
+
+=item emulate_soap_queries (boolean)
+
+If this attribute is true, the methods that would normally use the SOAP
+interface (that is, C<query()> and friends) use the script interface
+instead.
+
+The purpose of this attribute is to give the user a way to manage the
+deprecation and ultimate removal of the SOAP interface from the SIMBAD
+servers. It may go away once that interface disappears, but it will be
+put through a deprecation cycle.
+
+The default is false, but will become true once the University of
+Strasbourg shuts down its SOAP server.
+
 =for html <a name="format"></a>
 
 =item format (hash)
@@ -58,7 +58,6 @@ EOD
 	'query id Arcturus (txt) - radial velocity in recession';
 }
 
-
 clear;
 call set => parser => 'script=Parse_TXT_Simple';
 
@@ -139,6 +138,43 @@ deref 0, 'radial';
 test canned( arcturus => 'radial' ),
     'script_file t/arcturus.simple - radial velocity in recession';
 
+clear;
+echo <<'EOD';
+
+The following tests use the script interface to SIMBAD to emulate the
+SOAP interface.
+
+EOD
+
+call set => emulate_soap_queries => 1;
+
+call query => id => 'Arcturus';
+count;
+test 1, 'query id Arcturus (txt) - number of objects returned';
+
+deref 0, 'name';
+test canned( arcturus => 'name' ), 'query id Arcturus (txt) - name';
+
+deref 0, 'ra';
+test canned( arcturus => 'ra' ), 'query id Arcturus (txt) - right ascension';
+
+deref 0, 'dec';
+test canned( arcturus => 'dec' ), 'query id Arcturus (txt) - declination';
+
+deref 0, 'plx';
+test canned( arcturus => 'plx' ), 'query id Arcturus (txt) - parallax';
+
+deref 0, 'pmra';
+test canned( arcturus => 'pmra' ),
+    'query id Arcturus (txt) - proper motion in right ascension';
+
+deref 0, 'pmdec';
+test canned( arcturus => 'pmdec' ),
+    'query id Arcturus (txt) - proper motion in declination';
+
+deref 0, 'radial';
+test canned( arcturus => 'radial' ),
+    'query id Arcturus (txt) - radial velocity in recession';
 
 end;
 
@@ -126,6 +126,16 @@ deref 0, 'data';
 count;
 test 1, 'url_query id arcturus (vo) - count of rows';
 
+note <<'EOD';
+
+We do not test for the MAIN_ID when using the url interface. A note from
+SIMBAD support on February 6 2014 says that there is no way to influence
+what SIMBAD returns in a url VO-format query.
+
+EOD
+
+=begin comment
+
 TODO: {
 
     local $TODO = 'Return changed Feb 3 2014. Unable to influence.';
@@ -137,6 +147,10 @@ TODO: {
     # script-based VO-format querues (I used catalog LFT, picked at
     # random). But the VO-format URL query seems insensitive to this. I
     # sent a note to SIMBAD on February 5 2014, and made this a TODO.
+    #
+    # The above-mentioned note says the most recent change in the data
+    # for Arcturus was February 4 2014, which of course does not rule
+    # out a change on the 3rd.
 
     deref 0, data => 0;
     find meta => 1, name => 'MAIN_ID';
@@ -145,6 +159,10 @@ TODO: {
 
 }
 
+=end comment
+
+=cut
+
 deref 0, data => 0;
 find meta => 1, name => 'RA_d';
 deref_curr 'value';
@@ -202,6 +220,47 @@ deref_curr 'value';
 test canned( arcturus => 'radial' ),
     'url_query id Arcturus (vo) - radial velocity';
 
+call set => emulate_soap_queries => 1;
+clear;
+
+echo <<'EOD';
+
+The following tests use the script interface, but emulate SOAP queries.
+EOD
+
+call query => id => 'Arcturus';
+
+count;
+test 1, 'query id Arcturus (vo) - count of tables';
+
+deref 0, 'data';
+count;
+test 1, 'query id arcturus (vo) - count of rows';
+
+deref 0, data => 0, 0, 'value';
+test canned( arcturus => 'name' ), 'query id Arcturus (vo) - name';
+
+deref 0, data => 0, 2, 'value';
+test canned( arcturus => 'ra' ), 'query id Arcturus (vo) - right ascension';
+
+deref 0, data => 0, 3, 'value';
+test canned( arcturus => 'dec' ), 'query id Arcturus (vo) - declination';
+
+deref 0, data => 0, 4, 'value';
+test canned( arcturus => 'plx' ), 'query id Arcturus (vo) - parallax';
+
+deref 0, data => 0, 5, 'value';
+test canned( arcturus => 'pmra' ),
+    'query id Arcturus (vo) - proper motion in right ascension';
+
+deref 0, data => 0, 6, 'value';
+test canned( arcturus => 'pmdec' ),
+    'query id Arcturus (vo) - proper motion in declination';
+
+deref 0, data => 0, 7, 'value';
+test canned( arcturus => 'radial' ),
+    'query id Arcturus (vo) - radial velocity';
+
 end;
 
 
@@ -166,7 +166,43 @@ deref 0, 'radial';
 test canned( arcturus => 'radial' ),
     'script_file t/arcturus.yaml - radial velocity in recession';
 
+clear;
+module_loaded 'YAML', call => set => parser => 'txt=YAML::Load';
+call set => emulate_soap_queries => 1;
+
+echo <<'EOD';
+
+The following tests use the script interface, but emulate SOAP.
+EOD
+
+call query => id => 'Arcturus';
+
+count;
+test 1, 'query id Arcturus (txt) - number of objects returned';
+
+deref 0, 'name';
+test canned( arcturus => 'name' ), 'query id Arcturus (txt) - name';
+
+deref 0, 'ra';
+test canned( arcturus => 'ra' ), 'query id Arcturus (txt) - right ascension';
 
+deref 0, 'dec';
+test canned( arcturus => 'dec' ), 'query id Arcturus (txt) - declination';
+
+deref 0, 'plx';
+test canned( arcturus => 'plx' ), 'query id Arcturus (txt) - parallax';
+
+deref 0, 'pm', 0;
+test canned( arcturus => 'pmra' ),
+    'query id Arcturus (txt) - proper motion in right ascension';
+
+deref 0, 'pm', 1;
+test canned( arcturus => 'pmdec' ),
+    'query id Arcturus (txt) - proper motion in declination';
+
+deref 0, 'radial';
+test canned( arcturus => 'radial' ),
+    'query id Arcturus (txt) - radial velocity in recession';
 
 end;