rafini 1.2.1 → 2.0.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
- SHA1:
3
- metadata.gz: b1b74cb41e460e337bb956cf0bb3607bea04b500
4
- data.tar.gz: 9a7974b36425a5f9e1d85e465621540cc8583426
2
+ SHA256:
3
+ metadata.gz: b81e63f8b4651660cd62560692546173a7ae971ce0a0a76b6bc772c573f2d181
4
+ data.tar.gz: 37146803ff33ddcf74da2cd90bb5ddd4a2b1da0fe2be0c55b1b5b984a14029ca
5
5
  SHA512:
6
- metadata.gz: 537fcf606f5228cbeddd25fd78b2f3b79fb191f580191a03f33d3377ef4fedc61f1c6e3eeb45836081accbd44bcdd5e0e141139053cab83f3b2d193a6f3d0f08
7
- data.tar.gz: 94aa362d8c89d23da926516ea4f0b1620d22486782e96bb21167c38f7b940129acc729477882dab5c989ff0e20fb53db6a49695c51255a6522159eb4bfcc6a6e
6
+ metadata.gz: ecb3a3935d9892365a7568e304994605657b0ff0ed9c4e5adab0eee83c4d42d9584b0b6c6cdcd2d602f2817371d3a632f51396bf62b9ca134153c7eae926f22a
7
+ data.tar.gz: a1795c03155fbaa64fd90b4a5a8ab4ad033fa5489bb925168a765ab4be71b742cca5bc61d282c88c9c4af75c2b9c24feb8c2bd87f5d01189a5b32e34fd2a8c89
@@ -0,0 +1,117 @@
1
+ # rafini 2.0.0
2
+
3
+ ## DESCRIPTION:
4
+
5
+ Just a collection of useful refinements.
6
+
7
+ ## SYNOPSIS:
8
+
9
+ ### using Rafini::Array
10
+
11
+ # joins
12
+ ['a','b','c','d','e','f'].joins('-','-',' '){':'} #=> "a-b-c d:e:f"
13
+
14
+ # per
15
+ h={}
16
+ ['a','b','c'].per(['A','B','C']){|l,u| h[l]=u}
17
+ h #=> {'a'=>'A','b'=>'B','c'=>'C'}
18
+
19
+ # which
20
+ ['dog','cat','bunny'].which{|a|a=~/c/} #=> "cat"
21
+
22
+ # is
23
+ [:a,:b,:c].is(true) #=> {a: true, b: true, c: true}
24
+
25
+ ### using Rafini::Exception
26
+
27
+ # $!.puts
28
+ begin
29
+ raise 'Ugly Message'
30
+ rescue RuntimeError
31
+ $!.puts 'Nice Message'
32
+ end
33
+
34
+ # Rafini.bang!
35
+ value = Rafini.bang!('Nice Message') do
36
+ raise 'Ugly Message'
37
+ end
38
+ value #=> return value of block or error object
39
+
40
+ # Rafini.thread_bang!
41
+ Rafini.thread_bang!('Nice Message') do
42
+ # this is in a thread
43
+ raise 'Ugly Message'
44
+ end
45
+
46
+ ### using Rafini::Hash
47
+
48
+ # to_struc
49
+ struct = {a:'A',b:'C',c:'C'}.to_struct
50
+ struct.a #=> 'A'
51
+
52
+ # modify
53
+ {a:'A',b:'B'}.modify({b:'X',c:'C'},{c:'Y',d:'D'}) #=> {a:'A',b:'X',c:'Y',d:'D'}
54
+
55
+ # supplement
56
+ {a:'A',b:'B'}.supplement({b:'X',c:'C'},{c:'Y',d:'D'}) #=> {a:'A',b:'B',c:'C',d:'D'}
57
+
58
+ # amend
59
+ {a:'A',b:'B'}.amend({b:'X',c:'C'},{c:'Y',d:'D'}) #=> {a:'A',b:'X'}
60
+
61
+ # maps
62
+ {a:'A',b:'B',c:'C',c:'D'}.maps(:c,:a,:b) #=> ['C','A','B']
63
+
64
+ ### using Rafini::Integer
65
+
66
+ # odometer
67
+ 123.odometer(10,10) #=> [3,2,1]
68
+ 30.odometer(2,3,5) #=> [0,0,0,1]
69
+
70
+ ### using Rafini::Odometers
71
+
72
+ # sec2time
73
+ 12501.sec2time.to_s #=> "3 hours and 28 minutes"
74
+
75
+ # illion
76
+ 3_512_325.illion.to_s #=> "3.51M"
77
+
78
+ ### using Rafini::String
79
+
80
+ # camelize
81
+ 'a_camel_kick'.camelize #=> "ACamelKick"
82
+
83
+ # semantic
84
+ '1.2.3'.semantic(0..1) #=> '1.2'
85
+
86
+ ### Rafini::Empty
87
+
88
+ STRING, ARRAY, HASH = ''.frozen, [].frozen, {}.frozen
89
+
90
+ ## INSTALL:
91
+
92
+ $ gem install rafini
93
+
94
+ ## LICENSE:
95
+
96
+ (The MIT License)
97
+
98
+ Copyright (c) 2020 carlosjhr64
99
+
100
+ Permission is hereby granted, free of charge, to any person obtaining
101
+ a copy of this software and associated documentation files (the
102
+ 'Software'), to deal in the Software without restriction, including
103
+ without limitation the rights to use, copy, modify, merge, publish,
104
+ distribute, sublicense, and/or sell copies of the Software, and to
105
+ permit persons to whom the Software is furnished to do so, subject to
106
+ the following conditions:
107
+
108
+ The above copyright notice and this permission notice shall be
109
+ included in all copies or substantial portions of the Software.
110
+
111
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
112
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
113
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
114
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
115
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
116
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
117
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,13 +1,12 @@
1
- require 'rafini/version'
2
-
3
- require 'rafini/array'
4
- require 'rafini/exception'
5
- require 'rafini/hash'
6
- require 'rafini/integer'
7
- require 'rafini/string'
8
-
9
- require 'rafini/odometers'
10
- require 'rafini/empty'
11
-
1
+ module Rafini
2
+ VERSION = '2.0.0'
3
+ require 'rafini/array'
4
+ require 'rafini/exception'
5
+ require 'rafini/hash'
6
+ require 'rafini/integer'
7
+ require 'rafini/string'
8
+ require 'rafini/odometers'
9
+ require 'rafini/empty'
10
+ end
12
11
  # Requires:
13
12
  #`ruby`
@@ -1,7 +1,6 @@
1
1
  module Rafini
2
2
  module Array
3
3
  refine ::Array do
4
-
5
4
  # string = array.joins(sep1,sep2,sep3,...){|i| sep[i]}
6
5
  #
7
6
  # Returns a string created by converting each element of the array to
@@ -16,7 +15,7 @@ module Rafini
16
15
  # ['a','b','c'].joins{|i|i} #=> 'a1b2c'
17
16
  def joins(*p, &block)
18
17
  str = ''
19
- if length > 1
18
+ if length > 0
20
19
  str << self[0]
21
20
  1.upto(length-1) do |i|
22
21
  str << (p.empty? ? (block ? block.call(i).to_s : '') : p.shift.to_s)
@@ -41,10 +40,7 @@ module Rafini
41
40
  #
42
41
  # Returns first object for which block is true.
43
42
  # ['dog','cat','bunny'].which{|a|a=~/c/} #=> "cat"
44
- def which
45
- self.each{|obj| return obj if yield(obj)}
46
- return nil
47
- end
43
+ alias which detect
48
44
 
49
45
  # [:a,:b,:c].is(true) #=> {:a=>true,:b=>true,:c=>true}
50
46
  #
@@ -53,7 +49,6 @@ module Rafini
53
49
  self.each{|key| hash[key]=value}
54
50
  return hash
55
51
  end
56
-
57
52
  end
58
53
  end
59
54
  end
@@ -1,7 +1,6 @@
1
1
  module Rafini
2
2
  module Exception
3
3
  refine ::Exception do
4
-
5
4
  # $!.puts outputs to standard error what went bang!
6
5
  # The given message is what you normally want to see.
7
6
  # The exeption message is also shown if in verbose mode.
@@ -1,7 +1,6 @@
1
1
  module Rafini
2
2
  module Hash
3
3
  refine ::Hash do
4
-
5
4
  # struct = hash.to_struct
6
5
  # Why not?
7
6
  def to_struct
@@ -1,7 +1,6 @@
1
1
  module Rafini
2
2
  module Integer
3
3
  refine ::Integer do
4
-
5
4
  # odometer
6
5
  # Kinda hard to explain...
7
6
  # 123.odometer(10,10) #=> [3,2,1]
metadata CHANGED
@@ -1,25 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rafini
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - carlosjhr64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-02 00:00:00.000000000 Z
11
+ date: 2020-08-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Just a collection of useful refinements.
14
14
 
15
- '
15
+ '
16
16
  email: carlosjhr64@gmail.com
17
17
  executables: []
18
18
  extensions: []
19
- extra_rdoc_files:
20
- - README.rdoc
19
+ extra_rdoc_files: []
21
20
  files:
22
- - README.rdoc
21
+ - README.md
23
22
  - lib/rafini.rb
24
23
  - lib/rafini/array.rb
25
24
  - lib/rafini/empty.rb
@@ -28,15 +27,12 @@ files:
28
27
  - lib/rafini/integer.rb
29
28
  - lib/rafini/odometers.rb
30
29
  - lib/rafini/string.rb
31
- - lib/rafini/version.rb
32
30
  homepage: https://github.com/carlosjhr64/rafini
33
31
  licenses:
34
32
  - MIT
35
33
  metadata: {}
36
34
  post_install_message:
37
- rdoc_options:
38
- - "--main"
39
- - README.rdoc
35
+ rdoc_options: []
40
36
  require_paths:
41
37
  - lib
42
38
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -50,9 +46,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
46
  - !ruby/object:Gem::Version
51
47
  version: '0'
52
48
  requirements:
53
- - 'ruby: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]'
54
- rubyforge_project:
55
- rubygems_version: 2.6.11
49
+ - 'ruby: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]'
50
+ rubygems_version: 3.1.2
56
51
  signing_key:
57
52
  specification_version: 4
58
53
  summary: Just a collection of useful refinements.
@@ -1,117 +0,0 @@
1
- = rafini
2
-
3
- == DESCRIPTION:
4
-
5
- Just a collection of useful refinements.
6
-
7
- == SYNOPSIS:
8
-
9
- === using Rafini::Array
10
-
11
- # joins
12
- ['a','b','c','d','e','f'].joins('-','-',' '){':'} #=> "a-b-c d:e:f"
13
-
14
- # per
15
- h={}
16
- ['a','b','c'].per(['A','B','C']){|l,u| h[l]=u}
17
- h #=> {'a'=>'A','b'=>'B','c'=>'C'}
18
-
19
- # which
20
- ['dog','cat','bunny'].which{|a|a=~/c/} #=> "cat"
21
-
22
- # is
23
- [:a,:b,:c].is(true) #=> {a: true, b: true, c: true}
24
-
25
- === using Rafini::Exception
26
-
27
- # $!.puts
28
- begin
29
- raise 'Ugly Message'
30
- rescue RuntimeError
31
- $!.puts 'Nice Message'
32
- end
33
-
34
- # Rafini.bang!
35
- value = Rafini.bang!('Nice Message') do
36
- raise 'Ugly Message'
37
- end
38
- value #=> return value of block or error object
39
-
40
- # Rafini.thread_bang!
41
- Rafini.thread_bang!('Nice Message') do
42
- # this is in a thread
43
- raise 'Ugly Message'
44
- end
45
-
46
- === using Rafini::Hash
47
-
48
- # to_struc
49
- struct = {a:'A',b:'C',c:'C'}.to_struct
50
- struct.a #=> 'A'
51
-
52
- # modify
53
- {a:'A',b:'B'}.modify({b:'X',c:'C'},{c:'Y',d:'D'}) #=> {a:'A',b:'X',c:'Y',d:'D'}
54
-
55
- # supplement
56
- {a:'A',b:'B'}.supplement({b:'X',c:'C'},{c:'Y',d:'D'}) #=> {a:'A',b:'B',c:'C',d:'D'}
57
-
58
- # amend
59
- {a:'A',b:'B'}.amend({b:'X',c:'C'},{c:'Y',d:'D'}) #=> {a:'A',b:'X'}
60
-
61
- # maps
62
- {a:'A',b:'B',c:'C',c:'D'}.maps(:c,:a,:b) #=> ['C','A','B']
63
-
64
- === using Rafini::Integer
65
-
66
- # odometer
67
- 123.odometer(10,10) #=> [3,2,1]
68
- 30.odometer(2,3,5) #=> [0,0,0,1]
69
-
70
- === using Rafini::Odometers
71
-
72
- # sec2time
73
- 12501.sec2time.to_s #=> "3 hours and 28 minutes"
74
-
75
- # illion
76
- 3_512_325.illion.to_s #=> "3.51M"
77
-
78
- === using Rafini::String
79
-
80
- # camelize
81
- 'a_camel_kick'.camelize #=> "ACamelKick"
82
-
83
- # semantic
84
- '1.2.3'.semantic(0..1) #=> '1.2'
85
-
86
- === Rafini::Empty
87
-
88
- STRING, ARRAY, HASH = ''.frozen, [].frozen, {}.frozen
89
-
90
- == INSTALL:
91
-
92
- $ sudo gem install rafini
93
-
94
- == LICENSE:
95
-
96
- (The MIT License)
97
-
98
- Copyright (c) 2017 carlosjhr64
99
-
100
- Permission is hereby granted, free of charge, to any person obtaining
101
- a copy of this software and associated documentation files (the
102
- 'Software'), to deal in the Software without restriction, including
103
- without limitation the rights to use, copy, modify, merge, publish,
104
- distribute, sublicense, and/or sell copies of the Software, and to
105
- permit persons to whom the Software is furnished to do so, subject to
106
- the following conditions:
107
-
108
- The above copyright notice and this permission notice shall be
109
- included in all copies or substantial portions of the Software.
110
-
111
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
112
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
113
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
114
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
115
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
116
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
117
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,3 +0,0 @@
1
- module Rafini
2
- VERSION = '1.2.1'
3
- end