You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2010/05/29 19:53:01 UTC

svn commit: r949428 - in /lucene/lucy/trunk/perl: lib/Lucy/Index/Snapshot.pm t/binding/206-snapshot.t

Author: marvin
Date: Sat May 29 17:53:01 2010
New Revision: 949428

URL: http://svn.apache.org/viewvc?rev=949428&view=rev
Log:
Add Perl bindings for Snapshot.  (snapshot_perl_binding.patch from LUCY-103)

Added:
    lucene/lucy/trunk/perl/lib/Lucy/Index/Snapshot.pm   (with props)
    lucene/lucy/trunk/perl/t/binding/206-snapshot.t   (with props)

Added: lucene/lucy/trunk/perl/lib/Lucy/Index/Snapshot.pm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/lib/Lucy/Index/Snapshot.pm?rev=949428&view=auto
==============================================================================
--- lucene/lucy/trunk/perl/lib/Lucy/Index/Snapshot.pm (added)
+++ lucene/lucy/trunk/perl/lib/Lucy/Index/Snapshot.pm Sat May 29 17:53:01 2010
@@ -0,0 +1,72 @@
+package Lucy::Index::Snapshot;
+use Lucy;
+
+1;
+
+__END__
+
+__BINDING__
+
+my $synopsis = <<'END_SYNOPSIS';
+    my $snapshot = Lucy::Index::Snapshot->new;
+    $snapshot->read_file( folder => $folder );    # load most recent snapshot
+    my $files = $snapshot->list;
+    print "$_\n" for @$files;
+END_SYNOPSIS
+
+my $constructor = <<'END_CONSTRUCTOR';
+    my $snapshot = Lucy::Index::Snapshot->new;
+END_CONSTRUCTOR
+
+Clownfish::Binding::Perl::Class->register(
+    parcel       => "Lucy",
+    class_name   => "Lucy::Index::Snapshot",
+    bind_methods => [
+        qw(
+            List
+            Num_Entries
+            Add_Entry
+            Delete_Entry
+            Read_File
+            Write_File
+            Set_Path
+            Get_Path
+            )
+    ],
+    bind_constructors => ["new"],
+    make_pod          => {
+        synopsis    => $synopsis,
+        constructor => { sample => $constructor },
+        methods     => [
+            qw(
+                list
+                num_entries
+                add_entry
+                delete_entry
+                read_file
+                write_file
+                set_path
+                get_path
+                )
+        ],
+    },
+);
+
+__COPYRIGHT__
+
+    /**
+     * Copyright 2010 The Apache Software Foundation
+     *
+     * Licensed under the Apache License, Version 2.0 (the "License");
+     * you may not use this file except in compliance with the License.
+     * You may obtain a copy of the License at
+     *
+     *     http://www.apache.org/licenses/LICENSE-2.0
+     *
+     * Unless required by applicable law or agreed to in writing, software
+     * distributed under the License is distributed on an "AS IS" BASIS,
+     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+     * implied.  See the License for the specific language governing
+     * permissions and limitations under the License.
+     */
+

Propchange: lucene/lucy/trunk/perl/lib/Lucy/Index/Snapshot.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lucene/lucy/trunk/perl/t/binding/206-snapshot.t
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/t/binding/206-snapshot.t?rev=949428&view=auto
==============================================================================
--- lucene/lucy/trunk/perl/t/binding/206-snapshot.t (added)
+++ lucene/lucy/trunk/perl/t/binding/206-snapshot.t Sat May 29 17:53:01 2010
@@ -0,0 +1,17 @@
+use strict;
+use warnings;
+use Test::More tests => 4;
+use Lucy::Test;
+
+my $folder   = Lucy::Store::RAMFolder->new;
+my $snapshot = Lucy::Index::Snapshot->new;
+$snapshot->add_entry("foo");
+$snapshot->add_entry("bar");
+ok( $snapshot->delete_entry("bar"), "delete_entry" );
+is_deeply( $snapshot->list, ['foo'], "add_entry, list" );
+$snapshot->write_file( folder => $folder );
+is( $snapshot->read_file( folder => $folder ),
+    $snapshot, "write_file, read_file" );
+$snapshot->set_path("snapfile");
+is( $snapshot->get_path, "snapfile", "set_path, get_path" );
+

Propchange: lucene/lucy/trunk/perl/t/binding/206-snapshot.t
------------------------------------------------------------------------------
    svn:eol-style = native