ozemmouri_palindrome 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b91b943f4dbd7532953778fcb5097cdb0c27c521135861314805c362e8c182b5
4
+ data.tar.gz: d0408c68f0e8fe4d1dfa5d61b128d1905bfbc9d26c6ce7b029390646d42f882c
5
+ SHA512:
6
+ metadata.gz: 99caf4b87705aae7d2b6dbfd37c2e28f908e9867217f4bd40ce3a29f9615361c02888b4993e04c8898fb5d04dcdffbb7e9f7a20ef1ea84fded02c91021f2c79e
7
+ data.tar.gz: 3140a645e8f96c4df6f6c55f8c567642eec0a2c57b46d7597f9e481ae7136be445cab526be5c55be154dc975c8b3fbeb33d455dc42874aca4a686cf417205cf6
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in ozemmouri_palindrome.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.14"
11
+
12
+ gem "minitest-reporters", "~> 1.5"
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ozemmouri_palindrome (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ansi (1.5.0)
10
+ builder (3.2.4)
11
+ minitest (5.19.0)
12
+ minitest-reporters (1.6.1)
13
+ ansi
14
+ builder
15
+ minitest (>= 5.0)
16
+ ruby-progressbar
17
+ rake (13.0.6)
18
+ ruby-progressbar (1.13.0)
19
+
20
+ PLATFORMS
21
+ x86_64-darwin-21
22
+
23
+ DEPENDENCIES
24
+ minitest (~> 5.14)
25
+ minitest-reporters (~> 1.5)
26
+ ozemmouri_palindrome!
27
+ rake (~> 13.0)
28
+
29
+ BUNDLED WITH
30
+ 2.4.13
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Palindrome detector
2
+
3
+ `mhartl_palindrome` is a sample Ruby gem created in [*Learn Enough Ruby to Be Dangerous*](https://www.learnenough.com/ruby-tutorial) by Michael Hartl.
4
+
5
+ ## Installation
6
+
7
+ To install `mhartl_palindrome`, add this line to your application's `Gemfile`:
8
+
9
+ ```
10
+ gem 'mhartl_palindrome'
11
+ ```
12
+
13
+ Then install as follows:
14
+
15
+ ```
16
+ $ bundle install
17
+ ```
18
+
19
+ Or install it directly using `gem`:
20
+
21
+ ```
22
+ $ gem install mhartl_palindrome
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ `mhartl_palindrome` adds a `palindrome?` method to the `String` class, and can be used as follows:
28
+
29
+ ```
30
+ $ irb
31
+ >> require 'mhartl_palindrome'
32
+ >> "honey badger".palindrome?
33
+ => false
34
+ >> "deified".palindrome?
35
+ => true
36
+ >> "Able was I, ere I saw Elba.".palindrome?
37
+ => true
38
+ >> phrase = "Madam, I'm Adam."
39
+ >> phrase.palindrome?
40
+ => true
41
+ ```
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
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
+ task default: :test
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OzemmouriPalindrome
4
+ VERSION = "0.2.0"
5
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ozemmouri_palindrome/version"
4
+
5
+ module OzemmouriPalindrome
6
+ # Returns true for a palindrome, false otherwise.
7
+ def palindrome?
8
+ processed_content == processed_content.reverse
9
+ end
10
+
11
+ # Returns the letters in the string
12
+ # def letters
13
+ # the_letters = []
14
+ # letter_regex = /[a-z]/i
15
+ # self.chars.each do |char|
16
+ # if char.match(letter_regex)
17
+ # the_letters << char
18
+ # end
19
+ # end
20
+ # the_letters.join
21
+ # end
22
+
23
+ # def letters
24
+ # self.chars.select {|c| c.match(/[a-z]/i)}.join
25
+ # end
26
+
27
+ private
28
+
29
+
30
+ # Returns content for palindrome testing.
31
+ def processed_content
32
+ self.to_s.scan(/[a-z\d]/i).join.downcase
33
+ # self.downcase.split(/\W+/).join
34
+ end
35
+
36
+
37
+ end
38
+
39
+ class String
40
+ include OzemmouriPalindrome
41
+ end
42
+
43
+ class Integer
44
+ include OzemmouriPalindrome
45
+ end
46
+
@@ -0,0 +1,4 @@
1
+ module OzemmouriPalindrome
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ozemmouri_palindrome
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Othmane Zemmouri
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Learn Enough palindrome detector.
14
+ email:
15
+ - oth.zemmouri@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Gemfile
21
+ - Gemfile.lock
22
+ - README.md
23
+ - Rakefile
24
+ - lib/ozemmouri_palindrome.rb
25
+ - lib/ozemmouri_palindrome/version.rb
26
+ - sig/ozemmouri_palindrome.rbs
27
+ homepage: https://github.com/ozemmouri/ozemmouri_palindrome
28
+ licenses: []
29
+ metadata:
30
+ allowed_push_host: https://rubygems.org/
31
+ homepage_uri: https://github.com/ozemmouri/ozemmouri_palindrome
32
+ source_code_uri: https://github.com/ozemmouri/ozemmouri_palindrome
33
+ changelog_uri: https://github.com/ozemmouri/ozemmouri_palindrome/blob/main/CHANGELOG.md
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.6.0
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.3.7
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Palindrome detector.
53
+ test_files: []