Ascii85 1.0.3 → 1.1.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
- SHA1:
3
- metadata.gz: 5677cdd3585a3d528ba316387231b110f6bcc23e
4
- data.tar.gz: 3e6f35796a2b92ee46210fa2abc67dcd54e7f79f
2
+ SHA256:
3
+ metadata.gz: dcb6cc7ca3f3ca02c235e5a0d5b908396524e265c9adaaf56c50bc62117c5ee7
4
+ data.tar.gz: c005e9a67ecc1def46d040f06e91cb7984d0cfd43d9729638d60b2fe19d2ab8c
5
5
  SHA512:
6
- metadata.gz: f0899095dd358dacddf940655b3b184ca578a6e48e9a965b26d99ab3c44665ed8fbb1df18ec23a0ff5ce3adbb0507c8c97947bdad4573c692cf955ba2f638e1c
7
- data.tar.gz: 69d6130a76e34c6a124714147ffada5b6b14908bedc80c9ec7d966aa2a11a86a64b6fcf635dad7ab9762c5e7198d5ea5507ae7379a8b3e579ac8b7f6b24ece23
6
+ metadata.gz: c6fef31cebe36d41eee64ff857e87007b176b262fc4c667666f6360714b9d15274afb192572cf5bba31953f13ecde7c1b1ea60697ebf83a43dc80b35f64d94dd
7
+ data.tar.gz: 2bd0e1367f729cb42d2163e5eeeba540e243138a23cfeb6bf9e2d93d49c80dc12227d65b60bd1db2f6272ab8c9bac19d0aaac37a5e9d48e14dd50d45abb8a749
@@ -1,7 +1,30 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8
4
3
  - 1.9
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3
8
+ - 2.4
5
9
  - 2.5
10
+ - 2.6
11
+ - 2.7
6
12
  - ruby-head
7
13
  - jruby
14
+ - truffleruby
15
+ env:
16
+ - RUBYOPT="--enable-frozen-string-literal"
17
+ - RUBYOPT=""
18
+ matrix:
19
+ exclude:
20
+ - rvm: 1.9
21
+ env: RUBYOPT="--enable-frozen-string-literal"
22
+ - rvm: 2.0
23
+ env: RUBYOPT="--enable-frozen-string-literal"
24
+ - rvm: 2.1
25
+ env: RUBYOPT="--enable-frozen-string-literal"
26
+ - rvm: 2.2
27
+ env: RUBYOPT="--enable-frozen-string-literal"
28
+ # bundler did not support this back then
29
+ - rvm: 2.3
30
+ env: RUBYOPT="--enable-frozen-string-literal"
@@ -1,3 +1,8 @@
1
+ === 1.1.0 / 2020-11-11
2
+
3
+ * Make use of frozen_string_literal
4
+ * Update tests to use newer minitest syntax
5
+
1
6
  === 1.0.3 / 2018-01-25
2
7
 
3
8
  * Updated the gem's metadata
data/README.md CHANGED
@@ -56,6 +56,13 @@ Encodes or decodes FILE or STDIN using Ascii85 and writes to STDOUT.
56
56
  ```
57
57
 
58
58
 
59
+ ## Contributors
60
+
61
+ Thank you for your contribution!
62
+
63
+ * [@aliismayilov](https://github.com/aliismayilov) contributed frozen String handling
64
+
65
+
59
66
  ## License
60
67
 
61
68
  Ascii85 is distributed under the MIT License. See the accompanying LICENSE file
@@ -51,7 +51,6 @@ ARGV.options do |opts|
51
51
  else
52
52
  abort "Superfluous operand(s): \"#{remaining_args.join('", "')}\""
53
53
  end
54
-
55
54
  end
56
55
 
57
56
  if @options[:file] == '-'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ascii85
2
- VERSION = "1.0.3"
4
+ VERSION = "1.1.0"
3
5
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
 
4
5
  #
@@ -15,7 +16,6 @@
15
16
 
16
17
 
17
18
  module Ascii85
18
-
19
19
  #
20
20
  # Encodes the bytes of the given String as Ascii85.
21
21
  #
@@ -37,7 +37,6 @@ module Ascii85
37
37
  #
38
38
  #
39
39
  def self.encode(str, wrap_lines = 80)
40
-
41
40
  to_encode = str.to_s
42
41
  return '' if to_encode.empty?
43
42
 
@@ -59,7 +58,7 @@ module Ascii85
59
58
  if tuple == 0
60
59
  'z'
61
60
  else
62
- tmp = ""
61
+ tmp = String.new
63
62
  5.times do
64
63
  tmp << ((tuple % 85) + 33).chr
65
64
  tuple /= 85
@@ -82,7 +81,6 @@ module Ascii85
82
81
  end
83
82
 
84
83
  # Otherwise we wrap the lines
85
-
86
84
  line_length = [2, wrap_lines.to_i].max
87
85
 
88
86
  wrapped = []
@@ -122,7 +120,6 @@ module Ascii85
122
120
  # encountered.
123
121
  #
124
122
  def self.decode(str)
125
-
126
123
  input = str.to_s
127
124
 
128
125
  opening_delim = '<~'
@@ -134,9 +131,9 @@ module Ascii85
134
131
  # errors if an especially exotic input encoding is introduced.
135
132
  # As of Ruby 1.9.2 all non-dummy encodings work fine though.
136
133
  #
137
- if opening_delim.respond_to?(:encode!)
138
- opening_delim.encode!(input.encoding)
139
- closing_delim.encode!(input.encoding)
134
+ if opening_delim.respond_to?(:encode)
135
+ opening_delim = opening_delim.encode(input.encoding)
136
+ closing_delim = closing_delim.encode(input.encoding)
140
137
  end
141
138
 
142
139
  # Get the positions of the opening/closing delimiters. If there is
@@ -153,7 +150,6 @@ module Ascii85
153
150
  result = []
154
151
 
155
152
  input.each_byte do |c|
156
-
157
153
  case c.chr
158
154
  when " ", "\t", "\r", "\n", "\f", "\0"
159
155
  # Ignore whitespace
@@ -189,7 +185,6 @@ module Ascii85
189
185
  raise(Ascii85::DecodingError,
190
186
  "Illegal character inside Ascii85: #{c.chr.dump}")
191
187
  end
192
-
193
188
  end
194
189
 
195
190
  # Convert result into a String
@@ -225,5 +220,4 @@ module Ascii85
225
220
  # at least two characters.
226
221
  #
227
222
  class DecodingError < StandardError; end
228
-
229
223
  end
@@ -7,11 +7,9 @@ require 'minitest/autorun'
7
7
  require File.expand_path('../../../lib/ascii85', __FILE__)
8
8
 
9
9
  describe Ascii85 do
10
-
11
10
  UNSUPPORTED_MSG = "This version of Ruby does not support encodings"
12
11
 
13
12
  TEST_CASES = {
14
-
15
13
  "" => "",
16
14
  " " => "<~+9~>",
17
15
 
@@ -44,9 +42,8 @@ describe Ascii85 do
44
42
  }
45
43
 
46
44
  it "#decode should be the inverse of #encode" do
47
-
48
45
  # Generate a random string
49
- test_str = ""
46
+ test_str = String.new
50
47
  (1 + rand(255)).times do
51
48
  test_str << rand(256).chr
52
49
  end
@@ -54,14 +51,13 @@ describe Ascii85 do
54
51
  encoded = Ascii85.encode(test_str)
55
52
  decoded = Ascii85.decode(encoded)
56
53
 
57
- decoded.must_equal test_str
54
+ assert_equal decoded, test_str
58
55
  end
59
56
 
60
57
  describe "#encode" do
61
-
62
58
  it "should encode all specified test-cases correctly" do
63
59
  TEST_CASES.each_pair do |input, encoded|
64
- Ascii85.encode(input).must_equal encoded
60
+ assert_equal Ascii85.encode(input), encoded
65
61
  end
66
62
  end
67
63
 
@@ -73,7 +69,7 @@ describe Ascii85 do
73
69
  input_EUC_JP = 'どうもありがとうミスターロボット'.encode('EUC-JP')
74
70
  input_binary = input_EUC_JP.force_encoding('ASCII-8BIT')
75
71
 
76
- Ascii85.encode(input_EUC_JP).must_equal Ascii85.encode(input_binary)
72
+ assert_equal Ascii85.encode(input_EUC_JP), Ascii85.encode(input_binary)
77
73
  end
78
74
 
79
75
  it "should produce output lines no longer than specified" do
@@ -82,7 +78,7 @@ describe Ascii85 do
82
78
  #
83
79
  # No wrap
84
80
  #
85
- Ascii85.encode(test_str, false).count("\n").must_equal 0
81
+ assert_equal Ascii85.encode(test_str, false).count("\n"), 0
86
82
 
87
83
  #
88
84
  # x characters per line, except for the last one
@@ -107,23 +103,21 @@ describe Ascii85 do
107
103
  count_arr.delete_if { |len| len == x }
108
104
 
109
105
  # Now count_arr should be empty
110
- count_arr.must_be_empty
106
+ assert_empty count_arr
111
107
  end
112
108
 
113
109
  it "should not split the end-marker to achieve correct line length" do
114
- Ascii85.encode("\0" * 4, 4).must_equal "<~z\n~>"
110
+ assert_equal Ascii85.encode("\0" * 4, 4), "<~z\n~>"
115
111
  end
116
-
117
112
  end
118
113
 
119
114
  describe "#decode" do
120
-
121
115
  it "should decode all specified test-cases correctly" do
122
116
  TEST_CASES.each_pair do |decoded, input|
123
117
  if String.new.respond_to?(:encoding)
124
- Ascii85.decode(input).must_equal decoded.dup.force_encoding('ASCII-8BIT')
118
+ assert_equal Ascii85.decode(input), decoded.dup.force_encoding('ASCII-8BIT')
125
119
  else
126
- Ascii85.decode(input).must_equal decoded
120
+ assert_equal Ascii85.decode(input), decoded
127
121
  end
128
122
  end
129
123
  end
@@ -149,7 +143,7 @@ describe Ascii85 do
149
143
 
150
144
  begin
151
145
  to_test = input_ascii85.encode(encoding)
152
- Ascii85.decode(to_test).force_encoding('UTF-8').must_equal input
146
+ assert_equal Ascii85.decode(to_test).force_encoding('UTF-8'), input
153
147
  rescue Encoding::ConverterNotFoundError
154
148
  # Ignore this encoding
155
149
  end
@@ -157,19 +151,19 @@ describe Ascii85 do
157
151
  end
158
152
 
159
153
  it "should only process data within delimiters" do
160
- Ascii85.decode("<~~>").must_be_empty
161
- Ascii85.decode("Doesn't contain delimiters").must_be_empty
162
- Ascii85.decode("Mismatched ~> delimiters 1").must_be_empty
163
- Ascii85.decode("Mismatched <~ delimiters 2").must_be_empty
164
- Ascii85.decode("Mismatched ~><~ delimiters 3").must_be_empty
165
-
166
- Ascii85.decode("<~;KZGo~><~z~>").must_equal "Ruby"
167
- Ascii85.decode("FooBar<~z~>BazQux").must_equal "\0\0\0\0"
154
+ assert_empty Ascii85.decode("<~~>")
155
+ assert_empty Ascii85.decode("Doesn't contain delimiters")
156
+ assert_empty Ascii85.decode("Mismatched ~> delimiters 1")
157
+ assert_empty Ascii85.decode("Mismatched <~ delimiters 2")
158
+ assert_empty Ascii85.decode("Mismatched ~><~ delimiters 3")
159
+
160
+ assert_equal Ascii85.decode("<~;KZGo~><~z~>"), "Ruby"
161
+ assert_equal Ascii85.decode("FooBar<~z~>BazQux"), "\0\0\0\0"
168
162
  end
169
163
 
170
164
  it "should ignore whitespace" do
171
165
  decoded = Ascii85.decode("<~6 #LdYA\r\08\n \n\n- *rF*(i\"Ch[s \t(D.RU,@ <-\'jDJ=0\f/~>")
172
- decoded.must_equal 'Antidisestablishmentarianism'
166
+ assert_equal decoded, 'Antidisestablishmentarianism'
173
167
  end
174
168
 
175
169
  it "should return ASCII-8BIT encoded strings" do
@@ -177,29 +171,25 @@ describe Ascii85 do
177
171
  skip(UNSUPPORTED_MSG)
178
172
  end
179
173
 
180
- Ascii85.decode("<~;KZGo~>").encoding.name.must_equal "ASCII-8BIT"
174
+ assert_equal Ascii85.decode("<~;KZGo~>").encoding.name, "ASCII-8BIT"
181
175
  end
182
176
 
183
177
  describe "Error conditions" do
184
-
185
178
  it "should raise DecodingError if it encounters a word >= 2**32" do
186
- lambda { Ascii85.decode('<~s8W-#~>') }.must_raise(Ascii85::DecodingError)
179
+ assert_raises(Ascii85::DecodingError) { Ascii85.decode('<~s8W-#~>') }
187
180
  end
188
181
 
189
182
  it "should raise DecodingError if it encounters an invalid character" do
190
- lambda { Ascii85.decode('<~!!y!!~>') }.must_raise(Ascii85::DecodingError)
183
+ assert_raises(Ascii85::DecodingError) { Ascii85.decode('<~!!y!!~>') }
191
184
  end
192
185
 
193
186
  it "should raise DecodingError if the last tuple consists of a single character" do
194
- lambda { Ascii85.decode('<~!~>') }.must_raise(Ascii85::DecodingError)
187
+ assert_raises(Ascii85::DecodingError) { Ascii85.decode('<~!~>') }
195
188
  end
196
189
 
197
190
  it "should raise DecodingError if a z is found inside a 5-tuple" do
198
- lambda { Ascii85.decode('<~!!z!!~>') }.must_raise Ascii85::DecodingError
191
+ assert_raises(Ascii85::DecodingError) { Ascii85.decode('<~!!z!!~>') }
199
192
  end
200
-
201
193
  end
202
-
203
194
  end
204
-
205
195
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ascii85
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Holzfuß
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-25 00:00:00.000000000 Z
11
+ date: 2020-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,8 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.6.13
95
+ rubygems_version: 3.1.4
97
96
  signing_key:
98
97
  specification_version: 4
99
98
  summary: Ascii85 encoder/decoder