wrapify 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46882c990c833be9eec428161e711869de91d2c2ee45204b2022d89f8e11b4fd
4
- data.tar.gz: 9da50c7299fa35eaaa3448955ba16ff8661dc74d5c7feaa90f564bc0231bc711
3
+ metadata.gz: cc4d00eec7c721d08079dfd04d01775ac8ed1795ea64e82d476da366ba6b397e
4
+ data.tar.gz: 8e470a50652486291b6f3bdbb21faccb81c7b125dfc6664f1ae4ba6992826473
5
5
  SHA512:
6
- metadata.gz: 7db8232a984beeb94e5de8e45aa1ec89164582972eba6df4a09a973880bd2097a1491229b6bd250182400e1eddead7f280ff6ad383cebc9314e81ae856952f02
7
- data.tar.gz: cd2cced512cbca5c49bb48c0267b3d1d209750aad61a2e5518e7afbc74d50ad3d3089b95f06cc0e4a23e5759d89c8e8a77cdafa09b2d6efcff1b70431a848c5f
6
+ metadata.gz: 7a7cd4d5fecba7fcfce741727634369ba2320ce0c44fbccfc092fc8a45d20e59a86b70203fae9a16471959b40a0da6289f7252ebf0518f587050417b65f8783e
7
+ data.tar.gz: 6f786dbf119c90378022c07afcf94d91da0602ee73b4ae68959f05ace1e61c2e88063a344abb205f64cd806d5f03a55955b448cce54a34f8f89d6d2dcfa2edcb
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.4
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in wrapify.gemspec
6
+ gemspec
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wrapify (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (10.4.2)
11
+ rspec (3.7.0)
12
+ rspec-core (~> 3.7.0)
13
+ rspec-expectations (~> 3.7.0)
14
+ rspec-mocks (~> 3.7.0)
15
+ rspec-core (3.7.1)
16
+ rspec-support (~> 3.7.0)
17
+ rspec-expectations (3.7.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.7.0)
20
+ rspec-mocks (3.7.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.7.0)
23
+ rspec-support (3.7.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.16)
30
+ rake (~> 10.0)
31
+ rspec (~> 3.7, >= 3.7.0)
32
+ wrapify!
33
+
34
+ BUNDLED WITH
35
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Frank Germano
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.
@@ -0,0 +1,47 @@
1
+ # Wrapify
2
+
3
+ Wrapify is a gem that extends the string class to add a method wrapify(wraplimit).
4
+ This gem supports wrapping text to a specified boundary, e.g. 20. The string can include multiple newlines.
5
+
6
+ Algorithm: Convert all runs of white space (spaces, tabs, new lines, carriage returns) to single spaces.
7
+ Define the runs of characters between the spaces as "words". Add words to a line until they no longer
8
+ fit (hitting the word wrap limit). Once a line is complete, add it to the final result, with a closing new line. Continue adding lines to the result until there is no more to process. The result can be a multiline string.
9
+
10
+ If a word is longer than the wraplimit, it is added to its own "long" line; this line will extend past the wordwrap limit. This is by design. One could add an option to the method to force wrap the line to avoid lines. This alternative has not been implemented.
11
+
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'wrapify'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install wrapify
28
+
29
+ ## Usage
30
+
31
+ For a given string, mystring, invoke the string method, wrap_to_string, with a wraplimit.
32
+
33
+ mystring.wrap_to_string(20)
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ 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).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fgermanojr/wrapify.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). More generally, do whatever you want with it.
@@ -0,0 +1,10 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
6
+ t.rspec_opts = '--format documentation'
7
+ # t.rspec_opts << ' more options'
8
+ # t.rcov = true # ADD GEM LATER
9
+ end
10
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "wrapify"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -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
@@ -0,0 +1,73 @@
1
+ require "wrapify/version"
2
+
3
+ class String
4
+
5
+ # Wrap string to given wraplimit.
6
+ #
7
+ # @param decimal wraplimit
8
+ # @return [String]
9
+ #
10
+ # @example
11
+
12
+ # doc1 = <<-DOC1HERE
13
+ # line 1 contains a lot of stuff
14
+ # line 2 contains even more, which we will wrap to a fixed short
15
+ # line 3 boundry if we are lucky. Who knows what will really happen.
16
+ # line 4
17
+ # DOC1HERE
18
+
19
+ # doc1.wrap_to_limit(20) === doc1_wrapped
20
+
21
+ # doc1_ wrapped = <<-RESULT
22
+ # line 1 contains a
23
+ # lot of stuff line
24
+ # 2 contains even
25
+ # more, which we
26
+ # will wrap to a
27
+ # fixed short line 3
28
+ # boundry if we are
29
+ # lucky. Who knows
30
+ # what will really
31
+ # happen. line 4
32
+ # RESULT
33
+
34
+ def wrap_to_limit(wrap_limit)
35
+ str = self.gsub(/\s+/, ' ') # convert runs of white space to single space
36
+ String.wrap_process(str, wrap_limit)
37
+ end
38
+
39
+ private
40
+
41
+ def self.wrap_process(str, wrap_limit)
42
+ # Wrap units into line not to exceed wrap_limit of line
43
+ # In case where next_up is longer than wrap we include with overlength.
44
+ # Could add option, :force, 'xxxyy\n'.wrap_to_limit(4) = 'xxxy\ny\n'
45
+ # Thnik about.
46
+
47
+ str_array = str.split(' ')
48
+ run_index = 0
49
+ result = ''
50
+ line = ''
51
+
52
+ until str_array.empty? do
53
+ next_up = str_array.shift
54
+ # puts "next_up=#{next_up}"
55
+ if (line.length + next_up.length + 1 < wrap_limit)
56
+ # got room add it in
57
+ line += next_up + ' '
58
+ run_index += 1
59
+ else
60
+ line = next_up if line.empty? # edge case, test 4
61
+ # start new line
62
+ result += line + "\n" unless str_array.empty? # edge case, test 2
63
+ # puts 'reset'
64
+ line = next_up + ' '
65
+ run_index += 1
66
+ end
67
+ end
68
+
69
+ result += line.strip + "\n" if line.length > 0 # Don't lose what is left
70
+ result
71
+ end
72
+
73
+ end
@@ -0,0 +1,3 @@
1
+ module Wrapify
2
+ VERSION = "0.1.2" # changed repo in spec
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'rspec/core/rake_task'
2
+ RSpec::Core::RakeTask.new(:spec)
3
+
4
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
Binary file
Binary file
@@ -0,0 +1,36 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "wrapify/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "wrapify"
8
+ spec.version = Wrapify::VERSION
9
+ spec.authors = ["Frank Germano"]
10
+ spec.email = ["fgermano@earthlink.net"]
11
+
12
+ spec.summary = "Wrap lines at given char limit"
13
+ spec.description = "Wrap lines at given char limit"
14
+ spec.homepage = "https://github.com/fgermanojr/wrapify.git"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.16"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.7", ">= 3.7.0"
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wrapify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Germano
@@ -64,8 +64,23 @@ email:
64
64
  executables: []
65
65
  extensions: []
66
66
  extra_rdoc_files: []
67
- files: []
68
- homepage: https://github.com/fgermanojr/emrbear_repo.git
67
+ files:
68
+ - ".gitignore"
69
+ - ".travis.yml"
70
+ - Gemfile
71
+ - Gemfile.lock
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - bin/console
76
+ - bin/setup
77
+ - lib/wrapify.rb
78
+ - lib/wrapify/version.rb
79
+ - tasks/rspec.rake
80
+ - wrapify-0.1.0.gem
81
+ - wrapify-0.1.1.gem
82
+ - wrapify.gemspec
83
+ homepage: https://github.com/fgermanojr/wrapify.git
69
84
  licenses:
70
85
  - MIT
71
86
  metadata: {}