Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
perl-WebService-Redmine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
perl-WebService-Redmine
Commits
a73b6570
Commit
a73b6570
authored
11 years ago
by
Anton Soldatov
Browse files
Options
Downloads
Patches
Plain Diff
* WebService::Redmine 0.0.6
* Added perlcritic tests
parent
c4a693b0
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/WebService/Redmine.pm
+38
-22
38 additions, 22 deletions
lib/WebService/Redmine.pm
t/06-perlcritic.t
+17
-0
17 additions, 0 deletions
t/06-perlcritic.t
xt/perlcritic.rc
+11
-0
11 additions, 0 deletions
xt/perlcritic.rc
with
66 additions
and
22 deletions
lib/WebService/Redmine.pm
+
38
−
22
View file @
a73b6570
...
...
@@ -4,7 +4,7 @@ use 5.010;
use
strict
;
use
warnings
;
our
$VERSION
=
'
0.0
4
';
our
$VERSION
=
'
0.0
6
';
use
URI
;
use
URI::
QueryParam
;
...
...
@@ -253,6 +253,8 @@ sub new
}
bless
$self
,
$class
;
return
$self
;
}
=head2 error
...
...
@@ -265,7 +267,7 @@ be dispatched into an HTTP request), contains description of the client error.
=cut
sub
error
{
$_
[
0
]
->
{
error
}
}
sub
error
{
return
$_
[
0
]
->
{
error
}
}
=head2 errorDetails
...
...
@@ -281,7 +283,7 @@ be dispatched into an HTTP request), return value is
=cut
sub
errorDetails
{
$_
[
0
]
->
{
error_details
}
}
sub
errorDetails
{
return
$_
[
0
]
->
{
error_details
}
}
sub
_set_error
{
$_
[
0
]
->
{
error
}
=
$_
[
1
]
//
'';
return
;
}
...
...
@@ -372,7 +374,7 @@ sub _dispatch_name
my
$name
=
shift
//
return
$self
->
_set_client_error
('
Undefined method name
');
my
@args
=
@_
;
my
(
$action
,
$objects
)
=
(
$name
=~
/^(get|read|create|update|delete)?([A-Za-z]+?)$/
);
my
(
$action
,
$objects
)
=
(
$name
=~
/^(get|read|create|update|delete)?([A-Za-z]+?)$/
x
);
if
(
!
$action
||
$action
eq
'
read
')
{
$action
=
'
get
';
...
...
@@ -411,8 +413,6 @@ sub _dispatch_name
}
$objects
=
$self
->
_normalize_objects
(
$objects
);
delete
$self
->
{
expect_single_object
};
my
$i
=
0
;
my
@objects
;
while
(
$objects
=~
/([A-Z][a-z]+)/g
)
{
...
...
@@ -423,10 +423,12 @@ sub _dispatch_name
next
if
$object
eq
$category
;
my
$is_last_object
=
pos
(
$objects
)
==
length
(
$objects
);
# We need to attach an object ID to the path if an object is singular and
# we either perform anything but creation or we create a new object inside
# another object (createProjectMembership)
if
(
$action
ne
'
create
'
||
pos
(
$objects
)
!=
length
(
$
object
s
)
)
{
# another object (
e.g.
createProjectMembership)
if
(
$action
ne
'
create
'
||
!
$is_last_
object
)
{
my
$object_id
=
$args
[
$i
++
];
return
$self
->
_set_client_error
(
...
...
@@ -436,22 +438,36 @@ sub _dispatch_name
push
@objects
,
$object_id
;
}
if
(
pos
(
$objects
)
==
length
(
$objects
))
{
# Last object in the chain:
$self
->
_dispatch_last_object
(
$action
,
$object
,
$data
)
if
$is_last_object
;
}
$data
->
{
path
}
=
join
'
/
',
@objects
;
return
$data
;
}
sub
_dispatch_last_object
{
my
$self
=
shift
;
my
$action
=
shift
;
my
$object
=
shift
;
my
$data
=
shift
;
delete
$self
->
{
expect_single_object
};
if
(
length
$object
)
{
if
(
$action
eq
'
get
'
||
$action
eq
'
create
')
{
$self
->
{
expect_single_object
}
=
$object
;
}
if
(
defined
$data
->
{
content
}
&&
$self
->
{
no_wrapper_object
})
{
# Automatically wrap object data, otherwise we pass everything as is:
$data
->
{
content
}
=
{
$object
=>
$data
->
{
content
}
};
if
(
$self
->
{
no_wrapper_object
})
{
if
(
$action
eq
'
create
'
||
$action
eq
'
update
')
{
# Wrap object data unless we pass everything as is:
$data
->
{
content
}
=
{
$object
=>
$data
->
{
content
}
};
}
}
}
$data
->
{
path
}
=
join
'
/
',
@objects
;
return
$data
;
return
1
;
}
sub
_normalize_objects
...
...
@@ -478,9 +494,9 @@ sub _object
my
$object
=
lc
(
shift
);
# Process compound words:
$object
=~
s/timeentr/time_entr/ig
;
$object
=~
s/issue(categor|status)/issue_$1/ig
;
$object
=~
s/customfield/custom_field/ig
;
$object
=~
s/timeentr/time_entr/ig
x
;
$object
=~
s/issue(categor|status)/issue_$1/ig
x
;
$object
=~
s/customfield/custom_field/ig
x
;
return
$object
;
}
...
...
This diff is collapsed.
Click to expand it.
t/06-perlcritic.t
0 → 100644
+
17
−
0
View file @
a73b6570
# BEGIN {
# if (!$ENV{REDMINER_DEVEL}) {
# require Test::More;
# Test::More::plan(skip_all => 'Development tests (REDMINER_DEVEL not set)' );
# }
# }
use
strict
;
use
warnings
;
use
Test::
More
;
eval
'
use Test::Perl::Critic
';
plan
skip_all
=>
'
Test::Perl::Critic required to criticise code
'
if
$@
;
Test::Perl::
Critic
->
import
(
-
profile
=>
'
xt/perlcritic.rc
')
if
-
e
'
xt/perlcritic.rc
';
all_critic_ok
();
This diff is collapsed.
Click to expand it.
xt/perlcritic.rc
0 → 100644
+
11
−
0
View file @
a73b6570
severity = 3
verbose = 6
top = 50
theme = pbp || core || bugs || security || maintenance
criticism-fatal = 1
color = 1
allow-unsafe = 1
[-ClassHierarchies::ProhibitAutoloading]
[-Subroutines::RequireArgUnpacking]
[RegularExpressions::RequireExtendedFormatting]
minimum_regex_length_to_complain_about = 15
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment