is_palindromic 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +33 -0
- data/.travis.yml +33 -0
- data/CHANGELOG.md +5 -0
- data/CODEOWNERS +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/is_palindromic.gemspec +29 -0
- data/lib/is_palindromic.rb +8 -0
- data/lib/is_palindromic/overloads.rb +29 -0
- data/lib/is_palindromic/version.rb +3 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0d6f74090687bd9169229cf04b7d5e37c7cd8da5
|
4
|
+
data.tar.gz: b55dbe113cd8825eaffd46ca3d3001dd59b7e2ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d30e1b619c3d28a8e970f6cdcbfe7706b0b37e510c1978b5cd98387e5cd26f69c60aab72bf8cec795d166bc66c10171600fd8fcb29b4143e0645d018893d433f
|
7
|
+
data.tar.gz: e848945029502cb167388d394df354287c84381eddc2baf002f9d7e2ad235e95efd6066d6867d5f3101e95c2200686963b973161cac59327d96f819b9da1e021
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Layout/IndentationWidth:
|
2
|
+
Width: 4
|
3
|
+
|
4
|
+
Metrics/AbcSize:
|
5
|
+
Max: 50
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Max: 40
|
12
|
+
|
13
|
+
Metrics/CyclomaticComplexity:
|
14
|
+
Max: 20
|
15
|
+
|
16
|
+
Metrics/MethodLength:
|
17
|
+
Max: 60
|
18
|
+
|
19
|
+
Metrics/PerceivedComplexity:
|
20
|
+
Max: 20
|
21
|
+
|
22
|
+
Naming/PredicateName:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/GlobalVars:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/RaiseArgs:
|
29
|
+
EnforcedStyle: compact
|
30
|
+
|
31
|
+
Style/WordArray:
|
32
|
+
EnforcedStyle: brackets
|
33
|
+
|
data/.travis.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
sudo: required
|
2
|
+
matrix:
|
3
|
+
include:
|
4
|
+
- language: ruby
|
5
|
+
rvm: 2.2
|
6
|
+
before_install:
|
7
|
+
- gem install bundler -v 1.16.1
|
8
|
+
- language: ruby
|
9
|
+
rvm: 2.4.4
|
10
|
+
before_install:
|
11
|
+
- gem install bundler -v 1.17.3
|
12
|
+
- language: ruby
|
13
|
+
env: SKIP_INTERPRETER=true
|
14
|
+
rvm: 2.4.4
|
15
|
+
before_install:
|
16
|
+
- git clone https://github.com/TravisToolbox/rubocop-travis.git
|
17
|
+
install:
|
18
|
+
- ./rubocop-travis/install.sh
|
19
|
+
script:
|
20
|
+
- ./rubocop-travis/scan.sh
|
21
|
+
- language: ruby
|
22
|
+
rvm: 2.2
|
23
|
+
before_install:
|
24
|
+
- mkdir travis
|
25
|
+
- git clone https://github.com/TravisToolbox/awesomebot-travis.git travis/awesomebot
|
26
|
+
install:
|
27
|
+
- ./travis/awesomebot/install.sh
|
28
|
+
script:
|
29
|
+
- ./travis/awesomebot/scan.sh
|
30
|
+
notifications:
|
31
|
+
email: false
|
32
|
+
slack:
|
33
|
+
secure: rbQSkhkUa7TroB8cCguoo8iR/WkbdUC2VRYGwOn+yboPEWJeXR+9t/XvaCMqM16fs5gTH0/S8HBVhzPyY9aGUa8YlC0KK+4zC+ncUZfHf3K5MnzYrkGQwqcHiBZjed49LWE9tceJSYPsxjSrAhS0LzMEA8XJD/WFBdvzcmgDit4Dw0JSsX5PqL0Ijowh6QrFBgJaUDLSreDnsCOOE+pdtAC+wJHSVYEYHzuIeu1J5jTMREgIgJIo/f0/GcbEFGgob4XwEdFehK8z6BCOfY7RHixB4W8FMQC5jSYxX1ar5rPnP4XqP6W21+ikfaqmszfYqITx+lh4hGfJqnzUOFcZzSMfA1Blvn2yfLn68B99wBElHD8HKN2TXA/pO4YK324b/+7DsjkERtD1kOvCfSVb7QhOsRK+3yWD4RlYfSEV30cEhmQ4VIw8jQe3DaayOSICg/UXJ+8GVP9aoJkmyDMvcr5mJiqLlhyHBkuZQ5qAtM4ocIvaOyaZco1sLBxoDvH6Xx8aHObMWeOsafij/yegvzSuuaxTfKMXH4E7mR6ZEuktMmn2xt/gW7qI8EuS7ZSZrLILnC2gn1MFPPGbFEP1VpWwLMiHn+TsDV7Fdt9mU+23S+HCPM9Zq2p6P1huDtIUQRniJvbO3mtola6hnvla/sWrMAQrdCtrZ3G8wDWxuec=
|
data/CHANGELOG.md
ADDED
data/CODEOWNERS
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at wolf@tgwolf.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Tim Gurney aka Wolf
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
[![Build Status](https://img.shields.io/travis/WolfSoftware/is_palindromic/master.svg)](https://travis-ci.org/WolfSoftware/is_palindromic)
|
2
|
+
[![Software License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
|
3
|
+
[![Release](https://img.shields.io/github/release/wolfsoftware/is_palindromic.svg)](https://github.com/wolfsoftware/is_palindromic/releases/latest)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/is_palindromic.svg)](https://badge.fury.io/rb/is_palindromic)
|
5
|
+
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/wolfsoftware/is_palindromic/latest.svg)](https://github.com/wolfsoftware/is_palindromic/commits)
|
6
|
+
[![GitHub repo size in bytes](https://img.shields.io/github/repo-size/wolfsoftware/is_palindromic.svg)](https://github.com/wolfsoftware/is_palindromic)
|
7
|
+
[![GitHub contributors](https://img.shields.io/github/contributors/wolfsoftware/is_palindromic.svg)](https://github.com/wolfsoftware/is_palindromic)
|
8
|
+
|
9
|
+
# Is Palindromic
|
10
|
+
|
11
|
+
A very simply Gem to test is a string or integer is palindromic or not.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'is_palindromic'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install is_palindromic
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
### Testing strings
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require 'is_palindromic'
|
35
|
+
|
36
|
+
puts 'test'.is_palindromic?
|
37
|
+
puts '12321'.is_palindromic?
|
38
|
+
puts '123! 21'.is_palindromic?
|
39
|
+
```
|
40
|
+
|
41
|
+
### Testing integers
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'is_palindromic'
|
45
|
+
|
46
|
+
puts 123.is_palindromic?
|
47
|
+
puts 12321.is_palindromic?
|
48
|
+
```
|
49
|
+
|
50
|
+
## Development
|
51
|
+
|
52
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
53
|
+
|
54
|
+
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).
|
55
|
+
|
56
|
+
## Testing
|
57
|
+
|
58
|
+
For local testing make sure that you run `bundle exec rspec spec` and then `rake install` to install the gem locally.
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/is_palindromic. 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.
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
67
|
+
|
68
|
+
## Code of Conduct
|
69
|
+
|
70
|
+
Everyone interacting in the IsPalindromic project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/is_palindromic/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "is_palindromic"
|
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__)
|
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "is_palindromic/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "is_palindromic"
|
8
|
+
spec.version = IsPalindromic::VERSION
|
9
|
+
spec.authors = ["Tim Gurney aka Wolf"]
|
10
|
+
spec.email = ["wolf@tgwolf.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A very simply Gem to test is a string or integer is palindromic or not.}
|
13
|
+
spec.description = %q{A very simply Gem to test is a string or integer is palindromic or not.}
|
14
|
+
spec.homepage = "https://github.com/WolfSoftware/is_palindromic"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Overload the Integer class
|
3
|
+
#
|
4
|
+
class Integer
|
5
|
+
def is_palindromic?
|
6
|
+
return false if processed_content.empty?
|
7
|
+
|
8
|
+
processed_content == processed_content.reverse
|
9
|
+
end
|
10
|
+
|
11
|
+
def processed_content
|
12
|
+
to_s.scan(/[[:alnum:]]/i).join.downcase
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Overload the String class
|
18
|
+
#
|
19
|
+
class String
|
20
|
+
def is_palindromic?
|
21
|
+
return false if processed_content.empty?
|
22
|
+
|
23
|
+
processed_content == processed_content.reverse
|
24
|
+
end
|
25
|
+
|
26
|
+
def processed_content
|
27
|
+
scan(/[[:alnum:]]/i).join.downcase
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: is_palindromic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Gurney aka Wolf
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: A very simply Gem to test is a string or integer is palindromic or not.
|
56
|
+
email:
|
57
|
+
- wolf@tgwolf.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".rubocop.yml"
|
65
|
+
- ".travis.yml"
|
66
|
+
- CHANGELOG.md
|
67
|
+
- CODEOWNERS
|
68
|
+
- CODE_OF_CONDUCT.md
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- bin/console
|
74
|
+
- bin/setup
|
75
|
+
- is_palindromic.gemspec
|
76
|
+
- lib/is_palindromic.rb
|
77
|
+
- lib/is_palindromic/overloads.rb
|
78
|
+
- lib/is_palindromic/version.rb
|
79
|
+
homepage: https://github.com/WolfSoftware/is_palindromic
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.6.14
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: A very simply Gem to test is a string or integer is palindromic or not.
|
103
|
+
test_files: []
|