range_list_jack 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2aa19df7981770c4adee46bdcc27f1065434d59ed560e7ed39f50dc4faa78789
4
+ data.tar.gz: d23b72c9fadaff46fb6825284b1dbc51bf7fda7be6f236cb9fcc6574337bed84
5
+ SHA512:
6
+ metadata.gz: f16829d796cf04ef7b48ea56dc64df498bfc49be396a32027b31b6d127d4a7d0d3a1cc0cf51a362fd81fbc42c9737c9a260dfd343e7b64b90aed23e1bd79e790
7
+ data.tar.gz: 73ce7f34025a1d5096f1c178510e6c786f2d83a1c4545a9b0fd4e658596415143d71719f1d6ac4af5c814086eadfd482bc967d306bf5056b4e518a6264befe0d
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rspec_status ADDED
@@ -0,0 +1,4 @@
1
+ example_id | status | run_time |
2
+ ----------------------------------------- | ------ | --------------- |
3
+ ./spec/range_list/range_list_spec.rb[1:1] | passed | 0.002 seconds |
4
+ ./spec/range_list/range_list_spec.rb[1:2] | passed | 0.00228 seconds |
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at maojie@yunify.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rangelist.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ range_list (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.5.0)
10
+ rake (10.5.0)
11
+ rspec (3.11.0)
12
+ rspec-core (~> 3.11.0)
13
+ rspec-expectations (~> 3.11.0)
14
+ rspec-mocks (~> 3.11.0)
15
+ rspec-core (3.11.0)
16
+ rspec-support (~> 3.11.0)
17
+ rspec-expectations (3.11.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.11.0)
20
+ rspec-mocks (3.11.1)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.11.0)
23
+ rspec-support (3.11.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.17)
30
+ rake (~> 10.0)
31
+ range_list!
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 1.17.2
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # RangeList
2
+
3
+ A RangeList implement to solve range union and except problem
4
+
5
+ ## Installation
6
+
7
+ ##### From [RubyGems](https://rubygems.org)
8
+
9
+ $ gem install range_list
10
+
11
+ ##### From source code
12
+
13
+ Get Code from Gitlab:
14
+
15
+ $ git clone https://gitlab.com/Jack.Mao/rangelist.git
16
+
17
+ Build and Install with Bundle:
18
+
19
+ $ cd rangelist
20
+ $ bundle install
21
+ $ bundle exec rake install
22
+
23
+ ## Uninstall
24
+
25
+ $ gem uninstall qingcloud-cli
26
+
27
+ ## Examples
28
+
29
+ ```ruby
30
+ require range_list
31
+
32
+ rl = RangeList::RangeList.new
33
+ rl.add([1, 5])
34
+ rl.print
35
+ # Should display: [1, 5)
36
+ rl.add([10, 20])
37
+ rl.print
38
+ # Should display: [1, 5) [10, 20)
39
+ rl.add([20, 20])
40
+ rl.print
41
+ # // Should display: [1, 5) [10, 20)
42
+ rl.add([20, 21])
43
+ rl.print
44
+ # Should display: [1, 5) [10, 21)
45
+ rl.add([2, 4])
46
+ rl.print
47
+ # Should display: [1, 5) [10, 21)
48
+ rl.add([3, 8])
49
+ rl.print
50
+ # Should display: [1, 8) [10, 21)
51
+ rl.remove([10, 10])
52
+ rl.print
53
+ # Should display: [1, 8) [10, 21)
54
+ rl.remove([10, 11])
55
+ rl.print
56
+ # Should display: [1, 8) [11, 21)
57
+ rl.remove([15, 17])
58
+ rl.print
59
+ # Should display: [1, 8) [11, 15) [17, 21)
60
+ rl.remove([3, 19])
61
+ rl.print
62
+ # Should display: [1, 3) [19, 21)
63
+ ```
64
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "range_list"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/demo.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'rangelist'
2
+
3
+ puts RangeList::VERSION
@@ -0,0 +1,38 @@
1
+ # Your code goes here...
2
+ # A pair of integers define a range, for example: [1, 5).
3
+ # This range includes integers: 1, 2, 3, and 4.
4
+ # A range list is an aggregate of these ranges: [1, 5), [10, 11), [100, 201)
5
+ module RangeList
6
+ class RangeList
7
+ def initialize
8
+ @all = Set.new
9
+ end
10
+
11
+ def add(range)
12
+ @all += Set.new(range[0]...range[1])
13
+ end
14
+
15
+ def remove(range)
16
+ @all -= Set.new(range[0]...range[1])
17
+ end
18
+
19
+ def print
20
+ puts to_s
21
+ end
22
+
23
+ def to_s
24
+ ret, before = "", 0
25
+ a = @all.sort
26
+ # append a number greater than max element to avoid last range problem
27
+ a.append(a[-1]+3)
28
+ for i in (1...a.size)
29
+ if a[i] - a[i-1] > 1
30
+ ret += "#{ret.empty? ? '':' '}[#{a[before]}, #{a[i-1] + 1})"
31
+ before = i
32
+ end
33
+ end
34
+ return ret
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,3 @@
1
+ module RangeList
2
+ VERSION = "0.1.1"
3
+ end
data/lib/range_list.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "range_list/version"
2
+ require "range_list/range_list"
3
+
4
+ module RangeList
5
+ class Error < StandardError; end
6
+ end
@@ -0,0 +1,41 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "range_list/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "range_list_jack"
8
+ spec.version = RangeList::VERSION
9
+ spec.authors = ["Jack Mao"]
10
+ spec.email = ["18064097690@164.com"]
11
+
12
+ spec.summary = %q{A RangeList implement to solve range union and except problem.}
13
+ spec.description = %q{A RangeList implement to solve range union and except problem.}
14
+ spec.homepage = "https://gitlab.com/Jack.Mao/rangelist"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://gitlab.com/Jack.Mao/rangelist."
23
+ spec.metadata["changelog_uri"] = "https://gitlab.com/Jack.Mao/rangelist."
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 1.17"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: range_list_jack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jack Mao
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: A RangeList implement to solve range union and except problem.
56
+ email:
57
+ - 18064097690@164.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".rspec"
63
+ - ".rspec_status"
64
+ - CODE_OF_CONDUCT.md
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - demo.rb
72
+ - lib/range_list.rb
73
+ - lib/range_list/range_list.rb
74
+ - lib/range_list/version.rb
75
+ - range_list.gemspec
76
+ homepage: https://gitlab.com/Jack.Mao/rangelist
77
+ licenses: []
78
+ metadata:
79
+ allowed_push_host: https://rubygems.org
80
+ homepage_uri: https://gitlab.com/Jack.Mao/rangelist
81
+ source_code_uri: https://gitlab.com/Jack.Mao/rangelist.
82
+ changelog_uri: https://gitlab.com/Jack.Mao/rangelist.
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubygems_version: 3.0.3
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: A RangeList implement to solve range union and except problem.
102
+ test_files: []