Skip to content

Commit

Permalink
Migrate to GitHub actions
Browse files Browse the repository at this point in the history
- Add test and publish workflows
- Format codebase using StandardRB
- Add test cases
  • Loading branch information
krmbzds committed Mar 15, 2022
1 parent 8586a33 commit 295aa1f
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 40 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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}}

54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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

1 change: 0 additions & 1 deletion .ruby-gemset

This file was deleted.

1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.1.1
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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].

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
36 changes: 19 additions & 17 deletions guessmail.gemspec
Original file line number Diff line number Diff line change
@@ -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 = ['[email protected]']
spec.name = "guessmail"
spec.version = Guessmail::VERSION
spec.authors = ["Kerem Bozdas"]
spec.email = ["[email protected]"]

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
16 changes: 10 additions & 6 deletions lib/guessmail.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion lib/guessmail/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Guessmail
VERSION = '0.2.0'
VERSION = "0.2.0"
end
34 changes: 32 additions & 2 deletions spec/guessmail_spec.rb
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 295aa1f

Please sign in to comment.