Chorus
view release on metacpan or search on metacpan
- eca/skills/: chorus-pdf, chorus-feed, chorus-check, chorus-create-project,
chorus-import-project, chorus-strengthen skills added
- lib/Chorus/Engine/AIAgent.pod : AI agent integration reference added
(replaces ECA.pod; tool-neutral, covers all six chorus-* commands)
- Tests: t/28-Engine-addrule-dedup.t, t/29-Engine-yaml-aliases.t,
t/30-Engine-logging.t, t/31-Frame-fselect.t, t/32-Frame-on-delete.t,
t/33-Frame-complete.t, t/34-Frame-alternatives.t added
(total: 25 test files, 170 assertions)
1.03 2015-12-14
- Some tests added (Chorus::Frame : get - set - delete - getZ - getN - fmatch - weaken
- Frame method inherits() renamed to _inherits()
- bug 90530 : fixed - pod test only if $ENV{AUTHOR_TESTING}
1.02 2013-12-18
- Chorus::Frame : DESTROY debbuged (unblessed reference)
- Chorus::Frame : method _inherits() added
- Chorus::Frame : fmatch() new syntax fmatch(slot => 'SLOT_NAME') or fmatch(slot => ['SLOT1_NAME', 'SLOT2_NAME'])
- Chorus::Frame : fmatch() optimized with %INSTANCES
- Chorus::Frame : _push() method added
- Chorus::Frame : bug fixed with set + multiple inheritance
sandboxes/demo_en/run.pl
sandboxes/README.md
t/00-load.t
t/02-manifest.t
t/03-pod.t
t/10-Frame-get.t
t/12-Frame-set.t
t/13-Frame-delete.t
t/14-Frame-getZ-getN.t
t/15-Frame-fmatch.t
t/16-Frame-weaken.t
t/17-Frame-cow.t
t/20-Engine-loop.t
t/21-Expert.t
t/22-Collection-List.t
t/23-Collection-Filter.t
t/24-Engine-codeRule.t
t/25-Expert-construction.t
t/26-Frame-reset.t
t/27-Engine-terminal.t
t/28-Engine-addrule-dedup.t
lib/Chorus/Frame.pm view on Meta::CPAN
@EXPORT = qw($SELF &fmatch &fselect &setMode REQUIRE_FAILED );
@EXPORT_OK = qw();
# %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ];
}
use strict;
use warnings;
use Carp; # warn of errors (from perspective of caller)
use Digest::MD5;
use Scalar::Util qw(weaken);
use constant DEBUG_MEMORY => 0;
use vars qw($AUTOLOAD);
use constant SUCCESS => 1;
use constant FAILED => 0;
use constant REQUIRE_FAILED => -1;
use constant VALUATION_ORDER => ('_VALUE', '_DEFAULT', '_NEEDED');
lib/Chorus/Frame.pm view on Meta::CPAN
$this->{$slot} = [ defined($this->{$slot}) ? ($this->{$slot}) : () ] unless ref($this->{$slot}) eq 'ARRAY';
push @{$this->{$slot}}, @elems;
}
sub _addInstance {
my ($this, $instance) = @_;
my $k = $instance->{_KEY};
$INSTANCES{$this->{_KEY}}->{$k} = $instance;
# weaken($INSTANCES{$instance); # TOCHECK - does the SAME !!??
#
weaken($INSTANCES{$this->{_KEY}}->{$k}); # Will not increase garbage ref counter to $instance !!
}
=head2 _inherits
Adds one or more parent frames to the inheritance chain outside the constructor.
Each parent is added at most once; duplicates are silently ignored.
$frame->_inherits($parent1, $parent2);
Used internally by C<Chorus::Engine::new()> to wire agent instances to the engine
prototype.
=cut
sub _inherits {
my ($this, @inherited) = @_;
my $k = $this->{_KEY};
for (grep { ! $INSTANCES{$_->{_KEY}}->{$k} } @inherited) { #Â clean list
$_->_addInstance($this); # will use weaken on
$this->_push('_ISA', $_);
}
return $this;
}
sub _removeInstance {
my ($this, $instance) = @_;
my $k = $instance->{_KEY};
(warn "Instance NOT FOUND !?", return) unless $INSTANCES{$this->{_KEY}}->{$k};
delete $INSTANCES{$this->{_KEY}}->{$k};
lib/Chorus/Frame.pm view on Meta::CPAN
do { $k = Digest::MD5::md5_base64(rand) } while exists($FMAP{$k});
foreach my $slot (keys(%$this)) { # register all slots # not yet _KEY
$REPOSITORY{$slot} = {} unless exists $REPOSITORY{$slot};
$REPOSITORY{$slot}->{$k} = 'Y';
}
$this->{_KEY} = $k; # _KEY SET HERE !!
$FMAP{$k} = $this;
weaken($FMAP{$k}); # will not increase garbage ref counter to $this !!
return $this;
}
sub _blessToFrameRec {
local $_ = shift;
if (_isa($_,'Chorus::Frame')) {
while(my ($k, $val) = each %$_) {
if (_isa($val,'HASH')) { # Warn - Will convert all hash tables to Chorus::Frame -> be carefull with function ref() !!
next if $val->{_NOFRAME};
t/16-Frame-weaken.t view on Meta::CPAN
sub set_weak_frame {
my $f = Chorus::Frame->new(
WEAK_FRAME => 'Y'
);
}
sub test_weaken {
set_weak_frame();
return undef if fmatch(slot => 'WEAK_FRAME');
return 1;
}
ok(test_weaken, 'test weaken');
done_testing();
( run in 0.746 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )