ruby-superparser 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 +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/generators/ruby_superparser/install_generator.rb +13 -0
- data/lib/generators/ruby_superparser/templates/initializer.rb +4 -0
- data/lib/ruby/superparser/version.rb +7 -0
- data/lib/ruby/superparser.rb +38 -0
- data/ruby-superparser.gemspec +39 -0
- data/sig/ruby/superparser.rbs +6 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dd3ec2e737d36d5496e842dac973746f9db2de3400ba26eff4df4833a96ba01d
|
4
|
+
data.tar.gz: c2b11e0282c9c4d4d8700709939ab5a4dbd364d9fbaff4a33484e81574a5a47c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5729012f101cdeece775f4216cb277573d65d1bee6b49345151ec4999804b71ac9996debfd1f70120e8366332fb7667e4fd65db17c1aea2fcf0d6cf893bd35bd
|
7
|
+
data.tar.gz: 1b5d053e783d85b94a19ff9f822932bc938f5f591707c12cb28a61e57c0c72beffee33691b45d618b1588a0b77b514e69243cf2cecab765d65c58f3cb6f5a68d
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 JP Silvashy
|
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,70 @@
|
|
1
|
+
# Ruby Superparser
|
2
|
+
|
3
|
+
Ruby Superparser is a gem that simplifies making HTTP requests to the SuperParser API for parsing resume documents.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ruby-superparser', git: 'https://github.com/jpsilvashy/ruby-superparser.git'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ gem install ruby-superparser
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
1. Set the `SUPERPARSER_API_KEY` environment variable with your SuperParser API key:
|
28
|
+
|
29
|
+
```sh
|
30
|
+
export SUPERPARSER_API_KEY=your_api_key_here
|
31
|
+
```
|
32
|
+
|
33
|
+
### In a Rails application
|
34
|
+
|
35
|
+
To use this gem in a Rails application, run the generator to create an initializer:
|
36
|
+
|
37
|
+
```sh
|
38
|
+
rails generate ruby_superparser:install
|
39
|
+
```
|
40
|
+
|
41
|
+
This will create a `config/initializers/ruby_superparser.rb` file, which initializes the `SUPERPARSER_CLIENT` constant.
|
42
|
+
|
43
|
+
Now you can use the gem throughout your Rails application:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
json_result = SUPERPARSER_CLIENT.parse_resume('path/to/your/resume.pdf')
|
47
|
+
puts json_result
|
48
|
+
```
|
49
|
+
|
50
|
+
### In other Ruby applications
|
51
|
+
|
52
|
+
In other Ruby applications, create a `Client` instance and use it to parse resumes:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
require 'ruby_superparser'
|
56
|
+
|
57
|
+
api_key = ENV['SUPERPARSER_API_KEY']
|
58
|
+
client = RubySuperparser::Client.new(api_key)
|
59
|
+
json_result = client.parse_resume('path/to/your/resume.pdf')
|
60
|
+
puts json_result
|
61
|
+
```
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jpsilvashy/ruby-superparser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/jpsilvashy/ruby-superparser/blob/main/CODE_OF_CONDUCT.md).
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
The gem is available as open-source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
70
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "ruby/superparser"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# lib/generators/ruby_superparser/install_generator.rb
|
2
|
+
|
3
|
+
require 'rails/generators/base'
|
4
|
+
|
5
|
+
module RubySuperparser
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
8
|
+
|
9
|
+
def create_initializer_file
|
10
|
+
copy_file 'initializer.rb', 'config/initializers/ruby_superparser.rb'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# lib/ruby_superparser.rb
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'net/http/post/multipart'
|
5
|
+
|
6
|
+
module RubySuperparser
|
7
|
+
class Client
|
8
|
+
API_URL = 'https://api.superparser.com/parse'.freeze
|
9
|
+
|
10
|
+
def initialize(api_key)
|
11
|
+
@api_key = api_key
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse_resume(file_path)
|
15
|
+
uri = URI(API_URL)
|
16
|
+
|
17
|
+
request = Net::HTTP::Post::Multipart.new(uri.path,
|
18
|
+
'file_name' => UploadIO.new(File.open(file_path), 'application/pdf')
|
19
|
+
)
|
20
|
+
request['accept'] = 'application/json'
|
21
|
+
request['X-API-Key'] = @api_key
|
22
|
+
request['Content-Type'] = 'multipart/form-data'
|
23
|
+
|
24
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
25
|
+
http.use_ssl = true
|
26
|
+
|
27
|
+
response = http.request(request)
|
28
|
+
|
29
|
+
if response.is_a?(Net::HTTPSuccess)
|
30
|
+
puts 'Successfully parsed the document'
|
31
|
+
return response.body
|
32
|
+
else
|
33
|
+
puts 'Failed to parse the document'
|
34
|
+
return nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/ruby/superparser/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ruby-superparser"
|
7
|
+
spec.version = Ruby::Superparser::VERSION
|
8
|
+
spec.authors = ["JP Silvashy"]
|
9
|
+
spec.email = ["jpsilvashy@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{A Ruby client for the SuperParser API}
|
12
|
+
spec.description = %q{The Ruby Superparser gem simplifies making HTTP requests to the SuperParser API for parsing resume documents.}
|
13
|
+
spec.homepage = "https://github.com/jpsilvashy/ruby-superparser"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = "https://github.com/jpsilvashy/ruby-superparser"
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/jpsilvashy/ruby-superparser"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/jpsilvashy/ruby-superparser/blob/main/CHANGELOG.md"
|
19
|
+
|
20
|
+
spec.required_ruby_version = ">= 2.6.0"
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
# Uncomment to register a new dependency of your gem
|
34
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
35
|
+
spec.add_development_dependency 'rails', '>= 6.0'
|
36
|
+
|
37
|
+
# For more information and examples about making a new gem, checkout our
|
38
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-superparser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- JP Silvashy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-04-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.0'
|
27
|
+
description: The Ruby Superparser gem simplifies making HTTP requests to the SuperParser
|
28
|
+
API for parsing resume documents.
|
29
|
+
email:
|
30
|
+
- jpsilvashy@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".rspec"
|
36
|
+
- CHANGELOG.md
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE.txt
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- bin/console
|
42
|
+
- bin/setup
|
43
|
+
- lib/generators/ruby_superparser/install_generator.rb
|
44
|
+
- lib/generators/ruby_superparser/templates/initializer.rb
|
45
|
+
- lib/ruby/superparser.rb
|
46
|
+
- lib/ruby/superparser/version.rb
|
47
|
+
- ruby-superparser.gemspec
|
48
|
+
- sig/ruby/superparser.rbs
|
49
|
+
homepage: https://github.com/jpsilvashy/ruby-superparser
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata:
|
53
|
+
homepage_uri: https://github.com/jpsilvashy/ruby-superparser
|
54
|
+
source_code_uri: https://github.com/jpsilvashy/ruby-superparser
|
55
|
+
changelog_uri: https://github.com/jpsilvashy/ruby-superparser/blob/main/CHANGELOG.md
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.6.0
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubygems_version: 3.2.33
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: A Ruby client for the SuperParser API
|
75
|
+
test_files: []
|