nrser 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nrser/refinements/hash.rb +18 -0
- data/lib/nrser/refinements/pathname.rb +37 -0
- data/lib/nrser/refinements/string.rb +23 -0
- data/lib/nrser/refinements.rb +5 -57
- data/lib/nrser/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67b64d7d401f7308d82547b735f58755611532c1
|
4
|
+
data.tar.gz: 76e9645d945ada898275daff780063de2ce16f0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cc10e1ae945e617d2afb5d5f0e35e41a579f82745cd0340c8eb33527d5601e01a16ee376ab62fa298d206a3889333e2c1c2b04edd4b4d48cb798c9da939ce01
|
7
|
+
data.tar.gz: 28f8b3bc7e60b3a02e510a0e4abd43c7ae0bdafa6e4293bb2adb8b71eaab3b2bbe7097f468159afafc2c154a39ed8b2d78d4dfde02205bbac199ef4fdf2cb386
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module NRSER
|
2
|
+
refine Hash do
|
3
|
+
# lifted from ActiveSupport
|
4
|
+
def except! *keys
|
5
|
+
keys.each { |key| delete(key) }
|
6
|
+
self
|
7
|
+
end
|
8
|
+
|
9
|
+
alias_method :omit!, :except!
|
10
|
+
|
11
|
+
# lifted from ActiveSupport
|
12
|
+
def except *keys
|
13
|
+
dup.except! *keys
|
14
|
+
end
|
15
|
+
|
16
|
+
alias_method :omit, :except
|
17
|
+
end # Hash
|
18
|
+
end # NRSER
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module NRSER
|
4
|
+
refine Pathname do
|
5
|
+
# override to accept Pathname instances.
|
6
|
+
#
|
7
|
+
# @param [String] *prefixes
|
8
|
+
# the prefixes to see if the Pathname starts with.
|
9
|
+
#
|
10
|
+
# @return [Boolean]
|
11
|
+
# true if the Pathname starts with any of the prefixes.
|
12
|
+
#
|
13
|
+
def start_with? *prefixes
|
14
|
+
to_s.start_with? *prefixes.map(&:to_s)
|
15
|
+
end
|
16
|
+
|
17
|
+
# override sub to support Pathname instances as patterns.
|
18
|
+
#
|
19
|
+
# @param [String | Regexp | Pathname] pattern
|
20
|
+
# thing to replace.
|
21
|
+
#
|
22
|
+
# @param [String | Hash] replacement
|
23
|
+
# thing to replace it with.
|
24
|
+
#
|
25
|
+
# @return [Pathname]
|
26
|
+
# new Pathname.
|
27
|
+
#
|
28
|
+
def sub pattern, replacement
|
29
|
+
case pattern
|
30
|
+
when Pathname
|
31
|
+
super pattern.to_s, replacement
|
32
|
+
else
|
33
|
+
super pattern, replacement
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end # Pathname
|
37
|
+
end # NRSER
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module NRSER
|
2
|
+
refine String do
|
3
|
+
def squish
|
4
|
+
NRSER.squish self
|
5
|
+
end
|
6
|
+
|
7
|
+
def unblock
|
8
|
+
NRSER.unblock self
|
9
|
+
end
|
10
|
+
|
11
|
+
def dedent
|
12
|
+
NRSER.dedent self
|
13
|
+
end
|
14
|
+
|
15
|
+
def indent *args
|
16
|
+
NRSER.indent self, *args
|
17
|
+
end
|
18
|
+
|
19
|
+
def truncate *args
|
20
|
+
NRSER.truncate self, *args
|
21
|
+
end
|
22
|
+
end # refine String
|
23
|
+
end # NRSER
|
data/lib/nrser/refinements.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
|
+
require_relative 'refinements/string'
|
4
|
+
require_relative 'refinements/hash'
|
5
|
+
require_relative 'refinements/pathname'
|
6
|
+
|
3
7
|
module NRSER
|
4
8
|
refine Object do
|
5
9
|
def pipe
|
@@ -7,28 +11,6 @@ module NRSER
|
|
7
11
|
end
|
8
12
|
end
|
9
13
|
|
10
|
-
refine String do
|
11
|
-
def squish
|
12
|
-
NRSER.squish self
|
13
|
-
end
|
14
|
-
|
15
|
-
def unblock
|
16
|
-
NRSER.unblock self
|
17
|
-
end
|
18
|
-
|
19
|
-
def dedent
|
20
|
-
NRSER.dedent self
|
21
|
-
end
|
22
|
-
|
23
|
-
def indent *args
|
24
|
-
NRSER.indent self, *args
|
25
|
-
end
|
26
|
-
|
27
|
-
def truncate *args
|
28
|
-
NRSER.truncate self, *args
|
29
|
-
end
|
30
|
-
end # refine String
|
31
|
-
|
32
14
|
refine Exception do
|
33
15
|
def format
|
34
16
|
NRSER.format_exception self
|
@@ -39,39 +21,5 @@ module NRSER
|
|
39
21
|
def erb str
|
40
22
|
NRSER.template self, str
|
41
23
|
end
|
42
|
-
end
|
43
|
-
|
44
|
-
refine Pathname do
|
45
|
-
# override to accept Pathname instances.
|
46
|
-
#
|
47
|
-
# @param [String] *prefixes
|
48
|
-
# the prefixes to see if the Pathname starts with.
|
49
|
-
#
|
50
|
-
# @return [Boolean]
|
51
|
-
# true if the Pathname starts with any of the prefixes.
|
52
|
-
#
|
53
|
-
def start_with? *prefixes
|
54
|
-
to_s.start_with? *prefixes.map(&:to_s)
|
55
|
-
end
|
56
|
-
|
57
|
-
# override sub to support Pathname instances as patterns.
|
58
|
-
#
|
59
|
-
# @param [String | Regexp | Pathname] pattern
|
60
|
-
# thing to replace.
|
61
|
-
#
|
62
|
-
# @param [String | Hash] replacement
|
63
|
-
# thing to replace it with.
|
64
|
-
#
|
65
|
-
# @return [Pathname]
|
66
|
-
# new Pathname.
|
67
|
-
#
|
68
|
-
def sub pattern, replacement
|
69
|
-
case pattern
|
70
|
-
when Pathname
|
71
|
-
super pattern.to_s, replacement
|
72
|
-
else
|
73
|
-
super pattern, replacement
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end # Pathname
|
24
|
+
end
|
77
25
|
end # NRSER
|
data/lib/nrser/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nrser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
@@ -98,6 +98,9 @@ files:
|
|
98
98
|
- lib/nrser/collection.rb
|
99
99
|
- lib/nrser/logger.rb
|
100
100
|
- lib/nrser/refinements.rb
|
101
|
+
- lib/nrser/refinements/hash.rb
|
102
|
+
- lib/nrser/refinements/pathname.rb
|
103
|
+
- lib/nrser/refinements/string.rb
|
101
104
|
- lib/nrser/types.rb
|
102
105
|
- lib/nrser/types/any.rb
|
103
106
|
- lib/nrser/types/array.rb
|