-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
523 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
CONTRIBUTING | ||
|
||
Thank you for considering contributing to this distribution. This file | ||
contains instructions that will help you work with the source code. | ||
|
||
The distribution is managed with Dist::Zilla. This means than many of the | ||
usual files you might expect are not in the repository, but are generated | ||
at release time (e.g. Makefile.PL). | ||
|
||
However, you can run tests directly using the 'prove' tool: | ||
|
||
$ prove -l | ||
$ prove -lv t/some_test_file.t | ||
|
||
For most distributions, 'prove' is entirely sufficent for you to test any | ||
patches you have. | ||
|
||
You may need to satisfy some dependencies. See the included META.json | ||
file for a list. If you install App::mymeta_requires from CPAN, it's easy | ||
to satisfy any that you are missing by piping the output to your favorite | ||
CPAN client: | ||
|
||
$ mymeta-requires | cpanm | ||
$ cpan `mymeta-requires` | ||
|
||
Likewise, much of the documentation Pod is generated at release time. | ||
Depending on the distribution, some documentation may be written in a Pod | ||
dialect called WikiDoc. (See Pod::WikiDoc on CPAN.) If you would like to | ||
submit a documentation edit, please limit yourself to the documentation you | ||
see. | ||
|
||
If you see typos or documentation issues in the generated docs, please | ||
email or open a bug ticket instead of patching. | ||
|
||
Dist::Zilla is a very powerful authoring tool, but requires a number of | ||
author-specific plugins. If you would like to use it for contributing, | ||
install it from CPAN, then run one of the following commands, depending on | ||
your CPAN client: | ||
|
||
$ cpan `dzil authordeps` | ||
$ dzil authordeps | cpanm | ||
|
||
Once installed, here are some dzil commands you might try: | ||
|
||
$ dzil build | ||
$ dzil test | ||
$ dzil xtest | ||
|
||
You can learn more about Dist::Zilla at http://dzil.org/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Revision history for Dancer2-Session-JSON | ||
|
||
{{$NEXT}} | ||
|
||
- First release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"abstract" : "Dancer 2 session storage in files with JSON", | ||
"author" : [ | ||
"David Golden <[email protected]>" | ||
], | ||
"dynamic_config" : 0, | ||
"generated_by" : "Dist::Zilla version 4.300029, CPAN::Meta::Converter version 2.120921", | ||
"license" : [ | ||
"apache_2_0" | ||
], | ||
"meta-spec" : { | ||
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", | ||
"version" : "2" | ||
}, | ||
"name" : "Dancer2-Session-JSON", | ||
"no_index" : { | ||
"directory" : [ | ||
"t", | ||
"xt", | ||
"examples", | ||
"corpus" | ||
], | ||
"package" : [ | ||
"DB" | ||
] | ||
}, | ||
"prereqs" : { | ||
"configure" : { | ||
"requires" : { | ||
"ExtUtils::MakeMaker" : "6.30" | ||
} | ||
}, | ||
"develop" : { | ||
"requires" : { | ||
"Pod::Coverage::TrustPod" : "0", | ||
"Test::CPAN::Meta" : "0", | ||
"Test::Pod" : "1.41", | ||
"Test::Pod::Coverage" : "1.08" | ||
} | ||
}, | ||
"runtime" : { | ||
"requires" : { | ||
"Dancer2" : "2", | ||
"Dancer2::Core::Role::SessionFactory::File" : "0", | ||
"Dancer2::Core::Types" : "0", | ||
"JSON" : "0", | ||
"Moo" : "0", | ||
"perl" : "5.008001", | ||
"strict" : "0", | ||
"warnings" : "0" | ||
} | ||
}, | ||
"test" : { | ||
"requires" : { | ||
"Dancer2" : "0", | ||
"ExtUtils::MakeMaker" : "0", | ||
"File::Find" : "0", | ||
"File::Spec" : "0", | ||
"File::Spec::Functions" : "0", | ||
"File::Temp" : "0.22", | ||
"HTTP::Date" : "0", | ||
"LWP::UserAgent" : "0", | ||
"List::Util" : "0", | ||
"Test::More" : "0", | ||
"Test::TCP" : "1.13", | ||
"YAML" : "0" | ||
} | ||
} | ||
}, | ||
"provides" : { | ||
"Dancer2::Session::JSON" : { | ||
"file" : "lib/Dancer2/Session/JSON.pm", | ||
"version" : "0.001" | ||
} | ||
}, | ||
"release_status" : "stable", | ||
"resources" : { | ||
"bugtracker" : { | ||
"web" : "https://github.com/dagolden/dancer2-session-json/issues" | ||
}, | ||
"homepage" : "https://metacpan.org/release/Dancer2-Session-JSON", | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "git://github.com/dagolden/dancer2-session-json.git", | ||
"web" : "https://github.com/dagolden/dancer2-session-json" | ||
} | ||
}, | ||
"version" : "0.001" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
=pod | ||
|
||
=head1 NAME | ||
|
||
Dancer2::Session::JSON - Dancer 2 session storage in files with JSON | ||
|
||
=head1 VERSION | ||
|
||
version 0.001 | ||
|
||
=head1 DESCRIPTION | ||
|
||
This module implements Dancer 2 session engine based on L<JSON> files. | ||
|
||
This backend can be used in single-machine production environments, but two | ||
things should be kept in mind: The content of the session files is not | ||
encrypted or protected in anyway and old session files should be purged by a | ||
CRON job. | ||
|
||
=head1 CONFIGURATION | ||
|
||
The setting B<session> should be set to C<JSON> in order to use this session | ||
engine in a Dancer2 application. | ||
|
||
Files will be stored to the value of the setting C<session_dir>, whose default | ||
value is C<appdir/sessions>. | ||
|
||
Here is an example configuration that use this session engine and stores session | ||
files in /tmp/dancer-sessions | ||
|
||
session: "JSON" | ||
|
||
engines: | ||
session: | ||
JSON: | ||
session_dir: "/tmp/dancer-sessions" | ||
|
||
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan | ||
|
||
=head1 SUPPORT | ||
|
||
=head2 Bugs / Feature Requests | ||
|
||
Please report any bugs or feature requests through the issue tracker | ||
at L<https://github.com/dagolden/dancer2-session-json/issues>. | ||
You will be notified automatically of any progress on your issue. | ||
|
||
=head2 Source Code | ||
|
||
This is open source software. The code repository is available for | ||
public review and contribution under the terms of the license. | ||
|
||
L<https://github.com/dagolden/dancer2-session-json> | ||
|
||
git clone git://github.com/dagolden/dancer2-session-json.git | ||
|
||
=head1 AUTHOR | ||
|
||
David Golden <[email protected]> | ||
|
||
=head1 COPYRIGHT AND LICENSE | ||
|
||
This software is Copyright (c) 2013 by David Golden. | ||
|
||
This is free software, licensed under: | ||
|
||
The Apache License, Version 2.0, January 2004 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name = Dancer2-Session-JSON | ||
author = David Golden <[email protected]> | ||
license = Apache_2_0 | ||
copyright_holder = David Golden | ||
copyright_year = 2013 | ||
|
||
[@DAGOLDEN] | ||
:version = 0.035 | ||
AutoMetaResources.bugtracker.rt = 0 | ||
AutoMetaResources.bugtracker.github = user:dagolden | ||
|
||
[Prereqs] | ||
Dancer2 = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
use 5.008001; | ||
use strict; | ||
use warnings; | ||
|
||
package Dancer2::Session::JSON; | ||
# ABSTRACT: Dancer 2 session storage in files with JSON | ||
# VERSION | ||
|
||
use Moo; | ||
use Dancer2::Core::Types; | ||
use JSON -convert_blessed_universally; | ||
|
||
#--------------------------------------------------------------------------# | ||
# Attributes | ||
#--------------------------------------------------------------------------# | ||
|
||
has _suffix => ( | ||
is => 'ro', | ||
isa => Str, | ||
default => sub { ".json" }, | ||
); | ||
|
||
has _encoder => ( | ||
is => 'lazy', | ||
isa => InstanceOf ['JSON'], | ||
handles => { | ||
'_freeze' => 'encode', | ||
'_thaw' => 'decode' | ||
}, | ||
); | ||
|
||
sub _build__encoder { | ||
my ($self) = @_; | ||
return JSON->new->allow_blessed->convert_blessed; | ||
} | ||
|
||
#--------------------------------------------------------------------------# | ||
# Role composition | ||
#--------------------------------------------------------------------------# | ||
|
||
with 'Dancer2::Core::Role::SessionFactory::File'; | ||
|
||
sub _freeze_to_handle { | ||
my ( $self, $fh, $data ) = @_; | ||
binmode $fh; | ||
print {$fh} $self->_freeze($data); | ||
return; | ||
} | ||
|
||
sub _thaw_from_handle { | ||
my ( $self, $fh ) = @_; | ||
binmode($fh); | ||
return $self->_thaw( | ||
do { local $/; <$fh> } | ||
); | ||
} | ||
|
||
1; | ||
__END__ | ||
=head1 DESCRIPTION | ||
This module implements Dancer 2 session engine based on L<JSON> files. | ||
This backend can be used in single-machine production environments, but two | ||
things should be kept in mind: The content of the session files is not | ||
encrypted or protected in anyway and old session files should be purged by a | ||
CRON job. | ||
=head1 CONFIGURATION | ||
The setting B<session> should be set to C<JSON> in order to use this session | ||
engine in a Dancer2 application. | ||
Files will be stored to the value of the setting C<session_dir>, whose default | ||
value is C<appdir/sessions>. | ||
Here is an example configuration that use this session engine and stores session | ||
files in /tmp/dancer-sessions | ||
session: "JSON" | ||
engines: | ||
session: | ||
JSON: | ||
session_dir: "/tmp/dancer-sessions" | ||
=cut | ||
# vim: ts=4 sts=4 sw=4 et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
severity = 5 | ||
verbose = 8 | ||
|
||
[Variables::ProhibitPunctuationVars] | ||
allow = $@ $! | ||
|
||
[TestingAndDebugging::ProhibitNoStrict] | ||
allow = refs | ||
|
||
# Turn these off | ||
[-BuiltinFunctions::ProhibitStringyEval] | ||
[-ControlStructures::ProhibitPostfixControls] | ||
[-ControlStructures::ProhibitUnlessBlocks] | ||
[-Documentation::RequirePodSections] | ||
[-InputOutput::ProhibitInteractiveTest] | ||
[-References::ProhibitDoubleSigils] | ||
[-RegularExpressions::RequireExtendedFormatting] | ||
[-InputOutput::ProhibitTwoArgOpen] | ||
[-Modules::ProhibitEvilModules] | ||
|
||
# Turn this on | ||
[Lax::ProhibitStringyEval::ExceptForRequire] | ||
|
Oops, something went wrong.