view release on metacpan or search on metacpan
devel/closed-form.pl view on Meta::CPAN
sub new {
my ($class, %option) = @_;
my $array = delete $option{'array'} || die;
$option{'hi'} = $#$array;
$option{'name'} //= 'Const';
$option{'timebase'} ||= do {
require App::Chart::Timebase::Days;
App::Chart::Timebase::Days->new_from_iso ('2008-07-23')
};
return $class->SUPER::new (arrays => { values => $array },
%option);
}
sub fill_part {}
devel/makefile-from-grep.pl view on Meta::CPAN
sub requires {
my $self = shift;
if (@_) {
# store
my $trace = Devel::StackTrace->new;
my $frame = $trace->frame(2)
|| die "oops, no frame(2):\n$trace";
my %writeargs = $frame->args;
$self->{'extra_meta'} = $writeargs{'EXTRA_META'};
}
return $self->SUPER::requires (@_);
}
doc/weights.pl view on Meta::CPAN
sub new {
my ($class, %option) = @_;
my $array = delete $option{'array'} || die;
$option{'hi'} = $#$array;
$option{'name'} //= 'Const';
$option{'timebase'} ||= do {
require App::Chart::Timebase::Days;
App::Chart::Timebase::Days->new_from_iso ('2008-07-23')
};
return $class->SUPER::new (arrays => { values => $array },
%option);
}
sub fill_part {}
__END__
inc/MyMakeMakerGettext.pm view on Meta::CPAN
# sub shell_quote {
# my ($str) = @_;
# $str =~ s/[\\']/\\$1/;
# return "'$str'";
# }
# this didn't work, or something ...
#
# sub MY::special_targets {
# my $makemaker = shift;
# my $inherited = $makemaker->SUPER::special_targets(@_);
# $inherited =~ s/^\.SUFFIXES *:/$& .mo .po/
# or die "Oops, couldn't add to .SUFFIXES";
# # $inherited =~ s/^\.PHONY *:/$& mo pot/
# # or die "Oops, couldn't add to .PHONY";
# return $inherited;
# }
1;
__END__
lib/App/Chart/Annotation.pm view on Meta::CPAN
$id,
$self->{'price'},
$self->{'above'});
update_alert ($symbol);
});
App::Chart::chart_dirbroadcast()->send ('data-changed', { $symbol => 1 });
}
sub delete {
my ($self) = @_;
$self->SUPER::delete;
App::Chart::Annotation::Alert::update_alert ($self->{'symbol'});
}
sub draw {
my ($self, $graph, $region) = @_;
App::Chart::Gtk2::Graph::Plugin::Alerts->draw ($graph, $region, [ $self ]);
}
sub update_alert {
my ($symbol) = @_;
lib/App/Chart/DownloadHandler/DividendsPage.pm view on Meta::CPAN
use constant DEFAULT_DIVIDENDS_CHECK_DAYS => 3;
sub new {
my ($class, %options) = @_;
$options{'name'} or croak "missing name for ".__PACKAGE__;
$options{'key'} or croak "missing key for ".__PACKAGE__;
$options{'url'} or croak "missing url for ".__PACKAGE__;
$options{'recheck_days'} ||= DEFAULT_DIVIDENDS_CHECK_DAYS;
return $class->SUPER::new (%options,
proc => \÷nds_download,
proc_with_self => 1,
recheck_key => $options{'key'} . '-timestamp');
}
sub dividends_download {
my ($self, $symbol_list) = @_;
my $pred = $self->{'pred'};
my $key = $self->{'key'};
lib/App/Chart/DownloadHandler/IndivChunks.pm view on Meta::CPAN
use App::Chart;
use App::Chart::Download;
sub new {
my ($class, %options) = @_;
$options{'name'} or croak "missing name for ".__PACKAGE__;
$options{'chunk_size'} or croak "missing chunk_size for ".__PACKAGE__;
$options{'url_func'} or croak "missing url_func for ".__PACKAGE__;
return $class->SUPER::new (%options,
proc => \&indivchunks_download,
backto => \&backto,
proc_with_self => 1);
}
sub indivchunks_download {
my ($self, $symbol_list) = @_;
my $allow_http_codes = $self->{'allow_http_codes'} // [404];
foreach my $symbol (@$symbol_list) {
lib/App/Chart/DownloadHandler/IndivInfo.pm view on Meta::CPAN
use constant DEFAULT_INFO_CHECK_DAYS => 10;
sub new {
my ($class, %options) = @_;
$options{'name'} or croak "missing name for ".__PACKAGE__;
$options{'key'} or croak "missing key for ".__PACKAGE__;
$options{'url_func'} or croak "missing chunk_size for ".__PACKAGE__;
$options{'recheck_days'} ||= DEFAULT_INFO_CHECK_DAYS;
return $class->SUPER::new (%options,
proc => \&indivinfo_download,
proc_with_self => 1,
recheck_key => $options{'key'} . '-timestamp',
max_symbols => 1);
}
sub indivinfo_download {
my ($self, $symbol_list) = @_;
my $symbol = $symbol_list->[0];
lib/App/Chart/Gtk2/Ex/GdkColorAlloc.pm view on Meta::CPAN
$color_to_colormap{refaddr($self)} = $colormap;
return $self;
}
sub DESTROY {
my ($self) = @_;
if (my $colormap = delete $color_to_colormap{refaddr($self)}) {
$colormap->free_colors ($self);
}
### DESTROY leaves color_to_colormap: \%color_to_colormap
$self->SUPER::DESTROY;
}
sub colormap {
my ($self) = @_;
### in color_to_colormap: \%color_to_colormap
return $color_to_colormap{refaddr($self)};
}
1;
lib/App/Chart/Gtk2/Ex/ListStore/DragByCopy.pm view on Meta::CPAN
dragged.
If you want to impose extra conditions on dragging you can write your own
versions of these functions and chain up. For example if only the first
three rows of the model are draggable then
sub ROW_DRAGGABLE {
my ($self, $path) = @_;
my ($index) = $path->get_indices;
if ($index >= 3) { return 0; } # not draggable
return $self->SUPER::ROW_DRAGGABLE ($path);
}
=item C<< $bool = ROW_DROP_POSSIBLE ($liststore, $dst_path, $selection) >>
=item C<< $bool = DRAG_DATA_RECEIVED ($self, $dst_path, $selection) >>
The drop methods accept a row from any TreeModel. They get the row data
with C<< $src->get >> and store it with C<< $dst->insert_with_values >>.
=back
lib/App/Chart/Gtk2/Ex/ToplevelSingleton.pm view on Meta::CPAN
# }
# }
# use Class::Singleton 1.04; # 1.04 for has_instance()
# use base 'Class::Singleton';
#
# sub instance {
# my $class = shift;
# return $class->has_instance
# || do {
# my $instance = $class->SUPER::instance;
# $instance->signal_connect (destroy => \&_do_destroy, $ivar);
# $instance
# };
# }
#
# sub _do_destroy {
# my ($instance, $ivar) = @_;
# if (($instance->has_instance || 0) == $instance) {
# undef $ivar;
# }
lib/App/Chart/Gtk2/Ex/TreePath/Circular.pm view on Meta::CPAN
sub goto_index {
my ($self, $index) = @_;
$self->up;
$self->append_index ($index || 0);
}
sub next {
my ($self, $model) = @_;
if (! $model) { croak "TreePath::Circular next needs the tree model"; }
$self->SUPER::next;
my ($cur_index) = $self->get_indices;
my $rows = $model->iter_n_children (undef);
if ($cur_index >= $rows) {
$self->goto_index (0);
}
}
sub prev {
my ($self, $model) = @_;
if (! $model) { croak "TreePath::Circular next needs the tree model"; }
if (! $self->SUPER::prev) {
# was at position 0, wrap to end
$self->goto_index (max (0, $model->iter_n_children (undef) - 1));
}
}
sub row_inserted {
my ($self, $model, $ins_path, $ins_iter) = @_;
my ($cur_index) = $self->get_indices;
my ($ins_index) = $ins_path->get_indices;
# if inserted before current then advance
lib/App/Chart/Gtk2/Ex/TreePath/Subclass.pm view on Meta::CPAN
use strict;
use warnings;
use Gtk2;
# not "use base 'Gtk2::TreePath'" here because base.pm complains that
# Gtk2::TreePath is empty -- until it's autoloaded or something, presumably
our @ISA = ('Gtk2::TreePath');
sub new {
my $class = shift;
my $self = $class->SUPER::new (@_);
return bless $self, $class; # rebless
}
sub new_first {
my $class = shift;
my $self = $class->SUPER::new_first (@_);
return bless $self, $class; # rebless
}
sub new_from_indices {
my $class = shift;
my $self = $class->SUPER::new_from_indices (@_);
return bless $self, $class; # rebless
}
sub new_from_string {
my $class = shift;
my $self = $class->SUPER::new_from_string (@_);
# can return undef if string is bad
return $self && bless $self, $class; # rebless
}
1;
__END__
=for stopwords TreePath reblessing subclassing subclasses Gtk2-Perl Ryde multi-inheritance Gtk
lib/App/Chart/Gtk2/IntradaySave.pm view on Meta::CPAN
'', # default
Glib::G_PARAM_READWRITE)];
use constant { RESPONSE_REFRESH => 0,
RESPONSE_CROSS => 1 };
sub new {
my $class = shift;
# pending support for object "constructor" thingie
$class->SUPER::new (action => 'save', @_);
}
sub INIT_INSTANCE {
my ($self) = @_;
$self->{'symbol'} = ''; # defaults
$self->{'mode'} = '';
$self->set_title (__('Chart: Save Intraday Image'));
$self->add_buttons ('gtk-save' => 'accept',
'gtk-cancel' => 'cancel',
lib/App/Chart/Gtk2/Job/Download.pm view on Meta::CPAN
my $name;
if ($when) {
@when = ('--backto', $when);
$name = __x('Download {what} backto {year}',
what => $what,
year => $when);
} else {
$name = __x('Download {what}',
what => $what);
}
my $job = $class->SUPER::start (args => [ 'download', @when, $what ],
name => $name);
return $job;
}
sub type {
return __('Download');
}
1;
__END__
lib/App/Chart/Gtk2/Job/Intraday.pm view on Meta::CPAN
}
sub start {
my ($class, $symbol, $mode) = @_;
if (my $job = $class->find ($symbol, $mode)) {
if ($job->is_stoppable) {
### still running: $job, $symbol, $mode
return $job;
}
}
return $class->SUPER::start (args => [ 'intraday', $symbol, $mode ],
name => __x('Intraday {symbol} {mode}',
symbol => $symbol,
mode => $mode),
symbol => $symbol,
mode => $mode,
status => __('Downloading ...'));
}
sub find {
my ($class, $symbol, $mode) = @_;
lib/App/Chart/Gtk2/Job/Latest.pm view on Meta::CPAN
$symbol_list = $new_symbol_list;
$extra_list = [ grep {!$inprogress{$_}} @$extra_list ];
my $name = (@$extra_list
? __x('Latest {symbol_list} (and maybe {extra_list})',
symbol_list => form_symbol_list($symbol_list),
extra_list => form_symbol_list($extra_list))
: __x('Latest {symbol_list}',
symbol_list => form_symbol_list($symbol_list)));
my $job = $class->SUPER::start
(args => [ 'latest', $symbol_list, $extra_list ],
name => $name,
symbol_list => $symbol_list);
foreach my $symbol (@$symbol_list) {
$inprogress{$symbol} = $job;
}
### Job-Latest latest-changed for inprogress: "@$symbol_list"
my %symbol_hash;
@symbol_hash{@$symbol_list} = ();
App::Chart::chart_dirbroadcast()->send_locally
lib/App/Chart/Gtk2/JobQueue.pm view on Meta::CPAN
#
# Normally DESTROY is wrong for Glib::Object subclasses since it's called
# variously when the object loses its last Perl reference but not last C
# reference, or something like that. But here as a global the last Perl
# reference means program exit.
#
sub DESTROY {
my ($self) = @_;
### JobQueue DESTROY() ...
undef $self->{'hook'};
$self->SUPER::DESTROY;
}
sub INIT_INSTANCE {
my ($self) = @_;
require App::Chart::Gtk2::Job;
$self->set_column_types ('App::Chart::Gtk2::Job');
require App::Chart::Glib::Ex::EmissionHook;
$self->{'hook'} = App::Chart::Glib::Ex::EmissionHook->new
('App::Chart::Gtk2::Job',
lib/App/Chart/Gtk2/RawDialog.pm view on Meta::CPAN
use Gtk2::Ex::Datasheet::DBI;
use Gtk2::Ex::WidgetCursor;
use Gtk2::Ex::Units;
# hack for Gtk2::Ex::Datasheet::DBI 2.1
{ package Gtk2::Ex::Datasheet::DBI::CellRendererText;
sub GET_SIZE {
my ($self, $widget, $cell_area) = @_;
return $self->SUPER::GET_SIZE ($widget, $cell_area);
}
}
use App::Chart::Gtk2::Ex::NotebookLazyPages;
use App::Chart::Gtk2::GUI;
use App::Chart::Intraday;
use App::Chart::Gtk2::SeriesTreeView;
use App::Chart::Gtk2::RawLatest;
use App::Chart::Gtk2::RawInfo;
lib/App/Chart/Gtk2/Symlist.pm view on Meta::CPAN
# gtk_tree_drag_source_row_draggable ($self, $src_path)
sub ROW_DRAGGABLE {
my ($self, $src_path) = @_;
if (DEBUG) { print "Symlist ROW_DRAGGABLE path=",$src_path->to_string,"\n";
print " ",$self->can_edit?"yes":"no", ", can_edit\n"; }
$self->can_edit or do {
if (DEBUG) { print " no, cannot edit\n"; }
return undef;
};
if (DEBUG) { print " super:\n"; }
return $self->SUPER::ROW_DRAGGABLE ($src_path);
}
#------------------------------------------------------------------------------
# drag dest
# gtk_tree_drag_dest_row_drop_possible
#
sub ROW_DROP_POSSIBLE {
my ($self, $dst_path, $sel) = @_;
### Symlist ROW_DROP_POSSIBLE
lib/App/Chart/Gtk2/Symlist.pm view on Meta::CPAN
eval { $self->insert_with_values ($dst_index, COL_SYMBOL, $str); 1 }
or do {
### no, error from insert_with_values(): $@
return 0;
};
### yes, dropped text
return 1;
}
### go to SUPER
return $self->SUPER::DRAG_DATA_RECEIVED ($dst_path, $sel);
}
1;
__END__
=for stopwords arrayref hashref
=head1 NAME
lib/App/Chart/Gtk2/Symlist/Constructed.pm view on Meta::CPAN
use warnings;
use App::Chart::Gtk2::Symlist;
use Glib::Object::Subclass
'App::Chart::Gtk2::Symlist';
my $keynum = 0;
sub new {
my ($class, @symbols) = @_;
my $self = $class->SUPER::new (key => "_constructed_$keynum");
local $self->{'reading_database'} = 1;
my $pos = 0;
foreach my $symbol (@symbols) {
$self->insert_with_values ($pos++, 0 => $symbol);
}
return $self;
}
# sub INIT_INSTANCE {
lib/App/Chart/Gtk2/Symlist/Constructed.pm view on Meta::CPAN
# }
sub can_edit { return 0; }
sub can_destroy { return 0; }
sub _reread {
}
# sub name {
# my ($self) = @_;
# return $self->{'name'} || $self->SUPER::name;
# }
# sub symbol_list {
# my ($self) = @_;
# return $self->{'symbol_list'};
# }
1;
__END__
lib/App/Chart/Gtk2/SymlistListModel.pm view on Meta::CPAN
$self->reread;
}
#------------------------------------------------------------------------------
# local changes applied to database
sub remove {
my ($self, $iter) = @_;
my $key = $self->get($iter,COL_KEY);
delete $App::Chart::Gtk2::Symlist::instances{$key};
return $self->SUPER::remove ($iter);
}
# 'row-changed' class closure
sub _do_row_changed {
my ($self, $path, $iter) = @_;
$self->signal_chain_from_overridden ($path, $iter);
if ($self->{'reading_database'}) { return; }
my ($seq) = $path->get_indices;
lib/App/Chart/Gtk2/TickerModel.pm view on Meta::CPAN
# a brightish red, for contrast against a black background
DOWN_SPAN => '<span foreground="#FF7070">',
INPROGRESS_SPAN => '<span foreground="light blue">' };
sub new {
my ($class, $symlist) = @_;
# FIXME: As of Gtk2-Perl 1.201 Gtk2::TreeModelFilter::new() leaks a
# reference (its returned object is never destroyed), so go through
# Glib::Object::new() instead. Can switch to SUPER::new when ready to
# depend on a fixed Gtk2-Perl.
#
my $self = Glib::Object::new ($class, child_model => $symlist);
$self->{'symlist'} = $symlist;
$self->set_modify_func ([ 'Glib::String' ], \&_model_filter_func);
App::Chart::chart_dirbroadcast()->connect_for_object
('latest-changed', \&_do_latest_changed, $self);
return $self;
}
lib/App/Chart/Math/Moving/EMA.pm view on Meta::CPAN
},
];
sub warmup_omitted_fraction {
my ($self) = @_;
return $self->{'warmup_omitted_fraction'} || 0.001;
}
sub new {
my $class = shift;
my $self = SUPER::new (@_);
$self->{'f'} = $self->N_to_f ($self->{'N'});
$self->{'alpha'} = $self->N_to_alpha ($self->{'N'});
$self->{'sum'} = 0;
$self->{'weight'} = 0;
return $self;
}
sub next {
my ($self, $value) = @_;
lib/App/Chart/Series.pm view on Meta::CPAN
{ no strict; *$name = $subr; }
goto &$subr;
}
croak "App::Chart::Series unknown function '$name'";
}
sub can {
my ($self_or_class, $name) = @_;
### Series can(): "$self_or_class '$name'"
return $self_or_class->SUPER::can($name) || do {
if ($name =~ /^GT_/p) {
require App::Chart::Series::GT;
my $type = "I:${^POSTMATCH}";
return sub { App::Chart::Series::GT->new ($type, @_) };
}
if ($name =~ /^TA_/p) {
require App::Chart::Series::TA;
my $type = ${^POSTMATCH};
return sub { App::Chart::Series::TA->new ($type, @_) };
}
lib/App/Chart/Series/AddSub.pm view on Meta::CPAN
} else {
$timebase = $y_timebase;
}
my $x_offset = $timebase->convert_from_floor ($x_timebase, 0);
my $y_offset = $timebase->convert_from_floor ($y_timebase, 0);
my $hi = min ($timebase->convert_from_floor ($x_timebase, $x->hi),
$timebase->convert_from_floor ($y_timebase, $y->hi));
return $class->SUPER::new
(timebase => $timebase,
hi => $hi,
parent => $x,
parent2 => $y,
x_offset => $x_offset,
y_offset => $y_offset,
arrays => { map {; $_ => [] } keys %{$x->{'arrays'}} },
@more);
}
lib/App/Chart/Series/Database.pm view on Meta::CPAN
$symbol);
if (! $base) {
require App::Chart::TZ;
my $timezone = App::Chart::TZ->for_symbol ($symbol);
$base = $timezone->iso_date;
}
if (DEBUG) { print " base $base\n"; }
require App::Chart::Timebase::Days;
my $timebase = App::Chart::Timebase::Days->new_from_iso ($base);
$self = $class->SUPER::new (symbol => $symbol,
timebase => $timebase);
# lose any cache entries which have gone undef through weaks destroyed
delete @cache{grep {! $cache{$_}} keys %cache};
# add new entry
_init_cache();
$cache{$symbol} = $self;
Scalar::Util::weaken ($cache{$symbol});
lib/App/Chart/Series/Derived/ADX.pm view on Meta::CPAN
decimals => 0,
step => 1 } ];
}
sub new {
my ($class, $parent, $N) = @_;
$N //= parameter_info()->[0]->{'default'};
($N > 0) || croak "ADX bad N: $N";
return $class->SUPER::new
(parent => $parent,
parameters => [ $N ],
arrays => { values => [] });
}
*warmup_count = \&App::Chart::Series::Derived::ATR::warmup_count; # EMA(W)+1
*fill_part = \&App::Chart::Series::Derived::WilliamsR::fill_part;
sub proc {
my ($class_or_self, $N) = @_;
my $dmi_proc = App::Chart::Series::Derived::DMI->proc($N);
lib/App/Chart/Series/Derived/ASI.pm view on Meta::CPAN
use constant
{ type => 'indicator',
units => 'ASI',
parameter_info => [ ],
};
sub new {
my ($class, $parent) = @_;
return $class->SUPER::new
(parent => $parent,
parameters => [ ],
arrays => { values => [] },
array_aliases => { });
}
*fill_part = \&App::Chart::Series::Derived::OBV::fill_part;
sub proc {
my ($self) = @_;
my $parent = $self->parent;
lib/App/Chart/Series/Derived/ATR.pm view on Meta::CPAN
minimum => 1,
default => 14 } ],
};
sub new {
my ($class, $parent, $N) = @_;
$N //= parameter_info()->[0]->{'default'};
($N > 0) || croak "ATR bad N: $N";
return $class->SUPER::new
(parent => $parent,
parameters => [ $N ],
arrays => { values => [] },
array_aliases => { });
}
sub warmup_count {
my ($self_or_class, $N) = @_;
$N = App::Chart::Series::Derived::EMA::N_from_Wilder_N ($N);
return (App::Chart::Series::Derived::TrueRange->warmup_count()