base64 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a5ed97490e357afc22d3a6abd81a414b83f0ba0518ae6d70ce96e1fc27ceacc
4
- data.tar.gz: 6f5e2d2f066a6ef3fd672023ad169676bb91462edc19a4091bdb04f33bc4e2de
3
+ metadata.gz: e354beb33c4cd44aec636c9fef7f2948971fca963a60c87efb96d02f5a1a0b84
4
+ data.tar.gz: 6925a1c6847f48c78cc2ef572bceb84e2e0b88f08ad6cff08267c57d56fca9f6
5
5
  SHA512:
6
- metadata.gz: 472ef81375e3cfae4baf72a77f6253f219d044726ba2f108f93ad334a435912465dc231022760b7b05fdf76ef6da0dc8bdcd189f5d0c20c3f3386ad2b547a90a
7
- data.tar.gz: 13b206da0ad209a9ba9aee927b7f3512551b1649c15e10562a51e17845cc1b8d924eb0e36b481e0f31e4f2c8a90956d7cffeb61c771484073f812285329c5a60
6
+ metadata.gz: 5b12ef4b892b908de5a44db9822565082911af176add02b565a6d34a5d2bc0997fba5caf3bbd2554337c95ce8b78a53373c60da8b2d61449f078d8948c053330
7
+ data.tar.gz: 5dde38796eff1286680e7589a18862be76424c53fcfdea12e2964c7b290df738fb6c9830767dc9dc1370d989c30258564d0af0d6452bf8513780dfcf5cae8804
data/lib/base64.rb CHANGED
@@ -56,7 +56,7 @@ module Base64
56
56
  # This is line three
57
57
  # And so on...
58
58
  def decode64(str)
59
- str.unpack1("m")
59
+ str.unpack("m").first
60
60
  end
61
61
 
62
62
  # Returns the Base64-encoded version of +bin+.
@@ -71,7 +71,7 @@ module Base64
71
71
  # ArgumentError is raised if +str+ is incorrectly padded or contains
72
72
  # non-alphabet characters. Note that CR or LF are also rejected.
73
73
  def strict_decode64(str)
74
- str.unpack1("m0")
74
+ str.unpack("m0").first
75
75
  end
76
76
 
77
77
  # Returns the Base64-encoded version of +bin+.
@@ -82,8 +82,8 @@ module Base64
82
82
  # You can remove the padding by setting +padding+ as false.
83
83
  def urlsafe_encode64(bin, padding: true)
84
84
  str = strict_encode64(bin)
85
+ str.chomp!("==") or str.chomp!("=") unless padding
85
86
  str.tr!("+/", "-_")
86
- str.delete!("=") unless padding
87
87
  str
88
88
  end
89
89
 
@@ -99,9 +99,11 @@ module Base64
99
99
  # NOTE: RFC 4648 does say nothing about unpadded input, but says that
100
100
  # "the excess pad characters MAY also be ignored", so it is inferred that
101
101
  # unpadded input is also acceptable.
102
- str = str.tr("-_", "+/")
103
102
  if !str.end_with?("=") && str.length % 4 != 0
104
103
  str = str.ljust((str.length + 3) & ~3, "=")
104
+ str.tr!("-_", "+/")
105
+ else
106
+ str = str.tr("-_", "+/")
105
107
  end
106
108
  strict_decode64(str)
107
109
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base64
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke Endoh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Support for encoding and decoding binary data using a Base64 representation.
14
14
  email:
@@ -17,15 +17,8 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".github/workflows/test.yml"
21
- - ".gitignore"
22
- - Gemfile
23
20
  - LICENSE.txt
24
21
  - README.md
25
- - Rakefile
26
- - base64.gemspec
27
- - bin/console
28
- - bin/setup
29
22
  - lib/base64.rb
30
23
  homepage: https://github.com/ruby/base64
31
24
  licenses:
@@ -49,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
42
  - !ruby/object:Gem::Version
50
43
  version: '0'
51
44
  requirements: []
52
- rubygems_version: 3.2.0.rc.1
45
+ rubygems_version: 3.4.19
53
46
  signing_key:
54
47
  specification_version: 4
55
48
  summary: Support for encoding and decoding binary data using a Base64 representation.
@@ -1,24 +0,0 @@
1
- name: test
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- build:
7
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
- strategy:
9
- matrix:
10
- ruby: [ 2.7, 2.6, 2.5, head ]
11
- os: [ ubuntu-latest, macos-latest ]
12
- runs-on: ${{ matrix.os }}
13
- steps:
14
- - uses: actions/checkout@master
15
- - name: Set up Ruby
16
- uses: ruby/setup-ruby@v1
17
- with:
18
- ruby-version: ${{ matrix.ruby }}
19
- - name: Install dependencies
20
- run: |
21
- gem install bundler --no-document
22
- bundle install
23
- - name: Run test
24
- run: rake test
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "rake"
4
- gem "minitest"
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/test_*.rb"]
8
- end
9
-
10
- task :default => :test
data/base64.gemspec DELETED
@@ -1,22 +0,0 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = "base64"
3
- spec.version = "0.1.0"
4
- spec.authors = ["Yusuke Endoh"]
5
- spec.email = ["mame@ruby-lang.org"]
6
-
7
- spec.summary = %q{Support for encoding and decoding binary data using a Base64 representation.}
8
- spec.description = %q{Support for encoding and decoding binary data using a Base64 representation.}
9
- spec.homepage = "https://github.com/ruby/base64"
10
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
11
- spec.licenses = ["Ruby", "BSD-2-Clause"]
12
-
13
- spec.metadata["homepage_uri"] = spec.homepage
14
- spec.metadata["source_code_uri"] = spec.homepage
15
-
16
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- end
19
- spec.bindir = "exe"
20
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
22
- end
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "base64"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here