persistent-dmnd 1.0.1 → 2.0.1
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 +4 -4
- data/.gitlab-ci.yml +414 -0
- data/.ruby-version +1 -1
- data/README.adoc +8 -4
- data/bin/bundle +105 -0
- data/bin/pry +12 -4
- data/bin/rspec +12 -4
- data/gems.rb +3 -0
- data/lib/persistent-dmnd.rb +1 -0
- data/lib/persistent-/360/237/222/216.rb +1 -0
- data/lib/persistent_dmnd/array.rb +1 -0
- data/lib/persistent_dmnd/concurrent_ruby_support.rb +1 -0
- data/lib/persistent_dmnd/dmndifier.rb +1 -0
- data/lib/persistent_dmnd/everywhere.rb +1 -0
- data/lib/persistent_dmnd/hash.rb +1 -0
- data/lib/persistent_dmnd/is_persistent.rb +1 -0
- data/lib/persistent_dmnd/jruby_9_2_set_workaround.rb +155 -0
- data/lib/persistent_dmnd/jruby_workaround.rb +2 -1
- data/lib/persistent_dmnd/ruby_1_9_and_2_0_support.rb +1 -0
- data/lib/persistent_dmnd/self_conversion.rb +1 -0
- data/lib/persistent_dmnd/set.rb +12 -2
- data/lib/persistent_dmnd/version.rb +2 -1
- data/persistent-dmnd.gemspec +17 -9
- data/sorbet/config +2 -0
- data/sorbet/rbi/gems/concurrent-ruby.rbi +1587 -0
- data/sorbet/rbi/gems/hamster.rbi +682 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +1473 -0
- data/sorbet/rbi/hidden-definitions/hidden.rbi +2877 -0
- data/sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi +8684 -0
- data/sorbet/rbi/sorbet-typed/lib/ruby/all/gem.rbi +4222 -0
- data/sorbet/rbi/sorbet-typed/lib/ruby/all/open3.rbi +111 -0
- data/sorbet/rbi/sorbet-typed/lib/ruby/all/resolv.rbi +543 -0
- data/sorbet/rbi/todo.rbi +10 -0
- metadata +26 -28
- data/.travis.yml +0 -24
- data/Gemfile +0 -1
data/bin/bundle
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# This file was generated by Bundler.
|
|
6
|
+
#
|
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
|
8
|
+
# this file is here to facilitate running it.
|
|
9
|
+
#
|
|
10
|
+
|
|
11
|
+
require "rubygems"
|
|
12
|
+
|
|
13
|
+
m = Module.new do
|
|
14
|
+
module_function
|
|
15
|
+
|
|
16
|
+
def invoked_as_script?
|
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def env_var_version
|
|
21
|
+
ENV["BUNDLER_VERSION"]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def cli_arg_version
|
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
|
27
|
+
bundler_version = nil
|
|
28
|
+
update_index = nil
|
|
29
|
+
ARGV.each_with_index do |a, i|
|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
|
31
|
+
bundler_version = a
|
|
32
|
+
end
|
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
|
35
|
+
update_index = i
|
|
36
|
+
end
|
|
37
|
+
bundler_version
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def gemfile
|
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
|
43
|
+
|
|
44
|
+
File.expand_path("../../gems.rb", __FILE__)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def lockfile
|
|
48
|
+
lockfile =
|
|
49
|
+
case File.basename(gemfile)
|
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
|
51
|
+
else "#{gemfile}.lock"
|
|
52
|
+
end
|
|
53
|
+
File.expand_path(lockfile)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def lockfile_version
|
|
57
|
+
return unless File.file?(lockfile)
|
|
58
|
+
lockfile_contents = File.read(lockfile)
|
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
|
60
|
+
Regexp.last_match(1)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def bundler_version
|
|
64
|
+
@bundler_version ||= begin
|
|
65
|
+
env_var_version || cli_arg_version ||
|
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def load_bundler!
|
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
|
72
|
+
|
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
|
74
|
+
activate_bundler(bundler_version.dup)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def activate_bundler(bundler_version)
|
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
|
79
|
+
bundler_version = "< 2"
|
|
80
|
+
end
|
|
81
|
+
gem_error = activation_error_handling do
|
|
82
|
+
gem "bundler", bundler_version
|
|
83
|
+
end
|
|
84
|
+
return if gem_error.nil?
|
|
85
|
+
require_error = activation_error_handling do
|
|
86
|
+
require "bundler/version"
|
|
87
|
+
end
|
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
|
90
|
+
exit 42
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def activation_error_handling
|
|
94
|
+
yield
|
|
95
|
+
nil
|
|
96
|
+
rescue StandardError, LoadError => e
|
|
97
|
+
e
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
m.load_bundler!
|
|
102
|
+
|
|
103
|
+
if m.invoked_as_script?
|
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
|
105
|
+
end
|
data/bin/pry
CHANGED
|
@@ -8,13 +8,21 @@
|
|
|
8
8
|
# this file is here to facilitate running it.
|
|
9
9
|
#
|
|
10
10
|
|
|
11
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
12
|
-
load(bundle_binstub) if File.file?(bundle_binstub)
|
|
13
|
-
|
|
14
11
|
require "pathname"
|
|
15
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
|
|
16
13
|
Pathname.new(__FILE__).realpath)
|
|
17
14
|
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
18
26
|
require "rubygems"
|
|
19
27
|
require "bundler/setup"
|
|
20
28
|
|
data/bin/rspec
CHANGED
|
@@ -8,13 +8,21 @@
|
|
|
8
8
|
# this file is here to facilitate running it.
|
|
9
9
|
#
|
|
10
10
|
|
|
11
|
-
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
12
|
-
load(bundle_binstub) if File.file?(bundle_binstub)
|
|
13
|
-
|
|
14
11
|
require "pathname"
|
|
15
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../
|
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
|
|
16
13
|
Pathname.new(__FILE__).realpath)
|
|
17
14
|
|
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
|
+
|
|
17
|
+
if File.file?(bundle_binstub)
|
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
|
19
|
+
load(bundle_binstub)
|
|
20
|
+
else
|
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
18
26
|
require "rubygems"
|
|
19
27
|
require "bundler/setup"
|
|
20
28
|
|
data/gems.rb
CHANGED
data/lib/persistent-dmnd.rb
CHANGED
data/lib/persistent_dmnd/hash.rb
CHANGED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# typed: false
|
|
3
|
+
|
|
4
|
+
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
5
|
+
# Copyright (c) 2017-2018 Ivo Anjo <ivo.anjo@ist.utl.pt>
|
|
6
|
+
#
|
|
7
|
+
# This file is part of Persistent-💎, and parts were inspired by Ruby's set.rb
|
|
8
|
+
# https://github.com/ruby/ruby/blob/v2_6_0_preview2/lib/set.rb
|
|
9
|
+
# Copyright (c) 2002-2016 Akinori MUSHA <knu@iDaemons.org>
|
|
10
|
+
# All rights reserved. You can redistribute and/or modify it under the same terms as Ruby. See
|
|
11
|
+
# https://github.com/ruby/ruby/blob/v2_6_0_preview2/COPYING for more details.
|
|
12
|
+
|
|
13
|
+
# frozen_string_literal: true
|
|
14
|
+
|
|
15
|
+
require 'set'
|
|
16
|
+
|
|
17
|
+
module Persistent💎
|
|
18
|
+
# Workaround for https://github.com/jruby/jruby/issues/5227
|
|
19
|
+
# We monkey patch the Ruby Set methods affected to restore their interoperable behavior
|
|
20
|
+
#
|
|
21
|
+
module JRuby92SetWorkaround
|
|
22
|
+
def self.workaround_needed?
|
|
23
|
+
workaround_checker = Object.new
|
|
24
|
+
workaround_checker.instance_eval do
|
|
25
|
+
def is_a?(klass)
|
|
26
|
+
super || klass == Set
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def size
|
|
30
|
+
0
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def all?
|
|
34
|
+
false
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
begin
|
|
39
|
+
Set.new.superset?(workaround_checker)
|
|
40
|
+
false
|
|
41
|
+
rescue ArgumentError => e
|
|
42
|
+
e.message == "value must be a set"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
if RUBY_PLATFORM == 'java' && JRUBY_VERSION.start_with?('9.2.') && workaround_needed?
|
|
47
|
+
class ::Set
|
|
48
|
+
# Save existing Set methods
|
|
49
|
+
|
|
50
|
+
alias persistent_dmnd_workaround_original_equal ==
|
|
51
|
+
alias persistent_dmnd_workaround_original_superset? superset?
|
|
52
|
+
alias persistent_dmnd_workaround_original_proper_superset? proper_superset?
|
|
53
|
+
alias persistent_dmnd_workaround_original_subset? subset?
|
|
54
|
+
alias persistent_dmnd_workaround_original_proper_subset? proper_subset?
|
|
55
|
+
alias persistent_dmnd_workaround_original_intersect? intersect?
|
|
56
|
+
alias persistent_dmnd_workaround_original_disjoint? disjoint?
|
|
57
|
+
alias persistent_dmnd_workaround_original_flatten_merge flatten_merge
|
|
58
|
+
alias persistent_dmnd_workaround_original_flatten flatten
|
|
59
|
+
alias persistent_dmnd_workaround_original_flatten! flatten!
|
|
60
|
+
|
|
61
|
+
# Redefine all set methods that use instanceof RubySet to restore previous behavior
|
|
62
|
+
|
|
63
|
+
def ==(other)
|
|
64
|
+
persistent_dmnd_workaround_original_equal(other) ||
|
|
65
|
+
(other.is_a?(::Set) && size == other.size && other.all? { |o| include?(o) })
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def superset?(set)
|
|
69
|
+
persistent_dmnd_workaround_original_superset?(set)
|
|
70
|
+
rescue ArgumentError => e
|
|
71
|
+
raise unless e.message == "value must be a set" && set.is_a?(::Set)
|
|
72
|
+
size >= set.size && set.all? { |o| include?(o) }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def proper_superset?(set)
|
|
76
|
+
persistent_dmnd_workaround_original_proper_superset?(set)
|
|
77
|
+
rescue ArgumentError => e
|
|
78
|
+
raise unless e.message == "value must be a set" && set.is_a?(::Set)
|
|
79
|
+
size > set.size && set.all? { |o| include?(o) }
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def subset?(set)
|
|
83
|
+
persistent_dmnd_workaround_original_subset?(set)
|
|
84
|
+
rescue ArgumentError => e
|
|
85
|
+
raise unless e.message == "value must be a set" && set.is_a?(::Set)
|
|
86
|
+
size <= set.size && all? { |o| set.include?(o) }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def proper_subset?(set)
|
|
90
|
+
persistent_dmnd_workaround_original_proper_subset?(set)
|
|
91
|
+
rescue ArgumentError => e
|
|
92
|
+
raise unless e.message == "value must be a set" && set.is_a?(::Set)
|
|
93
|
+
size < set.size && all? { |o| set.include?(o) }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def intersect?(set)
|
|
97
|
+
persistent_dmnd_workaround_original_intersect?(set)
|
|
98
|
+
rescue ArgumentError => e
|
|
99
|
+
raise unless e.message == "value must be a set" && set.is_a?(::Set)
|
|
100
|
+
if size < set.size
|
|
101
|
+
any? { |o| set.include?(o) }
|
|
102
|
+
else
|
|
103
|
+
set.any? { |o| include?(o) }
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def disjoint?(set)
|
|
108
|
+
persistent_dmnd_workaround_original_disjoint?(set)
|
|
109
|
+
rescue ArgumentError => e
|
|
110
|
+
raise unless e.message == "value must be a set" && set.is_a?(::Set)
|
|
111
|
+
!(
|
|
112
|
+
if size < set.size
|
|
113
|
+
any? { |o| set.include?(o) }
|
|
114
|
+
else
|
|
115
|
+
set.any? { |o| include?(o) }
|
|
116
|
+
end
|
|
117
|
+
)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def flatten_merge(set, seen = ::Set.new)
|
|
121
|
+
set.each do |o|
|
|
122
|
+
if o.is_a?(::Set)
|
|
123
|
+
if seen.include?(o_id = o.object_id)
|
|
124
|
+
raise ArgumentError, "tried to flatten recursive Set"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
seen.add(o_id)
|
|
128
|
+
flatten_merge(o, seen)
|
|
129
|
+
seen.delete(o_id)
|
|
130
|
+
else
|
|
131
|
+
add(o)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
self
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def flatten
|
|
139
|
+
self.class.new.flatten_merge(self)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def flatten!
|
|
143
|
+
replace(flatten()) if any? { |o| o.is_a?(::Set) }
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Reset aliases to point to redefined methods (otherwise they would keep on pointing to the old variants)
|
|
147
|
+
|
|
148
|
+
alias >= superset?
|
|
149
|
+
alias > proper_superset?
|
|
150
|
+
alias <= subset?
|
|
151
|
+
alias < proper_subset?
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# typed: false
|
|
2
3
|
|
|
3
4
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
5
|
# Copyright (c) 2017 Ivo Anjo <ivo.anjo@ist.utl.pt>
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
|
|
32
33
|
module Persistent💎
|
|
33
34
|
module JRubyWorkaround
|
|
34
|
-
if RUBY_PLATFORM == 'java' # Only supposed to do something on JRuby
|
|
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
|
|
data/lib/persistent_dmnd/set.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# typed: true
|
|
2
3
|
|
|
3
4
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
5
|
# Copyright (c) 2017 Ivo Anjo <ivo.anjo@ist.utl.pt>
|
|
@@ -33,6 +34,7 @@ require 'persistent_dmnd/self_conversion'
|
|
|
33
34
|
require 'persistent_dmnd/is_persistent'
|
|
34
35
|
require 'persistent_dmnd/concurrent_ruby_support'
|
|
35
36
|
require 'persistent_dmnd/jruby_workaround'
|
|
37
|
+
require 'persistent_dmnd/jruby_9_2_set_workaround'
|
|
36
38
|
|
|
37
39
|
require 'hamster'
|
|
38
40
|
require 'set'
|
|
@@ -63,9 +65,17 @@ module Persistent💎
|
|
|
63
65
|
::Set.new(self)
|
|
64
66
|
end
|
|
65
67
|
|
|
66
|
-
#
|
|
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
|
|
67
70
|
def <=>(other)
|
|
68
|
-
|
|
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
|
|
69
79
|
end
|
|
70
80
|
|
|
71
81
|
def to_a💎
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
# typed: strong
|
|
2
3
|
|
|
3
4
|
# Persistent-💎: Ruby gem for easily creating immutable data structures
|
|
4
5
|
# Copyright (c) 2017 Ivo Anjo <ivo.anjo@ist.utl.pt>
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
# frozen_string_literal: true
|
|
31
32
|
|
|
32
33
|
module Persistent💎
|
|
33
|
-
VERSION = '
|
|
34
|
+
VERSION = '2.0.1'
|
|
34
35
|
end
|