catobills 0.4 → 0.5

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.
@@ -3,6 +3,10 @@ module Catobills
3
3
 
4
4
  attr_reader :bill_number, :bill_body, :version, :congress, :bill_type, :federal_bodies, :acts
5
5
 
6
+ FILTER_LIST = ['Commission', 'Board', 'Secretary', 'Department', 'Administrator', 'Administration', 'House', 'Senate', 'Director', 'Advisory Committee', 'Task Force',
7
+ "Secretary's", "Under Secretary", "Administrator's", "Board's", "Service", "Department of State's", "CSCC's", "Bureau", "Inspector General of the Office", "Office",
8
+ "Commissioner", "Assistant Secretary"]
9
+
6
10
  def initialize(params={})
7
11
  params.each_pair do |k,v|
8
12
  instance_variable_set("@#{k}", v)
@@ -20,13 +24,16 @@ module Catobills
20
24
  response = HTTParty.get(url)
21
25
  bill = Oj.load(response.body)
22
26
  bill_body = Ox.load(bill['billbody'])
23
- self.new(:bill_number => bill['billnumber'],
24
- :bill_body => bill_body,
25
- :version => bill['billversion'],
26
- :congress => bill['congress'],
27
- :bill_type => bill['billtype'],
28
- :federal_bodies => self.populate_federal_bodies(bill_body),
29
- :acts => self.populate_acts(bill_body))
27
+
28
+ self.new(
29
+ bill_number: bill['billnumber'],
30
+ bill_body: bill_body,
31
+ version: bill['billversion'],
32
+ congress: bill['congress'],
33
+ bill_type: bill['billtype'],
34
+ federal_bodies: self.populate_federal_bodies(bill_body),
35
+ acts: self.populate_acts(bill_body)
36
+ )
30
37
  end
31
38
 
32
39
  def self.populate_acts(bill_body)
@@ -37,7 +44,7 @@ module Catobills
37
44
  # collects mentions of federal bodies, removing 'Congress', leadership offices, 'Commission', 'Board' and offices within agencies.
38
45
  def self.populate_federal_bodies(bill_body)
39
46
  results = bill_body.locate('legis-body/*/cato:entity-ref').select{|ref| ref['entity-type'] == 'federal-body'}
40
- array_count(results.flatten.reject{|ref| ref['entity-id'] == "0001"}.reject{|ref| ref['entity-parent-id'] == '0050'}.reject{|ref| ref['entity-parent-id'] == '0010'}.map{|ref| ref.text.gsub(/\s+/, " ").strip}.compact.reject{|x| ['Commission', 'Board', 'Secretary', 'Department', 'Administrator', 'Administration', 'House', 'Senate', 'Director', 'Advisory Committee', 'Task Force', "Secretary's", "Under Secretary", "Administrator's"].include?(x)})
47
+ array_count(results.flatten.reject{|ref| ref['entity-id'] == "0001"}.reject{|ref| ref['entity-parent-id'] == '0050'}.reject{|ref| ref['entity-parent-id'] == '0010'}.map{|ref| ref.text.gsub(/\s+/, " ").strip}.compact.reject{|x| FILTER_LIST.include?(x)})
41
48
  end
42
49
 
43
50
  def self.array_count(array)
@@ -1,3 +1,3 @@
1
1
  module Catobills
2
- VERSION = "0.4"
2
+ VERSION = "0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catobills
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: