Dallycot

 view release on metacpan or  search on metacpan

lib/Dallycot/AST.pm  view on Meta::CPAN

  return @NODE_TYPES;
}

__PACKAGE__->node_types;

sub new {
  my ($class) = @_;

  $class = ref $class || $class;

  return bless [] => $class;
}

=method simplify

Simplifies the node and any child nodes.

=cut

sub simplify {
  my ($self) = @_;

lib/Dallycot/AST/All.pm  view on Meta::CPAN

use strict;
use warnings;

use utf8;
use parent 'Dallycot::AST::LoopBase';

sub new {
  my ( $class, @exprs ) = @_;

  $class = ref $class || $class;
  return bless \@exprs => $class;
}

sub to_rdf {
  my($self, $model) = @_;

  #
  # node -> expression_set -> [ ... ]
  #
  return $model -> apply(
    $model -> meta_uri('loc:all-true'),

lib/Dallycot/AST/Apply.pm  view on Meta::CPAN

Readonly my $EXPRESSION => 0;
Readonly my $BINDINGS   => 1;
Readonly my $OPTIONS    => 2;

sub new {
  my ( $class, $expression, $bindings, $options ) = @_;

  $class = ref $class || $class;
  $bindings //= [];
  $options  //= {};
  return bless [ $expression, $bindings, $options ] => $class;
}

sub to_rdf {
  my($self, $model) = @_;

  #
  # node -> expression_set -> [ ... ]
  #
  return $model -> apply(
    $self -> [0],

lib/Dallycot/AST/Fetch.pm  view on Meta::CPAN

use Dallycot::Util qw(maybe_promise);

use Promises       qw(deferred);
use Scalar::Util   qw(blessed);

sub new {
  my ( $class, $identifier ) = @_;

  $class = ref $class || $class;

  return bless [$identifier] => $class;
}

sub to_rdf {
  my($self, $model) = @_;

  my $label;

  if(@$self > 1) {
    # need namespace resolution
    my $uri = $model -> uri(join(":", @$self));

lib/Dallycot/AST/Invert.pm  view on Meta::CPAN

use strict;
use warnings;

use utf8;
use parent 'Dallycot::AST';

sub new {
  my ( $class, $expr ) = @_;

  $class = ref $class || $class;
  return bless [$expr] => $class;
}


sub to_rdf {
  my($self, $model) = @_;

  return $model -> apply(
    $model -> meta_uri('loc:invert'),
    [ $self->[0] ],
    {}

lib/Dallycot/AST/Lambda.pm  view on Meta::CPAN

Readonly my $OPTIONS                => 3;

sub new {
  my ( $self, $expr, $bindings, $bindings_with_defaults, $options ) = @_;

  my $class = ref $self || $self;
  $bindings               ||= [];
  $bindings_with_defaults ||= [];
  $options                ||= {};

  return bless [ $expr, $bindings, $bindings_with_defaults, $options ] => $class;
}

sub to_rdf {
  my($self, $model) = @_;

  my $bnode = $model -> bnode;
  $model -> add_type($bnode, 'loc:Algorithm');
  $model -> add_expression($bnode, $self -> [$EXPRESSION]);
  $model -> add_list(
    $bnode, 'loc:bindings',

lib/Dallycot/Parser.pm  view on Meta::CPAN

    bless_package  => 'Dallycot::AST',
    default_action => 'copy_arg0',
    source         => do { local ($/) = undef; my $s = <DATA>; \$s; }
  }
);

sub new {
  my ($class) = @_;

  $class = ref($class) || $class;
  return bless {} => $class;
}

sub grammar { return $grammar; }

sub wants_more {
  my ( $self, $val ) = @_;

  if ( @_ == 2 ) {
    $self->{wants_more} = $val;
  }

lib/Dallycot/Value/HTML.pm  view on Meta::CPAN


  $class = ref $class || $class;

  if ( !blessed($value) ) {
    my $parser = HTML::Parser->new( api_version => 3 );
    $parser->parse($value);
    $parser->eof;
    $value = HTML::Parser->new->parse($value);
  }

  return bless [ $value // '' ] => $class;
}

sub lang { return shift->[1] }

sub id {
  my ($self) = @_;

  return $self->[0] . "@" . $self->[1] . "^^String";
}

lib/Dallycot/Value/JSON.pm  view on Meta::CPAN

Long term, a JSON value will be a JSON-LD document that can be interpreted
as a set of triples. These triples will be stored as a triple-store.

=cut

sub new {
  my( $class, $hash ) = @_;

  $class = ref $class || $class;

  return bless [ $hash ] => $class;
}

sub calculate_length {
  my ( $self, $engine ) = @_;

  my $d = deferred;

  $d->resolve( $engine->make_numeric( $self->_object_size($self->[0]) ) );

  return $d->promise;

lib/Dallycot/Value/Numeric.pm  view on Meta::CPAN

use utf8;
use parent 'Dallycot::Value::Any';

use Promises qw(deferred);

sub new {
  my ( $class, $value ) = @_;

  $class = ref $class || $class;

  return bless [ ref($value) ? $value : Math::BigRat->new($value) ] => $class;
}

sub to_rdf {
  my($self, $model) = @_;

  if($self->[0]->is_int) {
    return $model -> integer($self -> [0] -> bstr);
  }
  elsif($self -> [0] -> is_nan) {
    my $bnode = $model->bnode;

lib/Dallycot/Value/Stream.pm  view on Meta::CPAN


use parent 'Dallycot::Value::Collection';

use experimental qw(switch);

use Promises qw(deferred);

sub new {
  my ( $class, $head, $tail, $promise ) = @_;
  $class = ref $class || $class;
  return bless [ $head, $tail, $promise ] => $class;
}

sub is_defined { return 1 }

sub is_empty {return}

sub to_rdf {
  my($self, $model) = @_;

  my @things;

lib/Dallycot/Value/String.pm  view on Meta::CPAN


use experimental qw(switch);

use Promises qw(deferred);

sub new {
  my ( $class, $value, $lang ) = @_;

  $class = ref $class || $class;

  return bless [ $value // '', $lang // 'en' ] => $class;
}

sub to_rdf {
  my ( $self, $model ) = @_;

  return $model -> string( $self -> value, $self -> lang );
}

sub lang { return shift->[1] }

lib/Dallycot/Value/URI.pm  view on Meta::CPAN


use experimental qw(switch);

sub new {
  my ( $class, $uri ) = @_;

  $class = ref $class || $class;

  $uri = URI->new($uri)->canonical;

  return bless [$uri] => $class;
}

sub to_rdf {
  my( $self, $model ) = @_;

  return RDF::Trine::Node::Resource->new($self->[0]->as_string);
}

sub calculate_length {
  my ( $self, $engine ) = @_;

lib/Dallycot/Value/Vector.pm  view on Meta::CPAN

use warnings;

use utf8;
use parent 'Dallycot::Value::Collection';

use Promises qw(deferred collect);

sub new {
  my ( $class, @values ) = @_;
  $class = ref $class || $class;
  return bless \@values => $class;
}

sub values {
  @{$_[0]};
}

sub is_empty {
  my ($self) = @_;

  return @$self == 0;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.445 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )