danieljackson_learning_palindrome 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b0409c21836af7a160b20054bbe99549bbf97bd8fa637cf2399d164d40cbed9f
4
+ data.tar.gz: a71687fe7fe91625428c3b93b20fff0963386fada641f8906d505f45935ae798
5
+ SHA512:
6
+ metadata.gz: b0f33e360f38f4eb7ae8d9765ebafab2bf9a3208c27d257a83692edf9ec285307baa23cc4017f90c97e7fd7dcb8445202aae80e880280aa51e218a1fb3394562
7
+ data.tar.gz: 50992b8eb32c1a6332bac5d11a864e13f52e3ccc4c374a10ff7e0ec6debc703d555768b5f8d79cbce68a11981d41c3eb304ed9b090e4157e8690867f737c1d2f
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in danieljackson_learning_palindrome.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+ gem 'minitest-reporters', '1.2.0'
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danieljackson_learning_palindrome (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ansi (1.5.0)
10
+ builder (3.2.4)
11
+ minitest (5.14.4)
12
+ minitest-reporters (1.2.0)
13
+ ansi
14
+ builder
15
+ minitest (>= 5.0)
16
+ ruby-progressbar
17
+ rake (13.0.6)
18
+ ruby-progressbar (1.11.0)
19
+
20
+ PLATFORMS
21
+ arm64-darwin-20
22
+
23
+ DEPENDENCIES
24
+ danieljackson_learning_palindrome!
25
+ minitest (~> 5.0)
26
+ minitest-reporters (= 1.2.0)
27
+ rake (~> 13.0)
28
+
29
+ BUNDLED WITH
30
+ 2.2.24
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Daniel Jackson
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,71 @@
1
+ # DanieljacksonLearningPalindrome
2
+
3
+ This simply extends String and Integer objects with a .palindrome? method.
4
+
5
+ The palindrome? method returns a boolean if the string or integer is a palindrome, that is, if it is the same in reverse.
6
+
7
+ It normalizes the string (or number) first, so that CaSiNg or formatting like commas or periods no longer matters.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'danieljackson_learning_palindrome'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install danieljackson_learning_palindrome
24
+
25
+ ## Usage
26
+
27
+
28
+ Example usage:
29
+
30
+ ```ruby
31
+
32
+ # Casing is ignored. Racecar with an upper case R works as well as racecar with a lower case r.
33
+ "racecar".palindrome?
34
+ # >> True
35
+ "Racecar".palindrome?
36
+ # >> True
37
+
38
+ # Non palindromes, of course, return False
39
+ "Horse".palindrome?
40
+ # >> False
41
+
42
+ # Punctuation is ignored
43
+ "Racecar!".palindrome?
44
+ # >> True
45
+
46
+ # Integers work
47
+ 12321.palindrome?
48
+ # >> True
49
+ 223.palindrome?
50
+ # >> False
51
+
52
+ # And floats:
53
+ 131.131.palindrome?
54
+ # >> True
55
+
56
+
57
+ ```
58
+
59
+ ## Development
60
+
61
+ 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.
62
+
63
+ 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).
64
+
65
+ ## Contributing
66
+
67
+ Bug reports and pull requests are welcome on GitHub at https://github.com/danieljackson/tutorial_palindrome.
68
+
69
+ ## License
70
+
71
+ 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
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "danieljackson_learning_palindrome"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/danieljackson_learning_palindrome/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "danieljackson_learning_palindrome"
7
+ spec.version = DanieljacksonLearningPalindrome::VERSION
8
+ spec.authors = ["Daniel Jackson"]
9
+ spec.email = ["daniel@snilldesign.no"]
10
+
11
+ spec.summary = "A tiny demo gem generating palindromes, from the learnenough.com Ruby course."
12
+ spec.homepage = "https://github.com/DanielJackson-Oslo/tutorial_palindrome"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 2.4.0"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/DanielJackson-Oslo/tutorial_palindrome"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # Uncomment to register a new dependency of your gem
31
+ # spec.add_dependency "example-gem", "~> 1.0"
32
+
33
+ # For more information and examples about making a new gem, checkout our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
@@ -0,0 +1,5 @@
1
+ require_relative "palindrome"
2
+
3
+ class Float
4
+ include Palindrome
5
+ end
@@ -0,0 +1,5 @@
1
+ require_relative "palindrome"
2
+
3
+ class Integer
4
+ include Palindrome
5
+ end
@@ -0,0 +1,5 @@
1
+ require_relative "palindrome"
2
+
3
+ class String
4
+ include Palindrome
5
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "danieljackson_learning_palindrome/version"
4
+ require_relative "String_palindrome"
5
+ require_relative "Float_palindrome"
6
+ require_relative "Integer_palindrome"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DanieljacksonLearningPalindrome
4
+ VERSION = "0.1.0"
5
+ end
data/lib/palindrome.rb ADDED
@@ -0,0 +1,18 @@
1
+ # Palindrome module to add
2
+ # palindrome? boolean for
3
+ # any string or integer or
4
+ # compatible class.
5
+ module Palindrome
6
+
7
+ def palindrome?
8
+ process_before_palindrome_test == process_before_palindrome_test.reverse
9
+ end
10
+
11
+ private
12
+
13
+ def process_before_palindrome_test
14
+ # Remove any non-alpha-numeric characters, and normalize to a downcase string
15
+ to_s.downcase.gsub(/[^[[:alnum:]]]/, "")
16
+ end
17
+
18
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danieljackson_learning_palindrome
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Jackson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-07-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - daniel@snilldesign.no
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - Gemfile.lock
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - bin/console
27
+ - bin/setup
28
+ - danieljackson_learning_palindrome.gemspec
29
+ - lib/Float_palindrome.rb
30
+ - lib/Integer_palindrome.rb
31
+ - lib/String_palindrome.rb
32
+ - lib/danieljackson_learning_palindrome.rb
33
+ - lib/danieljackson_learning_palindrome/version.rb
34
+ - lib/palindrome.rb
35
+ homepage: https://github.com/DanielJackson-Oslo/tutorial_palindrome
36
+ licenses:
37
+ - MIT
38
+ metadata:
39
+ allowed_push_host: https://rubygems.org/
40
+ homepage_uri: https://github.com/DanielJackson-Oslo/tutorial_palindrome
41
+ source_code_uri: https://github.com/DanielJackson-Oslo/tutorial_palindrome
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.4.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.2.22
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: A tiny demo gem generating palindromes, from the learnenough.com Ruby course.
61
+ test_files: []