wrappity_wrap 0.1.0 → 0.1.1

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: 20723882aa8e02c3544e307f4b05e66b7de649b912bc2d7a632e4ca9b08d039a
4
- data.tar.gz: d1f2379c9a81e7b9d784dc5ce93c542312fb9f401bbaf87fa48581ecd63014a3
3
+ metadata.gz: 456afef938beb41bd6368c5b40a24c8820e64789a0ce229a3236a03347a08a70
4
+ data.tar.gz: cd79fdfbc7e50f38a402478c3c526860d8f64f039fbb819cb22c3d9dff30815a
5
5
  SHA512:
6
- metadata.gz: a7f2253a814282c3c95f87e71f7ede3ee2a989d9fe8fb48b6f762b94308a1625a11e13030ebbd712634b6e0d166bfa4b39cd22a8ade2726f0bd6030d1345b4b5
7
- data.tar.gz: 84c9fe9253e9dd8c12502f26e93aa24b37092db80299f189533b7c2805e4c3db7b1a03817400b406fee1a94db8bdb77847ebff3b3f7caa88f7660e0950dd7453
6
+ metadata.gz: e5f893c01956565417deed778bacdfc8375c99e7067e320e85a67b7b685be541b7ea114d680714eecd53e8805840f48a511d3546f3edc00c6ab751921cc7dce3
7
+ data.tar.gz: c3ab7cac6f5566d7eecc2b79570f7d1f2e0cc332f73cc3a9494b375688f5719dd5537ebaa2e45795828eaace6efb5c893a7c597fbf056808499845b77c6277b9
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wrappity_wrap (0.1.0)
4
+ wrappity_wrap (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
- TODO: Write usage instructions here
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
- return ""
9
- end
10
-
11
- return string if string.length <= column
12
-
13
- if string[0..column].index(" ") != nil
14
- whitespace = string[0...column].rindex(" ")
15
- return string[0...whitespace] + "/n" +wrap(string[whitespace+1..-1],column)
16
- elsif string[column] == " "
17
- return string[0...colum] + "/n" + wrap(string[column..-1].strip,column)
18
- else
19
- string[0...column].strip + "/n" + wrap(string[column..-1], column)
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
 
@@ -1,3 +1,3 @@
1
1
  module WrappityWrap
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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{A single function that takes two arguments, a string, and a column number. The function returns the string, but with line breaks inserted at the right places to make sure that no line is longer than the column number. You try to break lines at word boundaries.}
12
- spec.description = %q{}
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.0
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://rubygems.org/gems/example
76
+ homepage: https://github.com/tonymadetech/wrappity_wrap_gem.git
77
77
  licenses:
78
78
  - MIT
79
79
  metadata:
80
- homepage_uri: https://rubygems.org/gems/example
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: A single function that takes two arguments, a string, and a column number.
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: []