corefines 1.9.0 → 1.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eac6f98f15a93c813142d0b65ce5864599e7d585
4
- data.tar.gz: a83d450c24803a0ff5363c3f4eab79a94157cbaf
3
+ metadata.gz: c4f2aa64f58e3be7d11dc02d322111b762bfe5fc
4
+ data.tar.gz: 283d79fe43753535b16469e15bf2413055713698
5
5
  SHA512:
6
- metadata.gz: 31fba38ae1940a1902a25792db99b61a828fceffdad0f8afaebe5e4c275f55ec451c9e83df2d0b2b29868c90b2522da72c566a3922b0eb06698f5ece3a744d32
7
- data.tar.gz: 59f91237d105623b8483882c1e3abd1c07d4134ff7211f4de3913fcc340e77724eca37eeba895fd21573a7ff97a58a0d3bca4aa82e5671d234cd63e154b4eb23
6
+ metadata.gz: 82a3e76586a5a45335a2838c11d108a875b2d5ff2ac9a7e92141017eac240c9c8c0e136c6c0e7fe007d889b6da92d3f78f73d878ba964cda665e714b0a101edc
7
+ data.tar.gz: a104e1756ebf9caa6621e4fc890238248e1a814dfc1ace32e36a725f3370809accb0b7fbf7354a356004af59b0b9da6a4fd4564f0c8077551274ecca1016fdd0
@@ -75,15 +75,15 @@ module Corefines
75
75
  # "Sugar is sweet".color(text: 7) # => "\e[0;37;49mSugar is sweet\e[0m"
76
76
  #
77
77
  # @overload color(text_color)
78
- # @param text_color [#to_sym, Fixnum] text (foreground) color (see
78
+ # @param text_color [#to_sym, Integer] text (foreground) color (see
79
79
  # {COLOR_CODES}).
80
80
  #
81
81
  # @overload color(opts)
82
- # @option opts [#to_sym, Fixnum] :mode text attributes (see
82
+ # @option opts [#to_sym, Integer] :mode text attributes (see
83
83
  # {MODE_CODES}).
84
- # @option opts [#to_sym, Fixnum] :text,:fg text (foreground) color (see
84
+ # @option opts [#to_sym, Integer] :text,:fg text (foreground) color (see
85
85
  # {COLOR_CODES}).
86
- # @option opts [#to_sym, Fixnum] :background,:bg background color (see
86
+ # @option opts [#to_sym, Integer] :background,:bg background color (see
87
87
  # {COLOR_CODES}).
88
88
  #
89
89
  # @return [String] a copy of this string colored for command line output
@@ -133,12 +133,12 @@ module Corefines
133
133
  private
134
134
 
135
135
  def self.color_code(color, offset)
136
- return color + offset if color.is_a? ::Fixnum
136
+ return color + offset if color.is_a? ::Integer
137
137
  COLOR_CODES[color.to_sym] + offset if color && COLOR_CODES[color.to_sym]
138
138
  end
139
139
 
140
140
  def self.mode_code(mode)
141
- return mode if mode.is_a? ::Fixnum
141
+ return mode if mode.is_a? ::Integer
142
142
  MODE_CODES[mode.to_sym] if mode
143
143
  end
144
144
  end
@@ -248,7 +248,7 @@ module Corefines
248
248
  # "foo\n\nbar".indent(2) # => " foo\n\n bar"
249
249
  # "foo\n\nbar".indent(2, nil, true) # => " foo\n \n bar"
250
250
  #
251
- # @param amount [Fixnum] the indent size.
251
+ # @param amount [Integer] the indent size.
252
252
  # @param indent_str [String, nil] the indent character to use.
253
253
  # The default is +nil+, which tells the method to make a guess by
254
254
  # peeking at the first indented line, and fallback to a space if
@@ -1,3 +1,3 @@
1
1
  module Corefines
2
- VERSION = '1.9.0'
2
+ VERSION = '1.10.0'
3
3
  end
@@ -21,7 +21,7 @@ describe String do
21
21
  end
22
22
  end
23
23
 
24
- context Fixnum do
24
+ context Integer do
25
25
  it "returns text with the specified foreground color" do
26
26
  expect(text.color(7)).to eq "\e[0;37;49m#{text}\e[0m"
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corefines
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Jirutka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-02 00:00:00.000000000 Z
11
+ date: 2017-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -104,10 +104,6 @@ executables: []
104
104
  extensions: []
105
105
  extra_rdoc_files: []
106
106
  files:
107
- - CHANGELOG.adoc
108
- - LICENSE
109
- - README.adoc
110
- - Rakefile
111
107
  - lib/corefines.rb
112
108
  - lib/corefines/array.rb
113
109
  - lib/corefines/class.rb
@@ -183,9 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
179
  version: '0'
184
180
  requirements: []
185
181
  rubyforge_project:
186
- rubygems_version: 2.4.5.1
182
+ rubygems_version: 2.6.11
187
183
  signing_key:
188
184
  specification_version: 4
189
185
  summary: A collection of refinements for Ruby core classes.
190
186
  test_files: []
191
- has_rdoc: yard
data/CHANGELOG.adoc DELETED
@@ -1,62 +0,0 @@
1
- = Corefines Changelog
2
- :repo-uri: https://github.com/jirutka/corefines
3
- :doc-base-url: http://www.rubydoc.info/github/jirutka/corefines/Corefines
4
- :issue-uri: {repo-uri}/issues
5
-
6
-
7
- == 1.9.0 (2016-02-03)
8
-
9
- * Add new refinement {doc-base-url}/Enumerable/MapBy[Enumerable#map_by].
10
-
11
-
12
- == 1.8.0 (2015-07-06)
13
-
14
- * Add new refinement {doc-base-url}/Class/Descendants[Class#descendants].
15
-
16
-
17
- == 1.7.0 (2015-07-05)
18
-
19
- * Add new refinement {doc-base-url}/Enumerable/MapTo[Enumerable#map_to].
20
- * Add new refinement {doc-base-url}/Array/Wrap[Array#wrap].
21
- * Add new refinement {doc-base-url}/Enumerable/Many[Enumerable#many?].
22
-
23
-
24
- == 1.6.0 (2015-05-16)
25
-
26
- * Add new refinement {doc-base-url}/String/Camelcase[String#camelcase].
27
- * Add new refinement {doc-base-url}/String/SnakeCase[String#snake_case].
28
-
29
-
30
- == 1.5.0 (2015-05-03)
31
-
32
- * Rename String refinement `#to_regexp` to `#to_re` to avoid bug https://bugs.ruby-lang.org/issues/11117[#11117] in MRI.
33
-
34
-
35
- == 1.4.0 (2015-05-03)
36
-
37
- * Add new refinement {doc-base-url}/String/ForceUTF8[String#force_utf8].
38
-
39
-
40
- == 1.3.0 (2015-04-29)
41
-
42
- * Add new refinement {doc-base-url}/String/ToRegexp[String#to_regexp].
43
- * Add new refinement {doc-base-url}/String/RelativePathFrom[String#relative_path_from].
44
- * Add new refinement {doc-base-url}/Hash/Except[Hash#except].
45
- * Add new refinement {doc-base-url}/Hash/Only[Hash#only].
46
-
47
-
48
- == 1.2.0 (2015-04-27)
49
-
50
- * Add new refinement {doc-base-url}/String/Indent[String#indent].
51
-
52
-
53
- == 1.1.0 (2015-04-25)
54
-
55
- * Add new refinement {doc-base-url}/String/ToB[String#to_b].
56
- * Change alias for operator `+` from `OpPlus` to `OpAdd` and for operator `-` from `OpMinus` to `OpSub`.
57
- * Support operators `+@` (alias `OpPlus`) and `-@` (alias `OpMinus`).
58
-
59
-
60
- == 1.0.0 (2015-04-02)
61
-
62
- The first stable release.
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License
2
-
3
- Copyright 2015-2016 Jakub Jirutka <jakub@jirutka.cz>.
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
13
- all 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
21
- THE SOFTWARE.
data/README.adoc DELETED
@@ -1,217 +0,0 @@
1
- = Corefines
2
- Jakub Jirutka <https://github.com/jirutka[@jirutka]>
3
- :page-layout: base
4
- :idprefix:
5
- ifdef::env-github[:idprefix: user-content-]
6
- :idseparator: -
7
- :source-language: ruby
8
- :language: {source-language}
9
- // custom
10
- :gem-name: corefines
11
- :gh-name: jirutka/{gem-name}
12
- :gh-branch: master
13
- :badge-style: flat
14
- :doc-base-url: http://www.rubydoc.info/github/{gh-name}/{gh-branch}/Corefines
15
-
16
- ifdef::env-github[]
17
- image:https://img.shields.io/travis/{gh-name}/{gh-branch}.svg?style={badge-style}[Build Status, link="https://travis-ci.org/{gh-name}"]
18
- image:https://img.shields.io/codeclimate/coverage/github/{gh-name}.svg?style={badge-style}[Test Coverage, link="https://codeclimate.com/github/{gh-name}"]
19
- image:https://img.shields.io/codeclimate/github/{gh-name}.svg?style={badge-style}[Code Climate, link="https://codeclimate.com/github/{gh-name}"]
20
- image:https://img.shields.io/gem/v/{gem-name}.svg?style={badge-style}[Gem Version, link="https://rubygems.org/gems/{gem-name}"]
21
- image:https://img.shields.io/badge/yard-docs-blue.svg?style={badge-style}[Yard Docs, link="http://www.rubydoc.info/github/{gh-name}/{gh-branch}"]
22
- endif::env-github[]
23
-
24
- Corefines is a collection of general purpose _refinements_ for extending the core capabilities of Ruby’s built-in classes.
25
- It also provides a <<compatibility-mode>> for older Ruby versions and alternative Ruby implementations that don’t support refinements (yet).
26
-
27
-
28
- == Why refinements?
29
-
30
- Extending core classes with so called monkey-paching pollutes the _global_ scope, so it affects all files on the `$LOAD_PATH`, i.e. whole application including used gems.
31
- It’s not usually so big deal when you’re doing it in your application, but it’s very dangerous when used in a gem (library).
32
- This can result in strange and hard to debug behaviour if another gem overrides a core class with the same method as your gem, but different implementation, and both gems are used together.
33
-
34
- Refinements basically allows you to put monkey patches in an isolated namespace, so that your changes to core classes don’t affect other code.
35
-
36
- TODO
37
-
38
-
39
- == Installation
40
-
41
- Add this line to your application’s Gemfile:
42
-
43
- [source]
44
- gem 'corefines', '~> 1.9'
45
-
46
- or to your gemspec:
47
-
48
- [source]
49
- s.add_runtime_dependency 'corefines', '~> 1.9'
50
-
51
- and then execute:
52
-
53
- [source, sh]
54
- $ bundle install
55
-
56
-
57
- == Using
58
-
59
- First, you must require `corefines` prior using:
60
-
61
- [source]
62
- require 'corefines'
63
-
64
- This will _not_ activate any extensions (just register them), even when running in compatibility mode.
65
- Extensions (refinements) are activated selectively with the method http://ruby-doc.org/core-2.2.0/Module.html#method-i-using[`using`].
66
-
67
- Refinements are organized into modules by class which they refine, and further into submodules for individual methods.
68
- When an extension refines multiple classes, then it’s included in a module named after their nearest common ancestor (superclass).
69
-
70
- [source, plain]
71
- Corefines::<CLASS>::<METHOD>
72
-
73
- A single extension can be imported into the current scope classically, e.g.:
74
-
75
- [source]
76
- using Corefines::Object::ThenIf
77
-
78
- or preferably using its “alias”:
79
-
80
- [source]
81
- using Corefines::Object::then_if
82
-
83
- If you want to include all extensions for the class, then you can just import the parent module, e.g.:
84
-
85
- [source]
86
- using Corefines::Object
87
-
88
- But more often you want to include multiple extensions for the class, but not all of them, e.g.:
89
-
90
- [source]
91
- using Corefines::Object::then_if
92
- using Corefines::Object::in?
93
-
94
- this can be abbreviated to:
95
-
96
- [source]
97
- using Corefines::Object[:then_if, :in?]
98
-
99
- If you feel that _Corefines_ is too long, then you can also use abbreviation _CF_ instead:
100
-
101
- [source]
102
- using CF::Object::then_if
103
-
104
- Refinements can be activated (with `using`) at top-level (per file), inside a class, module or a method.
105
-
106
-
107
- == Compatibility mode
108
-
109
- Refinements are still a young feature, so there’s a possibility that your gem or application will have to work on a Ruby platform that doesn’t fully support refinements yet.
110
-
111
- The main Ruby implementation, https://en.wikipedia.org/wiki/Ruby_MRI[MRI] (aka CRuby), supports refinements since version 2.1.0 (https://www.ruby-lang.org/en/news/2013/12/25/ruby-2-1-0-is-released/[released in 25 Dec 2013]).
112
- footnote:[Actually, refinements has been introduced to MRI in 2.0.0, as an experimental feature. However, its design and implementation has been changed then, so refinements in 2.0.x and 2.1+ behaves quite differently.]
113
- Version 2.0.0 (https://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/[released in 24 Feb 2013]) is still supported though.
114
- http://www.jruby.org/[JRuby] doesn’t support refinements yet, it’s planned in the upcoming version 9.0.0.0 (https://github.com/jruby/jruby/issues/1062[#1062]).
115
- http://rubini.us/[Rubinius] also doesn’t support refinements yet.
116
-
117
- This gem is a collection of pure refinements, and yet, it works even on older Rubies that don’t support refinements.
118
- Wait… how?
119
- Well, when you use the gem with an older Ruby, it’s actually cheating.
120
- Instead of locally scoped changes, it falls back to global monkey-patching.
121
-
122
- The Corefines gem adds `refine` and `using` methods to the core classes, so you can define and use refinements just like in newer Rubies.
123
- But internally it works very differently.
124
- The `refine` method adds a given block to a collection of pending “refinements” inside its module.
125
- When `using` is called _first time_ for the module, it _evaluates_ module’s “refinements” in context of the target classes (i.e. do a monkey-patch).
126
-
127
- Not ideal indeed, but probably the best of what we can achieve.
128
-
129
-
130
- == List of refinements
131
-
132
- * {doc-base-url}/Array[Array]
133
- ** {doc-base-url}/Array/Second[#second]
134
- ** {doc-base-url}/Array/Third[#third]
135
- ** {doc-base-url}/Array/Wrap[.wrap]
136
- * {doc-base-url}/Class[Class]
137
- ** {doc-base-url}/Class/Descendants[#descendants]
138
- * {doc-base-url}/Enumerable[Enumerable]
139
- ** {doc-base-url}/Enumerable/IndexBy[#index_by]
140
- ** {doc-base-url}/Enumerable/Many[#many?]
141
- ** {doc-base-url}/Enumerable/MapBy[#map_by]
142
- ** {doc-base-url}/Enumerable/MapSend[#map_send]
143
- ** {doc-base-url}/Enumerable/MapTo[#map_to]
144
- * {doc-base-url}/Hash[Hash]
145
- ** {doc-base-url}/Hash/OpAdd[#+]
146
- ** {doc-base-url}/Hash/Compact[#compact]
147
- ** {doc-base-url}/Hash/Compact[#compact!]
148
- ** {doc-base-url}/Hash/Except[#except]
149
- ** {doc-base-url}/Hash/Except[#except!]
150
- ** {doc-base-url}/Hash/Only[#only]
151
- ** {doc-base-url}/Hash/Only[#only!]
152
- ** {doc-base-url}/Hash/Rekey[#rekey]
153
- ** {doc-base-url}/Hash/Rekey[#rekey!]
154
- ** {doc-base-url}/Hash/SymbolizeKeys[#symbolize_keys]
155
- ** {doc-base-url}/Hash/SymbolizeKeys[#symbolize_keys!]
156
- * {doc-base-url}/Module[Module]
157
- ** {doc-base-url}/Module/AliasClassMethod[#alias_class_method]
158
- ** {doc-base-url}/Module/AliasMethodChain[#alias_method_chain]
159
- * {doc-base-url}/Object[Object]
160
- ** {doc-base-url}/Object/Blank[#blank?]
161
- ** {doc-base-url}/Object/DeepDup[#deep_dup]
162
- ** {doc-base-url}/Object/Else[#else]
163
- ** {doc-base-url}/Object/In[#in?]
164
- ** {doc-base-url}/Object/InstanceValues[#instance_values]
165
- ** {doc-base-url}/Object/Blank[#presence]
166
- ** {doc-base-url}/Object/Then[#then]
167
- ** {doc-base-url}/Object/ThenIf[#then_if]
168
- ** {doc-base-url}/Object/Try[#try]
169
- ** {doc-base-url}/Object/Try[#try!]
170
- * {doc-base-url}/String[String]
171
- ** {doc-base-url}/String/Camelcase[#camelcase]
172
- ** {doc-base-url}/String/Color[#color]
173
- ** {doc-base-url}/String/Concat[#concat!]
174
- ** {doc-base-url}/String/Decolor[#decolor]
175
- ** {doc-base-url}/String/ForceUTF8[#force_utf8]
176
- ** {doc-base-url}/String/ForceUTF8[#force_utf8!]
177
- ** {doc-base-url}/String/Indent[#indent]
178
- ** {doc-base-url}/String/RelativePathFrom[#relative_path_from]
179
- ** {doc-base-url}/String/Remove[#remove]
180
- ** {doc-base-url}/String/SnakeCase[#snake_case]
181
- ** {doc-base-url}/String/ToB[#to_b]
182
- ** {doc-base-url}/String/ToRe[#to_re]
183
- ** {doc-base-url}/String/Unindent[#unindent] (alias `#strip_heredoc`)
184
- * {doc-base-url}/Symbol[Symbol]
185
- ** {doc-base-url}/Symbol/Call[#call]
186
-
187
-
188
- == Acknowledgement
189
-
190
- Most of the extension methods are based on, or highly inspired from:
191
-
192
- * https://github.com/rails/rails/tree/master/activesupport[Active Support (Ruby extensions)]
193
- * https://github.com/rubyworks/facets[Ruby Facets]
194
- * https://github.com/gregwebs/methodchain[methodchain]
195
- * https://github.com/fazibear/colorize[colorize]
196
- * https://github.com/seamusabshere/to_regexp[to_regexp]
197
-
198
- Very useful articles about refinements and how to “trick” them:
199
-
200
- * https://www.new-bamboo.co.uk/blog/2014/02/05/refinements-under-the-knife/[
201
- Refinements under the knife] by https://github.com/leemachin[@leemachin]
202
- * http://qiita.com/joker1007/items/68d066a12bc763bd2cb4[Refinement関係の小技とできない事をまとめてみた] by https://github.com/joker1007[@joker1007]
203
-
204
-
205
- == Contributing
206
-
207
- . Fork it.
208
- . Create your feature branch (`git checkout -b my-new-feature`).
209
- . Commit your changes (`git commit -am 'Add some feature'`).
210
- . Push to the branch (`git push origin my-new-feature`).
211
- . Create a new Pull Request.
212
-
213
-
214
- == License
215
-
216
- This project is licensed under http://opensource.org/licenses/MIT/[MIT License].
217
- For the full text of the license, see the link:LICENSE[LICENSE] file.
data/Rakefile DELETED
@@ -1,23 +0,0 @@
1
- require 'bundler/gem_tasks'
2
-
3
- begin
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task :test => :spec
9
- task :default => :spec
10
-
11
- rescue LoadError => e
12
- warn "#{e.path} is not available"
13
- end
14
-
15
- begin
16
- require 'yard'
17
-
18
- # options are defined in .yardopts
19
- YARD::Rake::YardocTask.new(:yard)
20
-
21
- rescue LoadError => e
22
- warn "#{e.path} is not available"
23
- end