lit_ipsum 0.9.0 → 0.9.1

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: 01a21c2acd77a0c3e3b0b2a7c1607bc2fc8494dda9eb01eb124f27ea193bf1e7
4
- data.tar.gz: ed65feac24615e76d6f16eadd4bd4a091dd27b5baa22c0a3da1c8e41a4e09010
3
+ metadata.gz: 9d91d66591b463b992c1e88502da6abe02779388b33c4e4ea3429084b1ccff40
4
+ data.tar.gz: 109c5ed2640867cc047f1a81f250e9fc4e1c5a5fb17fb15db81ed977de2e93c6
5
5
  SHA512:
6
- metadata.gz: 9fa50ceda137a5f5a8b2d2da4ff970715559956d0f76cf51f90e1ce820c67662d7b6df371701e7e71ec72103e6097e7a311e82a20b1fe50e98abfff6f6a760cc
7
- data.tar.gz: 52b42db5a295105cbc68383ddebd280ddffaed7828c9ba2b43bd59d8f6165f51eff82b83546fd86f50240011795b2c3cf1349439353993d2992aac0e918209b6
6
+ metadata.gz: 4c0c8fc68b428174bb365f4d1c74257f15ce4c8438f27ef7908fca1e283a4c5697df40bee686112b1de736fdfa61abe2790854acee48b1ffd86697db55c79bf6
7
+ data.tar.gz: 5ecf16bab610554f34f4f23b33719b82fb4fca65557217be1ed48bcf2d4a892115a48f0aec0e82174e01a64ee3e605fb9e095a672417638d35a2b7dc445671fc
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Lit Ipsum
2
+ [![Gem Version](https://badge.fury.io/rb/lit_ipsum.svg)](https://badge.fury.io/rb/lit_ipsum)
2
3
 
3
4
  This gem offers filler text from classical works of literature in place of standard "lorem ipsum" text. This can be useful for adding filler text for mockups and screenshots for new projects.
4
5
 
@@ -4,28 +4,14 @@ module LitIpsum
4
4
  class Austen
5
5
  class PrideAndPrejudice < Base
6
6
  FILENAME = 'texts/austen/pride-and-prejudice.txt'
7
- attr_reader :size
8
7
 
9
8
  class << self
10
- def sentences(count, max_sentence = 0)
11
- source = max_sentence.zero? ? get_text(FILENAME) : get_text(FILENAME).select { |sentence| sentence.length <= max_sentence }
12
- obj = []
13
- count.times do
14
- sentence = source.sample
15
- obj << sentence
16
- end
17
-
18
- obj.join(' ')
9
+ def sentences(count, max_sentence = 0, filename = FILENAME)
10
+ super(count, max_sentence, filename)
19
11
  end
20
12
 
21
- def words(count)
22
- source = get_text(FILENAME).select { |sentence| sentence.scan(/\w+/).size <= count }
23
- obj = []
24
- loop do
25
- obj << source.select { |sentence| sentence.scan(/\w+/).size <= count - obj.map { |el| el.scan(/\w+/) }.flatten.length }.sample
26
- break if obj.map { |el| el.scan(/\w+/) }.flatten.length == count
27
- end
28
- obj.join(' ')
13
+ def words(count, filename = FILENAME)
14
+ super(count, filename)
29
15
  end
30
16
  end
31
17
  end
@@ -4,28 +4,14 @@ module LitIpsum
4
4
  class Doyle
5
5
  class SherlockHolmes < Base
6
6
  FILENAME = 'texts/doyle/the-adventures-of-sherlock-holmes.txt'
7
- attr_reader :size
8
7
 
9
8
  class << self
10
- def sentences(count, max_sentence = 0)
11
- source = max_sentence.zero? ? get_text(FILENAME) : get_text(FILENAME).select { |sentence| sentence.length <= max_sentence }
12
- obj = []
13
- count.times do
14
- sentence = source.sample
15
- obj << sentence
16
- end
17
-
18
- obj.join(' ')
9
+ def sentences(count, max_sentence = 0, filename = FILENAME)
10
+ super(count, max_sentence, filename)
19
11
  end
20
12
 
21
- def words(count)
22
- source = get_text(FILENAME).select { |sentence| sentence.scan(/\w+/).size <= count }
23
- obj = []
24
- loop do
25
- obj << source.select { |sentence| sentence.scan(/\w+/).size <= count - obj.map { |el| el.scan(/\w+/) }.flatten.length }.sample
26
- break if obj.map { |el| el.scan(/\w+/) }.flatten.length == count
27
- end
28
- obj.join(' ')
13
+ def words(count, filename = FILENAME)
14
+ super(count, filename)
29
15
  end
30
16
  end
31
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LitIpsum
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
data/lib/lit_ipsum.rb CHANGED
@@ -6,9 +6,6 @@ module LitIpsum
6
6
  SENTENCE_PATTERN = /(?=“*)[A-Z]+.{1,}?[\.\!\?](?=”*\s*)(?<!Mr.|Mrs.|Ms.|Dr.|St.|S.A.)/.freeze
7
7
 
8
8
  class Error < StandardError; end
9
- def self.hello
10
- 'Hello, Friend.'
11
- end
12
9
 
13
10
  class Base
14
11
  class << self
@@ -22,6 +19,27 @@ module LitIpsum
22
19
  .uniq
23
20
  end
24
21
  end
22
+
23
+ def sentences(count, max_sentence, filename)
24
+ source = max_sentence.zero? ? get_text(filename) : get_text(filename).select { |sentence| sentence.length <= max_sentence }
25
+ obj = []
26
+ count.times do
27
+ sentence = source.sample
28
+ obj << sentence
29
+ end
30
+
31
+ obj.join(' ')
32
+ end
33
+
34
+ def words(count, filename)
35
+ source = get_text(filename).select { |sentence| sentence.scan(/\w+/).size <= count }
36
+ obj = []
37
+ loop do
38
+ obj << source.select { |sentence| sentence.scan(/\w+/).size <= count - obj.map { |el| el.scan(/\w+/) }.flatten.length }.sample
39
+ break if obj.map { |el| el.scan(/\w+/) }.flatten.length == count
40
+ end
41
+ obj.join(' ')
42
+ end
25
43
  end
26
44
  end
27
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lit_ipsum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jac Bergenson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-21 00:00:00.000000000 Z
11
+ date: 2019-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler