sovren-ruby 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
+ SHA1:
3
+ metadata.gz: 826c8c4566ffddb886a825da361325de687e1ffb
4
+ data.tar.gz: 36ec0270ace9c331872234d737393ea5f936a757
5
+ SHA512:
6
+ metadata.gz: ca33596c3bb5e0255ee32f5626e1d8f024e4be41b9df455874868a69ceabc5d4e8ce2e34214bb209e53ba9323917a0e4c31c7d22bd68aa5a955961c8164807b8
7
+ data.tar.gz: b6798b88ba9391a0caf078f63ee31bb9b806581088b6c7c84ba6211131fcd238575f7f051b9378b1e984aee22547d40c71f1a935f5c7a6c3f20687d615a1b78e
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /xml/
11
+ /json/
12
+ /test/fixtures
13
+ /test/support
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sovren.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,45 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :minitest do
19
+ # with Minitest::Unit
20
+ watch(%r{^test/(.*)\/?test_(.*)\.rb$})
21
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
22
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
23
+
24
+ watch(%r{^lib/(.+).rb$}) { |m| "test/#{m[1]}_test.rb" }
25
+ watch(%r{^test/(.+).rb$}) { |m| "test/#{m[1]}.rb" }
26
+
27
+ # with Minitest::Spec
28
+ # watch(%r{^spec/(.*)_spec\.rb$})
29
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
30
+ # watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
31
+
32
+ # Rails 4
33
+ # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
34
+ # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
35
+ # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
36
+ # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
37
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
38
+ # watch(%r{^test/.+_test\.rb$})
39
+ # watch(%r{^test/test_helper\.rb$}) { 'test' }
40
+
41
+ # Rails < 4
42
+ # watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
43
+ # watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
44
+ # watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
45
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 cqpx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Sovren
2
+
3
+ TODO: Delete this and the text above, and describe your gem
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sovren-ruby', path: 'PATH_TO_THE_GEM'
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ TODO: Write usage instructions here
16
+
17
+ ``` ruby
18
+ @resp = Sovren::Client.new(file,
19
+ account_id: '32215752',
20
+ service_key: 'zwbDwscb0qyc6RoZVeXybBYymzJvTtrA5mcuf6hM',
21
+ )
22
+ @resp.user_info
23
+ @resp.educations
24
+ @resp.employments
25
+ @resp.internships
26
+ @resp.all
27
+ @resp.to_xml
28
+ ```
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sovren"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
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,20 @@
1
+ ##
2
+ # Creates the Sovren initializer file for Rails apps.
3
+ #
4
+ # @example Invokation from terminal
5
+ # rails generate sovren ACCOUNT_ID SERVICE_KEY
6
+ #
7
+ module Sovren
8
+ class InstallGenerator < Rails::Generators::Base
9
+ # Adds current directory to source paths, so we can find the template file.
10
+ source_root File.expand_path('..', __FILE__)
11
+
12
+ argument :account_id, required: false
13
+ argument :service_key, required: false
14
+
15
+ desc 'Configures the Sovren client with your account id and service key'
16
+ def generate_layout
17
+ template 'sovren_initializer.rb.erb', 'config/initializers/sovren.rb'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ Sovren.configure do |c|
2
+ # You must set both account_id & service_key.
3
+ <% if account_id -%>
4
+ c.account_id = <%= account_id %>
5
+ <% else -%>
6
+ c.account_id = Rails.application.secrets.sovren_account_id
7
+ <% end -%>
8
+ <% if service_key -%>
9
+ c.service_key = '<%= service_key %>'
10
+ <% else -%>
11
+ c.service_key = Rails.application.secrets.sovren_service_key
12
+ <% end -%>
13
+ end
data/lib/sovren.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "sovren/version"
2
+ require "savon"
3
+ require "nokogiri"
4
+ require 'active_support/core_ext/hash/conversions'
5
+ require 'json'
6
+ require 'hashie'
7
+
8
+ require 'sovren/client'
9
+ require 'sovren/configuration'
10
+
11
+ module Sovren
12
+ end
@@ -0,0 +1,133 @@
1
+ module Sovren
2
+ class Client
3
+ def initialize file, options={}
4
+ @client = Savon.client(wsdl:"https://services.resumeparsing.com/ParsingService.asmx?WSDL", :log => false)
5
+
6
+ @response = @client.call(:parse_resume, message: { "request" => {
7
+ "AccountId" => Sovren.configuration.account_id,
8
+ "ServiceKey" => Sovren.configuration.service_key,
9
+ "FileBytes" => Base64.encode64(file.read),
10
+ "OutputHtml" => true,
11
+ "Configuration" => nil,
12
+ "RevisionDate" => nil,
13
+ } })
14
+
15
+ @result = @response.to_hash[:parse_resume_response][:parse_resume_result]
16
+
17
+ @doc = Nokogiri::XML(@result[:xml]).remove_namespaces!
18
+ end
19
+
20
+ def all
21
+ {
22
+ user: user_info,
23
+ educations: educations,
24
+ internships: internships,
25
+ employments: employments,
26
+ }
27
+ end
28
+
29
+ def user_info
30
+ majors = {}
31
+
32
+ educations.each do |edu|
33
+ type = edu[:degreeType]
34
+ major = edu[:major]
35
+ if type && major
36
+ if majors[type]
37
+ majors[type] << major
38
+ else
39
+ majors[type] = [major]
40
+ end
41
+ end
42
+ end
43
+
44
+ hsh = {
45
+ first_name: @doc.at_css('PersonName GivenName'),
46
+ last_name: @doc.at_css('PersonName FamilyName'),
47
+ name: @doc.at_css('PersonName FormattedName'),
48
+ phone: @doc.at_css('Telephone FormattedNumber') || @doc.at_css('Mobile FormattedNumber'),
49
+ email: @doc.at_css('InternetEmailAddress'),
50
+ majors: majors
51
+ }
52
+
53
+ format_hash hsh
54
+ end
55
+
56
+ def educations
57
+ @doc.css('SchoolOrInstitution').map do |edu|
58
+ {
59
+ degreeType: edu.at_css('Degree').attr('degreeType'),
60
+ degree: edu.at_css('Degree DegreeName'),
61
+ started_on: edu.at_css('Degree DatesOfAttendance StartDate AnyDate'),
62
+ ended_on: edu.at_css('Degree DatesOfAttendance EndDate AnyDate'),
63
+ major: edu.at_css('Degree DegreeMajor'),
64
+ minor: edu.at_css('Degree DegreeMinor'),
65
+ name: edu.at_css('School SchoolName')
66
+ }
67
+ end.map do |hsh|
68
+ format_hash hsh
69
+ end
70
+ end
71
+
72
+ def internships
73
+ positions 'internship'
74
+ end
75
+
76
+ def employments
77
+ positions 'directHire'
78
+ end
79
+
80
+ def positions type
81
+ @doc.css('PositionHistory').select do |emp|
82
+ emp.attr('positionType') == type
83
+ end.map do |emp|
84
+ {
85
+ "company": emp.at_css('OrgName OrganizationName'),
86
+ "description": emp.at_css('Description'),
87
+ "ended_on": emp.at_css('EndDate AnyDate'),
88
+ "started_on": emp.at_css('StartDate AnyDate'),
89
+ "title": emp.at_css('Title'),
90
+ "current_employer": emp.attr('currentEmployer') == 'true' ? true : false,
91
+ }
92
+ end.map do |hsh|
93
+ format_hash hsh
94
+ end
95
+ end
96
+
97
+ def to_xml
98
+ @result[:xml]
99
+ end
100
+
101
+ private
102
+
103
+ def format_hash hash
104
+ formatted = hash.map do |k, v|
105
+ value = if [:started_on, :ended_on].include? k
106
+ begin
107
+ Date.strptime(v.text.strip, "%Y-%m-%d")
108
+ rescue ArgumentError
109
+ nil
110
+ end
111
+ elsif v.is_a?(Nokogiri::XML::Element)
112
+ if v.text && !v.text.blank?
113
+ v.text.strip
114
+ else
115
+ nil
116
+ end
117
+ elsif v.is_a?(String)
118
+ if v.blank?
119
+ nil
120
+ else
121
+ v.strip
122
+ end
123
+ else
124
+ v
125
+ end
126
+
127
+ [k.to_sym, value]
128
+ end
129
+
130
+ Hash[formatted]
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,19 @@
1
+ module Sovren
2
+ class << self
3
+ attr_accessor :configuration
4
+ end
5
+
6
+ def self.configure
7
+ self.configuration ||= Configuration.new
8
+ yield(configuration)
9
+ end
10
+
11
+ class Configuration
12
+ attr_accessor :account_id, :service_key
13
+
14
+ def initialize
15
+ @account_id = 'donotreply@example.com'
16
+ @service_key = 'donotreply@example.com'
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Sovren
2
+ VERSION = "0.1.0"
3
+ end
data/sovren.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sovren/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sovren-ruby"
8
+ spec.version = Sovren::VERSION
9
+ spec.authors = ["cqpx"]
10
+ spec.email = ["cqpanxu@gmail.com"]
11
+
12
+ spec.summary = %q{Sovren resume parsing API client for Meed Inc.}
13
+ spec.description = %q{Sovren resume parsing API client for Meed Inc.}
14
+ spec.homepage = "http://github.com/cqpx/sovren-ruby"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "activesupport"
31
+ spec.add_dependency "nokogiri"
32
+ spec.add_dependency "savon"
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.11"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "minitest", "~> 5.0"
37
+ spec.add_development_dependency "minitest-reporters"
38
+ spec.add_development_dependency "vcr"
39
+ spec.add_development_dependency "webmock"
40
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sovren-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - cqpx
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: savon
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.11'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.11'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest-reporters
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: vcr
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Sovren resume parsing API client for Meed Inc.
140
+ email:
141
+ - cqpanxu@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".travis.yml"
148
+ - Gemfile
149
+ - Guardfile
150
+ - LICENSE.txt
151
+ - README.md
152
+ - Rakefile
153
+ - bin/console
154
+ - bin/setup
155
+ - lib/generators/sovren/install/install_generator.rb
156
+ - lib/generators/sovren/install/sovren_initializer.rb.erb
157
+ - lib/sovren.rb
158
+ - lib/sovren/client.rb
159
+ - lib/sovren/configuration.rb
160
+ - lib/sovren/version.rb
161
+ - sovren.gemspec
162
+ homepage: http://github.com/cqpx/sovren-ruby
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.5.1
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Sovren resume parsing API client for Meed Inc.
186
+ test_files: []