genderize_io_rb 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "http2"
7
+ gem "json"
8
+ gem "string-cases"
9
+
10
+ # Add dependencies to develop your gem here.
11
+ # Include everything needed to run rake, tests, features, etc.
12
+ group :development do
13
+ gem "rspec", "~> 2.8.0"
14
+ gem "rdoc", "~> 3.12"
15
+ gem "bundler", ">= 1.0.0"
16
+ gem "jeweler", :git => "https://github.com/technicalpickles/jeweler.git"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,73 @@
1
+ GIT
2
+ remote: https://github.com/technicalpickles/jeweler.git
3
+ revision: f7e0a55a207d83f56637dd8fbabf26a803410faf
4
+ specs:
5
+ jeweler (1.8.7)
6
+ builder
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ github_api (= 0.10.1)
10
+ highline (>= 1.6.15)
11
+ nokogiri (= 1.5.10)
12
+ rake
13
+ rdoc
14
+
15
+ GEM
16
+ remote: http://rubygems.org/
17
+ specs:
18
+ addressable (2.3.5)
19
+ builder (3.2.2)
20
+ diff-lcs (1.1.3)
21
+ faraday (0.8.8)
22
+ multipart-post (~> 1.2.0)
23
+ git (1.2.6)
24
+ github_api (0.10.1)
25
+ addressable
26
+ faraday (~> 0.8.1)
27
+ hashie (>= 1.2)
28
+ multi_json (~> 1.4)
29
+ nokogiri (~> 1.5.2)
30
+ oauth2
31
+ hashie (2.0.5)
32
+ highline (1.6.19)
33
+ http2 (0.0.22)
34
+ httpauth (0.2.0)
35
+ json (1.8.0)
36
+ jwt (0.1.8)
37
+ multi_json (>= 1.5)
38
+ multi_json (1.7.9)
39
+ multi_xml (0.5.5)
40
+ multipart-post (1.2.0)
41
+ nokogiri (1.5.10)
42
+ oauth2 (0.9.2)
43
+ faraday (~> 0.8)
44
+ httpauth (~> 0.2)
45
+ jwt (~> 0.1.4)
46
+ multi_json (~> 1.0)
47
+ multi_xml (~> 0.5)
48
+ rack (~> 1.2)
49
+ rack (1.5.2)
50
+ rake (10.1.0)
51
+ rdoc (3.12.2)
52
+ json (~> 1.4)
53
+ rspec (2.8.0)
54
+ rspec-core (~> 2.8.0)
55
+ rspec-expectations (~> 2.8.0)
56
+ rspec-mocks (~> 2.8.0)
57
+ rspec-core (2.8.0)
58
+ rspec-expectations (2.8.0)
59
+ diff-lcs (~> 1.1.2)
60
+ rspec-mocks (2.8.0)
61
+ string-cases (0.0.0)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ bundler (>= 1.0.0)
68
+ http2
69
+ jeweler!
70
+ json
71
+ rdoc (~> 3.12)
72
+ rspec (~> 2.8.0)
73
+ string-cases
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Kasper Johansen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = genderize_io_rb
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to genderize_io_rb
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * 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.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Kasper Johansen. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "genderize_io_rb"
18
+ gem.homepage = "http://github.com/kaspernj/genderize_io_rb"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A small Gem that makes it possible to determine gender from a name via the Genderize.io service.}
21
+ gem.description = %Q{A small Gem that makes it possible to determine gender from a name via the Genderize.io service.}
22
+ gem.email = "kaspernj@gmail.com"
23
+ gem.authors = ["Kasper Johansen"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "genderize_io_rb #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.4
data/include/result.rb ADDED
@@ -0,0 +1,29 @@
1
+ class GenderizeIoRb::Result
2
+ def initialize(args)
3
+ @args = args
4
+ end
5
+
6
+ def genderize_io_rb
7
+ return @args[:genderize_io_rb]
8
+ end
9
+
10
+ def name
11
+ return @args[:data]["name"]
12
+ end
13
+
14
+ def gender
15
+ return @args[:data]["gender"]
16
+ end
17
+
18
+ def probability
19
+ return @args[:data]["probability"].to_f
20
+ end
21
+
22
+ def count
23
+ return @args[:data]["count"].to_i
24
+ end
25
+
26
+ def to_s
27
+ return "#<GenderizeIoRb::Result::#{@args[:data]}>"
28
+ end
29
+ end
@@ -0,0 +1,33 @@
1
+ require "http2" unless ::Kernel.const_defined?(:Http2)
2
+ require "cgi" unless ::Kernel.const_defined?(:CGI)
3
+ require "json" unless ::Kernel.const_defined?(:JSON)
4
+ require "string-cases" unless ::Kernel.const_defined?(:StringCases)
5
+
6
+ class GenderizeIoRb
7
+ def self.const_missing(name)
8
+ require_relative "../include/#{::StringCases.camel_to_snake(name)}"
9
+ raise LoadError, "Still not defined: '#{name}'." unless ::GenderizeIoRb.const_defined?(name)
10
+ return ::GenderizeIoRb.const_get(name)
11
+ end
12
+
13
+ def initialize(args = {})
14
+ @args = args
15
+
16
+ @http = Http2.new(
17
+ :host => "api.genderize.io"
18
+ )
19
+ end
20
+
21
+ def info_for_name(name)
22
+ res = @http.get("?name=#{CGI.escape(name)}")
23
+
24
+ return ::GenderizeIoRb::Result.new(
25
+ :data => JSON.parse(res.body),
26
+ :genderize_io_rb => self
27
+ )
28
+ end
29
+
30
+ def destroy
31
+ @http.close
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "GenderizeIoRb" do
4
+ it "can detect various names" do
5
+ gir = GenderizeIoRb.new
6
+
7
+ res = gir.info_for_name("kasper")
8
+ res.name.should eql("kasper")
9
+ res.gender.should eql("male")
10
+
11
+ res = gir.info_for_name("christina")
12
+ res.name.should eql("christina")
13
+ res.gender.should eql("female")
14
+
15
+ gir.destroy
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'genderize_io_rb'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: genderize_io_rb
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.4
6
+ platform: ruby
7
+ authors:
8
+ - Kasper Johansen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ none: false
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ name: http2
22
+ type: :runtime
23
+ prerelease: false
24
+ requirement: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ name: json
38
+ type: :runtime
39
+ prerelease: false
40
+ requirement: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ name: string-cases
54
+ type: :runtime
55
+ prerelease: false
56
+ requirement: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.8.0
69
+ name: rspec
70
+ type: :development
71
+ prerelease: false
72
+ requirement: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.8.0
78
+ - !ruby/object:Gem::Dependency
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ~>
83
+ - !ruby/object:Gem::Version
84
+ version: '3.12'
85
+ name: rdoc
86
+ type: :development
87
+ prerelease: false
88
+ requirement: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '3.12'
94
+ - !ruby/object:Gem::Dependency
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: 1.0.0
101
+ name: bundler
102
+ type: :development
103
+ prerelease: false
104
+ requirement: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.0.0
110
+ - !ruby/object:Gem::Dependency
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ name: jeweler
118
+ type: :development
119
+ prerelease: false
120
+ requirement: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: A small Gem that makes it possible to determine gender from a name via
127
+ the Genderize.io service.
128
+ email: kaspernj@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files:
132
+ - LICENSE.txt
133
+ - README.rdoc
134
+ files:
135
+ - .document
136
+ - .rspec
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - LICENSE.txt
140
+ - README.rdoc
141
+ - Rakefile
142
+ - VERSION
143
+ - include/result.rb
144
+ - lib/genderize_io_rb.rb
145
+ - spec/genderize_io_rb_spec.rb
146
+ - spec/spec_helper.rb
147
+ homepage: http://github.com/kaspernj/genderize_io_rb
148
+ licenses:
149
+ - MIT
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ segments:
160
+ - 0
161
+ hash: 296559983704932826
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ! '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 1.8.23
172
+ signing_key:
173
+ specification_version: 3
174
+ summary: A small Gem that makes it possible to determine gender from a name via the
175
+ Genderize.io service.
176
+ test_files: []