Ascii85 1.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcb6cc7ca3f3ca02c235e5a0d5b908396524e265c9adaaf56c50bc62117c5ee7
4
- data.tar.gz: c005e9a67ecc1def46d040f06e91cb7984d0cfd43d9729638d60b2fe19d2ab8c
3
+ metadata.gz: e134217a95580db89dd446ac40511345e8c0a317be617b9b04e2ac8ca5db9670
4
+ data.tar.gz: bcc1f3f71f2f5748958825602ef58c7365ef52f7fe3265a9409fd1b84b5c8d4f
5
5
  SHA512:
6
- metadata.gz: c6fef31cebe36d41eee64ff857e87007b176b262fc4c667666f6360714b9d15274afb192572cf5bba31953f13ecde7c1b1ea60697ebf83a43dc80b35f64d94dd
7
- data.tar.gz: 2bd0e1367f729cb42d2163e5eeeba540e243138a23cfeb6bf9e2d93d49c80dc12227d65b60bd1db2f6272ab8c9bac19d0aaac37a5e9d48e14dd50d45abb8a749
6
+ metadata.gz: 4c15434410e46485ada5dcc04929092f77da1533861d22ffe65ab0e2f1e8300a821b16524fbeb5ad137cc6a139232a5684dfe6fd34c5ad33e19d68a95d3f604e
7
+ data.tar.gz: a397048e6009d3adf0c2582cfe9dbd913f6b8888c19fbf48939b1a7ab48de704fa7fb76253d5d3a05d105215fb9e9f2da299d91c12cf5e6c2a3cb2636a2b6f8a
data/Ascii85.gemspec CHANGED
@@ -1,25 +1,26 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "Ascii85/version"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/Ascii85/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "Ascii85"
6
+ s.name = 'Ascii85'
7
7
  s.version = Ascii85::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.author = "Johannes Holzfuß"
10
- s.email = "johannes@holzfuss.name"
9
+ s.author = 'Johannes Holzfuß'
10
+ s.email = 'johannes@holzfuss.name'
11
11
  s.license = 'MIT'
12
- s.homepage = "https://github.com/DataWraith/ascii85gem/"
13
- s.summary = %q{Ascii85 encoder/decoder}
14
- s.description = %q{Ascii85 provides methods to encode/decode Adobe's binary-to-text encoding of the same name.}
12
+ s.homepage = 'https://github.com/DataWraith/ascii85gem/'
13
+ s.summary = 'Ascii85 encoder/decoder'
14
+ s.description = "Ascii85 provides methods to encode/decode Adobe's binary-to-text encoding of the same name."
15
+
16
+ s.required_ruby_version = '>= 2.7.0'
15
17
 
16
- s.add_development_dependency "bundler", ">= 1.0.0"
17
- s.add_development_dependency "minitest",">= 2.6.0"
18
- s.add_development_dependency "rake", ">= 0.9.2"
18
+ s.add_development_dependency 'minitest', '~> 5', '>= 5.12.0'
19
+ s.add_development_dependency 'rake', '~> 13'
19
20
 
20
- s.files = `git ls-files`.split("\n") - ['.gitignore']
21
+ s.files = `git ls-files`.split("\n") - ['.gitignore', '.github/workflows/ruby.yml']
21
22
  s.test_files = `git ls-files -- spec/*`.split("\n")
22
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
- s.require_paths = ["lib"]
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
24
+ s.require_paths = ['lib']
24
25
  s.extra_rdoc_files = ['README.md', 'LICENSE']
25
26
  end
data/CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
1
+ # Ascii85 Changelog
2
+
3
+ ## [2.0.0] - 2024-08-20
4
+
5
+ ### BREAKING CHANGES
6
+
7
+ - The minimum required Ruby version has been raised to 2.7.0.
8
+
9
+ ### Added
10
+
11
+ - `Ascii85.decode_raw` method that doesn't expect the input to be wrapped in `<~` and `~>` delimiters.
12
+ - `Ascii85.extract` method to extract encoded text from between `<~` and `~>` for feeding to `#decode_raw`.
13
+ - Option to pass an IO-object as input to `#encode` and `#decode_raw` instead of a String.
14
+ - Option to pass an IO-object to `#encode` and `#decode_raw` for output. Output is written to the object instead of being returned as a String.
15
+ - Streaming capability for `#encode` and `#decode_raw` when both input and output are IO objects, using constant memory.
16
+
17
+ ## [1.1.1] - 2024-05-09
18
+
19
+ ### Fixed
20
+
21
+ - Make `bin/ascii85` Ruby 3.2-compatible (thanks @tylerwillingham)
22
+ - Slightly improved error handling of `bin/ascii85`
23
+
24
+ ## [1.1.0] - 2020-11-11
25
+
26
+ ### Added
27
+
28
+ - Make use of frozen_string_literal (thanks @aliismayilov)
29
+
30
+ ### Changed
31
+
32
+ - Updated tests to use newer minitest syntax
33
+
34
+ ## [1.0.3] - 2018-01-25
35
+
36
+ ### Changed
37
+
38
+ - Updated the gem's metadata
39
+
40
+ ## [1.0.2] - 2012-09-16
41
+
42
+ ### Changed
43
+
44
+ - Changed test runner from RSpec to MiniSpec
45
+ - Added support for rubygems-test
46
+ - Minor changes to make packaging easier
47
+
48
+ ## [1.0.1] - 2011-05-05
49
+
50
+ ### Changed
51
+
52
+ - Removed `hoe` dependency in favor of `bundler`
53
+ - Minor corrections in the documentation
54
+
55
+ ## [1.0.0] - 2009-12-25
56
+
57
+ ### Added
58
+
59
+ - Ruby 1.9 compatibility
60
+ - Command-line en- and decoder
61
+
62
+ ## [0.9.0] - 2009-02-17
63
+
64
+ - Initial release
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source "http://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'http://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in Ascii85.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -1,27 +1,30 @@
1
- **Status**: This project is in maintenance mode. I will not develop new features, but I will address Issues and Pull Requests.
1
+ **Status**: This project is feature-complete. With the exception of fixes to reported bugs, no further development will take place.
2
2
 
3
3
  # Ascii85
4
4
 
5
- [![Build Status](https://travis-ci.org/DataWraith/ascii85gem.svg?branch=master)](https://travis-ci.org/DataWraith/ascii85gem)
6
-
7
5
  ## Description
8
6
 
9
- Ascii85 is a simple gem that provides methods for encoding/decoding Adobe's
7
+ Ascii85 is a Ruby gem that provides methods for encoding/decoding Adobe's
10
8
  binary-to-text encoding of the same name.
11
9
 
12
- See http://www.adobe.com/products/postscript/pdfs/PLRM.pdf page 131 and
13
- http://en.wikipedia.org/wiki/Ascii85 for more information about the format.
10
+ See the Adobe PostScript Language Reference ([archived version][PLRM]) page 131
11
+ and [Wikipedia](https://en.wikipedia.org/wiki/Ascii85) for more information
12
+ about the format.
13
+
14
+ [PLRM]: https://web.archive.org/web/20161222092741/https://www.adobe.com/products/postscript/pdfs/PLRM.pdf
14
15
 
15
16
 
16
17
  ## Installation
17
18
 
18
- `sudo gem install Ascii85`
19
+ `$ gem install Ascii85`
20
+
21
+ > [!IMPORTANT]
22
+ > Note that the gem name is capitalized.
19
23
 
20
24
 
21
25
  ## Usage
22
26
 
23
- ```
24
- require 'rubygems'
27
+ ```ruby
25
28
  require 'ascii85'
26
29
 
27
30
  Ascii85.encode("Ruby")
@@ -29,15 +32,28 @@ Ascii85.encode("Ruby")
29
32
 
30
33
  Ascii85.decode("<~;KZGo~>")
31
34
  => "Ruby"
35
+
36
+ Ascii85.extract("Foo<~;KZGo~>Bar")
37
+ => ";KZGo"
38
+
39
+ Ascii85.decode_raw(";KZGo")
40
+ => "Ruby"
32
41
  ```
33
42
 
34
- In addition, Ascii85.encode can take a second parameter that specifies the
43
+ In addition, `Ascii85.encode` can take a second parameter that specifies the
35
44
  length of the returned lines. The default is 80; use `false` for unlimited.
36
45
 
37
- Ascii85.decode expects the input to be enclosed in <~ and ~> — it
38
- ignores everything outside of these. The output of Ascii85.decode
39
- will have the ASCII-8BIT encoding, so in Ruby 1.9 you may have to use
40
- <tt>String#force_encoding</tt> to correct the encoding.
46
+ `Ascii85.decode` expects the input to be enclosed in `<~` and `~>` — it
47
+ ignores everything outside of these, while `Ascii85.decode_raw` assumes that
48
+ the entire String passed in is encoded in Ascii85. If you need to, you can use
49
+ `Ascii85.extract` to find and extract the first substring of the input that is
50
+ enclosed by the `<~` and `~>` delimiters.
51
+
52
+ The output of `Ascii85.decode` and `Ascii85.decode_raw` will be a String that
53
+ has the `ASCII-8BIT` encoding, so you may have to use `String#force_encoding` to
54
+ convert it to the desired encoding.
55
+
56
+ For further options, see the [Documentation](https://www.rubydoc.info/gems/Ascii85/).
41
57
 
42
58
 
43
59
  ## Command-line utility
@@ -52,17 +68,10 @@ Encodes or decodes FILE or STDIN using Ascii85 and writes to STDOUT.
52
68
  -w, --wrap COLUMN Wrap lines at COLUMN. Default is 80, use 0 for no wrapping
53
69
  -d, --decode Decode the input
54
70
  -h, --help Display this help and exit
55
- --version Output version information
71
+ -V, --version Output version information
56
72
  ```
57
73
 
58
74
 
59
- ## Contributors
60
-
61
- Thank you for your contribution!
62
-
63
- * [@aliismayilov](https://github.com/aliismayilov) contributed frozen String handling
64
-
65
-
66
75
  ## License
67
76
 
68
77
  Ascii85 is distributed under the MIT License. See the accompanying LICENSE file
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
@@ -7,6 +9,6 @@ Rake::TestTask.new do |t|
7
9
  t.test_files = FileList['spec/**/*_spec.rb']
8
10
  end
9
11
 
10
- task :specs => :test
11
- task :tests => :test
12
- task :default => :test
12
+ task specs: :test
13
+ task tests: :test
14
+ task default: :test
data/bin/ascii85 CHANGED
@@ -1,80 +1,112 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+ # frozen_string_literal: true
3
3
 
4
4
  #
5
5
  # A simple command-line tool to de- and encode Ascii85, modeled after `base64`
6
6
  # from the GNU Coreutils.
7
7
  #
8
8
 
9
-
10
- require "optparse"
9
+ require 'optparse'
11
10
  require File.join(File.dirname(__FILE__), '..', 'lib', 'ascii85')
11
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'Ascii85', 'version')
12
12
 
13
- @options = {
14
- :wrap => 80,
15
- :decode => false
16
- }
17
-
18
- ARGV.options do |opts|
19
- opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [OPTIONS] [FILE]\n" +
20
- "Encodes or decodes FILE or STDIN using Ascii85 and writes to STDOUT."
13
+ class CLI
14
+ attr_reader :options
21
15
 
16
+ def initialize(argv, stdin: $stdin, stdout: $stdout)
17
+ @in = stdin
18
+ @out = stdout
22
19
 
23
- opts.on( "-w", "--wrap COLUMN", Integer,
24
- "Wrap lines at COLUMN. Default is 80, use 0 for no wrapping") do |opt|
20
+ @options = {
21
+ wrap: 80,
22
+ action: :encode
23
+ }
25
24
 
26
- @options[:wrap] = opt.abs
27
- @options[:wrap] = false if opt.zero?
25
+ parse_options(argv)
28
26
  end
29
27
 
30
- opts.on( "-d", "--decode", "Decode the input") do
31
- @options[:decode] = true
28
+ def parse_options(argv)
29
+ @parser = OptionParser.new do |opts|
30
+ opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [OPTIONS] [FILE]\n" \
31
+ 'Encodes or decodes FILE or STDIN using Ascii85 and writes to STDOUT.'
32
+
33
+ opts.on('-w', '--wrap COLUMN', Integer,
34
+ 'Wrap lines at COLUMN. Default is 80, use 0 for no wrapping') do |opt|
35
+ @options[:wrap] = opt.abs
36
+ @options[:wrap] = false if opt.zero?
37
+ end
38
+
39
+ opts.on('-d', '--decode', 'Decode the input') do
40
+ @options[:action] = :decode
41
+ end
42
+
43
+ opts.on('-h', '--help', 'Display this help and exit') do
44
+ @options[:action] = :help
45
+ end
46
+
47
+ opts.on('-V', '--version', 'Output version information') do |_opt|
48
+ @options[:action] = :version
49
+ end
50
+
51
+ end
52
+
53
+ remaining_args = @parser.parse!(argv)
54
+
55
+ case remaining_args.size
56
+ when 0
57
+ @options[:file] = '-'
58
+ when 1
59
+ @options[:file] = remaining_args.first
60
+ else
61
+ raise(OptionParser::ParseError, "Superfluous operand(s): \"#{remaining_args[1..].join('", "')}\"")
62
+ end
32
63
  end
64
+
65
+ def input
66
+ fn = @options[:file]
33
67
 
34
- opts.on( "-h", "--help", "Display this help and exit") do
35
- puts opts
36
- exit
37
- end
68
+ return @in.binmode if fn == '-'
38
69
 
39
- opts.on( "--version", "Output version information") do |opt|
40
- puts "Ascii85 v#{Ascii85::VERSION},\nwritten by Johannes Holzfuß"
41
- exit
70
+ raise(StandardError, "File not found: \"#{fn}\"") unless File.exist?(fn)
71
+ raise(StandardError, "File is not readable: \"#{fn}\"") unless File.readable_real?(fn)
72
+
73
+ File.new(fn, 'rb')
42
74
  end
43
75
 
44
- remaining_args = opts.parse!
76
+ def decode
77
+ Ascii85.decode(input.read, out: @out)
78
+ end
45
79
 
46
- case remaining_args.size
47
- when 0
48
- @options[:file] = '-'
49
- when 1
50
- @options[:file] = remaining_args.first
51
- else
52
- abort "Superfluous operand(s): \"#{remaining_args.join('", "')}\""
80
+ def encode
81
+ Ascii85.encode(input, @options[:wrap], out: @out)
53
82
  end
54
- end
55
83
 
56
- if @options[:file] == '-'
57
- @input = $stdin.binmode.read
58
- else
59
- unless File.exists?(@options[:file])
60
- abort "File not found: \"#{@options[:file]}\""
84
+ def version
85
+ "Ascii85 v#{Ascii85::VERSION},\nwritten by Johannes Holzfuß"
61
86
  end
62
87
 
63
- unless File.readable_real?(@options[:file])
64
- abort "File is not readable: \"#{@options[:file]}\""
88
+ def help
89
+ @parser
65
90
  end
66
91
 
67
- File.open(@options[:file], 'rb') do |f|
68
- @input = f.read
92
+ def call
93
+ case @options[:action]
94
+ when :help then @out.puts help
95
+ when :version then @out.puts version
96
+ when :encode then encode
97
+ when :decode then decode
98
+ end
69
99
  end
70
100
  end
71
101
 
72
- if @options[:decode]
102
+ if File.basename($PROGRAM_NAME) == "ascii85"
73
103
  begin
74
- print Ascii85.decode(@input)
75
- rescue Ascii85::DecodingError => error
76
- abort "Decoding Error: #{error.message.to_s}"
104
+ CLI.new(ARGV).call
105
+ rescue OptionParser::ParseError => e
106
+ abort e.message
107
+ rescue Ascii85::DecodingError => e
108
+ abort "Decoding Error: #{e.message}"
109
+ rescue StandardError => e
110
+ abort "Error: #{e.message}"
77
111
  end
78
- else
79
- print Ascii85.encode(@input, @options[:wrap])
80
112
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ascii85
4
- VERSION = "1.1.0"
4
+ VERSION = '2.0.0'
5
5
  end