Git Product home page Git Product logo

word_wrap's Introduction

WordWrap

Gem Version

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#ww function directly
  • Use the String#wrap and String#fit functions this module adds to the standard String class.

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

  1. Fork it ( http://github.com/pazdera/word_wrap/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

word_wrap's People

Contributors

pazdera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

word_wrap's Issues

Feature request: make core extensions (monkey patches) optional

What would you say to making it possible to use word_wrap without it monkey patching String?

Background: I prefer to avoid, or at least minimize, gems that monkey patch core classes. It can get ugly in a hurry as the program grows and starts including other libraries that also monkey patch core classes.

I can think of a few ways to go, if you wanted to allow this. One would be to make the monkey-patch be omitted by:

require 'word_wrap'

and put into a piece you could require separately, if you wanted it:

require 'word_wrap/core_extensions'

This is a breaking API change. The other way, which is not a breaking API change, is to make the monkey patch be included, as it is now, by:

require 'word_wrap'

But omitted by, for example:

require 'word_wrap/core'

What do you think? Good idea? If so, how would you like it to work?

Updating to 0.2.1 fails

Updating this gem using RubyGems like this failes:

sudo gem update <gem>

Traceback

radek@mac:~/code/word_wrap$ sudo gem update word_wrap --backtrace
Updating installed gems
Updating word_wrap
ERROR:  While executing gem ... (NoMethodError)
    undefined method `satisfied_by?' for #<Gem::Version "0.2.1">
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/source_local.rb:60:in `block in find_gem'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/source_local.rb:56:in `each'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/source_local.rb:56:in `find_gem'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency_installer.rb:285:in `find_spec_by_name_and_version'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency_installer.rb:110:in `available_set_for'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency_installer.rb:322:in `install'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/commands/update_command.rb:97:in `update_gem'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/commands/update_command.rb:111:in `block in update_gems'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/commands/update_command.rb:110:in `each'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/commands/update_command.rb:110:in `update_gems'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/commands/update_command.rb:79:in `execute'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/command.rb:305:in `invoke_with_build_args'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/command_manager.rb:170:in `process_args'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/command_manager.rb:130:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/gem_runner.rb:60:in `run'
    /usr/bin/gem:21:in `<main>'

Workaround: uninstall the old version and install the new one.

Can't install word_wrap 1.0.0 on mac

I tried this:
sudo gem install -V --debug word_wrap

NOTE: Debugging mode prints all exceptions even when rescued
Exception LoadError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:171 - LoadError HEAD https://api.rubygems.org/api/v1/dependencies 200 OK GET https://api.rubygems.org/api/v1/dependencies?gems=word_wrap 200 OK Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org
Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.hegn.us Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.pubedu.hegn.us
Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.ad.hmco.com Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.rpcsys.hmco.com
Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.rvdp.riverdeep.net Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.riverdeep.net
Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.harcourtbrace.com Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.hmco.com
Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.harcourt.com Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.hmhpub.com
Exception Resolv::DNS::Config::NXDomain' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.hmhco.com Exception Resolv::ResolvError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/resolv.rb:494 - DNS result has no information for _rubygems._tcp.api.rubygems.org
Getting SRV record failed: DNS result has no information for _rubygems._tcp.api.rubygems.org
GET https://api.rubygems.org/quick/Marshal.4.8/word_wrap-1.0.0.gemspec.rz
200 OK
GET https://api.rubygems.org/quick/Marshal.4.8/word_wrap-1.0.0.gemspec.rz
200 OK
Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0 Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/specifications/word_wrap-1.0.0.gemspec
Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0 Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/.gitignore
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/.gitignore Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/.gitignore
Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0 /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/.gitignore Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #<Zlib::GzipReader:0x007ffe6a297410> Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/Gemfile
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/Gemfile Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/Gemfile
Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0 /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/Gemfile Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #<Zlib::GzipReader:0x007ffe6a297410> Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/LICENSE.txt
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/LICENSE.txt Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/LICENSE.txt
Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0 /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/LICENSE.txt Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #<Zlib::GzipReader:0x007ffe6a297410> Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/README.md
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/README.md Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/README.md
Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0 /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/README.md Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #<Zlib::GzipReader:0x007ffe6a297410> Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/Rakefile
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/Rakefile Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/Rakefile
Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0 /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/Rakefile Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #<Zlib::GzipReader:0x007ffe6a297410> Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/bin/ww
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/bin/ww Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/bin/ww
/usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/bin/ww
Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #Zlib::GzipReader:0x007ffe6a297410
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap.rb Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap.rb
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap.rb /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap.rb Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #<Zlib::GzipReader:0x007ffe6a297410> Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/core_ext.rb
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/core_ext.rb Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/core_ext.rb
/usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/core_ext.rb
Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #Zlib::GzipReader:0x007ffe6a297410
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/version.rb Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/version.rb
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/version.rb Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap
/usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/version.rb
Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #Zlib::GzipReader:0x007ffe6a297410
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/wrapper.rb Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/wrapper.rb
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/wrapper.rb Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap
/usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/lib/word_wrap/wrapper.rb
Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #Zlib::GzipReader:0x007ffe6a297410
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/spec/core_ext_spec.rb Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/spec/core_ext_spec.rb
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/spec/core_ext_spec.rb /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/spec/core_ext_spec.rb Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #<Zlib::GzipReader:0x007ffe6a297410> Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/spec/ww_spec.rb
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/spec/ww_spec.rb Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/spec/ww_spec.rb
Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/spec /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/spec/ww_spec.rb Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #<Zlib::GzipReader:0x007ffe6a297410> Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/word_wrap.gemspec
Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1331 - No such file or directory @ rb_file_s_lstat - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/word_wrap.gemspec Exception Errno::ENOENT' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:1451 - No such file or directory @ unlink_internal - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/word_wrap.gemspec
Exception Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0 /usr/local/lib/ruby/gems/2.3.0/gems/word_wrap-1.0.0/word_wrap.gemspec Exception NoMethodError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/package/tar_reader.rb:72 - undefined method seek' for #<Zlib::GzipReader:0x007ffe6a297410> Exception TypeError' at /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/installer.rb:227 - no implicit conversion of nil into String
ERROR: While executing gem ... (TypeError)
no implicit conversion of nil into String
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/installer.rb:227:in check_executable_overwrite' /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/installer.rb:468:in block in generate_bin'
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/installer.rb:455:in each' /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/installer.rb:455:in generate_bin'
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/installer.rb:295:in install' /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/request_set.rb:167:in block in install'
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/request_set.rb:151:in each' /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/request_set.rb:151:in install'
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/commands/install_command.rb:250:in install_gem' /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/commands/install_command.rb:300:in block in install_gems'
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/commands/install_command.rb:296:in each' /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/commands/install_command.rb:296:in install_gems'
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/commands/install_command.rb:203:in execute' /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/command.rb:308:in invoke_with_build_args'
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/command_manager.rb:169:in process_args' /usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/command_manager.rb:139:in run'
/usr/local/Cellar/ruby/2.3.0/lib/ruby/2.3.0/rubygems/gem_runner.rb:55:in run' /usr/local/bin/gem:21:in

'

DEFAULT_WIDTH undefined

When monkey patching string, the DEFAULT_WIDTH constant isn't set.

https://github.com/pazdera/word_wrap/blob/master/lib/word_wrap.rb#L17

2.0.0-p598 :001 > require 'word_wrap'
 => true
2.0.0-p598 :002 > 'foo bar'.wrap
NameError: uninitialized constant String::DEFAULT_WIDTH
    from /Users/ben/.rvm/gems/ruby-2.0.0-p598@mdl/gems/word_wrap-0.2.1/lib/word_wrap.rb:17:in `wrap'
    from (irb):2
    from /Users/ben/.rvm/rubies/ruby-2.0.0-p598/bin/irb:12:in `<main>'

fails to extend String class

Same issue on Ruby 2.4.1 and 2.2.1. Looks like some module namespacing issue.

$ bundle exec irb
2.4.1 :001 > require 'word_wrap/core_ext'
 => true
2.4.1 :002 > "laksjdf laksdflkasdf".wrap
NameError: uninitialized constant String::WordWrap
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/word_wrap-1.0.0/lib/word_wrap/core_ext.rb:11:in `wrap'
        from (irb):2
        from /home/adam/.rvm/rubies/ruby-2.4.1/bin/irb:11:in `<top (required)>'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `load'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `kernel_load'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:28:in `run'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli.rb:424:in `exec'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli.rb:27:in `dispatch'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/cli.rb:18:in `start'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/exe/bundle:30:in `block in <top (required)>'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:122:in `with_friendly_errors'
        from /home/adam/.rvm/gems/ruby-2.4.1/gems/bundler-1.16.1/exe/bundle:22:in `<top (required)>'
        from /home/adam/.rvm/gems/ruby-2.4.1/bin/bundle:23:in `load'
        from /home/adam/.rvm/gems/ruby-2.4.1/bin/bundle:23:in `<main>'
        from /home/adam/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
        from /home/adam/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.