string-builder 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9be05a5fa8302af3f75659e915cd1ed84f8c87ff6ff5ec177d1dde71910e66a
4
- data.tar.gz: 6c3840f7d0ae83a84ad66439ea370b3a25f36dfaee0512c6aeaebb549f0d3253
3
+ metadata.gz: a280b06b8f17ed966e832b72587fc45d0f117e89abc265fb4bf30584419c9274
4
+ data.tar.gz: e75b8e1247185d638bd31c23faa2bb77ed82397facb42c13a583ee1f3b3b3186
5
5
  SHA512:
6
- metadata.gz: 8a7d470f28efeb3c0fff8539d908a105f406a8f6b2eeba496c5be6bdd61356cee33a6b96dcac7e663ee2d781c9d4ba991b28027c980e1b03fb44c9123a917493
7
- data.tar.gz: 2af21fb239aef87a7ca89f06c7ee4b020f930f5a9c75aef42dc08c0b948f5ad9ff49897264608cc2b385b73062e74e604b2fad82ba9d4c7b2f2a1a07ccaeb9d6
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
- Modified and extended port of the [String::Builder](https://crystal-lang.org/api/0.20.3/String/Builder.html#build%28capacity%3AInt%3D64%2C%26block%29%3AString-class-method) IO-style initializer for the `String` class of the Crystal programming language in the form of a Ruby gem refinement module.
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 three new methods in this extension of the `String` class:
11
+ There are four new methods in this extension of the `String` class:
12
12
 
13
13
  ### Instance methods
14
14
 
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ require "bundler/gem_tasks"
1
2
  task :default => :spec
2
3
 
3
4
  desc "Runs specs"
@@ -1,34 +1,41 @@
1
1
  module String::Builder
2
- refine String.singleton_class do
3
2
 
4
- def [](*args) args.map(&:to_s)*self.new end
3
+ refine String.singleton_class do
4
+ def [](*objs) objs.map(&:to_s)*self.new end
5
5
 
6
- def build(obj = String.new)
7
- return obj.to_s unless block_given?
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
- obj.dup.to_s << builder
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
- def build
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
@@ -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.2.0"
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{Modified and extended port of the String::Builder IO-style initializer for the String class of the Crystal programming language in the form of a Ruby gem refinement module.}
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.2.0
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-06-10 00:00:00.000000000 Z
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: Modified and extended port of the String::Builder IO-style initializer for
97
- the String class of the Crystal programming language in the form of a Ruby gem refinement
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: []