rambling-trie-opal 2.1.1 → 2.1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rambling/trie.rb +23 -20
- data/lib/rambling/trie/configuration.rb +8 -6
- data/lib/rambling/trie/configuration/properties.rb +17 -8
- data/lib/rambling/trie/nodes.rb +10 -8
- data/lib/rambling/trie/readers.rb +7 -5
- data/lib/rambling/trie/serializers.rb +9 -8
- data/lib/rambling/trie/version.rb +1 -1
- data/rambling-trie-opal.gemspec +2 -3
- data/spec/integration/rambling/trie_spec.rb +16 -16
- data/spec/lib/rambling/trie/configuration/properties_spec.rb +3 -4
- data/spec/lib/rambling/trie/serializers/zip_spec.rb +20 -20
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac5ccedda6019e5a941b12ac2e130ee6239ab5903c4ab98ba2bf2e5bf6ed98cf
|
4
|
+
data.tar.gz: 13008e8a98897b470788b4d7aaa45d42774fc2dc633b9b49604c2fcd52652b0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 022d379f95a38a8ec29374309fcf7c6306202867d74ef67fee377d648c0543675463847fc43134b8668a4f33547000d56690dae4cf41a16af37c83a2a0c01c36
|
7
|
+
data.tar.gz: 5e832cf45b8c946d840fab912b2ca4b2c34e550935104175facd968c848b263f0976bc632c919f9ac736b171472b168af931d2be31ea1bb0275c6b56b3f13fb1
|
data/lib/rambling/trie.rb
CHANGED
@@ -1,25 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
require 'rambling/trie/
|
11
|
-
require 'rambling/trie/
|
12
|
-
require 'rambling/trie/
|
13
|
-
require 'rambling/trie/
|
14
|
-
require 'rambling/trie/
|
15
|
-
require 'rambling/trie/
|
16
|
-
require 'rambling/trie/
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
3
|
+
if RUBY_ENGINE == 'opal'
|
4
|
+
require 'rambling/trie/configuration'
|
5
|
+
require 'rambling/trie/comparable'
|
6
|
+
require 'rambling/trie/compressible'
|
7
|
+
require 'rambling/trie/compressor'
|
8
|
+
require 'rambling/trie/container'
|
9
|
+
require 'rambling/trie/enumerable'
|
10
|
+
require 'rambling/trie/inspectable'
|
11
|
+
require 'rambling/trie/invalid_operation'
|
12
|
+
require 'rambling/trie/readers'
|
13
|
+
require 'rambling/trie/serializers'
|
14
|
+
require 'rambling/trie/stringifyable'
|
15
|
+
require 'rambling/trie/nodes'
|
16
|
+
require 'rambling/trie/version'
|
17
|
+
else
|
18
|
+
%w(
|
19
|
+
comparable compressible compressor configuration container enumerable
|
20
|
+
inspectable invalid_operation readers serializers stringifyable nodes
|
21
|
+
version
|
22
|
+
).each do |file|
|
23
|
+
require File.join('rambling', 'trie', file)
|
24
|
+
end
|
25
|
+
end
|
23
26
|
|
24
27
|
# General namespace for all Rambling gems.
|
25
28
|
module Rambling
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
require 'rambling
|
3
|
+
if RUBY_ENGINE == 'opal'
|
4
|
+
require 'rambling/trie/configuration/properties'
|
5
|
+
require 'rambling/trie/configuration/provider_collection'
|
6
|
+
else
|
7
|
+
%w(properties provider_collection).each do |file|
|
8
|
+
require File.join('rambling', 'trie', 'configuration', file)
|
9
|
+
end
|
10
|
+
end
|
9
11
|
|
10
12
|
module Rambling
|
11
13
|
module Trie
|
@@ -59,15 +59,24 @@ module Rambling
|
|
59
59
|
def reset_serializers
|
60
60
|
marshal_serializer = Rambling::Trie::Serializers::Marshal.new
|
61
61
|
yaml_serializer = Rambling::Trie::Serializers::Yaml.new
|
62
|
-
|
62
|
+
zip_serializer = Rambling::Trie::Serializers::Zip.new self unless RUBY_ENGINE == 'opal'
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
if RUBY_ENGINE == 'opal'
|
65
|
+
@serializers = Rambling::Trie::Configuration::ProviderCollection.new(
|
66
|
+
:serializer,
|
67
|
+
marshal: marshal_serializer,
|
68
|
+
yml: yaml_serializer,
|
69
|
+
yaml: yaml_serializer,
|
70
|
+
)
|
71
|
+
else
|
72
|
+
@serializers = Rambling::Trie::Configuration::ProviderCollection.new(
|
73
|
+
:serializer,
|
74
|
+
marshal: marshal_serializer,
|
75
|
+
yml: yaml_serializer,
|
76
|
+
yaml: yaml_serializer,
|
77
|
+
zip: zip_serializer,
|
78
|
+
)
|
79
|
+
end
|
71
80
|
end
|
72
81
|
end
|
73
82
|
end
|
data/lib/rambling/trie/nodes.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
require 'rambling/trie/nodes/
|
8
|
-
|
9
|
-
|
10
|
-
require 'rambling
|
3
|
+
if RUBY_ENGINE == 'opal'
|
4
|
+
require 'rambling/trie/nodes/node'
|
5
|
+
require 'rambling/trie/nodes/compressed'
|
6
|
+
require 'rambling/trie/nodes/missing'
|
7
|
+
require 'rambling/trie/nodes/raw'
|
8
|
+
else
|
9
|
+
%w(node missing compressed raw).each do |file|
|
10
|
+
require File.join('rambling', 'trie', 'nodes', file)
|
11
|
+
end
|
12
|
+
end
|
11
13
|
|
12
14
|
module Rambling
|
13
15
|
module Trie
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
require 'rambling
|
3
|
+
if RUBY_ENGINE == 'opal'
|
4
|
+
require 'rambling/trie/readers/plain_text'
|
5
|
+
else
|
6
|
+
%w(plain_text).each do |file|
|
7
|
+
require File.join('rambling', 'trie', 'readers', file)
|
8
|
+
end
|
9
|
+
end
|
8
10
|
|
9
11
|
module Rambling
|
10
12
|
module Trie
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require 'rambling
|
10
|
-
|
3
|
+
if RUBY_ENGINE == 'opal'
|
4
|
+
require 'rambling/trie/serializers/file'
|
5
|
+
require 'rambling/trie/serializers/marshal'
|
6
|
+
require 'rambling/trie/serializers/yaml'
|
7
|
+
else
|
8
|
+
%w(file marshal yaml zip).each do |file|
|
9
|
+
require File.join('rambling', 'trie', 'serializers', file)
|
10
|
+
end
|
11
|
+
end
|
11
12
|
|
12
13
|
module Rambling
|
13
14
|
module Trie
|
data/rambling-trie-opal.gemspec
CHANGED
@@ -4,11 +4,10 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
4
4
|
require 'rambling/trie/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.authors = ['Ribose
|
8
|
-
gem.email = ['open.source@ribose.com']
|
7
|
+
gem.authors = ['Ribose Open']
|
9
8
|
|
10
9
|
gem.description = <<~DESCRIPTION.gsub(%r{\s+}, ' ')
|
11
|
-
The
|
10
|
+
The Rambling Trie Opal is an opal compatible version of rambling-trie gem.
|
12
11
|
DESCRIPTION
|
13
12
|
|
14
13
|
gem.summary = 'A Ruby implementation (Opal Compatible) of the trie data structure.'
|
@@ -65,23 +65,23 @@ describe Rambling::Trie do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
context 'when serialized with zipped Ruby marshal format' do
|
69
|
+
before do
|
70
|
+
@original_on_exists_proc = ::Zip.on_exists_proc
|
71
|
+
@original_continue_on_exists_proc = ::Zip.continue_on_exists_proc
|
72
|
+
::Zip.on_exists_proc = true
|
73
|
+
::Zip.continue_on_exists_proc = true
|
74
|
+
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
after do
|
77
|
+
::Zip.on_exists_proc = @original_on_exists_proc
|
78
|
+
::Zip.continue_on_exists_proc = @original_continue_on_exists_proc
|
79
|
+
end
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
81
|
+
it_behaves_like 'a serializable trie' do
|
82
|
+
let(:trie_to_serialize) { Rambling::Trie.create words_filepath }
|
83
|
+
let(:format) { 'marshal.zip' }
|
84
|
+
end
|
85
|
+
end unless RUBY_ENGINE == 'opal'
|
86
86
|
end
|
87
87
|
end
|
@@ -8,14 +8,13 @@ describe Rambling::Trie::Configuration::Properties do
|
|
8
8
|
describe '.new' do
|
9
9
|
it 'configures the serializers' do
|
10
10
|
serializers = properties.serializers
|
11
|
-
|
12
|
-
expect(serializers.formats).to match_array %i(marshal yaml yml)
|
11
|
+
expect(serializers.formats).to match_array %i(marshal yaml yml zip) unless RUBY_ENGINE == 'opal'
|
13
12
|
expect(serializers.providers.to_a).to match_array [
|
14
13
|
[:marshal, Rambling::Trie::Serializers::Marshal],
|
15
14
|
[:yaml, Rambling::Trie::Serializers::Yaml],
|
16
15
|
[:yml, Rambling::Trie::Serializers::Yaml],
|
17
|
-
|
18
|
-
]
|
16
|
+
[:zip, Rambling::Trie::Serializers::Zip],
|
17
|
+
] unless RUBY_ENGINE == 'opal'
|
19
18
|
end
|
20
19
|
|
21
20
|
it 'configures the readers' do
|
@@ -2,27 +2,27 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
describe Rambling::Trie::Serializers::Zip do
|
6
|
+
it_behaves_like 'a serializer' do
|
7
|
+
let(:properties) { Rambling::Trie::Configuration::Properties.new }
|
8
|
+
let(:serializer) { Rambling::Trie::Serializers::Zip.new properties }
|
9
|
+
let(:format) { 'marshal.zip' }
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
before do
|
12
|
+
properties.tmp_path = tmp_path
|
13
|
+
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
let(:filename) { File.basename(filepath).gsub %r{\.zip}, '' }
|
16
|
+
let(:formatted_content) { zip Marshal.dump content }
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def zip content
|
19
|
+
cursor = Zip::OutputStream.write_buffer do |io|
|
20
|
+
io.put_next_entry filename
|
21
|
+
io.write content
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
cursor.rewind
|
25
|
+
cursor.read
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end unless RUBY_ENGINE == 'opal'
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rambling-trie-opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.1
|
4
|
+
version: 2.1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Ribose
|
7
|
+
- Ribose Open
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
@@ -52,9 +52,9 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.9.25
|
55
|
-
description: 'The
|
56
|
-
|
57
|
-
|
55
|
+
description: 'The Rambling Trie Opal is an opal compatible version of rambling-trie
|
56
|
+
gem. '
|
57
|
+
email:
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|