multi_range 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,29 +1,29 @@
1
- sudo: false
2
- env:
3
- global:
4
- - CC_TEST_REPORTER_ID=a2bb1313ac63f7ae7a7f13ac962870e3cdb0c345b6c60d2857807cc5153d7c3b
5
- language: ruby
6
- rvm:
7
- - 2.2
8
- - 2.6
9
- - 2.7
10
- gemfile:
11
- - gemfiles/Gemfile
12
- matrix:
13
- include:
14
- - dist: trusty
15
- rvm: 1.8.7
16
- gemfile: gemfiles/ruby_1_8_7.gemfile
17
- before_install:
18
- - if `ruby -e 'exit(RUBY_VERSION.to_f < 2.7)'`; then
19
- gem i rubygems-update -v '< 3' && update_rubygems;
20
- gem install bundler -v '< 2';
21
- fi
22
- - gem --version
23
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
24
- - chmod +x ./cc-test-reporter
25
- - ./cc-test-reporter before-build
26
- script:
27
- - bundle exec rake test
28
- after_script:
29
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
1
+ sudo: false
2
+ env:
3
+ global:
4
+ - CC_TEST_REPORTER_ID=a2bb1313ac63f7ae7a7f13ac962870e3cdb0c345b6c60d2857807cc5153d7c3b
5
+ language: ruby
6
+ rvm:
7
+ - 2.2
8
+ - 2.6
9
+ - 2.7
10
+ gemfile:
11
+ - gemfiles/Gemfile
12
+ matrix:
13
+ include:
14
+ - dist: trusty
15
+ rvm: 1.8.7
16
+ gemfile: gemfiles/ruby_1_8_7.gemfile
17
+ before_install:
18
+ - if `ruby -e 'exit(RUBY_VERSION.to_f < 2.7)'`; then
19
+ gem i rubygems-update -v '< 3' && update_rubygems;
20
+ gem install bundler -v '< 2';
21
+ fi
22
+ - gem --version
23
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
24
+ - chmod +x ./cc-test-reporter
25
+ - ./cc-test-reporter before-build
26
+ script:
27
+ - bundle exec rake test
28
+ after_script:
29
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -1,6 +1,6 @@
1
1
  ## Change Log
2
2
 
3
- ### [upcoming](https://github.com/khiav223577/multi_range/compare/v0.0.2...HEAD) 2020/03/02
3
+ ### [v0.0.3](https://github.com/khiav223577/multi_range/compare/v0.0.2...v0.0.3) 2020/03/02
4
4
  - [#6](https://github.com/khiav223577/multi_range/pull/6) freeze internal ranges variable (@khiav223577)
5
5
  - [#5](https://github.com/khiav223577/multi_range/pull/5) Add min, max, to_a method (@khiav223577)
6
6
 
@@ -1,49 +1,49 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at mrtmrt15xn@yahoo.com.tw. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at mrtmrt15xn@yahoo.com.tw. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Rumble Huang
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Rumble Huang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,104 +1,111 @@
1
- # MultiRange
2
-
3
- [![Gem Version](https://img.shields.io/gem/v/multi_range.svg?style=flat)](http://rubygems.org/gems/multi_range)
4
- [![Build Status](https://travis-ci.org/khiav223577/multi_range.svg?branch=master)](https://travis-ci.org/khiav223577/multi_range)
5
- [![RubyGems](http://img.shields.io/gem/dt/multi_range.svg?style=flat)](http://rubygems.org/gems/multi_range)
6
- [![Code Climate](https://codeclimate.com/github/khiav223577/multi_range/badges/gpa.svg)](https://codeclimate.com/github/khiav223577/multi_range)
7
- [![Test Coverage](https://codeclimate.com/github/khiav223577/multi_range/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/multi_range/coverage)
8
-
9
- ## Supports
10
- - Ruby 1.8 ~ 2.7
11
-
12
- ## Installation
13
-
14
- ```ruby
15
- gem 'multi_range'
16
- ```
17
-
18
- And then execute:
19
-
20
- $ bundle
21
-
22
- Or install it yourself as:
23
-
24
- $ gem install multi_range
25
-
26
- ## Usage
27
-
28
- Allow you to manipulate a group of ranges.
29
-
30
- ### Sample a number
31
- ```rb
32
- multi_range = MultiRange.new([1..5, 10..12])
33
- multi_range.sample
34
- # => equals to [1, 2, 3, 4, 5, 10, 11, 12].sample
35
- ```
36
-
37
- ### Range difference
38
- ```rb
39
- multi_range = MultiRange.new([1..10])
40
- multi_range -= 5..7
41
- multi_range.ranges
42
- # => [1...5, 8..10]
43
- ```
44
-
45
- ```rb
46
- multi_range = MultiRange.new([1..10, 50..70, 80..100])
47
- multi_range -= 5..85
48
- multi_range.ranges
49
- # => [1...5, 86..100]
50
- ```
51
-
52
- ### Range-like interface
53
-
54
- #### each
55
- ```rb
56
- MultiRange.new([1..3, 6, 8..9]).each{|s| print s }
57
- # => 123689
58
- ```
59
-
60
- #### map
61
- ```rb
62
- MultiRange.new([1..3, 6, 8..9]).map{|s| s * 2 }
63
- # => [2, 4, 6, 12, 16, 18]
64
- ```
65
-
66
- #### index_with
67
- ```rb
68
- MultiRange.new([1..3, 6, 8..9]).index_with(true)
69
- # => { 1 => true, 2 => true, 3 => true, 6 => true, 8 => true, 9 => true }
70
- ```
71
-
72
- #### min
73
- ```rb
74
- MultiRange.new([1..3, 6, 8..9]).min
75
- # => 1
76
- ```
77
-
78
- #### max
79
- ```rb
80
- MultiRange.new([1..3, 6, 8..9]).max
81
- # => 9
82
- ```
83
-
84
- #### to_a
85
- ```rb
86
- MultiRange.new([1..3, 6, 8..9]).to_a
87
- # => [1, 2, 3, 6, 8, 9]
88
- ```
89
-
90
- ## Development
91
-
92
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
93
-
94
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
95
-
96
- ## Contributing
97
-
98
- Bug reports and pull requests are welcome on GitHub at https://github.com/khiav223577/multi_range. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
99
-
100
-
101
- ## License
102
-
103
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
104
-
1
+ # MultiRange
2
+
3
+ [![Gem Version](https://img.shields.io/gem/v/multi_range.svg?style=flat)](http://rubygems.org/gems/multi_range)
4
+ [![Build Status](https://travis-ci.com/khiav223577/multi_range.svg?branch=master)](https://travis-ci.org/khiav223577/multi_range)
5
+ [![RubyGems](http://img.shields.io/gem/dt/multi_range.svg?style=flat)](http://rubygems.org/gems/multi_range)
6
+ [![Code Climate](https://codeclimate.com/github/khiav223577/multi_range/badges/gpa.svg)](https://codeclimate.com/github/khiav223577/multi_range)
7
+ [![Test Coverage](https://codeclimate.com/github/khiav223577/multi_range/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/multi_range/coverage)
8
+
9
+ ## Supports
10
+ - Ruby 1.8 ~ 2.7
11
+
12
+ ## Installation
13
+
14
+ ```ruby
15
+ gem 'multi_range'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install multi_range
25
+
26
+ ## Usage
27
+
28
+ Allow you to manipulate a group of ranges.
29
+
30
+ ### Sample a number
31
+ ```rb
32
+ multi_range = MultiRange.new([1..5, 10..12])
33
+ multi_range.sample
34
+ # => equals to [1, 2, 3, 4, 5, 10, 11, 12].sample
35
+ ```
36
+
37
+ ### Range difference
38
+ ```rb
39
+ multi_range = MultiRange.new([1..10])
40
+ multi_range -= 5..7
41
+ multi_range.ranges
42
+ # => [1...5, 8..10]
43
+ ```
44
+
45
+ ```rb
46
+ multi_range = MultiRange.new([1..10, 50..70, 80..100])
47
+ multi_range -= 5..85
48
+ multi_range.ranges
49
+ # => [1...5, 86..100]
50
+ ```
51
+
52
+ ### Flatten
53
+ ```rb
54
+ multi_range = MultiRange.new([1, 2, 4..6, 7, 8..12])
55
+ multi_range.flatten.ranges
56
+ # => [1..2, 4..12]
57
+ ```
58
+
59
+ ### Range-like interface
60
+
61
+ #### each
62
+ ```rb
63
+ MultiRange.new([1..3, 6, 8..9]).each{|s| print s }
64
+ # => 123689
65
+ ```
66
+
67
+ #### map
68
+ ```rb
69
+ MultiRange.new([1..3, 6, 8..9]).map{|s| s * 2 }
70
+ # => [2, 4, 6, 12, 16, 18]
71
+ ```
72
+
73
+ #### index_with
74
+ ```rb
75
+ MultiRange.new([1..3, 6, 8..9]).index_with(true)
76
+ # => { 1 => true, 2 => true, 3 => true, 6 => true, 8 => true, 9 => true }
77
+ ```
78
+
79
+ #### min
80
+ ```rb
81
+ MultiRange.new([1..3, 6, 8..9]).min
82
+ # => 1
83
+ ```
84
+
85
+ #### max
86
+ ```rb
87
+ MultiRange.new([1..3, 6, 8..9]).max
88
+ # => 9
89
+ ```
90
+
91
+ #### to_a
92
+ ```rb
93
+ MultiRange.new([1..3, 6, 8..9]).to_a
94
+ # => [1, 2, 3, 6, 8, 9]
95
+ ```
96
+
97
+ ## Development
98
+
99
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
100
+
101
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
102
+
103
+ ## Contributing
104
+
105
+ Bug reports and pull requests are welcome on GitHub at https://github.com/khiav223577/multi_range. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
106
+
107
+
108
+ ## License
109
+
110
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
111
+
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << 'test'
6
- t.libs << 'lib'
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
9
-
10
- task :default => :test
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'multi_range'
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
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'multi_range'
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