commonmeta-ruby 3.0.7 → 3.0.8

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
  SHA256:
3
- metadata.gz: a8554b09a4a7efef4be8b21703eec6013c56b679b3cd84b1c82f1e3c7c8747ae
4
- data.tar.gz: cb597fd50b0ba17d9e379344aa2c84647e0eb32829676def9e63356bdb415a4c
3
+ metadata.gz: d158d95fcca721c5fd2052bd4175e5a39657794bc0b3478813c124b7627bbc4c
4
+ data.tar.gz: 89fae69b601b26e68e87f7714496c9b7dde50a77bbe11b7646756eefe1ffa13d
5
5
  SHA512:
6
- metadata.gz: 2e4907bf337d9296440b40fbeaa6d97f2da4125f83b649db9787d1e220ee70d53d1dcf57739e2dcf0653b01261f512291e34ba4d4905fbf7f59864878daa90ad
7
- data.tar.gz: 9328e0618e95c59dc8e2e0d61238fc2a2de9cc0cd2210619e5a797f0742d26d4360e2cecdb47ac318f749f073b5a8919606773f16398df61fc983c016c247922
6
+ metadata.gz: 01e3aa82db4b968dc8b72670bec686c08e7f671c271173c32c53b1e027cc49b02e209da1826dcd24d2444d7b8bc434ce88f343568fde2dd467ec0dffadbe8cb7
7
+ data.tar.gz: 53ccb0ee19bb71c53eca55168185b77fe9535b55aa87634b239cf0b6bc83bef9692749d02c974c6101436a0089b99accd59d6d6181b56a5584e2eb993c7e225c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- commonmeta-ruby (3.0.7)
4
+ commonmeta-ruby (3.0.8)
5
5
  activesupport (>= 4.2.5, < 8.0)
6
6
  addressable (~> 2.8.1, < 2.8.2)
7
7
  base32-url (>= 0.5.0, < 1)
@@ -64,7 +64,7 @@ module Commonmeta
64
64
  desc '', 'encode_id'
65
65
 
66
66
  def encode_id
67
- puts encode_id
67
+ puts encode_container_id
68
68
  end
69
69
 
70
70
  desc '', 'decode'
@@ -76,7 +76,7 @@ module Commonmeta
76
76
  desc '', 'decode_id'
77
77
 
78
78
  def decode_id(id)
79
- puts decode_id(id)
79
+ puts decode_container_id(id)
80
80
  end
81
81
 
82
82
  default_task :convert
@@ -1351,14 +1351,14 @@ module Commonmeta
1351
1351
  Base32::URL.decode(suffix)
1352
1352
  end
1353
1353
 
1354
- def encode_id
1354
+ def encode_container_id
1355
1355
  # suffix has 5 digits plus two checksum digits. With base32 there are
1356
1356
  # 32 possible digits, so 5 digits gives 32^5 possible combinations
1357
1357
  random_int = SecureRandom.random_number(32 ** 4..(32 ** 5) - 1)
1358
1358
  Base32::URL.encode(random_int, checksum: true)
1359
1359
  end
1360
1360
 
1361
- def decode_id(id)
1361
+ def decode_container_id(id)
1362
1362
  Base32::URL.decode(id)
1363
1363
  end
1364
1364
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmeta
4
- VERSION = '3.0.7'
4
+ VERSION = '3.0.8'
5
5
  end
data/spec/cli_spec.rb CHANGED
@@ -306,4 +306,18 @@ describe Commonmeta::CLI do
306
306
  expect { subject.decode input }.to output(/464528469187255429864\n/).to_stdout
307
307
  end
308
308
  end
309
+
310
+ describe "encode_id" do
311
+ it "random" do
312
+ expect { subject.encode_id }.to output(/[a-z0-9]+/).to_stdout
313
+ end
314
+ end
315
+
316
+ describe "decode_id" do
317
+ let(:input) { "h49ct36" }
318
+
319
+ it "blog post" do
320
+ expect { subject.decode_id input }.to output(/18397685862\n/).to_stdout
321
+ end
322
+ end
309
323
  end
data/spec/utils_spec.rb CHANGED
@@ -631,20 +631,20 @@ describe Commonmeta::Metadata, vcr: true do
631
631
 
632
632
  context 'random id' do
633
633
  it 'encode id' do
634
- response = subject.encode_id
634
+ response = subject.encode_container_id
635
635
  expect(response).to match(%r{[a-z0-9]+})
636
636
  expect(response.length).to eq(7)
637
637
  end
638
638
 
639
639
  it 'decode id' do
640
640
  id= '4425y27'
641
- response = subject.decode_id(id)
641
+ response = subject.decode_container_id(id)
642
642
  expect(response).to eq(4_431_476_807)
643
643
  end
644
644
 
645
645
  it 'decode another id' do
646
646
  id = 'gr1by89'
647
- response = subject.decode_id(id)
647
+ response = subject.decode_container_id(id)
648
648
  expect(response).to eq(17_986_615_561)
649
649
  end
650
650
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commonmeta-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner