diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..f3fbf1b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + build: + name: Publish Packages + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Publish to RubyGems + uses: dawidd6/action-publish-gem@v1 + with: + api_key: ${{secrets.RUBYGEMS_AUTH_TOKEN}} + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1f48ab1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,54 @@ +name: Test + +on: + pull_request: + + push: + branches: [ develop, master ] + +env: + GIT_COMMIT_SHA: ${{ github.sha }} + GIT_BRANCH: ${{ github.ref }} + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + +jobs: + + lint: + runs-on: ubuntu-latest + name: lint ${{ matrix.ruby }} + strategy: + fail-fast: false + matrix: + ruby: [ '2.6.9', '2.7.5', '3.0.3', '3.1.1' ] + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: StandardRB + continue-on-error: ${{ matrix.experimental }} + run: bundle exec standardrb --parallel --format progress + + test: + needs: [ lint ] + runs-on: ubuntu-latest + name: test ${{ matrix.ruby }} + strategy: + fail-fast: false + matrix: + ruby: [ '2.6.9', '2.7.5', '3.0.3', '3.1.1' ] + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Test + continue-on-error: ${{ matrix.experimental }} + run: bundle exec rake + diff --git a/.ruby-gemset b/.ruby-gemset deleted file mode 100644 index 55fdc27..0000000 --- a/.ruby-gemset +++ /dev/null @@ -1 +0,0 @@ -guessmail diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index bff6ce5..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -ruby-2.7.1 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..e7f4c11 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.1.1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8e27c59..0000000 --- a/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: ruby -rvm: - - 2.7.1 diff --git a/Gemfile b/Gemfile index 26b1452..9a4f4dc 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" # Specify your gem's dependencies in guessmail.gemspec gemspec diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..4481351 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Kerem Bozdas + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index e68ae0f..a81b737 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # Guessmail 💌 -[![Travis](https://img.shields.io/travis/krmbzds/guessmail.svg)](https://travis-ci.org/krmbzds/guessmail) -[![Gem](https://img.shields.io/gem/dt/guessmail.svg)](https://rubygems.org/gems/guessmail) -[![Gem](https://img.shields.io/gem/v/guessmail.svg)](https://rubygems.org/gems/guessmail) +[![Build Status](https://img.shields.io/github/workflow/status/krmbzds/guessmail/Test/master)](https://github.com/krmbzds/guessmail/actions/workflows/test.yml) +[![Coveralls](https://img.shields.io/coveralls/github/krmbzds/guessmail)](https://coveralls.io/github/krmbzds/guessmail) +[![Maintainability](https://img.shields.io/codeclimate/maintainability/krmbzds/guessmail.svg)](https://codeclimate.com/github/krmbzds/guessmail/maintainability) +[![Downloads](https://img.shields.io/gem/dt/guessmail.svg)](https://rubygems.org/gems/guessmail) +[![Gem Version](https://img.shields.io/gem/v/guessmail.svg)](https://rubygems.org/gems/guessmail) + [**guessmail**][Guessmail] helps you find possible email addresses of a person. @@ -101,7 +104,7 @@ You can donate me at [Liberapay][Donation]. Thanks! ☕️ ## License -Copyright © 2016-2020 [Kerem Bozdas][Personal Webpage] +Copyright © 2016-2022 [Kerem Bozdas][Personal Webpage] This project is available under the terms of the [MIT License][License]. diff --git a/Rakefile b/Rakefile index 82bb534..b6ae734 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'bundler/gem_tasks' -require 'rspec/core/rake_task' +require "bundler/gem_tasks" +require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) diff --git a/guessmail.gemspec b/guessmail.gemspec index 00d7523..9b03912 100644 --- a/guessmail.gemspec +++ b/guessmail.gemspec @@ -1,26 +1,28 @@ # frozen_string_literal: true -lib = File.expand_path('lib', __dir__) +lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'guessmail/version' +require "guessmail/version" Gem::Specification.new do |spec| - spec.name = 'guessmail' - spec.version = Guessmail::VERSION - spec.authors = ['Kerem Bozdas'] - spec.email = ['krmbzds.github@gmail.com'] + spec.name = "guessmail" + spec.version = Guessmail::VERSION + spec.authors = ["Kerem Bozdas"] + spec.email = ["krmbzds.github@gmail.com"] - spec.summary = "Find anyone's email address" - spec.description = "Find anyone's email address" - spec.homepage = 'https://github.com/krmbzds/guessmail' + spec.summary = "Find anyone's email address" + spec.description = "Find anyone's email address" + spec.homepage = "https://github.com/krmbzds/guessmail" - spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - spec.bindir = 'bin' - spec.executables = ['guessmail'] - spec.require_paths = ['lib'] + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + spec.bindir = "bin" + spec.executables = ["guessmail"] + spec.require_paths = ["lib"] - spec.add_runtime_dependency 'tate', '~> 1.6.0' - spec.add_development_dependency 'bundler' - spec.add_development_dependency 'rake' - spec.add_development_dependency 'rspec' + spec.add_runtime_dependency "tate", "~> 1.7.0" + spec.add_development_dependency "bundler" + spec.add_development_dependency "rake" + spec.add_development_dependency "rspec" + spec.add_development_dependency "standardrb" + spec.add_development_dependency "coveralls_reborn" end diff --git a/lib/guessmail.rb b/lib/guessmail.rb index ab9b6eb..1903ed7 100644 --- a/lib/guessmail.rb +++ b/lib/guessmail.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -lib = File.expand_path(File.dirname(__FILE__) + '/../lib') +lib = File.expand_path(File.dirname(__FILE__) + "/../lib") $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib) -require 'guessmail/version' -require 'tate' -require 'templates' +require "guessmail/version" +require "tate" +require "templates" module Guessmail def self.guess(names, options) @@ -16,8 +16,12 @@ def self.guess(names, options) ln = names.pop mn = names.pop - params = { fn: fn, mn: mn, ln: ln, fi: fn[0], mi: (mn[0] if mn), li: ln[0], dn: dn } - template = options[:extended] ? (mn ? FMLE : FLE) : (mn ? FL : FML) + params = {fn: fn, mn: mn, ln: ln, fi: fn[0], mi: (mn[0] if mn), li: ln[0], dn: dn} + template = if options[:extended] + mn ? FMLE : FLE + else + (mn ? FML : FL) + end string = format(template, params) Tate.transliterate(string, options[:language]) diff --git a/lib/guessmail/version.rb b/lib/guessmail/version.rb index 8ef652d..7a5282d 100644 --- a/lib/guessmail/version.rb +++ b/lib/guessmail/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Guessmail - VERSION = '0.2.0' + VERSION = "0.2.0" end diff --git a/spec/guessmail_spec.rb b/spec/guessmail_spec.rb index 444b60d..b683a04 100644 --- a/spec/guessmail_spec.rb +++ b/spec/guessmail_spec.rb @@ -1,9 +1,39 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" describe Guessmail do - it 'has a version number' do + it "has a version number" do expect(Guessmail::VERSION).not_to be nil end + + it "returns guesses" do + guess = Guessmail.guess(["F", "L", "D"], {extended: false}) + expected = "f@d\nl@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nlf@d\nl.f@d\n" + expect(guess).to eq expected + end + + it "returns extended guesses" do + guess = Guessmail.guess(["F", "L", "D"], {extended: true}) + expected = "f@d\nl@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nf-l@d\nf-l@d\nf-l@d\nf-l@d\nl-f@d\nl-f@d\nl-f@d\nl-f@d\nf_l@d\nf_l@d\nf_l@d\nf_l@d\nl_f@d\nl_f@d\nl_f@d\nl_f@d\n" + expect(guess).to eq expected + end + + it "returns guesses with middle name" do + guess = Guessmail.guess(["F", "M", "L", "D"], {extended: false}) + expected = "f@d\nl@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nfml@d\nfm.l@d\nfml@d\nf.m.l@d\nfml@d\nf.m.l@d\nm@d\n" + expect(guess).to eq expected + end + + it "returns extended guesses with middle name" do + guess = Guessmail.guess(["F", "M", "L", "D"], {extended: true}) + expected = "f@d\nl@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nfl@d\nf.l@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nlf@d\nl.f@d\nfml@d\nfm.l@d\nfml@d\nf.m.l@d\nfml@d\nf.m.l@d\nf-l@d\nf-l@d\nf-l@d\nf-l@d\nl-f@d\nl-f@d\nl-f@d\nl-f@d\nfm-l@d\nf-m-l@d\nf-m-l@d\nf_l@d\nf_l@d\nf_l@d\nf_l@d\nl_f@d\nl_f@d\nl_f@d\nl_f@d\nfm_l@d\nf_m_l@d\nf_m_l@d\nm@d\n" + expect(guess).to eq expected + end + + it "returns guesses for custom language" do + guess = Guessmail.guess(["Ö", "Ü", "D"], {extended: false, language: "de"}) + expected = "oe@d\nue@d\noeue@d\noe.ue@d\noeue@d\noe.ue@d\noeue@d\noe.ue@d\noeue@d\noe.ue@d\nueoe@d\nue.oe@d\nueoe@d\nue.oe@d\nueoe@d\nue.oe@d\nueoe@d\nue.oe@d\n" + expect(guess).to eq expected + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5544456..47baed9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,7 @@ # frozen_string_literal: true -$LOAD_PATH.unshift File.expand_path('../lib', __dir__) -require 'guessmail' +require "coveralls" +Coveralls.wear! + +$LOAD_PATH.unshift File.expand_path("../lib", __dir__) +require "guessmail"