wrappity_wrap 0.1.0 → 0.1.1
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +26 -7
- data/lib/wrappity_wrap.rb +14 -17
- data/lib/wrappity_wrap/version.rb +1 -1
- data/wrappity_wrap.gemspec +2 -3
- metadata +5 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 456afef938beb41bd6368c5b40a24c8820e64789a0ce229a3236a03347a08a70
|
4
|
+
data.tar.gz: cd79fdfbc7e50f38a402478c3c526860d8f64f039fbb819cb22c3d9dff30815a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5f893c01956565417deed778bacdfc8375c99e7067e320e85a67b7b685be541b7ea114d680714eecd53e8805840f48a511d3546f3edc00c6ab751921cc7dce3
|
7
|
+
data.tar.gz: c3ab7cac6f5566d7eecc2b79570f7d1f2e0cc332f73cc3a9494b375688f5719dd5537ebaa2e45795828eaace6efb5c893a7c597fbf056808499845b77c6277b9
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# WrappityWrap
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/wrappity_wrap`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
@@ -22,7 +19,32 @@ Or install it yourself as:
|
|
22
19
|
|
23
20
|
## Usage
|
24
21
|
|
25
|
-
|
22
|
+
``` ruby
|
23
|
+
it "returns "" when given nil" do
|
24
|
+
expect(WrappityWrap.wrap(nil, 4)).to eq("")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns "" when given empty string" do
|
28
|
+
expect(WrappityWrap.wrap("", 4)).to eq("")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns wrapped string when string is shorter than column" do
|
32
|
+
expect(WrappityWrap.wrap("word", 6)).to eq("word")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns wrapped string when string has a space before the column" do
|
36
|
+
expect(WrappityWrap.wrap("long word", 6)).to eq("long\nword")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns wrapped string when space occurs at column" do
|
40
|
+
expect(WrappityWrap.wrap("long word", 5)).to eq("long\nword")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns wrapped string when space after the column" do
|
44
|
+
expect(WrappityWrap.wrap("verylong word", 4)).to eq("very\nlong\nword")
|
45
|
+
end
|
46
|
+
|
47
|
+
```
|
26
48
|
|
27
49
|
## Development
|
28
50
|
|
@@ -30,9 +52,6 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
30
52
|
|
31
53
|
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).
|
32
54
|
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/wrappity_wrap. 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.
|
36
55
|
|
37
56
|
## License
|
38
57
|
|
data/lib/wrappity_wrap.rb
CHANGED
@@ -3,23 +3,20 @@ require "wrappity_wrap/version"
|
|
3
3
|
module WrappityWrap
|
4
4
|
class Error < StandardError; end
|
5
5
|
|
6
|
-
def wrap(string, column)
|
7
|
-
if string.nil?
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
""
|
22
|
-
end
|
6
|
+
def wrap(string, column)
|
7
|
+
return "" if string.nil?
|
8
|
+
|
9
|
+
return string if string.length <= column
|
10
|
+
|
11
|
+
if string[0... column].index(" ") != nil
|
12
|
+
white_space = string[0... column].rindex(" ")
|
13
|
+
string[0... white_space] + "\n" + wrap(string[white_space+1.. -1], column)
|
14
|
+
elsif string[column] == " "
|
15
|
+
string[0... column] + "\n" + wrap(string[column.. -1].strip, column)
|
16
|
+
else
|
17
|
+
string[0... column].strip + "\n" + wrap(string[column.. -1], column)
|
18
|
+
end
|
19
|
+
end
|
23
20
|
end
|
24
21
|
|
25
22
|
|
data/wrappity_wrap.gemspec
CHANGED
@@ -8,9 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Tony Griffin"]
|
9
9
|
spec.email = ["tony@madetech.com"]
|
10
10
|
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.
|
13
|
-
spec.homepage = 'https://rubygems.org/gems/example'
|
11
|
+
spec.summary = %q{Word wrapper gem that takes a word and wraps into lines at given column boundaries}
|
12
|
+
spec.homepage = 'https://github.com/tonymadetech/wrappity_wrap_gem.git'
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
16
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrappity_wrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Griffin
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- tony@madetech.com
|
58
58
|
executables: []
|
@@ -73,11 +73,11 @@ files:
|
|
73
73
|
- lib/wrappity_wrap.rb
|
74
74
|
- lib/wrappity_wrap/version.rb
|
75
75
|
- wrappity_wrap.gemspec
|
76
|
-
homepage: https://
|
76
|
+
homepage: https://github.com/tonymadetech/wrappity_wrap_gem.git
|
77
77
|
licenses:
|
78
78
|
- MIT
|
79
79
|
metadata:
|
80
|
-
homepage_uri: https://
|
80
|
+
homepage_uri: https://github.com/tonymadetech/wrappity_wrap_gem.git
|
81
81
|
source_code_uri: https://github.com/tonymadetech/wrappity_wrap_gem.git
|
82
82
|
changelog_uri: https://github.com/tonymadetech/wrappity_wrap_gem.git
|
83
83
|
post_install_message:
|
@@ -98,8 +98,5 @@ requirements: []
|
|
98
98
|
rubygems_version: 3.0.3
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
|
-
summary:
|
102
|
-
The function returns the string, but with line breaks inserted at the right places
|
103
|
-
to make sure that no line is longer than the column number. You try to break lines
|
104
|
-
at word boundaries.
|
101
|
+
summary: Word wrapper gem that takes a word and wraps into lines at given column boundaries
|
105
102
|
test_files: []
|