similaritybairesdev 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: 76abf005ac2a81816acf431410323b011627b62689b70077eef02a26aff9b015
4
+ data.tar.gz: 6adabfcea5c91fea922b9fa79f1af740d3693897d77cd46f6425cd19a83173a3
5
+ SHA512:
6
+ metadata.gz: e09a07e96bbf2207ab2b2f1af823bf2be7c978fde0b968bb1a57924280f06b7e6f47ae6182cdd56ca52aa464e7e1788badaa1c2a7a5bce526a8d11b599a85dfd
7
+ data.tar.gz: 2b54a2c564890b6419f88759b7343e149deaf3727e60c8080da8e31d18194f212cccd374e26e57f8f1093402ed169aa7e6929aed70bdbd6c2565ef18ad583bcb
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,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in similaritybairesdev.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Similaritybairesdev
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/similaritybairesdev`. 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
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'similaritybairesdev'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install similaritybairesdev
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/similaritybairesdev.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
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 "similaritybairesdev"
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,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "similaritybairesdev/version"
4
+
5
+ module Similaritybairesdev
6
+ def distance_to(word)
7
+ raise StandardError.new "Initial string cannot be empty, do not use ''.distance_to('word')" if self.empty?
8
+ raise StandardError.new "Argument cannot be empty: Do not use 'myString'.distance_to('')" if word.empty?
9
+
10
+ return 0 if self == word
11
+
12
+ m = self.length
13
+ n = word.length
14
+
15
+ #ASK Thiago about this syntax
16
+ d = Array.new(m + 1) { Array.new(n + 1) }
17
+
18
+ (0..m).each { |i| d[i][0] = i }
19
+ (0..n).each { |j| d[0][j] = j }
20
+ (1..n).each do |j|
21
+ (1..m).each do |i|
22
+ d[i][j] = if self[i - 1] == word[j - 1]
23
+ d[i - 1][j - 1]
24
+ else
25
+ [d[i - 1][j] + 1,
26
+ d[i][j - 1] + 1,
27
+ d[i - 1][j - 1] + 1].min
28
+ end
29
+ end
30
+ end
31
+ d[m][n]
32
+ end
33
+ end
34
+
35
+
36
+ class String
37
+ include Similaritybairesdev
38
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Similaritybairesdev
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/similaritybairesdev/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "similaritybairesdev"
7
+ spec.version = Similaritybairesdev::VERSION
8
+ spec.authors = ["Reinaldo"]
9
+ spec.email = ["reinaldoacosta93@hotmail.com"]
10
+
11
+ spec.summary = "Write a short summary, because RubyGems requires one."
12
+ spec.description = "Write a longer description or delete this line."
13
+ spec.homepage = "https://github.com/reinaldoacosta/Similarity"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
15
+
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/reinaldoacosta/Similarity"
19
+ spec.metadata["changelog_uri"] = "https://github.com/reinaldoacosta/Similarity/CHANGELOG.md"
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
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: similaritybairesdev
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Reinaldo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-04-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Write a longer description or delete this line.
14
+ email:
15
+ - reinaldoacosta93@hotmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - README.md
23
+ - Rakefile
24
+ - bin/console
25
+ - bin/setup
26
+ - lib/similaritybairesdev.rb
27
+ - lib/similaritybairesdev/version.rb
28
+ - similaritybairesdev.gemspec
29
+ homepage: https://github.com/reinaldoacosta/Similarity
30
+ licenses: []
31
+ metadata:
32
+ homepage_uri: https://github.com/reinaldoacosta/Similarity
33
+ source_code_uri: https://github.com/reinaldoacosta/Similarity
34
+ changelog_uri: https://github.com/reinaldoacosta/Similarity/CHANGELOG.md
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.4.0
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 2.7.6
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: Write a short summary, because RubyGems requires one.
55
+ test_files: []