Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE: perltidy all the cassandane tiny tests #4964

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
77 changes: 35 additions & 42 deletions cassandane/Cassandane/Address.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,60 +42,53 @@ use strict;
use warnings;
use overload qw("") => \&as_string;

sub new
{
my $class = shift;
my %params = @_;
my $self = {
name => undef,
localpart => undef,
domain => undef,
};
sub new {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer when blocks in column 0 (i.e. global function/arrays/hash/etc definitions) have their opening bracket also in column 0 of the next line (which has been Cyrus style forever), like this:

sub new
{

Specifically, I like it because my muscle memory wants to use [[ and ]] to jump between them in vim.

I prefer the opening bracket on the same line everywhere else... unless pushing it to the next line improves readability in context.

my $class = shift;
my %params = @_;
my $self = {
name => undef,
localpart => undef,
domain => undef,
};

$self->{name} = $params{name}
if defined $params{name};
$self->{localpart} = $params{localpart}
if defined $params{localpart};
$self->{domain} = $params{domain}
if defined $params{domain};
$self->{name} = $params{name}
if defined $params{name};
$self->{localpart} = $params{localpart}
if defined $params{localpart};
$self->{domain} = $params{domain}
if defined $params{domain};

bless $self, $class;
return $self;
bless $self, $class;
return $self;
}

sub name
{
my ($self) = @_;
return $self->{name};
sub name {
my ($self) = @_;
return $self->{name};
}

sub localpart
{
my ($self) = @_;
return ($self->{localpart} || 'unknown-user');
sub localpart {
my ($self) = @_;
return ($self->{localpart} || 'unknown-user');
}

sub domain
{
my ($self) = @_;
return ($self->{domain} || 'unspecified-domain');
sub domain {
my ($self) = @_;
return ($self->{domain} || 'unspecified-domain');
}

sub address
{
my ($self) = @_;
return $self->localpart() . '@' . $self->domain();
sub address {
my ($self) = @_;
return $self->localpart() . '@' . $self->domain();
}

sub as_string
{
my ($self) = @_;
my $s = '';
$s .= $self->{name} . ' '
if defined $self->{name};
$s .= '<' . $self->address() . '>';
return $s;
sub as_string {
my ($self) = @_;
my $s = '';
$s .= $self->{name} . ' '
if defined $self->{name};
$s .= '<' . $self->address() . '>';
return $s;
}


1;
70 changes: 34 additions & 36 deletions cassandane/Cassandane/BuildInfo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,56 +45,54 @@ use Cassandane::Cassini;
use Cassandane::Util::Log;

sub new {
my $class = shift;
my %params = @_;
my $self = {};
my $class = shift;
my %params = @_;
my $self = {};

my $cassini = Cassandane::Cassini->instance();
my $cassini = Cassandane::Cassini->instance();

my $prefix = $cassini->val("cyrus default", 'prefix', '/usr/cyrus');
$prefix = $params{cyrus_prefix}
if defined $params{cyrus_prefix};
my $prefix = $cassini->val("cyrus default", 'prefix', '/usr/cyrus');
$prefix = $params{cyrus_prefix}
if defined $params{cyrus_prefix};

my $destdir = $cassini->val("cyrus default", 'destdir', '');
$destdir = $params{cyrus_destdir}
if defined $params{cyrus_destdir};
my $destdir = $cassini->val("cyrus default", 'destdir', '');
$destdir = $params{cyrus_destdir}
if defined $params{cyrus_destdir};

$self->{data} = _read_buildinfo($destdir, $prefix);
$self->{data} = _read_buildinfo($destdir, $prefix);

return bless $self, $class;
return bless $self, $class;
}

sub _read_buildinfo
{
my ($destdir, $prefix) = @_;

my $cyr_buildinfo;
foreach my $bindir (qw(sbin cyrus/bin)) {
my $p = "$destdir$prefix/$bindir/cyr_buildinfo";
if (-x $p) {
$cyr_buildinfo = $p;
last;
}
}
sub _read_buildinfo {
my ($destdir, $prefix) = @_;

if (not defined $cyr_buildinfo) {
xlog "Couldn't find cyr_buildinfo: ".
"don't know what features Cyrus supports";
return;
my $cyr_buildinfo;
foreach my $bindir (qw(sbin cyrus/bin)) {
my $p = "$destdir$prefix/$bindir/cyr_buildinfo";
if (-x $p) {
$cyr_buildinfo = $p;
last;
}
}

if (not defined $cyr_buildinfo) {
xlog "Couldn't find cyr_buildinfo: "
. "don't know what features Cyrus supports";
return;
}

my $jsondata = qx($cyr_buildinfo);
return if not $jsondata;
my $jsondata = qx($cyr_buildinfo);
return if not $jsondata;

return JSON::decode_json($jsondata);
return JSON::decode_json($jsondata);
}

sub get
{
my ($self, $category, $key) = @_;
sub get {
my ($self, $category, $key) = @_;

return if not exists $self->{data}->{$category}->{$key};
return $self->{data}->{$category}->{$key};
return if not exists $self->{data}->{$category}->{$key};
return $self->{data}->{$category}->{$key};
}

1;
Loading