corefines 1.0.0 → 1.1.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: a692c4abce603d86050acd275daec0cdd2c303e6
4
- data.tar.gz: 7d8a10a41f2eff14a549d7f192ed1485ecf2348e
3
+ metadata.gz: 82c26f93d1bc1ddcc3dcb1c97969c68e8c0cef6f
4
+ data.tar.gz: 6054a13281a7d9fa3b271e0b0346807ad544ae13
5
5
  SHA512:
6
- metadata.gz: 8507ca0ade2ee56e6e430a552fc5edfd32a28dbe9e434b61f8b884143a9cf25c604b3ce71b5f76dbec7663a77cda404cde7689569cbca89e7c0f568dfb046a7d
7
- data.tar.gz: e3136911b789c35cdc559c0280fcd31bae9a64f6465b7a8eaa3428e1a368da021e65c69c406a2c3e2bf7320897739f6571d6d586054e43945e00f01826a8ac62
6
+ metadata.gz: c610bd41cde34fdb019703195c19e634581da8aea88ee5453e777f4479fc7d800b4a02fede7d99ef55c8cd17ec6dc3b26b63ccd4e2e514c02575265e84b4e2fe
7
+ data.tar.gz: 6bbc9e703f2e9f705340c7be511950f81d5e443cb3143cd2928d2c66dc14b330bbea79c0333100dd3015c2bd36b7797ee09663a8407a3c55621b74edf20396de
data/CHANGELOG.adoc ADDED
@@ -0,0 +1,15 @@
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
+ == 1.1.0 (2015-04-25)
7
+
8
+ * Add new refinement {doc-base-url}/String/ToB[String#to_b].
9
+ * Change alias for operator `+` from `OpPlus` to `OpAdd` and for operator `-` from `OpMinus` to `OpSub`.
10
+ * Support operators `+@` (alias `OpPlus`) and `-@` (alias `OpMinus`).
11
+
12
+
13
+ == 1.0.0 (2015-04-02)
14
+
15
+ The first stable release.
data/README.adoc CHANGED
@@ -136,7 +136,7 @@ Not ideal indeed, but probably the best of what we can achieve.
136
136
  ** {doc-base-url}/Enumerable/IndexBy[#index_by]
137
137
  ** {doc-base-url}/Enumerable/MapSend[#map_send]
138
138
  * {doc-base-url}/Hash[Hash]
139
- ** {doc-base-url}/Hash/OpPlus[#+]
139
+ ** {doc-base-url}/Hash/OpAdd[#+]
140
140
  ** {doc-base-url}/Hash/Compact[#compact]
141
141
  ** {doc-base-url}/Hash/Compact[#compact!]
142
142
  ** {doc-base-url}/Hash/Rekey[#rekey]
@@ -162,6 +162,7 @@ Not ideal indeed, but probably the best of what we can achieve.
162
162
  ** {doc-base-url}/String/Concat[#concat]
163
163
  ** {doc-base-url}/String/Decolor[#decolor]
164
164
  ** {doc-base-url}/String/Remove[#remove]
165
+ ** {doc-base-url}/String/ToB[#to_b]
165
166
  ** {doc-base-url}/String/Unindent[#unindent] (alias `#strip_heredoc`)
166
167
  * {doc-base-url}/Symbol[Symbol]
167
168
  ** {doc-base-url}/Symbol/Call[#call]
@@ -44,7 +44,7 @@ module Corefines
44
44
  # this hash. The value for entries with duplicate keys will be that of
45
45
  # _other_hash_.
46
46
  #
47
- module OpPlus
47
+ module OpAdd
48
48
  refine ::Hash do
49
49
  def +(other_hash)
50
50
  merge other_hash
@@ -165,6 +165,33 @@ module Corefines
165
165
  end
166
166
  end
167
167
 
168
+ ##
169
+ # @!method to_b
170
+ # Interprets common affirmative string meanings as +true+, otherwise
171
+ # +false+. White spaces and case are ignored.
172
+ #
173
+ # The following strings are interpreted as +true+:
174
+ # <tt>'true', 'yes', 'on', 't', 'y', '1'</tt>.
175
+ #
176
+ # @example
177
+ # 'yes'.to_b #=> true
178
+ # 'Yes '.to_b #=> true
179
+ # ' t '.to_b #=> true
180
+ # 'no'.to_b #=> false
181
+ # 'xyz'.to_b #=> false
182
+ # ''.to_b #=> false
183
+ #
184
+ # @return [Boolean] +true+ if this string represents truthy,
185
+ # +false+ otherwise.
186
+ #
187
+ module ToB
188
+ refine ::String do
189
+ def to_b
190
+ %w[true yes on t y 1].include? self.downcase.strip
191
+ end
192
+ end
193
+ end
194
+
168
195
  ##
169
196
  # @!method unindent
170
197
  # Remove excessive indentation. Useful for multi-line strings embeded in
@@ -26,8 +26,10 @@ module Corefines
26
26
  module AliasSubmodules
27
27
 
28
28
  OPERATORS_MAP = {
29
- :op_plus => :+,
30
- :op_minus => :-,
29
+ :op_plus => :+@,
30
+ :op_minus => :-@,
31
+ :op_add => :+,
32
+ :op_sub => :-,
31
33
  :op_pow => :**,
32
34
  :op_mul => :*,
33
35
  :op_div => :/,
@@ -1,3 +1,3 @@
1
1
  module Corefines
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
File without changes
@@ -0,0 +1,20 @@
1
+ describe String do
2
+ using Corefines::String::to_b
3
+
4
+ describe '#to_b' do
5
+
6
+ ['true', 'yes', 'on', 't', 'y', '1', ' true ', 'YeS', ' 1'].each do |str|
7
+ context "given '#{str}'" do
8
+ subject { str.to_b }
9
+ it { is_expected.to be true }
10
+ end
11
+ end
12
+
13
+ ['false', 'no', 'off', 'f', 'n', '0', ' FalsE ', 'xyz', ''].each do |str|
14
+ context "given '#{str}'" do
15
+ subject { str.to_b }
16
+ it { is_expected.to be false }
17
+ end
18
+ end
19
+ end
20
+ 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.0.0
4
+ version: 1.1.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: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2015-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -104,6 +104,7 @@ executables: []
104
104
  extensions: []
105
105
  extra_rdoc_files: []
106
106
  files:
107
+ - CHANGELOG.adoc
107
108
  - LICENSE
108
109
  - README.adoc
109
110
  - Rakefile
@@ -124,7 +125,7 @@ files:
124
125
  - spec/enumerable/index_by_spec.rb
125
126
  - spec/enumerable/map_send_spec.rb
126
127
  - spec/hash/compact_spec.rb
127
- - spec/hash/op_plus_spec.rb
128
+ - spec/hash/op_add_spec.rb
128
129
  - spec/hash/rekey_spec.rb
129
130
  - spec/hash/symbolize_keys_spec.rb
130
131
  - spec/module/alias_class_method_spec.rb
@@ -142,6 +143,7 @@ files:
142
143
  - spec/string/concat_spec.rb
143
144
  - spec/string/decolor_spec.rb
144
145
  - spec/string/remove_spec.rb
146
+ - spec/string/to_b_spec.rb
145
147
  - spec/string/unindent_spec.rb
146
148
  - spec/support/alias_submodules_spec.rb
147
149
  - spec/support/classes_including_module_spec.rb
@@ -167,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
169
  version: '0'
168
170
  requirements: []
169
171
  rubyforge_project:
170
- rubygems_version: 2.4.6
172
+ rubygems_version: 2.4.5
171
173
  signing_key:
172
174
  specification_version: 4
173
175
  summary: A collection of refinements for Ruby core classes.