https://github.com/pazdera/word_wrap
A simple word-wrapping tool and a tiny single-purpose library written in Ruby.
https://github.com/pazdera/word_wrap
Last synced: about 12 hours ago
JSON representation
Repository metadata
A simple word-wrapping tool and a tiny single-purpose library written in Ruby.
- Host: GitHub
- URL: https://github.com/pazdera/word_wrap
- Owner: pazdera
- License: mit
- Created: 2014-01-23T22:29:03.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-04-22T10:02:49.000Z (almost 11 years ago)
- Last Synced: 2026-02-06T07:41:32.605Z (26 days ago)
- Language: Ruby
- Homepage:
- Size: 528 KB
- Stars: 20
- Watchers: 1
- Forks: 4
- Open Issues: 3
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
README.md
WordWrap
This gem is a extremely simple tool to word-wrap texts, which is the one and
only thing it can do. It comes with a script called ww that you can use
in the command line. And of course, you can get the functionality from within
Ruby as well.
For more information on usage, please refer to the Usage section of this
README bellow.
Installation
Add this line to your application's Gemfile:
gem 'word_wrap'
And then execute:
$ bundle
Or install it yourself as:
$ gem install word_wrap
Usage
You can use either the binary for the command line or the library directly
from your Ruby scripts. Both use cases are explained bellow.
Command Line
When in shell, you can use the ww tool (ww stands for word-wrap). It takes
only two arguments:
-w W, --width WIDTH- The width to which the text should be wrapped.
It is set to 80 by default.-f, --fit- In this case, the program will also rearrange lines, that are
shorter than 80 to fit them as much as possible to the
predefined width, in addition to wrapping the lines that exceed
it. This option is generally better for plain text. For code,
however, it will mess up your indentation.
Examples
The example file looks like this:
$ cat hip.txt
Forage Shoreditch disrupt Pitchfork meh.
Mustache 3 wolf moon gluten-free whatever master burn
vinyl.
$ ww -w 20 hip.txt
Forage Shoreditch
disrupt Pitchfork
meh.
Mustache 3 wolf moon
gluten-free whatever
master burn
vinyl.
But you can also use stdin:
$ cat hip | ww -w 20
Forage Shoreditch
disrupt Pitchfork
meh.
Mustache 3 wolf moon
gluten-free whatever
master burn
vinyl.
Note the difference at end of the second paragraph:
$ cat hip | ww -w 20 -f
Forage Shoreditch
disrupt Pitchfork
meh.
Mustache 3 wolf moon
gluten-free whatever
master burn vinyl.
Ruby library
If you would like to use the library in Ruby, you have two options:
- Use the
WordWrap#wwfunction directly - Use the
String#wrapandString#fitfunctions this module adds to the
standardStringclass.
Important: Since version 1.0.0 the extensions of the String class will be only available when explicitely loaded via
require 'word_wrap/core_ext'
Examples
irb(main):001:0> require 'word_wrap'
=> true
irb(main):003:0> WordWrap.ww "123 456 789", 5
=> "123\n456\n789\n"
irb(main):002:0> require 'word_wrap/core_ext'
=> true
irb(main):004:0> "123 456 789".wrap 5
=> "123\n456\n789\n"
irb(main):005:0> "123 456 789".fit 8
=> "123 456\n789\n"
Contributing
- Fork it ( http://github.com/pazdera/word_wrap/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Owner metadata
- Name: Radek Pazdera
- Login: pazdera
- Email:
- Kind: user
- Description:
- Website: http://radek.io
- Location: London
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/169328?u=cc6a9850d506dfc043576ad7bb54daab12c5ebba&v=4
- Repositories: 35
- Last ynced at: 2024-04-29T17:07:32.483Z
- Profile URL: https://github.com/pazdera
GitHub Events
Total
Last Year
Committers metadata
Last synced: about 22 hours ago
Total Commits: 31
Total Committers: 2
Avg Commits per committer: 15.5
Development Distribution Score (DDS): 0.032
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Radek Pazdera | r****k@p****k | 30 |
| Jikku Jose | j****e@q****m | 1 |
Committer domains:
- qucentis.com: 1
- pazdera.co.uk: 1
Issue and Pull Request metadata
Last synced: 7 days ago
Total issues: 7
Total pull requests: 2
Average time to close issues: about 1 month
Average time to close pull requests: 14 days
Total issue authors: 6
Total pull request authors: 2
Average comments per issue: 1.43
Average comments per pull request: 2.5
Merged pull request: 2
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- pazdera (2)
- binford2k (1)
- jikkujose (1)
- aspiers (1)
- cedoucette (1)
- wconrad (1)
Top Pull Request Authors
- jikkujose (1)
- pazdera (1)
Top Issue Labels
- bug (2)
- enhancement (1)
Top Pull Request Labels
Package metadata
- Total packages: 2
-
Total downloads:
- rubygems: 212,154,742 total
- Total docker downloads: 84,875,638
- Total dependent packages: 32 (may contain duplicates)
- Total dependent repositories: 20,350 (may contain duplicates)
- Total versions: 14
- Total maintainers: 1
gem.coop: word_wrap
As simple as it gets CLI tool for word-wrapping plain-text. You can also use the library in your Ruby scripts. Check out the sources for details.
- Homepage: https://github.com/pazdera/word_wrap
- Documentation: http://www.rubydoc.info/gems/word_wrap/
- Licenses: MIT
- Latest release: 1.0.0 (published almost 11 years ago)
- Last Synced: 2026-03-01T17:35:16.003Z (2 days ago)
- Versions: 7
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 106,080,930 Total
- Docker Downloads: 42,437,819
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.084%
- Downloads: 0.251%
- Maintainers (1)
rubygems.org: word_wrap
As simple as it gets CLI tool for word-wrapping plain-text. You can also use the library in your Ruby scripts. Check out the sources for details.
- Homepage: https://github.com/pazdera/word_wrap
- Documentation: http://www.rubydoc.info/gems/word_wrap/
- Licenses: MIT
- Latest release: 1.0.0 (published almost 11 years ago)
- Last Synced: 2026-03-01T10:00:26.786Z (3 days ago)
- Versions: 7
- Dependent Packages: 32
- Dependent Repositories: 20,350
- Downloads: 106,073,812 Total
- Docker Downloads: 42,437,819
-
Rankings:
- Dependent repos count: 0.252%
- Downloads: 0.338%
- Dependent packages count: 0.747%
- Docker downloads count: 0.774%
- Average: 4.509%
- Stargazers count: 11.578%
- Forks count: 13.364%
- Maintainers (1)
Dependencies
- bundler ~> 1.5 development
- rake ~> 0 development
- rspec ~> 0 development
Score: 23.338058249807105
