Skip to content

Commit

Permalink
Some Files
Browse files Browse the repository at this point in the history
  • Loading branch information
vanyabrovary committed Aug 2, 2017
1 parent e687804 commit 8ff95e8
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cfg.pm
Expand Up @@ -39,7 +39,7 @@ Implementation of global access to configuration values via global variable $cfg
=over 4
=item * Using
=item * Using
use Cfg;
print Dumper($cfg);
Expand Down
8 changes: 4 additions & 4 deletions DB.pm
Expand Up @@ -4,13 +4,13 @@ use warnings;
use strict;

use Cfg;
use DBI;

BEGIN {
use Exporter;
our @ISA = qw( Exporter );
our @EXPORT = qw( $db );
use DBI;
our $db = DBI->connect(
our $db = DBI->connect(
'DBI:mysql:database=' . $cfg->{DB}->{database_name} . ';hostname=' . $cfg->{DB}->{database_host},
$cfg->{DB}->{database_user},
$cfg->{DB}->{database_pass}
Expand All @@ -35,9 +35,9 @@ Implementation of global access to DBI MySQL connection via global variable $db
=head1 REQUIRES
L<DBI>
L<DBI>
L<Cfg>
L<Cfg>
=head1 EXAMPLES
Expand Down
1 change: 1 addition & 0 deletions LICENSE
@@ -0,0 +1 @@
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
11 changes: 11 additions & 0 deletions MANIFEST
@@ -0,0 +1,11 @@
Cfg.pm
DB.pm
Model.pm
README.md
MANIFEST
cpanfile
LICENSE
Model
Model/FeedFileStat.pm
Model/FeedFile.pm
Model/FeedFileStatGaps.pm
26 changes: 13 additions & 13 deletions Model.pm
Expand Up @@ -5,7 +5,7 @@ use strict;

use DB;

sub new() {
sub new {
my ( $class, $arg ) = @_;
my $self = {};

Expand Down Expand Up @@ -34,7 +34,7 @@ sub load() {
return $self;
}

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

my $module = "Model/$class.pm";
Expand All @@ -52,7 +52,7 @@ sub list() {
return \@b;
}

sub list_where() {
sub list_where {
my ( $class, $val, $col ) = @_;

return 0 unless $val or $col;
Expand All @@ -72,13 +72,13 @@ sub list_where() {
return \@b;
}

sub save() {
sub save {
my $self = shift;
$self->_store_in_db();
return $self;
}

sub set() {
sub set {
my ( $self, $arg ) = @_;

foreach my $col ( $self->db_columns ) {
Expand All @@ -93,7 +93,7 @@ sub set() {
}

# fix for databases with TABLE_id as primary key instead id as primary key
sub _id() {
sub _id {
my ($class) = @_;

if ( grep /^id$/, $class->db_columns() ) {
Expand All @@ -105,7 +105,7 @@ sub _id() {

}

sub _fetch_from_db() {
sub _fetch_from_db {
my ( $cls, $col, $val ) = @_;

my $h = $db->prepare(
Expand All @@ -122,7 +122,7 @@ sub _fetch_from_db() {

}

sub _store_in_db() {
sub _store_in_db {
my $self = shift;
my @binds = ();
my @keys = ();
Expand Down Expand Up @@ -164,7 +164,7 @@ sub _store_in_db() {
#return 1;
}

sub newid() {
sub newid {
my $self = shift;
return $db->{mysql_insertid} || $self->{ $self->_id };
}
Expand Down Expand Up @@ -218,8 +218,8 @@ print $_->{some_field} foreach ( @{ Model::FeedFileStat->list() } )
=item * Read inner list.
foreach ( @{ Model::FeedFileStat->list() } ){
print Dumper($_) foreach ( @{ $_->gaps() } ); # if this method is implemented each row contain Model::FeedFileStatGaps
foreach ( @{ Model::FeedFileStat->list() } ){
print Dumper($_) foreach ( @{ $_->gaps() } ); # if this method is implemented each row contain Model::FeedFileStatGaps
}
=item * Delete.
Expand All @@ -242,11 +242,11 @@ newid - return bad for MySQL.
To finish smarter. It's fast fixme now
=item * ExtModel
Add ExtModel from Full version
=item * Replace
Add Replace from Full version
=back
Expand Down
1 change: 1 addition & 0 deletions Model/FeedFileStat.pm
Expand Up @@ -5,6 +5,7 @@ use strict;

use Model;
our @ISA = qw/Model/;

sub db_table() { 'feed_file_stat' }
sub db_columns() { qw/id feed_file_id channel_id started_at/ }

Expand Down
22 changes: 22 additions & 0 deletions cpanfile
@@ -0,0 +1,22 @@
requires 'File::Find::Rule', '';
requires 'File::Find::Rule::Perl', '';
requires 'File::HomeDir', '';
requires 'File::Spec', '';
requires 'Path::Tiny', '';
requires 'Perl::Metrics::Simple', '';
requires 'Pod::Coverage', '';
requires 'Test::EOL', '';
requires 'Test::Fixme', '';
requires 'Test::Kwalitee', '';
requires 'Test::More', '';
requires 'Test::NoBreakpoints', '';
requires 'Test::NoTabs', '';
requires 'Test::Perl::Critic', '';
requires 'Test::PerlTidy', '';
requires 'Test::Pod', '';
requires 'Test::Pod::Coverage', '';
requires 'Test::Portability::Files', '';
requires 'Test::Spelling', '';
requires 'Test::Strict', '';
requires 'YAML', '';
requires 'Readonly', '';

0 comments on commit 8ff95e8

Please sign in to comment.