rubysl-base64 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -6
- data/lib/rubysl/base64/base64.rb +51 -77
- data/lib/rubysl/base64/version.rb +1 -1
- data/rubysl-base64.gemspec +0 -1
- metadata +21 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83c207c5b4b8f77aae12e58bb926e1efebaf4d44
|
4
|
+
data.tar.gz: 98c67bddb662175aebd91380d899fd610a9ca301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a789483a947e367c962e18b4a15b1d7362e1c5334eae9336280cfa80b6680c267a18f6944b0ceee2fd5fc4d389c80de4993cdbeb4bf06127c1d357bceb29c138
|
7
|
+
data.tar.gz: ef664f97e4898bebde64cb5c75ee64c2fd30cbe38d116a3f832ec5e298b98afe23d205342838747a7952a217424df3186caeb3dea091046dbf1777a8589eb56c
|
data/.travis.yml
CHANGED
data/lib/rubysl/base64/base64.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
1
|
#
|
2
|
-
# = base64.rb: methods for base64-encoding and -decoding
|
3
|
-
#
|
4
|
-
# Author:: Yukihiro Matsumoto
|
5
|
-
# Documentation:: Dave Thomas and Gavin Sinclair
|
6
|
-
#
|
7
|
-
# Until Ruby 1.8.1, these methods were defined at the top-level. Now
|
8
|
-
# they are in the Base64 module but included in the top-level, where
|
9
|
-
# their usage is deprecated.
|
10
|
-
#
|
11
|
-
# See Base64 for documentation.
|
2
|
+
# = base64.rb: methods for base64-encoding and -decoding strings
|
12
3
|
#
|
13
4
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# The Base64 module provides for the encoding (#encode64) and decoding
|
18
|
-
# (#decode64) of binary data using a Base64 representation.
|
19
|
-
#
|
20
|
-
# The following particular features are also provided:
|
21
|
-
# - encode into lines of a given length (#b64encode)
|
22
|
-
# - decode the special format specified in RFC2047 for the
|
23
|
-
# representation of email headers (decode_b)
|
5
|
+
# The Base64 module provides for the encoding (#encode64, #strict_encode64,
|
6
|
+
# #urlsafe_encode64) and decoding (#decode64, #strict_decode64,
|
7
|
+
# #urlsafe_decode64) of binary data using a Base64 representation.
|
24
8
|
#
|
25
9
|
# == Example
|
26
10
|
#
|
27
|
-
# A simple encoding and decoding.
|
28
|
-
#
|
11
|
+
# A simple encoding and decoding.
|
12
|
+
#
|
29
13
|
# require "base64"
|
30
14
|
#
|
31
15
|
# enc = Base64.encode64('Send reinforcements')
|
32
|
-
# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
|
16
|
+
# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
|
33
17
|
# plain = Base64.decode64(enc)
|
34
18
|
# # -> "Send reinforcements"
|
35
19
|
#
|
36
20
|
# The purpose of using base64 to encode data is that it translates any
|
37
|
-
# binary data into purely printable characters.
|
38
|
-
# RFC 2045 (http://www.faqs.org/rfcs/rfc2045.html).
|
21
|
+
# binary data into purely printable characters.
|
39
22
|
|
40
23
|
module Base64
|
41
24
|
module_function
|
42
25
|
|
26
|
+
# Returns the Base64-encoded version of +bin+.
|
27
|
+
# This method complies with RFC 2045.
|
28
|
+
# Line feeds are added to every 60 encoded charactors.
|
29
|
+
#
|
30
|
+
# require 'base64'
|
31
|
+
# Base64.encode64("Now is the time for all good coders\nto learn Ruby")
|
32
|
+
#
|
33
|
+
# <i>Generates:</i>
|
34
|
+
#
|
35
|
+
# Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
|
36
|
+
# UnVieQ==
|
37
|
+
def encode64(bin)
|
38
|
+
[bin].pack("m")
|
39
|
+
end
|
40
|
+
|
43
41
|
# Returns the Base64-decoded version of +str+.
|
42
|
+
# This method complies with RFC 2045.
|
43
|
+
# Characters outside the base alphabet are ignored.
|
44
44
|
#
|
45
45
|
# require 'base64'
|
46
46
|
# str = 'VGhpcyBpcyBsaW5lIG9uZQpUaGlzIG' +
|
@@ -54,64 +54,38 @@ module Base64
|
|
54
54
|
# This is line two
|
55
55
|
# This is line three
|
56
56
|
# And so on...
|
57
|
-
|
58
57
|
def decode64(str)
|
59
|
-
str.unpack("m")
|
58
|
+
str.unpack("m").first
|
60
59
|
end
|
61
60
|
|
62
|
-
|
63
|
-
#
|
64
|
-
#
|
65
|
-
|
66
|
-
|
67
|
-
# the character sets ISO-2022-JP and SHIFT_JIS (so the only two
|
68
|
-
# encoded word sequences recognized are <tt>=?ISO-2022-JP?B?...=</tt> and
|
69
|
-
# <tt>=?SHIFT_JIS?B?...=</tt>). Recognition of these sequences is case
|
70
|
-
# insensitive.
|
71
|
-
|
72
|
-
def decode_b(str)
|
73
|
-
str.gsub!(/=\?ISO-2022-JP\?B\?([!->@-~]+)\?=/i) {
|
74
|
-
decode64($1)
|
75
|
-
}
|
76
|
-
#str = Kconv::toeuc(str)
|
77
|
-
str.gsub!(/=\?SHIFT_JIS\?B\?([!->@-~]+)\?=/i) {
|
78
|
-
decode64($1)
|
79
|
-
}
|
80
|
-
#str = Kconv::toeuc(str)
|
81
|
-
str.gsub!(/\n/, ' ')
|
82
|
-
str.gsub!(/\0/, '')
|
83
|
-
str
|
61
|
+
# Returns the Base64-encoded version of +bin+.
|
62
|
+
# This method complies with RFC 4648.
|
63
|
+
# No line feeds are added.
|
64
|
+
def strict_encode64(bin)
|
65
|
+
[bin].pack("m0")
|
84
66
|
end
|
85
67
|
|
86
|
-
# Returns the Base64-
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
|
91
|
-
|
92
|
-
#
|
93
|
-
# Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
|
94
|
-
# UnVieQ==
|
95
|
-
|
96
|
-
def encode64(bin)
|
97
|
-
[bin].pack("m")
|
68
|
+
# Returns the Base64-decoded version of +str+.
|
69
|
+
# This method complies with RFC 4648.
|
70
|
+
# ArgumentError is raised if +str+ is incorrectly padded or contains
|
71
|
+
# non-alphabet characters. Note that CR or LF are also rejected.
|
72
|
+
def strict_decode64(str)
|
73
|
+
str.unpack("m0").first
|
98
74
|
end
|
99
75
|
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
# <i>Generates:</i>
|
108
|
-
#
|
109
|
-
# Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
|
110
|
-
# UnVieQ==
|
76
|
+
# Returns the Base64-encoded version of +bin+.
|
77
|
+
# This method complies with ``Base 64 Encoding with URL and Filename Safe
|
78
|
+
# Alphabet'' in RFC 4648.
|
79
|
+
# The alphabet uses '-' instead of '+' and '_' instead of '/'.
|
80
|
+
def urlsafe_encode64(bin)
|
81
|
+
strict_encode64(bin).tr("+/", "-_")
|
82
|
+
end
|
111
83
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
84
|
+
# Returns the Base64-decoded version of +str+.
|
85
|
+
# This method complies with ``Base 64 Encoding with URL and Filename Safe
|
86
|
+
# Alphabet'' in RFC 4648.
|
87
|
+
# The alphabet uses '-' instead of '+' and '_' instead of '/'.
|
88
|
+
def urlsafe_decode64(str)
|
89
|
+
strict_decode64(str.tr("-_", "+/"))
|
90
|
+
end
|
117
91
|
end
|
data/rubysl-base64.gemspec
CHANGED
metadata
CHANGED
@@ -1,71 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-base64
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2013-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
version_requirements: !ruby/object:Gem::Requirement
|
15
|
-
requirements:
|
16
|
-
- - "~>"
|
17
|
-
- !ruby/object:Gem::Version
|
18
|
-
version: '1.3'
|
19
14
|
name: bundler
|
20
|
-
prerelease: false
|
21
15
|
requirement: !ruby/object:Gem::Requirement
|
22
16
|
requirements:
|
23
|
-
- -
|
17
|
+
- - ~>
|
24
18
|
- !ruby/object:Gem::Version
|
25
19
|
version: '1.3'
|
26
20
|
type: :development
|
27
|
-
|
21
|
+
prerelease: false
|
28
22
|
version_requirements: !ruby/object:Gem::Requirement
|
29
23
|
requirements:
|
30
|
-
- -
|
24
|
+
- - ~>
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
33
28
|
name: rake
|
34
|
-
prerelease: false
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- -
|
31
|
+
- - ~>
|
38
32
|
- !ruby/object:Gem::Version
|
39
33
|
version: '10.0'
|
40
34
|
type: :development
|
41
|
-
|
35
|
+
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
|
-
- -
|
38
|
+
- - ~>
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
47
42
|
name: mspec
|
48
|
-
prerelease: false
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '1.5'
|
54
48
|
type: :development
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '2.0'
|
61
|
-
name: rubysl-prettyprint
|
62
49
|
prerelease: false
|
63
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
51
|
requirements:
|
65
|
-
- -
|
52
|
+
- - ~>
|
66
53
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
68
|
-
type: :development
|
54
|
+
version: '1.5'
|
69
55
|
description: Ruby standard library base64.
|
70
56
|
email:
|
71
57
|
- brixen@gmail.com
|
@@ -73,8 +59,8 @@ executables: []
|
|
73
59
|
extensions: []
|
74
60
|
extra_rdoc_files: []
|
75
61
|
files:
|
76
|
-
-
|
77
|
-
-
|
62
|
+
- .gitignore
|
63
|
+
- .travis.yml
|
78
64
|
- Gemfile
|
79
65
|
- LICENSE
|
80
66
|
- README.md
|
@@ -98,17 +84,17 @@ require_paths:
|
|
98
84
|
- lib
|
99
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- -
|
87
|
+
- - '>='
|
102
88
|
- !ruby/object:Gem::Version
|
103
89
|
version: '0'
|
104
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
91
|
requirements:
|
106
|
-
- -
|
92
|
+
- - '>='
|
107
93
|
- !ruby/object:Gem::Version
|
108
94
|
version: '0'
|
109
95
|
requirements: []
|
110
96
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.0.7
|
112
98
|
signing_key:
|
113
99
|
specification_version: 4
|
114
100
|
summary: Ruby standard library base64.
|