chap8_ex_gem_palindrome 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +52 -0
- data/README.md +42 -0
- data/Rakefile +16 -0
- data/chap8_ex_gem_palindrome.gemspec +53 -0
- data/lib/chap8_ex_gem_palindrome/version.rb +5 -0
- data/lib/chap8_ex_gem_palindrome.rb +70 -0
- data/sig/chap8_ex_gem_palindrome.rbs +4 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e47e9b3ddd7ee07b6f70658ce895e4bd334eff938bc248d5d25a71f1a15e906
|
4
|
+
data.tar.gz: 7854344b1fdaee461d14f60f85dadf43045f6de6715f7e181c4e384b3823270c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 390450ffa4500ebefe7f027f7569f99306fdd6acf614f229e1788b45277d5fcdc5d8897498d875b88474b43384eb97dc8484cf37e793fa5188eccb64d3a8cdb0
|
7
|
+
data.tar.gz: 0016eafe396d38cf3301ffbeb9c350eacdadbc941e1ec9ad774c8d5542a166d21b68003eb210314fe2d63dd2ff57e8e3eb45e8bc04ca46d575d3f45f2e7820a6
|
data/.DS_Store
ADDED
Binary file
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in chap8_ex_gem_palindrome.gemspec
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
gem "rake", "~> 13.0"
|
11
|
+
|
12
|
+
gem "minitest", "~> 5.0"
|
13
|
+
|
14
|
+
gem "rubocop", "~> 1.21"
|
15
|
+
|
16
|
+
gem 'minitest-reporters', '1.2.0'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
chap8_ex_gem_palindrome (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ansi (1.5.0)
|
10
|
+
ast (2.4.2)
|
11
|
+
builder (3.2.4)
|
12
|
+
json (2.6.3)
|
13
|
+
minitest (5.18.0)
|
14
|
+
minitest-reporters (1.2.0)
|
15
|
+
ansi
|
16
|
+
builder
|
17
|
+
minitest (>= 5.0)
|
18
|
+
ruby-progressbar
|
19
|
+
parallel (1.22.1)
|
20
|
+
parser (3.2.1.1)
|
21
|
+
ast (~> 2.4.1)
|
22
|
+
rainbow (3.1.1)
|
23
|
+
rake (13.0.6)
|
24
|
+
regexp_parser (2.7.0)
|
25
|
+
rexml (3.2.5)
|
26
|
+
rubocop (1.48.1)
|
27
|
+
json (~> 2.3)
|
28
|
+
parallel (~> 1.10)
|
29
|
+
parser (>= 3.2.0.0)
|
30
|
+
rainbow (>= 2.2.2, < 4.0)
|
31
|
+
regexp_parser (>= 1.8, < 3.0)
|
32
|
+
rexml (>= 3.2.5, < 4.0)
|
33
|
+
rubocop-ast (>= 1.26.0, < 2.0)
|
34
|
+
ruby-progressbar (~> 1.7)
|
35
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
36
|
+
rubocop-ast (1.27.0)
|
37
|
+
parser (>= 3.2.1.0)
|
38
|
+
ruby-progressbar (1.13.0)
|
39
|
+
unicode-display_width (2.4.2)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
arm64-darwin-21
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
chap8_ex_gem_palindrome!
|
46
|
+
minitest (~> 5.0)
|
47
|
+
minitest-reporters (= 1.2.0)
|
48
|
+
rake (~> 13.0)
|
49
|
+
rubocop (~> 1.21)
|
50
|
+
|
51
|
+
BUNDLED WITH
|
52
|
+
2.3.26
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Chap8ExGemPalindrome
|
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/chap8_ex_gem_palindrome`. 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
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
|
+
|
11
|
+
$ bundle add chap8_ex_gem_palindrome
|
12
|
+
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
+
|
15
|
+
$ gem install chap8_ex_gem_palindrome
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
`chap8_ex_gem_palindrome` adds a `palindrome?` method to the `String` class, and can be used as follows:
|
20
|
+
|
21
|
+
```
|
22
|
+
$ irb
|
23
|
+
>> require 'chap8_ex_gem_palindrome'
|
24
|
+
>> "honey badger".palindrome?
|
25
|
+
=> false
|
26
|
+
>> "deified".palindrome?
|
27
|
+
=> true
|
28
|
+
>> "Able was I, ere I saw Elba.".palindrome?
|
29
|
+
=> true
|
30
|
+
>> phrase = "Madam, I'm Adam."
|
31
|
+
>> phrase.palindrome?
|
32
|
+
=> true
|
33
|
+
```
|
34
|
+
## Development
|
35
|
+
|
36
|
+
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.
|
37
|
+
|
38
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/chap8_ex_gem_palindrome.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rubocop/rake_task"
|
13
|
+
|
14
|
+
RuboCop::RakeTask.new
|
15
|
+
|
16
|
+
task default: %i[test rubocop]
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/chap8_ex_gem_palindrome/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "chap8_ex_gem_palindrome"
|
7
|
+
spec.version = Chap8ExGemPalindrome::VERSION
|
8
|
+
spec.authors = ["Xeniouska"]
|
9
|
+
spec.email = ["115425494+Xeniouska@users.noreply.github.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Palindrome detector}
|
12
|
+
spec.description = %q{Learn Enough Ruby palindrome detector}
|
13
|
+
spec.homepage = "https://github.com/mhartl/mhartl_palindrome"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the
|
19
|
+
# 'allowed_push_host'
|
20
|
+
# to allow pushing to a single host or delete this section to allow pushing to
|
21
|
+
# any host.
|
22
|
+
if spec.respond_to?(:metadata)
|
23
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
24
|
+
else
|
25
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
"public gem pushes."
|
27
|
+
end
|
28
|
+
|
29
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
30
|
+
|
31
|
+
# spec.metadata["homepage_uri"] = "https://www.learnenough.com/"
|
32
|
+
# spec.metadata["source_code_uri"] = spec.homepage
|
33
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# Specify which files should be added to the gem when it is released.
|
38
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
39
|
+
spec.files = Dir.chdir(__dir__) do
|
40
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
41
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
42
|
+
end
|
43
|
+
end
|
44
|
+
spec.bindir = "exe"
|
45
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
46
|
+
spec.require_paths = ["lib"]
|
47
|
+
|
48
|
+
# Uncomment to register a new dependency of your gem
|
49
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
50
|
+
|
51
|
+
# For more information and examples about making a new gem, check out our
|
52
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
53
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "chap8_ex_gem_palindrome/version"
|
4
|
+
|
5
|
+
class String
|
6
|
+
|
7
|
+
# Returns true for a palindrome, false otherwise.
|
8
|
+
def palindrome?
|
9
|
+
processed_content == processed_content.reverse
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns the letters of the string (made by myself).
|
13
|
+
# def letters
|
14
|
+
# self.scan(/[a-z*A-Z*]/).join
|
15
|
+
# end
|
16
|
+
|
17
|
+
# Longer version A (from Tutorial).
|
18
|
+
# def letters
|
19
|
+
# the_letters = []
|
20
|
+
# for i in 0..(self.length - 1) do
|
21
|
+
# if self[i].match(/[a-zA-Z]/)
|
22
|
+
# the_letters << self[i]
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# the_letters.join
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Longer version B (made by myself).
|
29
|
+
# def letters
|
30
|
+
# the_letters = []
|
31
|
+
# regex_letters = /[a-z]/i # i for case incensitive
|
32
|
+
# self.each_char do |letter|
|
33
|
+
# if letter.match(regex_letters)
|
34
|
+
# the_letters << letter
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
# the_letters.join
|
38
|
+
# end
|
39
|
+
|
40
|
+
# Shorter version (following tutorial, from myself)
|
41
|
+
# def letters
|
42
|
+
# the_letters = self.chars.select { |char| char.match?(/[a-z]/i) }
|
43
|
+
# the_letters.join
|
44
|
+
# end
|
45
|
+
|
46
|
+
# Shorter version (from tutorial)
|
47
|
+
# def letters
|
48
|
+
# chars.select { |char| char.match?(/[a-z]/i) }.join
|
49
|
+
# end
|
50
|
+
|
51
|
+
# Finally Hartl end ups with the same code as I.
|
52
|
+
# def letters
|
53
|
+
# self.scan(/[a-z*A-Z*]/).join
|
54
|
+
# end
|
55
|
+
# And he goes further by pasting this in the processed_content and
|
56
|
+
# deleting the letters method !
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
# Returns content for palindrome testing.
|
61
|
+
# FIRST version:
|
62
|
+
# def processed_content
|
63
|
+
# self.letters.downcase
|
64
|
+
# end
|
65
|
+
|
66
|
+
# SECOND version, after joining to it the letters method:
|
67
|
+
def processed_content
|
68
|
+
self.scan(/[a-z*A-Z*]/).join.downcase
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chap8_ex_gem_palindrome
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Xeniouska
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-03-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Learn Enough Ruby palindrome detector
|
14
|
+
email:
|
15
|
+
- 115425494+Xeniouska@users.noreply.github.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".DS_Store"
|
21
|
+
- ".rubocop.yml"
|
22
|
+
- CHANGELOG.md
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- chap8_ex_gem_palindrome.gemspec
|
28
|
+
- lib/chap8_ex_gem_palindrome.rb
|
29
|
+
- lib/chap8_ex_gem_palindrome/version.rb
|
30
|
+
- sig/chap8_ex_gem_palindrome.rbs
|
31
|
+
homepage: https://github.com/mhartl/mhartl_palindrome
|
32
|
+
licenses: []
|
33
|
+
metadata:
|
34
|
+
allowed_push_host: https://rubygems.org/
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.6.0
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubygems_version: 3.3.7
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Palindrome detector
|
54
|
+
test_files: []
|