persistent-dmnd 1.0.4 → 2.0.3
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 +5 -5
- data/.gitlab-ci.yml +140 -25
- data/.ruby-version +1 -1
- data/CODE_OF_CONDUCT.adoc +1 -1
- data/LICENSE +1 -1
- data/README.adoc +5 -4
- data/gems.rb +5 -11
- data/lib/persistent-dmnd.rb +4 -3
- data/lib/persistent-/360/237/222/216.rb +9 -8
- data/lib/persistent_dmnd/array.rb +9 -8
- data/lib/persistent_dmnd/concurrent_ruby_support.rb +6 -5
- data/lib/persistent_dmnd/dmndifier.rb +5 -4
- data/lib/persistent_dmnd/everywhere.rb +4 -4
- data/lib/persistent_dmnd/hash.rb +9 -8
- data/lib/persistent_dmnd/is_persistent.rb +3 -2
- data/lib/persistent_dmnd/jruby_9_2_set_workaround.rb +9 -10
- data/lib/persistent_dmnd/jruby_workaround.rb +12 -11
- data/lib/persistent_dmnd/ruby_1_9_and_2_0_support.rb +4 -3
- data/lib/persistent_dmnd/self_conversion.rb +4 -3
- data/lib/persistent_dmnd/set.rb +20 -11
- data/lib/persistent_dmnd/version.rb +4 -3
- data/persistent-dmnd.gemspec +28 -25
- data/sorbet/config +2 -0
- data/sorbet/rbi/gems/concurrent-ruby.rbi +1660 -0
- data/sorbet/rbi/gems/hamster.rbi +683 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +2552 -0
- data/sorbet/rbi/hidden-definitions/hidden.rbi +4180 -0
- data/sorbet/rbi/sorbet-typed/lib/rake/all/rake.rbi +645 -0
- data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +1891 -0
- data/sorbet/rbi/todo.rbi +10 -0
- metadata +32 -53
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# typed: false
|
|
2
3
|
|
|
3
4
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
|
-
# Copyright (c) 2017-
|
|
5
|
+
# Copyright (c) 2017-2021 Ivo Anjo <ivo@ivoanjo.me>
|
|
5
6
|
#
|
|
6
7
|
# This file is part of Persistent-💎, and parts were inspired by Ruby's set.rb
|
|
7
8
|
# https://github.com/ruby/ruby/blob/v2_6_0_preview2/lib/set.rb
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
|
|
12
13
|
# frozen_string_literal: true
|
|
13
14
|
|
|
14
|
-
require
|
|
15
|
+
require "set"
|
|
15
16
|
|
|
16
17
|
module Persistent💎
|
|
17
18
|
# Workaround for https://github.com/jruby/jruby/issues/5227
|
|
@@ -42,7 +43,7 @@ module Persistent💎
|
|
|
42
43
|
end
|
|
43
44
|
end
|
|
44
45
|
|
|
45
|
-
if RUBY_PLATFORM ==
|
|
46
|
+
if RUBY_PLATFORM == "java" && (JRUBY_VERSION.start_with?("9.2.") || JRUBY_VERSION.start_with?("9.3.")) && workaround_needed?
|
|
46
47
|
class ::Set
|
|
47
48
|
# Save existing Set methods
|
|
48
49
|
|
|
@@ -107,13 +108,11 @@ module Persistent💎
|
|
|
107
108
|
persistent_dmnd_workaround_original_disjoint?(set)
|
|
108
109
|
rescue ArgumentError => e
|
|
109
110
|
raise unless e.message == "value must be a set" && set.is_a?(::Set)
|
|
110
|
-
!(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
end
|
|
116
|
-
)
|
|
111
|
+
!(if size < set.size
|
|
112
|
+
any? { |o| set.include?(o) }
|
|
113
|
+
else
|
|
114
|
+
set.any? { |o| include?(o) }
|
|
115
|
+
end)
|
|
117
116
|
end
|
|
118
117
|
|
|
119
118
|
def flatten_merge(set, seen = ::Set.new)
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# typed: false
|
|
2
3
|
|
|
3
4
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
|
-
# Copyright (c) 2017 Ivo Anjo <ivo
|
|
5
|
+
# Copyright (c) 2017-2021 Ivo Anjo <ivo@ivoanjo.me>
|
|
5
6
|
#
|
|
6
7
|
# This file is part of Persistent-💎.
|
|
7
8
|
#
|
|
8
9
|
# MIT License
|
|
9
10
|
#
|
|
10
|
-
# Copyright (c) 2017 Ivo Anjo
|
|
11
|
+
# Copyright (c) 2017-2021 Ivo Anjo
|
|
11
12
|
#
|
|
12
13
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
14
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -31,11 +32,11 @@
|
|
|
31
32
|
|
|
32
33
|
module Persistent💎
|
|
33
34
|
module JRubyWorkaround
|
|
34
|
-
if RUBY_PLATFORM ==
|
|
35
|
+
if RUBY_PLATFORM == "java" && JRUBY_VERSION < "9.2.0.0" # Only supposed to do something on legacy JRuby versions
|
|
35
36
|
BROKEN_ENCODING = "\x00"
|
|
36
37
|
private_constant :BROKEN_ENCODING
|
|
37
38
|
|
|
38
|
-
BROKEN_ENCODING_JRUBY_1_7 = [239, 146, 142].pack(
|
|
39
|
+
BROKEN_ENCODING_JRUBY_1_7 = [239, 146, 142].pack("c*").force_encoding("UTF-8")
|
|
39
40
|
private_constant :BROKEN_ENCODING_JRUBY_1_7
|
|
40
41
|
|
|
41
42
|
def self.included(klass)
|
|
@@ -80,25 +81,25 @@ module Persistent💎
|
|
|
80
81
|
def maybe_fix_broken_encoding(name, target = nil)
|
|
81
82
|
name_string = name.to_s
|
|
82
83
|
|
|
83
|
-
if JRUBY_VERSION.start_with?(
|
|
84
|
+
if JRUBY_VERSION.start_with?("1.7.")
|
|
84
85
|
unless name_string.match(/\?.+/) ||
|
|
85
|
-
[
|
|
86
|
-
[
|
|
86
|
+
["a?", "h?", "s?", "each?"].include?(name_string) ||
|
|
87
|
+
["_?", "_a?", "_h?", "_s?"].any? { |suffix| name_string.end_with?(suffix) }
|
|
87
88
|
return
|
|
88
89
|
end
|
|
89
90
|
else
|
|
90
91
|
return unless name_string.end_with?(BROKEN_ENCODING)
|
|
91
92
|
end
|
|
92
93
|
|
|
93
|
-
fixed_name = name_string.sub(
|
|
94
|
-
fixed_name_jruby_1_7 = name_string.sub(
|
|
94
|
+
fixed_name = name_string.sub("?", "💎").delete(BROKEN_ENCODING).to_sym
|
|
95
|
+
fixed_name_jruby_1_7 = name_string.sub("?", BROKEN_ENCODING_JRUBY_1_7).to_sym
|
|
95
96
|
|
|
96
97
|
if target
|
|
97
98
|
target.instance_eval { alias_method(fixed_name, name) }
|
|
98
|
-
target.instance_eval { alias_method(fixed_name_jruby_1_7, name) } if JRUBY_VERSION.start_with?(
|
|
99
|
+
target.instance_eval { alias_method(fixed_name_jruby_1_7, name) } if JRUBY_VERSION.start_with?("1.7.")
|
|
99
100
|
else
|
|
100
101
|
alias_method(fixed_name, name)
|
|
101
|
-
alias_method(fixed_name_jruby_1_7, name) if JRUBY_VERSION.start_with?(
|
|
102
|
+
alias_method(fixed_name_jruby_1_7, name) if JRUBY_VERSION.start_with?("1.7.")
|
|
102
103
|
end
|
|
103
104
|
end
|
|
104
105
|
end
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
|
-
# Copyright (c) 2017 Ivo Anjo <ivo
|
|
5
|
+
# Copyright (c) 2017-2021 Ivo Anjo <ivo@ivoanjo.me>
|
|
5
6
|
#
|
|
6
7
|
# This file is part of Persistent-💎.
|
|
7
8
|
#
|
|
8
9
|
# MIT License
|
|
9
10
|
#
|
|
10
|
-
# Copyright (c) 2017 Ivo Anjo
|
|
11
|
+
# Copyright (c) 2017-2021 Ivo Anjo
|
|
11
12
|
#
|
|
12
13
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
14
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
module Persistent💎
|
|
33
34
|
module Ruby19And20Support
|
|
34
35
|
# Enumerable#to_h was only introduced in Ruby 2.1 so we have to do it by hand on 2.0/1.9
|
|
35
|
-
if RUBY_VERSION.start_with?(
|
|
36
|
+
if RUBY_VERSION.start_with?("2.0.") || RUBY_VERSION.start_with?("1.9.")
|
|
36
37
|
def self.enumerable_to_h(enumerable)
|
|
37
38
|
enumerable.each_with_object({}) do |(key, value), result|
|
|
38
39
|
result[key] = value
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
|
-
# Copyright (c) 2017 Ivo Anjo <ivo
|
|
5
|
+
# Copyright (c) 2017-2021 Ivo Anjo <ivo@ivoanjo.me>
|
|
5
6
|
#
|
|
6
7
|
# This file is part of Persistent-💎.
|
|
7
8
|
#
|
|
8
9
|
# MIT License
|
|
9
10
|
#
|
|
10
|
-
# Copyright (c) 2017 Ivo Anjo
|
|
11
|
+
# Copyright (c) 2017-2021 Ivo Anjo
|
|
11
12
|
#
|
|
12
13
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
14
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
|
|
30
31
|
# frozen_string_literal: true
|
|
31
32
|
|
|
32
|
-
require
|
|
33
|
+
require "persistent_dmnd/jruby_workaround"
|
|
33
34
|
|
|
34
35
|
module Persistent💎
|
|
35
36
|
# Implements trivial conversion to persistent data structures for our own classes
|
data/lib/persistent_dmnd/set.rb
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
|
-
# Copyright (c) 2017 Ivo Anjo <ivo
|
|
5
|
+
# Copyright (c) 2017-2021 Ivo Anjo <ivo@ivoanjo.me>
|
|
5
6
|
#
|
|
6
7
|
# This file is part of Persistent-💎.
|
|
7
8
|
#
|
|
8
9
|
# MIT License
|
|
9
10
|
#
|
|
10
|
-
# Copyright (c) 2017 Ivo Anjo
|
|
11
|
+
# Copyright (c) 2017-2021 Ivo Anjo
|
|
11
12
|
#
|
|
12
13
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
14
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -29,14 +30,14 @@
|
|
|
29
30
|
|
|
30
31
|
# frozen_string_literal: true
|
|
31
32
|
|
|
32
|
-
require
|
|
33
|
-
require
|
|
34
|
-
require
|
|
35
|
-
require
|
|
36
|
-
require
|
|
33
|
+
require "persistent_dmnd/self_conversion"
|
|
34
|
+
require "persistent_dmnd/is_persistent"
|
|
35
|
+
require "persistent_dmnd/concurrent_ruby_support"
|
|
36
|
+
require "persistent_dmnd/jruby_workaround"
|
|
37
|
+
require "persistent_dmnd/jruby_9_2_set_workaround"
|
|
37
38
|
|
|
38
|
-
require
|
|
39
|
-
require
|
|
39
|
+
require "hamster"
|
|
40
|
+
require "set"
|
|
40
41
|
|
|
41
42
|
module Persistent💎
|
|
42
43
|
class Set < Hamster::Set
|
|
@@ -64,9 +65,17 @@ module Persistent💎
|
|
|
64
65
|
::Set.new(self)
|
|
65
66
|
end
|
|
66
67
|
|
|
67
|
-
#
|
|
68
|
+
# Note: Behavior changed from Ruby < 3 (returned 0/nil) to match Ruby 3.0 Set#<=> (returns 0/nil/-1/+1);
|
|
69
|
+
# see also https://rubyreferences.github.io/rubychanges/3.0.html#standard-library for details
|
|
68
70
|
def <=>(other)
|
|
69
|
-
|
|
71
|
+
case size <=> other.size
|
|
72
|
+
when (-1)
|
|
73
|
+
(-1) if self < other
|
|
74
|
+
when (+1)
|
|
75
|
+
(+1) if self > other
|
|
76
|
+
else
|
|
77
|
+
0 if self == other
|
|
78
|
+
end
|
|
70
79
|
end
|
|
71
80
|
|
|
72
81
|
def to_a💎
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# typed: strong
|
|
2
3
|
|
|
3
4
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
|
-
# Copyright (c) 2017 Ivo Anjo <ivo
|
|
5
|
+
# Copyright (c) 2017-2021 Ivo Anjo <ivo@ivoanjo.me>
|
|
5
6
|
#
|
|
6
7
|
# This file is part of Persistent-💎.
|
|
7
8
|
#
|
|
8
9
|
# MIT License
|
|
9
10
|
#
|
|
10
|
-
# Copyright (c) 2017 Ivo Anjo
|
|
11
|
+
# Copyright (c) 2017-2021 Ivo Anjo
|
|
11
12
|
#
|
|
12
13
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
14
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
# frozen_string_literal: true
|
|
31
32
|
|
|
32
33
|
module Persistent💎
|
|
33
|
-
VERSION =
|
|
34
|
+
VERSION = "2.0.3"
|
|
34
35
|
end
|
data/persistent-dmnd.gemspec
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
3
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
|
-
# Copyright (c) 2017 Ivo Anjo <ivo
|
|
4
|
+
# Copyright (c) 2017-2021 Ivo Anjo <ivo@ivoanjo.me>
|
|
5
5
|
#
|
|
6
6
|
# This file is part of Persistent-💎.
|
|
7
7
|
#
|
|
8
8
|
# MIT License
|
|
9
9
|
#
|
|
10
|
-
# Copyright (c) 2017 Ivo Anjo
|
|
10
|
+
# Copyright (c) 2017-2021 Ivo Anjo
|
|
11
11
|
#
|
|
12
12
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
13
|
# of this software and associated documentation files (the "Software"), to deal
|
|
@@ -29,37 +29,40 @@
|
|
|
29
29
|
|
|
30
30
|
# frozen_string_literal: true
|
|
31
31
|
|
|
32
|
-
lib = File.expand_path(
|
|
32
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
33
33
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
34
|
-
require
|
|
34
|
+
require "persistent_dmnd/version"
|
|
35
35
|
|
|
36
36
|
Gem::Specification.new do |spec|
|
|
37
|
-
spec.name
|
|
38
|
-
spec.version
|
|
39
|
-
spec.authors
|
|
40
|
-
spec.email
|
|
37
|
+
spec.name = "persistent-dmnd"
|
|
38
|
+
spec.version = Persistent💎::VERSION
|
|
39
|
+
spec.authors = "Ivo Anjo"
|
|
40
|
+
spec.email = "ivo@ivoanjo.me"
|
|
41
41
|
|
|
42
|
-
spec.summary
|
|
43
|
-
spec.description
|
|
44
|
-
spec.homepage
|
|
45
|
-
spec.license
|
|
42
|
+
spec.summary = "Persistent-💎: Because Immutable Data Is Forever"
|
|
43
|
+
spec.description = "A tiny ruby gem that gives you a beautiful short-hand syntax for creating immutable arrays, hashes and sets"
|
|
44
|
+
spec.homepage = "https://gitlab.com/ivoanjo/persistent-dmnd/"
|
|
45
|
+
spec.license = "MIT"
|
|
46
46
|
|
|
47
|
-
spec.files
|
|
47
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
48
48
|
f.match(%r{^(test|spec|features)/})
|
|
49
49
|
end
|
|
50
|
-
spec.require_paths = [
|
|
50
|
+
spec.require_paths = ["lib"]
|
|
51
51
|
|
|
52
|
-
spec.required_ruby_version =
|
|
52
|
+
spec.required_ruby_version = ">= 1.9.3"
|
|
53
53
|
|
|
54
|
-
spec.add_development_dependency
|
|
55
|
-
spec.add_development_dependency
|
|
56
|
-
spec.add_development_dependency
|
|
57
|
-
spec.add_development_dependency
|
|
58
|
-
spec.add_development_dependency
|
|
59
|
-
spec.add_development_dependency
|
|
60
|
-
spec.add_development_dependency
|
|
61
|
-
spec.add_development_dependency
|
|
62
|
-
|
|
54
|
+
spec.add_development_dependency "bundler", "~> 1.16" if RUBY_VERSION < "2.6"
|
|
55
|
+
spec.add_development_dependency "rake", "~> 12.2" # Note: Rake 12.2 is the last that supports Ruby 1.9
|
|
56
|
+
spec.add_development_dependency "rspec", "~> 3.8"
|
|
57
|
+
spec.add_development_dependency "concurrent-ruby", "~> 1.1"
|
|
58
|
+
spec.add_development_dependency "rufo", "~> 0.13" if RUBY_VERSION >= "2.6.0"
|
|
59
|
+
spec.add_development_dependency "pry" if RUBY_VERSION >= "2.0.0"
|
|
60
|
+
spec.add_development_dependency "pry-byebug" if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.4"
|
|
61
|
+
spec.add_development_dependency "pry-debugger-jruby" if RUBY_ENGINE == "jruby" && !JRUBY_VERSION.start_with?("1.7.")
|
|
62
|
+
unless RUBY_ENGINE == "truffleruby"
|
|
63
|
+
spec.add_development_dependency "sorbet"
|
|
64
|
+
spec.add_development_dependency "spoom", "~> 1.1" if RUBY_VERSION >= "2.3.7"
|
|
65
|
+
end
|
|
63
66
|
|
|
64
|
-
spec.add_dependency
|
|
67
|
+
spec.add_dependency "hamster", "~> 3.0"
|
|
65
68
|
end
|
data/sorbet/config
ADDED