super_parser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 96a8d2e66a7bfe201bbeea71c95735a1cc3ba07743146298af615f7c23d9ae12
4
+ data.tar.gz: ec1e3dcf883fe8315a1c553465b834064426c5308d1664374ee2c8328ca6c747
5
+ SHA512:
6
+ metadata.gz: 0161adf0fe415fc5a687ddad10e2d753d92038ecdcb90fc9797537969c69e34870300a4a8971ab5e9e96e585f8c8d91da935fffd1b3cfdf420f8b9d13f6a713b
7
+ data.tar.gz: 2c7ef0440683534a43213c7f583ae9c61b6bfeff3cbffce5109187ce189e65c2ec225c71fd8485ba3df236372542d0ca9eeafa9f2bdebb13d167dbca3fe221b6
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,2 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-06-20
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at watling.james@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in super_parser.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "standard", "~> 1.3"
data/Gemfile.lock ADDED
@@ -0,0 +1,75 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ super_parser (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.0)
11
+ json (2.6.3)
12
+ language_server-protocol (3.17.0.3)
13
+ lint_roller (1.0.0)
14
+ parallel (1.23.0)
15
+ parser (3.2.2.3)
16
+ ast (~> 2.4.1)
17
+ racc
18
+ racc (1.7.1)
19
+ rainbow (3.1.1)
20
+ rake (13.0.6)
21
+ regexp_parser (2.8.1)
22
+ rexml (3.2.5)
23
+ rspec (3.12.0)
24
+ rspec-core (~> 3.12.0)
25
+ rspec-expectations (~> 3.12.0)
26
+ rspec-mocks (~> 3.12.0)
27
+ rspec-core (3.12.2)
28
+ rspec-support (~> 3.12.0)
29
+ rspec-expectations (3.12.3)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.12.0)
32
+ rspec-mocks (3.12.5)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.12.0)
35
+ rspec-support (3.12.0)
36
+ rubocop (1.50.2)
37
+ json (~> 2.3)
38
+ parallel (~> 1.10)
39
+ parser (>= 3.2.0.0)
40
+ rainbow (>= 2.2.2, < 4.0)
41
+ regexp_parser (>= 1.8, < 3.0)
42
+ rexml (>= 3.2.5, < 4.0)
43
+ rubocop-ast (>= 1.28.0, < 2.0)
44
+ ruby-progressbar (~> 1.7)
45
+ unicode-display_width (>= 2.4.0, < 3.0)
46
+ rubocop-ast (1.29.0)
47
+ parser (>= 3.2.1.0)
48
+ rubocop-performance (1.16.0)
49
+ rubocop (>= 1.7.0, < 2.0)
50
+ rubocop-ast (>= 0.4.0)
51
+ ruby-progressbar (1.13.0)
52
+ standard (1.28.5)
53
+ language_server-protocol (~> 3.17.0.2)
54
+ lint_roller (~> 1.0)
55
+ rubocop (~> 1.50.2)
56
+ standard-custom (~> 1.0.0)
57
+ standard-performance (~> 1.0.1)
58
+ standard-custom (1.0.1)
59
+ lint_roller (~> 1.0)
60
+ standard-performance (1.0.1)
61
+ lint_roller (~> 1.0)
62
+ rubocop-performance (~> 1.16.0)
63
+ unicode-display_width (2.4.2)
64
+
65
+ PLATFORMS
66
+ universal-darwin-21
67
+
68
+ DEPENDENCIES
69
+ rake (~> 13.0)
70
+ rspec (~> 3.0)
71
+ standard (~> 1.3)
72
+ super_parser!
73
+
74
+ BUNDLED WITH
75
+ 2.2.32
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 James Watling
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,43 @@
1
+ # SuperParser
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/super_parser`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'super_parser'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install super_parser
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/super_parser. 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/[USERNAME]/super_parser/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the SuperParser project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/super_parser/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
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 "super_parser"
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,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,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require_relative 'client_error'
5
+
6
+ module SuperParser # :nodoc:
7
+ class Client
8
+ def parse(filepath)
9
+ uri = URI('https://api.superparser.com/parse')
10
+ request = Net::HTTP::Post.new(uri)
11
+ request['X-API-KEY'] = SuperParser.api_key
12
+ request['accept'] = 'application/json'
13
+
14
+ File.open(filepath) do |file|
15
+ form_data = [['file_name', file]]
16
+
17
+ request.set_form form_data, 'multipart/form-data'
18
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
19
+ http.request(request)
20
+ end
21
+
22
+ if response.code != 200
23
+ SuperParser::ClientError.new response
24
+ else
25
+ SuperParser::Response.new(response.body)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser # :nodoc:
4
+ class ClientError < StandardError
5
+ attr_reader :status
6
+
7
+ def initialize(response)
8
+ error = JSON.parse response.body
9
+ @status = response.status
10
+ super(error['message'])
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'response_objects/base'
4
+ require_relative 'response_objects/name'
5
+ require_relative 'response_objects/email'
6
+ require_relative 'response_objects/employer'
7
+ require_relative 'response_objects/total_experience'
8
+ require_relative 'response_objects/education'
9
+ require_relative 'response_objects/address'
10
+ require_relative 'response_objects/project'
11
+ require_relative 'response_objects/skill'
12
+
13
+ module SuperParser # :nodoc:
14
+ class Response
15
+ attr_accessor :response
16
+
17
+ def initialize(response)
18
+ @response = JSON.parse(response)['data']
19
+ end
20
+
21
+ def name
22
+ ResponseObjects::Name.new(response['name'])
23
+ end
24
+
25
+ def total_experience
26
+ ResponseObjects::TotalExperience.new(response['total_experience'])
27
+ end
28
+
29
+ def address
30
+ ResponseObjects::Address.new(response['address'])
31
+ end
32
+
33
+ def skills
34
+ ResponseObjects::Skill.new(response['skills'])
35
+ end
36
+
37
+ def generated_summary_text
38
+ response['generated_summary_text']
39
+ end
40
+
41
+ def personal_urls
42
+ response['personal_urls']
43
+ end
44
+
45
+ def total_time
46
+ response['total_time']
47
+ end
48
+
49
+ def email
50
+ response['email'].map do |email|
51
+ ResponseObjects::Email.new(email)
52
+ end
53
+ end
54
+
55
+ def employer
56
+ response['employer'].map do |employer|
57
+ ResponseObjects::Employer.new(employer)
58
+ end
59
+ end
60
+
61
+ def education
62
+ response['education'].map do |education|
63
+ ResponseObjects::Education.new(education)
64
+ end
65
+ end
66
+
67
+ def projects
68
+ response['projects'].map do |projects|
69
+ ResponseObjects::Project.new(projects)
70
+ end
71
+ end
72
+
73
+ # def method_missing(method_name, *_args)
74
+ # response[method_name.to_s]
75
+ # end
76
+ end
77
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ module ResponseObjects
5
+ class Address < Base
6
+ attributes :city, :country_code
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ module ResponseObjects
5
+ class Base
6
+ class << self
7
+ def inspect
8
+ @data.to_s
9
+ end
10
+
11
+ def attributes(*attrs)
12
+ attrs.each do |attr|
13
+ define_method(attr) do
14
+ @data[attr.to_s]
15
+ rescue StandardError
16
+ nil
17
+ end
18
+ instance_variable_set("@#{attr}", true)
19
+ end
20
+ end
21
+ end
22
+
23
+ def initialize(data)
24
+ @data = data
25
+ end
26
+
27
+ def to_s
28
+ @data.to_s
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ module ResponseObjects
5
+ class Education < Base
6
+ attributes :institute, :degree, :course, :from_year, :from_month, :to_year, :to_month
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ module ResponseObjects
5
+ class Email < Base
6
+ attributes :email
7
+
8
+ def to_s
9
+ @data['email']
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ module ResponseObjects
5
+ class Employer < Base
6
+ attributes :company_name, :role, :from_year, :from_month, :is_current, :description, :skills, :to_year
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ module ResponseObjects
5
+ class Name < Base
6
+ attributes :first_name, :last_name, :full_name
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ module ResponseObjects
5
+ class Project < Base
6
+ attributes :description, :skills
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ module ResponseObjects
5
+ class Skill < Base
6
+ attributes :overall_skills, :skills_meta
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ module ResponseObjects
5
+ class TotalExperience < Base
6
+ attributes :years, :months
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SuperParser
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'super_parser/version'
4
+ require_relative 'super_parser/client'
5
+ require_relative 'super_parser/response'
6
+
7
+ module SuperParser
8
+ class Error < StandardError; end
9
+
10
+ class << self
11
+ attr_accessor :api_key
12
+ end
13
+
14
+ def self.configure
15
+ yield self
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: super_parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Watling
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Wrapper for SUPERPARSER API. https://www.superparser.com/documentation#/default
14
+ email:
15
+ - watling.james@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".rspec"
21
+ - ".standard.yml"
22
+ - CHANGELOG.md
23
+ - CODE_OF_CONDUCT.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - bin/console
30
+ - bin/setup
31
+ - lib/super_parser.rb
32
+ - lib/super_parser/client.rb
33
+ - lib/super_parser/client_error.rb
34
+ - lib/super_parser/response.rb
35
+ - lib/super_parser/response_objects/address.rb
36
+ - lib/super_parser/response_objects/base.rb
37
+ - lib/super_parser/response_objects/education.rb
38
+ - lib/super_parser/response_objects/email.rb
39
+ - lib/super_parser/response_objects/employer.rb
40
+ - lib/super_parser/response_objects/name.rb
41
+ - lib/super_parser/response_objects/project.rb
42
+ - lib/super_parser/response_objects/skill.rb
43
+ - lib/super_parser/response_objects/total_experience.rb
44
+ - lib/super_parser/version.rb
45
+ homepage: https://github.com/JamesWatling/super_parser
46
+ licenses:
47
+ - MIT
48
+ metadata:
49
+ allowed_push_host: https://rubygems.org
50
+ homepage_uri: https://github.com/JamesWatling/super_parser
51
+ source_code_uri: https://github.com/JamesWatling/super_parser
52
+ changelog_uri: https://github.com/JamesWatling/super_parser/CHANGELOG.md
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.0
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.0.3.1
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Wrapper for SUPERPARSER API. https://www.superparser.com
72
+ test_files: []