summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAkinori MUSHA <[email protected]>2020-12-22 12:20:21 +0900
committerAkinori MUSHA <[email protected]>2020-12-22 12:20:21 +0900
commit3fa4bd82928983cf5f6711c130711502397e05e2 (patch)
treedb80a406ef9497d1e53ac26c43ffa275edf2e61e /lib
parent63b872c409ec441718f55c60362a441cf108cfc0 (diff)
Import set 1.0.0
- SortedSet has been removed for dependency and performance reasons. - Set#join is added as a shorthand for `.to_a.join`. - Set#<=> is added. https://github.com/ruby/set/blob/v1.0.0/CHANGELOG.md
Diffstat (limited to 'lib')
-rw-r--r--lib/set.rb8
-rw-r--r--lib/set/set.gemspec (renamed from lib/set.gemspec)5
-rw-r--r--lib/set/sorted_set.rb6
3 files changed, 17 insertions, 2 deletions
diff --git a/lib/set.rb b/lib/set.rb
index 625046d37c..2bd2a0ffa5 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -641,6 +641,12 @@ class Set
end
end
+ # Returns a string created by converting each element of the set to a string
+ # See also: Array#join
+ def join(separator=nil)
+ to_a.join(separator)
+ end
+
InspectKey = :__inspect_key__ # :nodoc:
# Returns a string containing a human-readable representation of the
@@ -684,3 +690,5 @@ module Enumerable
klass.new(self, *args, &block)
end
end
+
+autoload :SortedSet, "#{__dir__}/set/sorted_set"
diff --git a/lib/set.gemspec b/lib/set/set.gemspec
index 72dee127e1..e258af4978 100644
--- a/lib/set.gemspec
+++ b/lib/set/set.gemspec
@@ -1,17 +1,18 @@
Gem::Specification.new do |spec|
spec.name = "set"
- spec.version = "0.1.0"
+ spec.version = "1.0.0"
spec.authors = ["Akinori MUSHA"]
spec.email = ["[email protected]"]
spec.summary = %q{Provides a class to deal with collections of unordered, unique values}
spec.description = %q{Provides a class to deal with collections of unordered, unique values}
spec.homepage = "https://github.com/ruby/set"
+ spec.license = "BSD-2-Clause"
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
- spec.licenses = ["Ruby", "BSD-2-Clause"]
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
+ spec.metadata["changelog_uri"] = "https://github.com/ruby/set/blob/v#{spec.version}/CHANGELOG.md"
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
diff --git a/lib/set/sorted_set.rb b/lib/set/sorted_set.rb
new file mode 100644
index 0000000000..e4e01ba4a8
--- /dev/null
+++ b/lib/set/sorted_set.rb
@@ -0,0 +1,6 @@
+begin
+ require 'sorted_set'
+rescue ::LoadError
+ raise "The `SortedSet` class has been extracted from the `set` library." \
+ "You must use the `sorted_set` gem or other alternatives."
+end