lit_ipsum 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +0 -0
- data/License.txt +21 -0
- data/README.md +50 -0
- data/lib/lit_ipsum/austen/pride_and_prejudice.rb +33 -0
- data/lib/lit_ipsum/doyle/sherlock_holmes.rb +33 -0
- data/lib/lit_ipsum/version.rb +5 -0
- data/lib/lit_ipsum.rb +30 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 01a21c2acd77a0c3e3b0b2a7c1607bc2fc8494dda9eb01eb124f27ea193bf1e7
|
4
|
+
data.tar.gz: ed65feac24615e76d6f16eadd4bd4a091dd27b5baa22c0a3da1c8e41a4e09010
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9fa50ceda137a5f5a8b2d2da4ff970715559956d0f76cf51f90e1ce820c67662d7b6df371701e7e71ec72103e6097e7a311e82a20b1fe50e98abfff6f6a760cc
|
7
|
+
data.tar.gz: 52b42db5a295105cbc68383ddebd280ddffaed7828c9ba2b43bd59d8f6165f51eff82b83546fd86f50240011795b2c3cf1349439353993d2992aac0e918209b6
|
data/CHANGELOG.md
ADDED
File without changes
|
data/License.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Jac Bergenson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Lit Ipsum
|
2
|
+
|
3
|
+
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
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem locally with the following command:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem install lit_ipsum
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'lit_ipsum', :git=> 'https://github.com/bergbergs/lit_ipsum.git', :branch => 'master'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then require the gem whereever you plan to use it.
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'lit_ipsum'
|
25
|
+
|
26
|
+
LitIpsum::Austen::PrideAndPrejudice.sentences(3) #=> "Other schemes, too, came into her head. As often as I can. I cannot think so very ill of Wickham."
|
27
|
+
LitIpsum::Austen::PrideAndPrejudice.words(7) #=> "Indeed, Jane, you ought to believe me."
|
28
|
+
|
29
|
+
LitIpsum::Doyle::SherlockHolmes.sentences(2) #=> "And how in the world did you find them? It is half-past ten now."
|
30
|
+
LitIpsum::Doyle::SherlockHolmes.words(5) #=> "Yes, it did. Get out!"
|
31
|
+
```
|
32
|
+
|
33
|
+
|
34
|
+
## Development
|
35
|
+
|
36
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
37
|
+
|
38
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bergbergs/lit_ipsum. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
47
|
+
|
48
|
+
## Code of Conduct
|
49
|
+
|
50
|
+
Everyone interacting in the LitIpsum project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bergbergs/lit_ipsum/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LitIpsum
|
4
|
+
class Austen
|
5
|
+
class PrideAndPrejudice < Base
|
6
|
+
FILENAME = 'texts/austen/pride-and-prejudice.txt'
|
7
|
+
attr_reader :size
|
8
|
+
|
9
|
+
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(' ')
|
19
|
+
end
|
20
|
+
|
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(' ')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LitIpsum
|
4
|
+
class Doyle
|
5
|
+
class SherlockHolmes < Base
|
6
|
+
FILENAME = 'texts/doyle/the-adventures-of-sherlock-holmes.txt'
|
7
|
+
attr_reader :size
|
8
|
+
|
9
|
+
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(' ')
|
19
|
+
end
|
20
|
+
|
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(' ')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/lit_ipsum.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lit_ipsum/version'
|
4
|
+
|
5
|
+
module LitIpsum
|
6
|
+
SENTENCE_PATTERN = /(?=“*)[A-Z]+.{1,}?[\.\!\?](?=”*\s*)(?<!Mr.|Mrs.|Ms.|Dr.|St.|S.A.)/.freeze
|
7
|
+
|
8
|
+
class Error < StandardError; end
|
9
|
+
def self.hello
|
10
|
+
'Hello, Friend.'
|
11
|
+
end
|
12
|
+
|
13
|
+
class Base
|
14
|
+
class << self
|
15
|
+
def get_text(filename)
|
16
|
+
File.open(filename, 'r') do |file|
|
17
|
+
return file.map(&:chomp)
|
18
|
+
.reject { |line| line.empty? || line.start_with?('#') }
|
19
|
+
.map { |line| line.delete('_') }
|
20
|
+
.join(' ')
|
21
|
+
.scan(SENTENCE_PATTERN)
|
22
|
+
.uniq
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# require objects
|
30
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'lit_ipsum', '/**/*.rb')).sort.each { |file| require file }
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lit_ipsum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jac Bergenson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- jonathan.bergenson@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- CHANGELOG.md
|
63
|
+
- License.txt
|
64
|
+
- README.md
|
65
|
+
- lib/lit_ipsum.rb
|
66
|
+
- lib/lit_ipsum/austen/pride_and_prejudice.rb
|
67
|
+
- lib/lit_ipsum/doyle/sherlock_holmes.rb
|
68
|
+
- lib/lit_ipsum/version.rb
|
69
|
+
homepage: https://github.com/bergbergs/lit_ipsum
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata:
|
73
|
+
homepage_uri: https://github.com/bergbergs/lit_ipsum
|
74
|
+
source_code_uri: https://github.com/bergbergs/lit_ipsum
|
75
|
+
changelog_uri: https://github.com/bergbergs/lit_ipsum/blob/master/CHANGELOG.md
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubygems_version: 3.0.6
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Lorem ipsum text, but with classical literature.
|
95
|
+
test_files: []
|