fillertext 0.2.0 → 0.3.5

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: 1854927a266ff9936d37c2f1e90a0d14f1a044c283657ace868b85184cb063a2
4
- data.tar.gz: 48e171c6f3516c02a603f42469ee8de3163814aa514078010b5ac2fb023975f0
3
+ metadata.gz: 1e2a17035c765225113cd70e39955295f581f7fc70927f6dba1d16f39a1c2b45
4
+ data.tar.gz: 8c82337dc95152006fa2f2b3729ad98cf50f78a5e0a5ade2d9c30a56e7ad591b
5
5
  SHA512:
6
- metadata.gz: 7771d06da89be76deb07919cb786a1cb5414d7d24e0c203ed40c9c092723edf5da904cc389051cb1ba07ac63f33b89928bb3ed142ae70e30ef411031dbc7f394
7
- data.tar.gz: fe5d627fa044ad8009937d24898560d9d0ab6a103503f745f93ff10faa7f4323b8d8624417e08ede0a2c41b3575139ee3da240ae8d888c706a3a5ec885cd0b77
6
+ metadata.gz: 2f576cd27a968bdd9e02488dabf6a017f8fa3af467fc1af5c21e74457e14a509e18864484a5a9a829dbfd489743a4fcf50d55d36d01e98bd3b1dc1ecd720eb22
7
+ data.tar.gz: c0604d8a1ee5f7bce4a9b96736e9a34651a2d98c278f98546cf31c0ffc8e4f31126fec752a3c4a9dfc194e36fce92ba7133711e9f049bc9c859bb3ea2389d6b3
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,183 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.6
7
+ NewCops: enable
8
+
9
+ Style/StringLiterals:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Style/StringLiteralsInInterpolation:
14
+ Enabled: true
15
+ EnforcedStyle: double_quotes
16
+
17
+ Layout/LineLength:
18
+ Max: 120
19
+ Exclude:
20
+ - 'lib/fillertext/styles/*.rb'
21
+
22
+ Gemspec/DeprecatedAttributeAssignment:
23
+ Enabled: true
24
+
25
+ Gemspec/RequireMFA:
26
+ Enabled: true
27
+
28
+ Layout/LineEndStringConcatenationIndentation:
29
+ Enabled: true
30
+
31
+ Layout/SpaceBeforeBrackets:
32
+ Enabled: true
33
+
34
+ Lint/AmbiguousAssignment:
35
+ Enabled: true
36
+
37
+ Lint/AmbiguousOperatorPrecedence:
38
+ Enabled: true
39
+
40
+ Lint/AmbiguousRange:
41
+ Enabled: true
42
+
43
+ Lint/DeprecatedConstants:
44
+ Enabled: true
45
+
46
+ Lint/DuplicateBranch:
47
+ Enabled: true
48
+
49
+ Lint/DuplicateRegexpCharacterClassElement:
50
+ Enabled: true
51
+
52
+ Lint/EmptyBlock:
53
+ Enabled: true
54
+
55
+ Lint/EmptyClass:
56
+ Enabled: true
57
+
58
+ Lint/EmptyInPattern:
59
+ Enabled: true
60
+
61
+ Lint/IncompatibleIoSelectWithFiberScheduler:
62
+ Enabled: true
63
+
64
+ Lint/LambdaWithoutLiteralBlock:
65
+ Enabled: true
66
+
67
+ Lint/NoReturnInBeginEndBlocks:
68
+ Enabled: true
69
+
70
+ Lint/NumberedParameterAssignment:
71
+ Enabled: true
72
+
73
+ Lint/OrAssignmentToConstant:
74
+ Enabled: true
75
+
76
+ Lint/RedundantDirGlobSort:
77
+ Enabled: true
78
+
79
+ Lint/RequireRelativeSelfPath:
80
+ Enabled: true
81
+
82
+ Lint/SymbolConversion:
83
+ Enabled: true
84
+
85
+ Lint/ToEnumArguments:
86
+ Enabled: true
87
+
88
+ Lint/TripleQuotes:
89
+ Enabled: true
90
+
91
+ Lint/UnexpectedBlockArity:
92
+ Enabled: true
93
+
94
+ Lint/UnmodifiedReduceAccumulator:
95
+ Enabled: true
96
+
97
+ Lint/UselessRuby2Keywords:
98
+ Enabled: true
99
+
100
+ Naming/BlockForwarding:
101
+ Enabled: true
102
+
103
+ Security/IoMethods:
104
+ Enabled: true
105
+
106
+ Style/ArgumentsForwarding:
107
+ Enabled: true
108
+
109
+ Style/CollectionCompact:
110
+ Enabled: true
111
+
112
+ Style/DocumentDynamicEvalDefinition:
113
+ Enabled: true
114
+
115
+ Style/EndlessMethod:
116
+ Enabled: true
117
+
118
+ Style/FileRead:
119
+ Enabled: true
120
+
121
+ Style/FileWrite:
122
+ Enabled: true
123
+
124
+ Style/HashConversion:
125
+ Enabled: true
126
+
127
+ Style/HashExcept:
128
+ Enabled: true
129
+
130
+ Style/IfWithBooleanLiteralBranches:
131
+ Enabled: true
132
+
133
+ Style/InPatternThen:
134
+ Enabled: true
135
+
136
+ Style/MapToHash:
137
+ Enabled: true
138
+
139
+ Style/MultilineInPatternThen:
140
+ Enabled: true
141
+
142
+ Style/NegatedIfElseCondition:
143
+ Enabled: true
144
+
145
+ Style/NilLambda:
146
+ Enabled: true
147
+
148
+ Style/NumberedParameters:
149
+ Enabled: true
150
+
151
+ Style/NumberedParametersLimit:
152
+ Enabled: true
153
+
154
+ Style/OpenStructUse:
155
+ Enabled: true
156
+
157
+ Style/QuotedSymbols:
158
+ Enabled: true
159
+
160
+ Style/RedundantArgument:
161
+ Enabled: true
162
+
163
+ Style/RedundantSelfAssignmentBranch:
164
+ Enabled: true
165
+
166
+ Style/SelectByRegexp:
167
+ Enabled: true
168
+
169
+ Style/StringChars:
170
+ Enabled: true
171
+
172
+ Style/SwapValues:
173
+ Enabled: true
174
+
175
+ Metrics/MethodLength:
176
+ Enabled: true
177
+ Exclude:
178
+ - 'lib/fillertext/styles/*.rb'
179
+
180
+ Metrics/BlockLength:
181
+ Enabled: true
182
+ Exclude:
183
+ - 'spec/*_spec.rb'
data/CHANGELOG.md ADDED
@@ -0,0 +1,77 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.3.5](https://github.com/colindean/fillertext/compare/v0.3.4...v0.3.5) (2022-10-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Update README.md, add instructions for: ([61e8e6f](https://github.com/colindean/fillertext/commit/61e8e6fa26f410badac701cdd3b064f29b0f222a))
14
+
15
+ ### [0.3.4](https://github.com/colindean/fillertext/compare/v0.3.3...v0.3.4) (2022-02-07)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * Fixes URL to Ashvith's profile ([256f4d3](https://github.com/colindean/fillertext/commit/256f4d353f19a9cec08d9a6ac76e95d8129933c2))
21
+
22
+ ### [0.3.3](https://github.com/colindean/fillertext/compare/v0.3.2...v0.3.3) (2022-02-07)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * Get all git tags during release process ([fc54124](https://github.com/colindean/fillertext/commit/fc54124f77e218a5ae4f383f4f101e5d1404bcdc))
28
+ * Satisfies Rubocop checks ([531ad51](https://github.com/colindean/fillertext/commit/531ad5191f40a23b28006db41cd66eda499c35c8))
29
+
30
+ ### [0.3.2](https://github.com/colindean/fillertext/compare/v0.3.1...v0.3.2) (2022-02-07)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * Set git user/email in release workflow ([806b49a](https://github.com/colindean/fillertext/commit/806b49a46256688c7101cc621d188236deb9fc33))
36
+
37
+ ### [0.3.1](https://github.com/colindean/fillertext/compare/v0.3.0...v0.3.1) (2022-02-07)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * Source gemspec version from version.rb ([fc791c5](https://github.com/colindean/fillertext/commit/fc791c5009ff4dc4ceb2f640687aff1bcfcb7007))
43
+
44
+ ## [0.3.0](https://github.com/colindean/fillertext/compare/v0.2.1...v0.3.0) (2022-02-07)
45
+
46
+
47
+ ### Features
48
+
49
+ * Adds release instructions and tests an automated release ([2dd6c80](https://github.com/colindean/fillertext/commit/2dd6c80d83eac2b7c05e431a505fbb4a4b5da175))
50
+
51
+
52
+ ## [0.2.1](https://www.github.com/colindean/fillertext/compare/v0.2.0...v0.2.1) (2021-10-27)
53
+
54
+ ### Added
55
+
56
+ * `MikeLange` style, comprised of phrases from the [famous Pittsburgh Penguins hockey announcer](https://en.wikipedia.org/wiki/Mike_Lange) in honor of his retirement
57
+ * Development: Adds `rake irb` to drop to a console for interaction (@m3xq)
58
+ * Development: CI is now testing on the latest JRuby and TruffleRuby as well as Ruby 3.0
59
+
60
+ ### Changed
61
+
62
+ * Updated CI links and badges in README
63
+ * Development: Now using GitHub Actions for CI instead of Travis
64
+ * Development: Prepare for Minitest 6 by updating test syntax and pinning Minitest 5+.
65
+
66
+ ### Fixed
67
+
68
+ * Gemfile & Gemfile.lock to reduce vulnerabilities ([4f2c55b](https://www.github.com/colindean/fillertext/commit/4f2c55b29868d8e9ea174e53508d17167a36c3d7))
69
+
70
+ ### Deprecated
71
+
72
+ * Ruby 2.5 support. Future releases will cease testing against Ruby 2.5 as it is end-of-life as of March 2021.
73
+ * Ruby 2.6 support. The first release after March 2022 will cease testing against Ruby 2.6 as it is end-of-life as of March 2022.
74
+
75
+ ### Removed
76
+
77
+ * `Gemfile.lock` dropped from versioning to follow gem development [best practices](https://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/).
data/CITATION.cff ADDED
@@ -0,0 +1,13 @@
1
+ cff-version: 1.2.0
2
+ message: >
3
+ If you use this software in research or other work
4
+ wherein you are citing references and tools,
5
+ please consider citing fillertext as indicated below.
6
+ authors:
7
+ - family-names: "Dean"
8
+ given-names: "Colin"
9
+ orcid: "https://orcid.org/0000-0002-3374-6891"
10
+ title: "fillertext"
11
+ version: 0.2.2
12
+ date-released: 2022-01-26
13
+ url: "https://github.com/colindean/fillertext"
data/Gemfile CHANGED
@@ -1,13 +1,16 @@
1
- source "http://rubygems.org"
2
-
3
- group :test do
4
- gem 'rake'
5
- gem 'minitest'
6
- end
7
-
8
- group :development do
9
- gem "rdoc"
10
- gem "jeweler"
11
- gem "simplecov"
12
- gem "turn"
13
- end
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in fillertext.gemspec
6
+ gemspec
7
+
8
+ gem "rake"
9
+
10
+ gem "rspec"
11
+
12
+ gem "rubocop"
13
+
14
+ gem "rubocop-rake"
15
+
16
+ gem "rubocop-rspec"
data/LICENSE.txt CHANGED
@@ -1,20 +1,21 @@
1
- Copyright (c) 2012 Colin Dean
1
+ FillerText is licensed under the MIT license.
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Copyright (C) 2011-2022 by Colin Dean
10
4
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
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:
13
11
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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,117 @@
1
+ FillerText
2
+ ==========
3
+
4
+ by @colindean
5
+
6
+ [![Testing Build Status](https://github.com/colindean/fillertext/actions/workflows/testing.yml/badge.svg)](https://github.com/colindean/fillertext/actions/workflows/testing.yml)
7
+ [![Release Build Status](https://github.com/colindean/fillertext/actions/workflows/release.yml/badge.svg)](https://github.com/colindean/fillertext/actions/workflows/release.yml)
8
+ [![Gem Version](https://badge.fury.io/rb/fillertext.svg)](https://badge.fury.io/rb/fillertext)
9
+
10
+ Introduction
11
+ ------------
12
+
13
+ FillerText is a gem useful for generating, well, filler text. It can do the standard "lorem ipsum" text or a variety of other clever substitute texts.
14
+
15
+ Installing FillerText
16
+ ---------------------
17
+
18
+ Install using:
19
+
20
+ ```sh
21
+ gem install fillertext
22
+ ```
23
+
24
+ or add the gem to your project's `Gemfile`:
25
+
26
+ ```ruby
27
+ gem 'fillertext'
28
+ ```
29
+
30
+ Using FillerText
31
+ ----------------
32
+
33
+ Here's how you use FillerText.
34
+
35
+ There are two main ways. One is cleaner because it keeps FillerText within its
36
+ own namespace. The other method will add `Fixnum#filler` to keep some tasty
37
+ syntactical sugar.
38
+
39
+ ```ruby
40
+ FillerText::FillerText.sentences 5
41
+ FillerText::FillerText.words 2
42
+ FillerText::FillerText.characters 5
43
+ FillerText::FillerText.bytes 4
44
+ FillerText::FillerText.paragraphs 1
45
+ ```
46
+
47
+ or the *much* easier and intended method:
48
+
49
+ ```ruby
50
+ 2.filler.sentences
51
+ 1.filler.paragraphs
52
+ ```
53
+
54
+ You can also change the style from the default "lorem ipsum" to something else.
55
+
56
+ ```ruby
57
+ # the old favorite
58
+ FillerText::FillerText.style = FillerText::Style::LoremIpsum
59
+ # a mash of words
60
+ FillerText::FillerText.style = FillerText::Style::HipsterIpsum
61
+ # handmade just like grandma's pierogies
62
+ FillerText::FillerText.style = FillerText::Style::YinzerIpsum
63
+ # homage to the great Pittsburgh Penguins announcer
64
+ FillerTest::FillerText.style = FillerText::Style::MikeLange
65
+ ```
66
+
67
+ Contributing to FillerText
68
+ --------------------------
69
+ ### Setting up the project
70
+ 1. [Create a fork](https://github.com/colindean/fillertext/fork) of the GitHub project repo.
71
+ 2. `git clone` the forked repository to your local system.
72
+ 3. Make sure that the version of Ruby you're using meets the [minimum requirement in the gemspec](https://github.com/colindean/fillertext/blob/master/fillertext.gemspec#L15).
73
+ 4. Run `bundle install` to install dependencies. It should tell you at this point if you don't have an adequate Ruby version installed.
74
+ 5. Check basic sanity by running `bundle exec rake` to run tests and checks _before_ you make any changes.
75
+ 6. Make your changes and commit them to a feature branch. If you're picking a particular GitHub issue, please put `gh-##-topic` in the branch where `##` is the ticket number and `topic` is a few words about it.
76
+ 7. Push to your own repo and then submit a pull request to this one!
77
+
78
+ ### Testing the project
79
+ FillerText uses [RSpec](https://github.com/rspec/rspec-core) for unit testing and [SimpleCov](https://github.com/simplecov-ruby/simplecov) for code coverage. New specifications can be added inside the `spec/` directory.
80
+
81
+ 1. Make sure that the project is set up properly (see [Setting up the project](#setting-up-the-project))
82
+ 2.
83
+ 1. Run `rspec` to run all the tests by default
84
+ 2. To run only a selected few tests, run `rspec spec/<test_you're_interested_in>_spec.rb`
85
+ 3. To access code coverage details, run `xdg-open coverage/index.html` (on Linux) or `open coverage/index.html` (on Mac)
86
+
87
+ Patches welcome. Please file using Github issues.
88
+
89
+ I sincerely thank [Ashvith Shetty](https://github.com/Ashvith) for modernizing the build system
90
+ for this software in 2022. Things are a lot easier to handle now than they were
91
+ in 2011!
92
+
93
+
94
+ ### Releases
95
+
96
+ As of 0.2.3, FillerText uses
97
+ [release-please](https://github.com/googleapis/release-please) along with
98
+ [release-please-action](https://github.com/google-github-actions/release-please-action)
99
+ for release automation in GitHub Actions.
100
+
101
+ Following [Conventional Commits v1.0
102
+ standard](https://www.conventionalcommits.org/en/v1.0.0/),
103
+ prefix a commit with `fix:` to increment the patch version in a future release,
104
+ prefix with `feat:` to increment the minor version, and
105
+ prefix with `feat!:` or `fix!:` or `refactor!:` to mark a breaking change and
106
+ a major version increment.
107
+
108
+ For more information, read the [release-please-action
109
+ documentation](https://github.com/google-github-actions/release-please-action#how-release-please-works)
110
+ on releasing.
111
+
112
+ License
113
+ -------
114
+
115
+ FillerText is licensed under the MIT license.
116
+ Copyright (C) 2011-2022 by Colin Dean.
117
+ See [LICENSE.txt](LICENSE.txt) for more.
data/Rakefile CHANGED
@@ -1,51 +1,12 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
- require 'rake/testtask'
12
- require 'jeweler'
13
- require 'simplecov'
14
- require 'rdoc/task'
1
+ # frozen_string_literal: true
15
2
 
16
- Jeweler::Tasks.new do |gem|
17
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
- gem.name = "fillertext"
19
- gem.homepage = "http://github.com/colindean/fillertext"
20
- gem.license = "MIT"
21
- gem.summary = %Q{Generates filler/placeholder text in a Rubyistic way}
22
- gem.description = %Q{Generates filler text through a direct interface or by monkeypatching Fixnum}
23
- gem.email = "git+gems@cad.cx"
24
- gem.authors = ["Colin Dean"]
25
- # dependencies defined in Gemfile
26
- end
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
27
5
 
28
- Jeweler::RubygemsDotOrgTasks.new
6
+ RSpec::Core::RakeTask.new(:spec)
29
7
 
30
- Rake::TestTask.new(:spec) do |t|
31
- t.libs.push 'lib'
32
- t.test_files = FileList['spec/*_spec.rb']
33
- t.verbose = true
34
- end
8
+ require "rubocop/rake_task"
35
9
 
36
- desc "Run :spec with code coverage"
37
- task :coverage do
38
- `rake spec COVERAGE=true`
39
- `open coverage/index.html`
40
- end
10
+ RuboCop::RakeTask.new
41
11
 
42
- Rake::RDocTask.new do |rdoc|
43
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
-
45
- rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "fillertext #{version}"
47
- rdoc.rdoc_files.include('README*')
48
- rdoc.rdoc_files.include('lib/**/*.rb')
49
- end
50
-
51
- task :default => :spec
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "fillertext"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,71 +1,36 @@
1
- module FillerText
2
- #this has to be here because of file require order issues
3
- #todo: fix this
4
- module Style; class LoremIpsum; end; end
1
+ # frozen_string_literal: true
5
2
 
6
- def self.paragraphs(n=nil)
7
- FillerText.paragraphs n
8
- end
9
- def self.words(n=nil)
10
- FillerText.words n
11
- end
12
- def self.bytes(n=nil)
13
- FillerText.bytes n
3
+ Dir[File.join(__dir__, "styles/*.rb")].sort.each { |file| require_relative file }
4
+
5
+ # Helper module to choose styles
6
+ module FillerText
7
+ class << self
8
+ attr_accessor :style, :num
14
9
  end
15
- def self.characters(n=nil)
16
- FillerText.characters n
10
+
11
+ @style = FillerText::Style::LoremIpsum
12
+
13
+ def self.bytes(num = nil)
14
+ num ||= self.num
15
+ style.text[0, num]
17
16
  end
18
- def self.sentences(n=nil)
19
- FillerText.sentences n
17
+
18
+ def self.characters(num = nil)
19
+ bytes(num)
20
20
  end
21
-
22
- class FillerText
23
21
 
24
- @@style = Style::LoremIpsum
25
-
26
- def self.style=(style)
27
- @@style = style
28
- end
22
+ def self.words(num = nil)
23
+ num ||= self.num
24
+ style.text.split[0, num].join(" ").gsub(/[^\w\s]/, "")
25
+ end
29
26
 
30
- def self.style
31
- @@style
32
- end
27
+ def self.sentences(num = nil)
28
+ num ||= self.num
29
+ style.text.split(".").slice(0, num).join(". ")
30
+ end
33
31
 
34
- @@num = 0
35
-
36
- def self.n=(n)
37
- @@num = n
38
- end
39
-
40
- def self.n
41
- @@num
42
- end
43
-
44
- def self.bytes(n=nil)
45
- n ||= self.n
46
- self.style.text[0,n]
47
- end
48
-
49
- def self.characters(n=nil)
50
- #same thing for now
51
- self.bytes(n)
52
- end
53
-
54
- def self.words(n=nil)
55
- n ||= self.n
56
- #the idea here is to find the nth space and return everything before it
57
- self.style.text.split[0,n].join(" ").gsub(/[^\w\s]/,'')
58
- end
59
-
60
- def self.sentences(n=nil)
61
- n ||= self.n
62
- self.style.text.split('.').slice(0,n).join(". ")
63
- end
64
-
65
- def self.paragraphs(n=nil)
66
- n ||= self.n
67
- self.style.text.split("\n").slice(0,n).join("\n")
68
- end
69
-
32
+ def self.paragraphs(num = nil)
33
+ num ||= self.num
34
+ style.text.split("\n").slice(0, num).join("\n")
70
35
  end
71
36
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FillerText
4
+ # Modification for Integer class
5
+ module Integer
6
+ def filler
7
+ FillerText.num = self
8
+ FillerText
9
+ end
10
+ end
11
+ end
12
+
13
+ class Integer
14
+ include FillerText::Integer
15
+ end