ribsum 0.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 +7 -0
- data/lib/ribsum/version.rb +3 -0
- data/lib/ribsum.rb +49 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e7a963a0693568f8b239555aaf9ee313cde0eb993171360057ac617dc7f65214
|
4
|
+
data.tar.gz: f55aa321ab5d637e617068e859578eeb2af82d454b94273d1c9e07afc2c1b57c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea43bc717d2c5fde7b290aa9967793a178cd96c7187fc2d8d838af0eeac07d0d01b0e8ea48383ae9982c4d58617672bdf7b0851c562e61a2e4ba81b99194d19a
|
7
|
+
data.tar.gz: 874f42e08cfc9f2308163a94bcd9dcc24990a994b201b5975f34102d24784a9a436045c564f06cf8fbdf00c5a49ad32ea16e973ca1004d07d35904e82a4baa5f
|
data/lib/ribsum.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'ribsum/version'
|
2
|
+
|
3
|
+
module Ribsum
|
4
|
+
extend self
|
5
|
+
|
6
|
+
PARAGRAPH = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
|
7
|
+
|
8
|
+
def paragraphs(total = 1)
|
9
|
+
total = total.to_i
|
10
|
+
return PARAGRAPH if total <= 1
|
11
|
+
|
12
|
+
# use << for best performance
|
13
|
+
# reference: https://dattdongare.com/blog/string-concatenation-ruby/
|
14
|
+
result = ''
|
15
|
+
total.times do |i|
|
16
|
+
result << PARAGRAPH
|
17
|
+
result << "\n\n" if i < total - 1
|
18
|
+
end
|
19
|
+
|
20
|
+
result
|
21
|
+
end
|
22
|
+
|
23
|
+
def sentences(total = 1)
|
24
|
+
total = 1 if total.to_i < 1
|
25
|
+
|
26
|
+
index = total - 1
|
27
|
+
@_sentences ||= {}
|
28
|
+
|
29
|
+
@_sentences[index] ||= PARAGRAPH.split('.')[0..index].map{|sentence| sentence.strip }.join('. ')
|
30
|
+
end
|
31
|
+
|
32
|
+
def words(total = 1)
|
33
|
+
total = 1 if total.to_i < 1
|
34
|
+
|
35
|
+
index = total - 1
|
36
|
+
@_words ||= {}
|
37
|
+
|
38
|
+
@_words[index] ||= PARAGRAPH.gsub('.', '').gsub(',', '').split(' ')[0..index].join(' ')
|
39
|
+
end
|
40
|
+
|
41
|
+
def chars(total = 1)
|
42
|
+
total = 1 if total.to_i < 1
|
43
|
+
|
44
|
+
index = total - 1
|
45
|
+
@_chars ||= {}
|
46
|
+
|
47
|
+
@_chars[index] ||= PARAGRAPH.gsub('.', '').gsub(',', '').gsub(' ', '')[0..index]
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ribsum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kunto Aji Kristianto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Ribsum is a lightweight Ruby gems library to generate Lorem Ipsum text.
|
14
|
+
You can directly call the module functions (e.g. Ribsum.paragraph or Ribsum.paragraph(2))
|
15
|
+
or include Ribsum module to your class.
|
16
|
+
email: kuntoaji@kaklabs.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/ribsum.rb
|
22
|
+
- lib/ribsum/version.rb
|
23
|
+
homepage: https://github.com/kuntoaji/ribsum
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 2.7.5
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubygems_version: 3.1.6
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Lightweight Lorem Ipsum text generator
|
46
|
+
test_files: []
|