law_school_outcomes 1.0.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
+ SHA1:
3
+ metadata.gz: be1fbd3ac17a4f60845b8d1b8392837137ae6221
4
+ data.tar.gz: 4183ad13fb62b44d289ef026063dd615874e2f78
5
+ SHA512:
6
+ metadata.gz: 1464732812a780069d33861070396bafeddf0b991ca01cb53f53302c1e5a24f41a56c3480a3943f1bd36e3f841b870bbcb067404e994d57409f30e6d7ae2b7a8
7
+ data.tar.gz: 76fda96d4e5972e81036a2a003366ea618556709b75b18ade1087d6023dd15b9d23951ae69d2610aeee956ffca2c7fdc65e351d18d13fcf3403bb47f8d5018fa
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.3
5
+ before_install: gem install bundler -v 1.13.6
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup-provider=redcarpet
2
+ --markup=markdown
@@ -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 datacreativellc@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/CONTRIBUTING.md ADDED
@@ -0,0 +1,32 @@
1
+ ## Contributor's Guide
2
+
3
+ ### Development
4
+
5
+ Check-out the repository:
6
+
7
+ ```` sh
8
+ git clone git@github.com:data-creative/law-school-outcomes-ruby.git
9
+ cd law-school-outcomes-ruby/
10
+ ````
11
+
12
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
13
+
14
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
15
+
16
+ ### Testing
17
+
18
+ Run tests:
19
+
20
+ ```` sh
21
+ bundle exec rspec spec/
22
+ ````
23
+
24
+ To install this gem onto your local machine, run `bundle exec rake install`.
25
+
26
+ ### Releasing
27
+
28
+ 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).
29
+
30
+ ### Code of Conduct
31
+
32
+ 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.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in law_school_outcomes.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 MJ Rossetti <datacreativellc@gmail.com>
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 MJ Rossetti
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,86 @@
1
+ # Law School Outcomes - Ruby
2
+
3
+ Process PDF reports of employment outcomes for recent graduates of ABA-accredited law schools.
4
+
5
+ Law schools accredited by the American Bar Association (ABA) publish in a standardized PDF format reports of employment outcomes for recent graduates. Use the `law_school_outcomes` ruby library to process these PDF files into memory for further use.
6
+
7
+ ## Installation
8
+
9
+ ```` sh
10
+ gem install law_school_outcomes
11
+ ````
12
+
13
+ If using a Gemfile: insert `gem 'law_school_outcomes'` then run `bundle install`.
14
+
15
+ ## Usage
16
+
17
+ #### Employment Summary Reports
18
+
19
+ Google search `[SCHOOL NAME] EMPLOYMENT SUMMARY FOR [year] GRADUATES` to find an Employment Summary Report hosted in PDF format. Note its url and year.
20
+
21
+ Given the report's url and year, read its contents into memory:
22
+
23
+ ```` rb
24
+ require 'law_school_outcomes'
25
+
26
+ report = LawSchoolOutcomes::EmploymentSummaryReport.new(year: 2015, url: "http://www.law.my-university.edu/some-random-path/some-report.pdf")
27
+
28
+ report.school_info
29
+ #> {:name=>"MY UNIVERSITY", :address=>{:street=>"123 MAIN STREET", :city=>"MY CITY", :state=>"ZZ", :zip=>"10101"}, :phone=>"123-456-7890", :website=>"http://www.law.my-university.edu/"}
30
+
31
+ report.total_grads #> 465
32
+
33
+ report.employment_status_results
34
+ #> [{:status=>"Employed - Bar Passage Required", :count=>310},
35
+ # {:status=>"Employed - J.D. Advantage", :count=>65},
36
+ # {:status=>"Employed - Professional Position", :count=>6},
37
+ # {:status=>"Employed - Non-Professional Position", :count=>1},
38
+ # {:status=>"Employed - Law School/University Funded", :count=>38},
39
+ # {:status=>"Employed - Undeterminable", :count=>0},
40
+ # {:status=>"Pursuing Graduate Degree Full Time", :count=>7},
41
+ # {:status=>"Unemployed - Start Date Deferred", :count=>3},
42
+ # {:status=>"Unemployed - Not Seeking", :count=>4},
43
+ # {:status=>"Unemployed - Seeking", :count=>30},
44
+ # {:status=>"Employment Status Unknown", :count=>1
45
+ # }]
46
+
47
+ report.employment_type_results
48
+ #> [{:type=>"Law Firms (Solo)", :count=>0},
49
+ # {:type=>"Law Firms (2 - 10)", :count=>34},
50
+ # {:type=>"Law Firms (11 - 25)", :count=>11},
51
+ # {:type=>"Law Firms (26 - 50)", :count=>6},
52
+ # {:type=>"Law Firms (51 - 100)", :count=>14},
53
+ # {:type=>"Law Firms (101 - 250)", :count=>15},
54
+ # {:type=>"Law Firms (251 - 500)", :count=>25},
55
+ # {:type=>"Law Firms (501 +)", :count=>109},
56
+ # {:type=>"Law Firms (Unknown Size)", :count=>1},
57
+ # {:type=>"Business & Industry", :count=>51},
58
+ # {:type=>"Government", :count=>79},
59
+ # {:type=>"Pub. Int.", :count=>40},
60
+ # {:type=>"Clerkships - Federal", :count=>16},
61
+ # {:type=>"Clerkships - State & Local", :count=>13},
62
+ # {:type=>"Clerkships - Other", :count=>2},
63
+ # {:type=>"Education", :count=>4},
64
+ # {:type=>"Employer Type Unknown", :count=>0}]
65
+
66
+ report.employment_location_results
67
+ #> [{:type=>"State - Largest Employment",
68
+ # :location=>"District Of Columbia",
69
+ # :count=>"221"},
70
+ # {:type=>"State - 2nd Largest Employment",
71
+ # :location=>"New York",
72
+ # :count=>"58"},
73
+ # {:type=>"State - 3rd Largest Employment",
74
+ # :location=>"Virginia",
75
+ # :count=>"32"},
76
+ # {:type=>"Employed in Foreign Countries",
77
+ # :location=>"Employed in Foreign Countries",
78
+ # :count=>8}]
79
+
80
+ report.results
81
+ #> etc ...
82
+ ````
83
+
84
+ ## [Contributing](/CONTRIBUTING.md)
85
+
86
+ ## [License](/LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "law_school_outcomes"
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
15
+
16
+ require 'pry'
17
+ Pry.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,44 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'law_school_outcomes/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "law_school_outcomes"
8
+ spec.version = LawSchoolOutcomes::VERSION
9
+ spec.authors = ["MJ Rossetti"]
10
+ spec.email = ["datacreativellc@gmail.com"]
11
+
12
+ spec.summary = %q{Process PDF reports of employment outcomes for recent graduates of ABA-accredited law schools.}
13
+ spec.description = %q{Law schools accredited by the American Bar Association (ABA) publish in a standardized PDF format reports of employment outcomes for recent graduates. Process these PDF files into memory for further use.}
14
+ spec.homepage = "https://github.com/data-creative/law-school-outcomes-ruby"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "pry", "~> 0.10"
37
+ spec.add_development_dependency "yard"
38
+ spec.add_development_dependency "redcarpet"
39
+ spec.add_development_dependency "github-markup"
40
+
41
+ spec.add_dependency "pdf-reader", "~> 2.0"
42
+ spec.add_dependency "domainatrix", "~> 0.0.11"
43
+
44
+ end
@@ -0,0 +1,7 @@
1
+ require "law_school_outcomes/version"
2
+
3
+ require "law_school_outcomes/employment_summary_report"
4
+
5
+ module LawSchoolOutcomes
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,115 @@
1
+ require "open-uri"
2
+ require "pdf-reader"
3
+ require "domainatrix"
4
+
5
+ require_relative "employment_summary_report/school"
6
+ require_relative "employment_summary_report/section"
7
+ require_relative "employment_summary_report/sections/employment_location_section"
8
+ require_relative "employment_summary_report/sections/employment_status_section"
9
+ require_relative "employment_summary_report/sections/employment_type_section"
10
+
11
+ module LawSchoolOutcomes
12
+ class EmploymentSummaryReport
13
+ class LineCountError < StandardError ; end
14
+
15
+ attr_reader :url, :year, :lines
16
+
17
+ def initialize(url: nil, year: 2015)
18
+ @url = url
19
+ @year = year
20
+ @lines = read_lines
21
+ end
22
+
23
+ def domain
24
+ Domainatrix.parse(url).domain
25
+ end
26
+ alias school_name domain
27
+
28
+ ###def year
29
+ ### @year ||= lines[5].gsub("EMPLOYMENT SUMMARY FOR ","").gsub(" GRADUATES","").to_i
30
+ ###end
31
+
32
+ def school_info
33
+ @school_info || School.new(self).info
34
+ end
35
+
36
+ def employment_status_section
37
+ @employment_status_section ||= EmploymentStatusSection.new(self)
38
+ end
39
+
40
+ def employment_status_results
41
+ employment_status_section.results
42
+ end
43
+
44
+ def total_grads
45
+ employment_status_section.total_graduates
46
+ end
47
+
48
+ def employment_type_results
49
+ @employment_type_results ||= EmploymentTypeSection.new(self).results
50
+ end
51
+
52
+ def school_funded_employment_results
53
+ # todo
54
+ end
55
+
56
+ def employment_location_results
57
+ @employment_location_results ||= EmploymentLocationSection.new(self).results
58
+ end
59
+
60
+ def results
61
+ {
62
+ url: url,
63
+ school_name: school_name,
64
+ school_info: school_info,
65
+ year: year,
66
+ total_grads: total_grads,
67
+ #pct_employed_grads: pct_employed_grads,
68
+ employment_outcomes:{
69
+ #total_employed_grads: total_employed_grads,
70
+ statuses: employment_status_results,
71
+ types: employment_type_results,
72
+ locations: employment_location_results
73
+ }
74
+ }
75
+ end
76
+
77
+ private
78
+
79
+ def file_source
80
+ File.join(File.expand_path("../../../reports/#{year}/", __FILE__), "#{domain}.pdf")
81
+ end
82
+
83
+ def url_source
84
+ open(url)
85
+ end
86
+
87
+ def download
88
+ FileUtils.rm_rf(file_source)
89
+
90
+ File.open(file_source, "wb") do |local_file|
91
+ open(url, "rb") do |remote_file|
92
+ local_file.write(remote_file.read)
93
+ end
94
+ end
95
+ end
96
+
97
+ def io
98
+ if File.exist?(file_source)
99
+ file_source
100
+ else
101
+ download # optionally download for next time, to avoid future network requests
102
+ url_source
103
+ end
104
+ end
105
+
106
+ def read_lines
107
+ reader = PDF::Reader.new(io)
108
+ lines = reader.pages.first.text.split("\n")
109
+ lines.select!{|line| line.size > 0 }
110
+ lines.map!{|line| line.strip }
111
+ raise LineCountError unless lines.count == 53
112
+ return lines
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,38 @@
1
+ module LawSchoolOutcomes
2
+ class School
3
+ attr_reader :report, :number_of_lines
4
+
5
+ def initialize(report)
6
+ @report = report
7
+ @number_of_lines = 5
8
+ end
9
+
10
+ def lines
11
+ report.lines.first(number_of_lines)
12
+ end
13
+
14
+ def info
15
+ return {
16
+ name: lines.first, #.upcase,
17
+ address:{
18
+ street: lines[1].strip, #.upcase,
19
+ city: city_and_state_and_zip.split(", ").first,
20
+ state: state_and_zip.split(" ").first,
21
+ zip: state_and_zip.split(" ").last
22
+ },
23
+ phone: lines[2].split("Phone : ").last.strip,
24
+ website: lines[4].split("Website : ").last.strip
25
+ }
26
+ end
27
+
28
+ private
29
+
30
+ def city_and_state_and_zip
31
+ lines[3].strip #.upcase
32
+ end
33
+
34
+ def state_and_zip
35
+ city_and_state_and_zip.split(", ").last
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,30 @@
1
+ module LawSchoolOutcomes
2
+ class Section
3
+ attr_reader :report, :header_content, :number_of_lines
4
+
5
+ def initialize(report:, header_content:, number_of_lines:)
6
+ @report = report
7
+ @header_content = header_content
8
+ @number_of_lines = number_of_lines
9
+ end
10
+
11
+ def first_line_index
12
+ report.lines.each_with_index.find{|line, i| line.include?(header_content)}.last
13
+ end
14
+
15
+ def last_line_index
16
+ first_line_index + number_of_lines
17
+ end
18
+
19
+ def lines
20
+ report.lines[first_line_index .. last_line_index]
21
+ end
22
+
23
+ private
24
+
25
+ # @param [String] line e.g. "New York 34"
26
+ def last_number(line)
27
+ line.split(" ").last.to_i
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,56 @@
1
+ require_relative "../section"
2
+
3
+ module LawSchoolOutcomes
4
+ class EmploymentStatusSection < Section
5
+ class EmploymentStatusTotalsError < StandardError ; end
6
+ class EmployedNonemployedTotalsError < StandardError ; end
7
+
8
+ EMPLOYMENT_STATUSES = [
9
+ "Employed - Bar Passage Required",
10
+ "Employed - J.D. Advantage",
11
+ "Employed - Professional Position",
12
+ "Employed - Non-Professional Position",
13
+ "Employed - Law School/University Funded",
14
+ "Employed - Undeterminable",
15
+ "Pursuing Graduate Degree Full Time",
16
+ "Unemployed - Start Date Deferred",
17
+ "Unemployed - Not Seeking",
18
+ "Unemployed - Seeking",
19
+ "Employment Status Unknown",
20
+ ]
21
+
22
+ def initialize(report)
23
+ super({
24
+ :report => report,
25
+ :header_content => "EMPLOYMENT STATUS",
26
+ :number_of_lines => EMPLOYMENT_STATUSES.count + 1 + 1 # consider right-sizing until the index of the last row: "Total Graduates"
27
+ })
28
+ end
29
+
30
+ def total_graduates
31
+ last_number(lines.last)
32
+ end
33
+
34
+ def results
35
+ counts = []
36
+
37
+ EMPLOYMENT_STATUSES.each do |status|
38
+ line = lines.find{|line| line.include?(status) }
39
+ number = line ? last_number(line) : 0
40
+ counts << {status: status, count: number}
41
+ end
42
+
43
+ calculated_total_graduates = counts.map{|h| h[:count] }.reduce{|sum, x| sum + x}
44
+ raise EmploymentStatusTotalsError unless calculated_total_graduates == total_graduates
45
+
46
+ employed_statuses = EMPLOYMENT_STATUSES.select{|status| status.include?("Employed - ")}
47
+ nonemployed_statuses = EMPLOYMENT_STATUSES.select{|status| !status.include?("Employed - ")}
48
+ employed_count = counts.select{|h| employed_statuses.include?(h[:status]) }.map{|h| h[:count] }.reduce{|sum, x| sum + x}
49
+ nonemployed_count = counts.select{|h| nonemployed_statuses.include?(h[:status]) }.map{|h| h[:count] }.reduce{|sum, x| sum + x}
50
+ raise EmployedNonemployedTotalsError if employed_count + nonemployed_count != total_graduates
51
+
52
+ return counts
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,39 @@
1
+ require_relative "../section"
2
+
3
+ module LawSchoolOutcomes
4
+ class EmploymentLocationSection < Section
5
+ LOCATION_TYPES = [
6
+ "State - Largest Employment",
7
+ "State - 2nd Largest Employment",
8
+ "State - 3rd Largest Employment",
9
+ "Employed in Foreign Countries"
10
+ ]
11
+ STATE_TYPES = LOCATION_TYPES.select{|location_type| location_type.include?("State - ")}
12
+ FOREIGN_TYPE = "Employed in Foreign Countries"
13
+
14
+ def initialize(report)
15
+ super({
16
+ :report => report,
17
+ :header_content => "EMPLOYMENT LOCATION",
18
+ :number_of_lines => LOCATION_TYPES.count + 1 # includes header line
19
+ })
20
+ end
21
+
22
+ def results
23
+ counts = []
24
+
25
+ STATE_TYPES.each do |state_type|
26
+ line = lines.find{|line| line.include?(state_type) }
27
+ state_and_count = line.gsub(state_type,"").strip.split(" ").select{|str| !str.empty?}.map{|str| str.strip }
28
+ counts << {type: state_type, location: state_and_count.first, count: state_and_count.last}
29
+ end
30
+
31
+ foreign_line = lines.find{|line| line.include?(FOREIGN_TYPE) }
32
+ foreign_count = last_number(foreign_line)
33
+ counts << {type: FOREIGN_TYPE, location: FOREIGN_TYPE, count: foreign_count}
34
+
35
+ return counts
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,51 @@
1
+ require_relative "../section"
2
+
3
+ module LawSchoolOutcomes
4
+ class EmploymentTypeSection < Section
5
+ class EmployedGraduatesTotalsError < StandardError ; end
6
+
7
+ EMPLOYMENT_TYPES = [
8
+ {label:"Law Firms", sizes:["Solo", "2 - 10", "11 - 25", "26 - 50", "51 - 100", "101 - 250", "251 - 500", "501 +", "Unknown Size"]},
9
+ {label:"Business & Industry"},
10
+ {label:"Government"},
11
+ {label:"Pub. Int."},
12
+ {label:"Clerkships - Federal"},
13
+ {label:"Clerkships - State & Local"},
14
+ {label:"Clerkships - Other"},
15
+ {label:"Education"},
16
+ {label:"Employer Type Unknown"}
17
+ ]
18
+ LAW_FIRM_SIZES = EMPLOYMENT_TYPES.find{|h| h[:label] == "Law Firms"}[:sizes]
19
+ NON_LAW_FIRM_TYPES = EMPLOYMENT_TYPES.reject{|h| h[:label] == "Law Firms"}.map{|h| h[:label]}
20
+
21
+ def initialize(report)
22
+ super({
23
+ :report => report,
24
+ :header_content => "EMPLOYMENT TYPE",
25
+ :number_of_lines => EMPLOYMENT_TYPES.count + LAW_FIRM_SIZES.count + 1 + 1
26
+ })
27
+ end
28
+
29
+ def results
30
+ counts = []
31
+
32
+ LAW_FIRM_SIZES.each do |size|
33
+ line = lines.find{|line| line.include?(size) }
34
+ number = last_number(line)
35
+ counts << {type: "Law Firms (#{size})", count: number}
36
+ end
37
+
38
+ NON_LAW_FIRM_TYPES.each do |type|
39
+ line = lines.find{|line| line.include?(type) }
40
+ number = last_number(line)
41
+ counts << {type: type, count: number}
42
+ end
43
+
44
+ total_employed_graduates = last_number(lines.last)
45
+ calculated_total_employed_graduates = counts.map{|h| h[:count] }.reduce{|sum, x| sum + x}
46
+ raise EmployedGraduatesTotalsError if total_employed_graduates != calculated_total_employed_graduates
47
+
48
+ return counts
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module LawSchoolOutcomes
2
+ VERSION = "1.0.0"
3
+ end
File without changes
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: law_school_outcomes
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - MJ Rossetti
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: redcarpet
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: github-markup
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: pdf-reader
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: domainatrix
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.0.11
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.0.11
139
+ description: Law schools accredited by the American Bar Association (ABA) publish
140
+ in a standardized PDF format reports of employment outcomes for recent graduates.
141
+ Process these PDF files into memory for further use.
142
+ email:
143
+ - datacreativellc@gmail.com
144
+ executables: []
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - ".gitignore"
149
+ - ".rspec"
150
+ - ".travis.yml"
151
+ - ".yardopts"
152
+ - CODE_OF_CONDUCT.md
153
+ - CONTRIBUTING.md
154
+ - Gemfile
155
+ - LICENSE
156
+ - LICENSE.txt
157
+ - README.md
158
+ - Rakefile
159
+ - bin/console
160
+ - bin/setup
161
+ - law_school_outcomes.gemspec
162
+ - lib/law_school_outcomes.rb
163
+ - lib/law_school_outcomes/employment_summary_report.rb
164
+ - lib/law_school_outcomes/employment_summary_report/school.rb
165
+ - lib/law_school_outcomes/employment_summary_report/section.rb
166
+ - lib/law_school_outcomes/employment_summary_report/sections/employment_location_section.rb
167
+ - lib/law_school_outcomes/employment_summary_report/sections/employment_status_section.rb
168
+ - lib/law_school_outcomes/employment_summary_report/sections/employment_type_section.rb
169
+ - lib/law_school_outcomes/version.rb
170
+ - reports/2015/.gitkeep
171
+ homepage: https://github.com/data-creative/law-school-outcomes-ruby
172
+ licenses:
173
+ - MIT
174
+ metadata: {}
175
+ post_install_message:
176
+ rdoc_options: []
177
+ require_paths:
178
+ - lib
179
+ required_ruby_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ requirements: []
190
+ rubyforge_project:
191
+ rubygems_version: 2.4.5.1
192
+ signing_key:
193
+ specification_version: 4
194
+ summary: Process PDF reports of employment outcomes for recent graduates of ABA-accredited
195
+ law schools.
196
+ test_files: []