Skip to content

Commit

Permalink
Upgrade to more current Raku idioms
Browse files Browse the repository at this point in the history
And make the distribution ready to be uploaded to zef
  • Loading branch information
lizmat committed Feb 9, 2022
1 parent 1d6c1c6 commit 33c2f7c
Show file tree
Hide file tree
Showing 14 changed files with 317 additions and 191 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: test

on:
push:
branches:
- '*'
tags-ignore:
- '*'
pull_request:

jobs:
raku:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
raku-version:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
- name: Install Dependencies
run: zef install --/test --test-depends --deps-only .
- name: Install App::Prove6
run: zef install --/test App::Prove6
- name: Run Tests
run: prove6 -l t
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.pir
.precomp/
/MIME-Base64-*
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Revision history for MIME-Base64

{{$NEXT}}
- Initial version on the zef ecosystem using App::Mi6
34 changes: 21 additions & 13 deletions META6.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
{
"perl" : "6.*",
"name" : "MIME::Base64",
"version" : "1.2.1",
"license" : "Artistic-2.0",
"author" : "github:retupmoca",
"description" : "Encoding and decoding Base64 ASCII strings",
"depends" : [],
"provides" : {
"MIME::Base64" : "lib/MIME/Base64.pm6",
"MIME::Base64::Perl" : "lib/MIME/Base64/Perl.pm6"
},
"source-url" : "git://github.com/raku-community-modules/MIME-Base64.git",
"source-type" : "git"
"auth": "zef:raku-community-modules",
"build-depends": [
],
"depends": [
],
"description": "Encoding and decoding Base64 ASCII strings",
"license": "Artistic-2.0",
"name": "MIME::Base64",
"perl": "6.*",
"provides": {
"MIME::Base64": "lib/MIME/Base64.rakumod",
"MIME::Base64::Perl": "lib/MIME/Base64/Perl.rakumod"
},
"resources": [
],
"source-url": "git://github.com/raku-community-modules/MIME-Base64.git",
"tags": [ "MIME", "BASE64", "ENCODING", "DECODING"
],
"test-depends": [
],
"version": "1.2.2"
}
89 changes: 45 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,81 @@
MIME::Base64
============
[![Actions Status](https://github.com/raku-community-modules/MIME-Base64/workflows/test/badge.svg)](https://github.com/raku-community-modules/MIME-Base64/actions)

## Name ##
NAME
====

MIME::Base64 - Encoding and decoding Base64 ASCII strings. A Raku implementation of MIME::Base64
MIME::Base64 - Encoding and decoding Base64 ASCII strings

## Description ##
SYNOPSIS
========

Implements encoding and decoding to and from base64.

## Status ##

Version 1.1 and later works on latest Rakudo based on nom. For earlier
versions of Rakudo based on ng, please use v1.0 (see tag v1.0-ng).
```raku
use MIME::Base64;

## Example Usage ##
my $encoded = MIME::Base64.encode-str("xyzzy‽");
my $decoded = MIME::Base64.decode-str($encoded);
```

use MIME::Base64;
or

my $encoded = MIME::Base64.encode-str("xyzzy‽");
my $decoded = MIME::Base64.decode-str($encoded);
```raku
use MIME::Base64;

or
my $encoded = MIME::Base64.encode($blob);
my $decoded-buf = MIME::Base64.decode($encoded);
```

use MIME::Base64;
DESCRIPTION
===========

my $encoded = MIME::Base64.encode($blob);
my $decoded-buf = MIME::Base64.decode($encoded);
Implements encoding and decoding to and from base64.

## Methods ##
METHODS
=======

### `encode(Blob $data, :$oneline --> Str)`
encode(Blob $data, :$oneline --> Str:D)
---------------------------------------

Encodeѕ binary data `$data` in base64 format.

By default, the output is wrapped every 76 characters. If `:$oneline` is set,
wrapping will be disabled.
By default, the output is wrapped every 76 characters. If `:$oneline` is set, wrapping will be disabled.

### `decode(Str $encoded --> Buf)`
decode(Str:D $encoded --> Str:D)
--------------------------------

Decodes base64 encoded data into a binary buffer.

### `encode-str(Str $string, :$oneline --> Str)`
encode-str(Str:D $string, :$oneline --> Str:D)`
-----------------------------------------------

Encodes `$string` into base64, assuming utf8 encoding.

(Ιnternally calls `.encode($string.encode('utf8'))` )

### `decode-str(Str $encoded --> Str)`
decode-str(Str:D $encoded --> Str:D)`
-------------------------------------

Decodes `$encoded` into a string, assuming utf8 encoding.

(Internally calls `.decode($encoded).decode('utf8')` )
COMPATIBILITY METHODS
=====================

## Compatibility Methods ##
encode_base64(Str:D $string --> Str:D)
--------------------------------------

### `encode_base64(Str $string --> Str)`
Same as `.encode-str($string`.

Calls `.encode-str($string)`

### `decode_base64(Str $encoded --> Str)`
decode_base64(Str:D $encoded --> Str:D)
---------------------------------------

Calls `.decode-str($encoded)`

### `MIME::Base64::Perl`

Pure Raku implementation of base64 encoding.
AUTHOR
======

## Known Issues ##
Originally written by Adrian White. Maintained by many other people over the years. Now being maintained as a Raku community module.

The previous precompilation issue has been fixed. The master branch should now be
usable for all backends.
COPYRIGHT AND LICENSE
=====================

## LICENSE and COPYRIGHT ##
Copyright 2010 - 2011 Adrian White Copyright 2012 - 2022 Raku Community

Use these files at your risk and without warranty. This module may be used
under the terms of the Artistic License 2.0.
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

Written by Adrian White.
13 changes: 13 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name = MIME-Base64

[ReadmeFromPod]
; enable = false
filename = lib/MIME/Base64.rakumod

[UploadToZef]

[PruneFiles]
; match = ^ 'xt/'

[Badges]
provider = github-actions/test
22 changes: 0 additions & 22 deletions lib/MIME/Base64.pm6

This file was deleted.

99 changes: 99 additions & 0 deletions lib/MIME/Base64.rakumod
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
use MIME::Base64::Perl:auth<zef:raku-community-modules>;

class MIME::Base64:auth<zef:raku-community-modules> is MIME::Base64::Perl {
method encode-str(Str:D $string, :$oneline --> Str:D) {
self.encode($string.encode('utf8'), :$oneline)
}

method decode-str(Str:D $encoded --> Str:D) {
self.decode($encoded).decode('utf8')
}

# compatibility methods
method encode_base64(Str:D $str --> Str:D) {
self.encode-str($str)
}

method decode_base64(Str:D $str --> Str:D) {
self.decode-str($str)
}
}

=begin pod
=head1 NAME
MIME::Base64 - Encoding and decoding Base64 ASCII strings
=head1 SYNOPSIS
=begin code :lang<raku>
use MIME::Base64;
my $encoded = MIME::Base64.encode-str("xyzzy‽");
my $decoded = MIME::Base64.decode-str($encoded);
=end code
or
=begin code :lang<raku>
use MIME::Base64;
my $encoded = MIME::Base64.encode($blob);
my $decoded-buf = MIME::Base64.decode($encoded);
=end code
=head1 DESCRIPTION
Implements encoding and decoding to and from base64.
=head1 METHODS
=head2 encode(Blob $data, :$oneline --> Str:D)
Encodeѕ binary data C<$data> in base64 format.
By default, the output is wrapped every 76 characters. If `:$oneline` is set,
wrapping will be disabled.
=head2 decode(Str:D $encoded --> Str:D)
Decodes base64 encoded data into a binary buffer.
=head2 encode-str(Str:D $string, :$oneline --> Str:D)`
Encodes C<$string> into base64, assuming utf8 encoding.
=head2 decode-str(Str:D $encoded --> Str:D)`
Decodes C<$encoded> into a string, assuming utf8 encoding.
=head1 COMPATIBILITY METHODS
=head2 encode_base64(Str:D $string --> Str:D)
Same as C<.encode-str($string>.
=head2 decode_base64(Str:D $encoded --> Str:D)
Calls C<.decode-str($encoded)>
=head1 AUTHOR
Originally written by Adrian White. Maintained by many other people over
the years. Now being maintained as a Raku community module.
=head1 COPYRIGHT AND LICENSE
Copyright 2010 - 2011 Adrian White
Copyright 2012 - 2022 Raku Community
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
=end pod

# vim: expandtab shiftwidth=4
Loading

0 comments on commit 33c2f7c

Please sign in to comment.