0.01
No commit activity in last 3 years
No release in over 3 years
A small Gem that makes it possible to determine gender from a name via the Genderize.io service.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.0.12
>= 1.0.0
~> 3.12
~> 2.8.0

Runtime

 Project Readme

Code Climate Test Coverage Build Status

GenderizeIoRb

Start by adding it to your Gemfile and bundle it:

gem 'genderize_io_rb'

Now check a name like this:

gir = GenderizeIoRb.new
res = gir.info_for_name("kasper")
puts "Name: #{res.name}"
puts "Gender: #{res.gender}"

It is also possible to look multiple names up:

GenderizeIoRb.new do |gir|
  gir.info_for_names(["kasper", "christina"]).each do |result|
    puts "Name: #{result.name}"
    puts "Gender: #{result.gender}"
  end
end

You can attach a database-cache through a Baza::Db if Genderize is a bit slow:

# SQLite3 database will automatically be created with table and everything. If an existing db is given, the table will automatically be created within it.
Baza::Db.new(type: "sqlite3", path: path) do |db|
  GenderizeIoRb.new(cache_db: db) do |gir|
    # First request will be done through a HTTP request:
    first_result = gir.info_for_name("kasper")
    puts "Through HTTP?: #{first_result.from_http_request?}"

    # Second result will be done by a
    second_result = gir.info_for_name("kasper")
    puts "Through DB cache? #{second_result.from_cache_db?}"
  end
end

If you need the connections to be kept open:

db = Baza::Db.new(type: "sqlite3", path: path)
gir = GenderizeIoRb.new(cache_db: db)

Contributing to genderize_io_rb

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2013 Kasper Johansen. See LICENSE.txt for further details.