string-builder 2.2.0 → 2.3.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 +4 -4
- data/README.md +2 -2
- data/Rakefile +1 -0
- data/lib/string/builder.rb +19 -12
- data/string-builder.gemspec +2 -2
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a280b06b8f17ed966e832b72587fc45d0f117e89abc265fb4bf30584419c9274
|
4
|
+
data.tar.gz: e75b8e1247185d638bd31c23faa2bb77ed82397facb42c13a583ee1f3b3b3186
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a912db26e86a8276c624f687cf0eb96d85bc8ff396ea72c82c788253e8a0d28617f8cf6be2087f213cdbe54afec79fbdcf6d8c6d67ad2f47546aac8f3644c94
|
7
|
+
data.tar.gz: c202c0b4673156a474e3c371a2562615ae165fb84fa722f25e6658b902fb0b76c73da59a685d00ea5a7a8982e7a81a78c50f8cb82a21d183512c0fe153a6274c
|
data/README.md
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
# String::Builder
|
6
6
|
|
7
|
-
|
7
|
+
Refinement of the core String class, extending it with class and instance methods for streamlined string construction.
|
8
8
|
|
9
9
|
## Methods
|
10
10
|
|
11
|
-
There are
|
11
|
+
There are four new methods in this extension of the `String` class:
|
12
12
|
|
13
13
|
### Instance methods
|
14
14
|
|
data/Rakefile
CHANGED
data/lib/string/builder.rb
CHANGED
@@ -1,34 +1,41 @@
|
|
1
1
|
module String::Builder
|
2
|
-
refine String.singleton_class do
|
3
2
|
|
4
|
-
|
3
|
+
refine String.singleton_class do
|
4
|
+
def [](*objs) objs.map(&:to_s)*self.new end
|
5
5
|
|
6
|
-
def build(
|
7
|
-
|
6
|
+
def build(*objs)
|
7
|
+
objs << String.new if objs.empty?
|
8
|
+
content = self.[](*objs)
|
9
|
+
return content unless block_given?
|
8
10
|
yield builder = self.new
|
9
|
-
|
11
|
+
content << builder
|
10
12
|
end
|
11
13
|
|
12
14
|
def respond_to?(id, private = false)
|
13
15
|
%i[[] build].include?(id.to_sym) ? true : super
|
14
16
|
end
|
15
|
-
|
16
17
|
end
|
17
|
-
refine String do
|
18
18
|
|
19
|
-
|
19
|
+
refine String do
|
20
|
+
def build(*objs)
|
21
|
+
objs << String.new if objs.empty?
|
22
|
+
content = String[*objs]
|
23
|
+
return self.dup << content unless block_given?
|
20
24
|
yield builder = String.new
|
21
|
-
self.dup << builder
|
25
|
+
self.dup << content << builder
|
22
26
|
end
|
23
27
|
|
24
|
-
def build!
|
28
|
+
def build!(*objs)
|
29
|
+
objs << String.new if objs.empty?
|
30
|
+
content = String[*objs]
|
31
|
+
return self << content unless block_given?
|
25
32
|
yield builder = String.new
|
26
|
-
self << builder
|
33
|
+
self << content << builder
|
27
34
|
end
|
28
35
|
|
29
36
|
def respond_to?(id, private = false)
|
30
37
|
%i[build build!].include?(id.to_sym) ? true : super
|
31
38
|
end
|
32
|
-
|
33
39
|
end
|
40
|
+
|
34
41
|
end
|
data/string-builder.gemspec
CHANGED
@@ -3,11 +3,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "string-builder"
|
6
|
-
spec.version = "2.
|
6
|
+
spec.version = "2.3.0"
|
7
7
|
spec.authors = ["Edwin Onuonga"]
|
8
8
|
spec.email = ["edwinonuonga@gmail.com"]
|
9
9
|
|
10
|
-
spec.summary = %q{
|
10
|
+
spec.summary = %q{Refinement of the core String class, extending it with class and instance methods for streamlined string construction.}
|
11
11
|
spec.homepage = "https://www.github.com/eonu/string-builder"
|
12
12
|
spec.license = "MIT"
|
13
13
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edwin Onuonga
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,7 +93,6 @@ rubyforge_project:
|
|
93
93
|
rubygems_version: 2.7.3
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
|
-
summary:
|
97
|
-
|
98
|
-
module.
|
96
|
+
summary: Refinement of the core String class, extending it with class and instance
|
97
|
+
methods for streamlined string construction.
|
99
98
|
test_files: []
|