palindrome_ext 0.2.0 → 0.5.0
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/.yardopts +3 -3
- data/README.md +28 -10
- data/lib/palindrome_ext/array.rb +16 -11
- data/lib/palindrome_ext/integer.rb +1 -1
- data/lib/palindrome_ext/version.rb +7 -7
- data/lib/palindrome_ext.rb +6 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c60b847f233df502210daa72da8a74170f6a20cb825513a055fc6c198dfe872
|
4
|
+
data.tar.gz: f9670ad65f3689972e49471fcd6653b4c9c7760728b4161bbeb28ada4d8b235c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8292bc8e1a564698686120537a99c4bae55415db64df4ad53800761f471a911e7a72fa09321552b163bfd5a69437554cb1ba43271f5b11ec45f9be4526826f34
|
7
|
+
data.tar.gz: 7e030117baebc557146d251de5851e492ce71fbf8e6e0bbcfd21b9b01c4a87a59b519888f3d4ceec0a553bc85d240e3de3dae0a6742feee17a79d6ab468457c4
|
data/.yardopts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
--no-private
|
2
|
-
--protected
|
3
|
-
-
|
1
|
+
--no-private
|
2
|
+
--protected
|
3
|
+
-
|
4
4
|
README.md
|
data/README.md
CHANGED
@@ -24,18 +24,20 @@ Or install it yourself as:
|
|
24
24
|
$ gem install palindrome_ext
|
25
25
|
|
26
26
|
## Usage
|
27
|
+
Detailed documentation can be found at https://rubydoc.info/gems/palindrome_ext.
|
27
28
|
|
28
29
|
### String
|
29
30
|
```ruby
|
30
31
|
require 'palindrome_ext/string'
|
31
32
|
|
32
|
-
# Palindrome -
|
33
|
+
# Palindrome - Case Sensitive & Whitespace Sensitive
|
33
34
|
'Example...'.palindrome? # => false
|
34
|
-
'
|
35
|
+
'radar'.palindrome? # => true
|
36
|
+
'Radar'.palindrome? # => false
|
35
37
|
|
36
|
-
# Strict Palindrome -
|
37
|
-
'Radar'.palindrome?
|
38
|
-
'RadaR'.palindrome?
|
38
|
+
# Non-Strict Palindrome - Removes whitespace, punctuation, and capitalization before checking.
|
39
|
+
'Radar'.palindrome? false # => true
|
40
|
+
'RadaR'.palindrome? # => false
|
39
41
|
```
|
40
42
|
|
41
43
|
### Integer
|
@@ -52,15 +54,31 @@ require 'palindrome_ext/integer'
|
|
52
54
|
|
53
55
|
## Development
|
54
56
|
|
55
|
-
|
57
|
+
### Dependency Management
|
58
|
+
After forking this repo, navigate to the root directory and run:
|
56
59
|
|
57
|
-
|
60
|
+
$ bundle install
|
61
|
+
|
62
|
+
### Testing with RSpec
|
63
|
+
To run tests, simply run:
|
64
|
+
|
65
|
+
$ rake test
|
66
|
+
|
67
|
+
### Linting with RuboCop
|
68
|
+
To check if there are any style offenses in your forked repository and automatically fix these offenses, run:
|
69
|
+
|
70
|
+
$ rake lint
|
71
|
+
|
72
|
+
### Benchmarking
|
73
|
+
To execute a benchmark report, run:
|
74
|
+
|
75
|
+
$ rake benchmark
|
58
76
|
|
59
|
-
To check if there are any style offenses in your forked repository, run `$ rubocop`. To attempt to automatically fix these offenses, run `$ rubocop -A`.
|
60
77
|
|
61
78
|
## Contributing
|
62
79
|
|
63
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/aj-rom/palindrome_ext.
|
80
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/aj-rom/palindrome_ext.
|
81
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/aj-rom/palindrome_ext/blob/master/CODE_OF_CONDUCT.md).
|
64
82
|
|
65
83
|
## License
|
66
84
|
|
@@ -68,4 +86,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
68
86
|
|
69
87
|
## Code of Conduct
|
70
88
|
|
71
|
-
Everyone interacting in the PalindromeExt project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
89
|
+
Everyone interacting in the PalindromeExt project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/aj-rom/palindrome_ext/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/palindrome_ext/array.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "palindrome_ext/string"
|
4
|
-
|
5
|
-
# Overrides Default Array Class by adding {palindrome?} method.
|
6
|
-
class Array
|
7
|
-
# @
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "palindrome_ext/string"
|
4
|
+
|
5
|
+
# Overrides Default Array Class by adding {palindrome?} method.
|
6
|
+
class Array
|
7
|
+
# @param strict whether or not to ignore whitespace and non-alphanumeric characters.
|
8
|
+
# @return [Boolean] Whether or not the array is a palindrome.
|
9
|
+
def palindrome?(strict = true)
|
10
|
+
return self == reverse if strict
|
11
|
+
|
12
|
+
arr = map { |x| x.to_s.downcase.tr("^a-z0-9", "") }
|
13
|
+
arr.delete_if(&:empty?)
|
14
|
+
arr == arr.reverse
|
15
|
+
end
|
16
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# palindrome_ext module and version.
|
4
|
-
# @private
|
5
|
-
module PalindromeExt
|
6
|
-
VERSION = "0.
|
7
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# palindrome_ext module and version.
|
4
|
+
# @private
|
5
|
+
module PalindromeExt
|
6
|
+
VERSION = "0.5.0"
|
7
|
+
end
|
data/lib/palindrome_ext.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "palindrome_ext/version"
|
4
|
-
require_relative "palindrome_ext/string"
|
5
|
-
require_relative "palindrome_ext/integer"
|
6
|
-
require_relative "palindrome_ext/array"
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "palindrome_ext/version"
|
4
|
+
require_relative "palindrome_ext/string"
|
5
|
+
require_relative "palindrome_ext/integer"
|
6
|
+
require_relative "palindrome_ext/array"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: palindrome_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A.J. Romaniello
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -144,7 +144,7 @@ metadata:
|
|
144
144
|
source_code_uri: https://github.com/aj-rom/palindrome_ext
|
145
145
|
changelog_uri: https://github.com/aj-rom/palindrome_ext
|
146
146
|
documentation_uri: https://www.rubydoc.info/gems/palindrome_ext
|
147
|
-
post_install_message:
|
147
|
+
post_install_message:
|
148
148
|
rdoc_options: []
|
149
149
|
require_paths:
|
150
150
|
- lib
|
@@ -159,8 +159,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
|
-
rubygems_version: 3.2.
|
163
|
-
signing_key:
|
162
|
+
rubygems_version: 3.2.32
|
163
|
+
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Adds methods for determining whether or not a string, integer, or array are
|
166
166
|
palindromes.
|