profession 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +59 -0
- data/.rubocop.yml +30 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +54 -0
- data/LICENSE.txt +21 -0
- data/README.md +74 -0
- data/Rakefile +24 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/profession.rb +54 -0
- data/lib/profession/professions.yml +1153 -0
- data/lib/profession/version.rb +3 -0
- data/profession.gemspec +40 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 69ab66c83d1674177280f38c2c45763a04295a5a5cbb573fc03457e6e742ff81
|
4
|
+
data.tar.gz: d9c0d5a0c55b77530367b87b3ea7fd81026e8bb6d6d4dad79a34232c470d9523
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b85cefbbb77c0f7a522e27febde1230c93f1029c18393c21f510fba42810f171d1c828a57eebffa6f7fa974d5d7ef02e2a3cffdd16e8bb1d7d3652bbe260cf3
|
7
|
+
data.tar.gz: 13c2d123b3585c8d0fde023a9482419347eaeee538831cf01f7c6dc20961538bcfc0af41141151500962d727fd68a7136f4b04001afa2f19fa79035453f22e3c
|
data/.gitignore
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
51
|
+
|
52
|
+
/.bundle/
|
53
|
+
/.yardoc
|
54
|
+
/_yardoc/
|
55
|
+
/coverage/
|
56
|
+
/doc/
|
57
|
+
/pkg/
|
58
|
+
/spec/reports/
|
59
|
+
/tmp/
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
Style/FrozenStringLiteralComment:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Metrics/LineLength:
|
5
|
+
Max: 120
|
6
|
+
|
7
|
+
AllCops:
|
8
|
+
TargetRubyVersion: 2.5.1
|
9
|
+
TargetRailsVersion: 5.2
|
10
|
+
|
11
|
+
Rails:
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
Layout/AlignHash:
|
15
|
+
EnforcedHashRocketStyle: separator
|
16
|
+
EnforcedColonStyle: separator
|
17
|
+
|
18
|
+
Layout/ExtraSpacing:
|
19
|
+
AllowForAlignment: true
|
20
|
+
# When true, forces the alignment of `=` in assignments on consecutive lines.
|
21
|
+
ForceEqualSignAlignment: true
|
22
|
+
|
23
|
+
Layout/IndentationConsistency:
|
24
|
+
EnforcedStyle: rails
|
25
|
+
|
26
|
+
Layout/DotPosition:
|
27
|
+
EnforcedStyle: trailing
|
28
|
+
|
29
|
+
Documentation:
|
30
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at nick.gorbikoff@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
profession (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
byebug (10.0.2)
|
11
|
+
coderay (1.1.2)
|
12
|
+
method_source (0.9.0)
|
13
|
+
minitest (5.11.3)
|
14
|
+
parallel (1.12.1)
|
15
|
+
parser (2.5.1.0)
|
16
|
+
ast (~> 2.4.0)
|
17
|
+
powerpack (0.1.1)
|
18
|
+
pry (0.11.3)
|
19
|
+
coderay (~> 1.1.0)
|
20
|
+
method_source (~> 0.9.0)
|
21
|
+
pry-byebug (3.6.0)
|
22
|
+
byebug (~> 10.0)
|
23
|
+
pry (~> 0.10)
|
24
|
+
pry-doc (0.13.4)
|
25
|
+
pry (~> 0.11)
|
26
|
+
yard (~> 0.9.11)
|
27
|
+
rainbow (3.0.0)
|
28
|
+
rake (10.5.0)
|
29
|
+
rubocop (0.55.0)
|
30
|
+
parallel (~> 1.10)
|
31
|
+
parser (>= 2.5)
|
32
|
+
powerpack (~> 0.1)
|
33
|
+
rainbow (>= 2.2.2, < 4.0)
|
34
|
+
ruby-progressbar (~> 1.7)
|
35
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
36
|
+
ruby-progressbar (1.9.0)
|
37
|
+
unicode-display_width (1.3.2)
|
38
|
+
yard (0.9.12)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
bundler (~> 1.16)
|
45
|
+
minitest (~> 5.0)
|
46
|
+
profession!
|
47
|
+
pry (~> 0.11)
|
48
|
+
pry-byebug (~> 3.5)
|
49
|
+
pry-doc (~> 0.11)
|
50
|
+
rake (~> 10.0)
|
51
|
+
rubocop (~> 0.55)
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Nick Gorbikoff
|
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,74 @@
|
|
1
|
+
# Profession
|
2
|
+
|
3
|
+
Simple gem with a list of professions (over 1000), for matching and parsing professions in a large body of text. For instance this was helpful for parsing out Wikipedia articles for a little school project for my kids.
|
4
|
+
|
5
|
+
Please fill free to add more professions to the list, just send a simple PR. Thank you!
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'profession'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install profession
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
# Return a sorted unique list of all professions
|
27
|
+
Profession::Profession.list
|
28
|
+
|
29
|
+
|
30
|
+
# Check if your value is in the list, and has an exact match
|
31
|
+
Profession::Profession.contains_exact?('Zoo Keeper')
|
32
|
+
|
33
|
+
# Return exact match
|
34
|
+
Profession::Profession.exact_match('Zoo Keeper')
|
35
|
+
|
36
|
+
# Do a fuzzy match
|
37
|
+
Profession::Profession.match('Keeper')
|
38
|
+
|
39
|
+
# [
|
40
|
+
# [0] "Book-keeper",
|
41
|
+
# [1] "Gamekeeper",
|
42
|
+
# [2] "Gate Keeper",
|
43
|
+
# [3] "Green Keeper",
|
44
|
+
# [4] "Housekeeper",
|
45
|
+
# [5] "Lighthouse Keeper",
|
46
|
+
# [6] "Lock Keeper",
|
47
|
+
# [7] "Park Keeper",
|
48
|
+
# [8] "Shop Keeper",
|
49
|
+
# [9] "Zoo Keeper"
|
50
|
+
# ]
|
51
|
+
|
52
|
+
```
|
53
|
+
|
54
|
+
### Important!
|
55
|
+
|
56
|
+
Matching is NOT case-sensitive and will also strip extra spaces when comparing.
|
57
|
+
|
58
|
+
## Development
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
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).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/konung/profession. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
71
|
+
|
72
|
+
## Code of Conduct
|
73
|
+
|
74
|
+
Everyone interacting in the Profession project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/profession/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
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: :test
|
11
|
+
|
12
|
+
task :console do
|
13
|
+
require 'pry'
|
14
|
+
require 'profession'
|
15
|
+
|
16
|
+
def reload!
|
17
|
+
files = $LOADED_FEATURES.select { |feat| feat =~ /\/profession\// }
|
18
|
+
files.each { |file| load file }
|
19
|
+
puts 'Reloaded!'
|
20
|
+
end
|
21
|
+
|
22
|
+
ARGV.clear
|
23
|
+
Pry.start
|
24
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "profession"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/lib/profession.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'profession/version'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Profession
|
5
|
+
PROFESSIONS_YML = YAML.load_file(File.join(File.dirname(__FILE__), 'profession', 'professions.yml'))
|
6
|
+
PROFESSIONS = PROFESSIONS_YML.map { |_, v| v }.flatten.compact.sort
|
7
|
+
PROFESSIONS_DOWNCASED = PROFESSIONS.map(&:downcase)
|
8
|
+
|
9
|
+
class Profession
|
10
|
+
class << self
|
11
|
+
def size
|
12
|
+
PROFESSIONS.map { |v| v }.flatten.size
|
13
|
+
end
|
14
|
+
|
15
|
+
def list
|
16
|
+
PROFESSIONS
|
17
|
+
end
|
18
|
+
|
19
|
+
def contains_exact?(option)
|
20
|
+
PROFESSIONS_DOWNCASED.include? clean_downcase_profession(option)
|
21
|
+
end
|
22
|
+
|
23
|
+
def exact_match(option)
|
24
|
+
PROFESSIONS_DOWNCASED.
|
25
|
+
select { |x| x == clean_downcase_profession(option) }.
|
26
|
+
map do |str|
|
27
|
+
str.split(' ').
|
28
|
+
map(&:capitalize).join(' ')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def match(option)
|
33
|
+
PROFESSIONS_DOWNCASED.
|
34
|
+
select { |x| x.include? clean_downcase_profession(option) }.
|
35
|
+
map do |str|
|
36
|
+
str.split(' ').
|
37
|
+
map(&:capitalize).join(' ')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def clean_downcase_profession(option)
|
44
|
+
option.to_s.strip.split(' ').map(&:strip).join(' ').downcase
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class ProfessionNotFound < StandardError
|
50
|
+
def initialize(msg = 'This profession is not yet on the list')
|
51
|
+
super
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|