rubysl-base64 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8006ad27cf4737a6495f304e91c4e9561009d366
4
- data.tar.gz: 9b7d555e5efda78af72a3aab36974d3050687434
3
+ metadata.gz: 83c207c5b4b8f77aae12e58bb926e1efebaf4d44
4
+ data.tar.gz: 98c67bddb662175aebd91380d899fd610a9ca301
5
5
  SHA512:
6
- metadata.gz: ad89310dbfffc3e6747c57f2cd3e1803d89a5d297c8a6241b2c29bf98d14696c19d8e7db0585d35e79dd5168d57e10727490685535f38d9c030d65b5a089aee2
7
- data.tar.gz: e5a13043792bb8dcda657f95da5dbe857dc1b280425426c0b4491c4c553432666673f8dbb9890ca186b99a2bac1f6d3a7e202cd10525efc312049fd356536f88
6
+ metadata.gz: a789483a947e367c962e18b4a15b1d7362e1c5334eae9336280cfa80b6680c267a18f6944b0ceee2fd5fc4d389c80de4993cdbeb4bf06127c1d357bceb29c138
7
+ data.tar.gz: ef664f97e4898bebde64cb5c75ee64c2fd30cbe38d116a3f832ec5e298b98afe23d205342838747a7952a217424df3186caeb3dea091046dbf1777a8589eb56c
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
- before_install:
3
- - gem update --system
4
- - gem --version
5
- - gem install rubysl-bundler
6
- script: bundle exec mspec spec
2
+ env:
3
+ - RUBYLIB=lib
4
+ script: bundle exec mspec
7
5
  rvm:
8
- - rbx-nightly-18mode
6
+ - 1.9.3
7
+ - rbx-nightly-19mode
@@ -1,46 +1,46 @@
1
1
  #
2
- # = base64.rb: methods for base64-encoding and -decoding stings
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
- require "kconv"
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. It is specified in
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")[0]
58
+ str.unpack("m").first
60
59
  end
61
60
 
62
-
63
- # Decodes text formatted using a subset of RFC2047 (the one used for
64
- # mime-encoding mail headers).
65
- #
66
- # Only supports an encoding type of 'b' (base 64), and only supports
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-encoded version of +str+.
87
- #
88
- # require 'base64'
89
- # Base64.b64encode("Now is the time for all good coders\nto learn Ruby")
90
- #
91
- # <i>Generates:</i>
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
- # _Prints_ the Base64 encoded version of +bin+ (a +String+) in lines of
101
- # +len+ (default 60) characters.
102
- #
103
- # require 'base64'
104
- # data = "Now is the time for all good coders\nto learn Ruby"
105
- # Base64.b64encode(data)
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
- def b64encode(bin, len = 60)
113
- encode64(bin).scan(/.{1,#{len}}/) do
114
- print $&, "\n"
115
- end
116
- end
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
@@ -1,5 +1,5 @@
1
1
  module RubySL
2
2
  module Base64
3
- VERSION = "1.0.1"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -19,5 +19,4 @@ Gem::Specification.new do |spec|
19
19
  spec.add_development_dependency "bundler", "~> 1.3"
20
20
  spec.add_development_dependency "rake", "~> 10.0"
21
21
  spec.add_development_dependency "mspec", "~> 1.5"
22
- spec.add_development_dependency "rubysl-prettyprint", "~> 2.0"
23
22
  end
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: 1.0.1
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: 2015-05-27 00:00:00.000000000 Z
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
- - !ruby/object:Gem::Dependency
21
+ prerelease: false
28
22
  version_requirements: !ruby/object:Gem::Requirement
29
23
  requirements:
30
- - - "~>"
24
+ - - ~>
31
25
  - !ruby/object:Gem::Version
32
- version: '10.0'
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
- - !ruby/object:Gem::Dependency
35
+ prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
- - - "~>"
38
+ - - ~>
45
39
  - !ruby/object:Gem::Version
46
- version: '1.5'
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
- requirement: !ruby/object:Gem::Requirement
50
+ version_requirements: !ruby/object:Gem::Requirement
64
51
  requirements:
65
- - - "~>"
52
+ - - ~>
66
53
  - !ruby/object:Gem::Version
67
- version: '2.0'
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
- - ".gitignore"
77
- - ".travis.yml"
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.4.6
97
+ rubygems_version: 2.0.7
112
98
  signing_key:
113
99
  specification_version: 4
114
100
  summary: Ruby standard library base64.