house_floor_bills 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91f2c4d62ba46bb4fc42b936fa74f78ff3326fd4
4
- data.tar.gz: a0f71872a6255f6eb04db140ed000a10da5982fb
3
+ metadata.gz: 926d9fa88f99bc48cf0c644347eea2c39a108662
4
+ data.tar.gz: dcd7e633ddf5d9c641918322f3520146e20e6006
5
5
  SHA512:
6
- metadata.gz: d3242b93aca411e5602b938b3e988150716f7ca6b7578358c972a09e8696fc76e7767c59f35411a16f87f777dc713f0859c7e11dd60d17d6c944d94c450a26dd
7
- data.tar.gz: 42e3c6eae2fecad31b7cf8fca6edaa7021a578103ca31b2e353e24ac4a8fdcfa5b2594d573d8146fca68140dc1638c31cdfafd0d33ca5925a1eee43f3d41dae1
6
+ metadata.gz: 58a266409160718a1b0a59d01514487473f51e18a5a67d80380b88f947cb6bc13561e52ef9b5ed2be606e1df7f33313fc4a0d6b5c14ca368710d6da788f24cc6
7
+ data.tar.gz: 3ebbb7964c7e44df0818ae3923df7f7d54e8cd2d28f2a2ed979a305661d3349b058a6b261e4fdb148abf504b887276b8e4190a9065cdfba1ca0fa21aefbb9914
data/.DS_Store ADDED
Binary file
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # HouseFloorBills
2
2
 
3
- The house-floor-bills CLI gem provides a CLI interface to view the schedule of bills to be debated on the House of Representatives floor this week. Further details about the scheduled bills can be viewed as well.
3
+ The house-floor-bills CLI gem provides a CLI interface to view the schedule of legislative bills to be debated on the House of Representatives floor this week. Further details about the scheduled bills can be viewed as well.
4
4
 
5
5
  ## Installation
6
6
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "house_floor_bills"
4
+ require_relative "../lib/house_floor_bills"
5
5
 
6
6
  HouseFloorBills::CLI.new.call
data/blog_post CHANGED
@@ -29,9 +29,11 @@ CLI Data Game Project Steps
29
29
  - git remote add origin git@github.com:dalmaboros/house-floor-bills-cli-app.git
30
30
  - git push -u origin master
31
31
 
32
- 6. encapsulate CLI logic in object
33
- - create class HouseFloorBills::CLI in "cli.rb" file in lib
34
- - define #call method
32
+ 6. create CLI object to encapsulate CLI logic:
33
+ a) define HouseFloorBills::CLI class in 'lib/cli.rb' and
34
+ - define #call method
35
+ b) add dependency to environment file (house_floor_bills.rb)
36
+ - require_relative "./house_floor_bills/cli"
35
37
 
36
38
  7. declare environment load dependencies
37
39
  - bin/house-floor-bills: require './lib/house_floor_bills'
@@ -43,8 +45,33 @@ CLI Data Game Project Steps
43
45
 
44
46
  8. stub cli.rb behaviors
45
47
 
46
- 03/18/17
47
-
48
48
  9. add spec file I forgot to add!
49
49
 
50
- 10. create 'bill.rb' and HouseFloorBills::Bill class, and add to environment file
50
+ 10. create the bill object:
51
+ a) define HouseFloorBills::Bill class in 'bill.rb' and
52
+ b) add dependency to environment file (house_floor_bills.rb)
53
+ - require_relative "./house_floor_bills/bill"
54
+
55
+ 11. hard-code fake bill data
56
+
57
+ 12. write real CLI behaviors
58
+
59
+ 13. scrape real bill data
60
+
61
+ At this point, the program was working, but it wasn't truly object-oriented.
62
+
63
+ 14. create the scraper object:
64
+ a) define HouseFloorBills::Scraper class in 'scraper.rb' and
65
+ b) add dependency to environment file (house_floor_bills.rb)
66
+ - require_relative "./house_floor_bills/scraper"
67
+
68
+ 15. create the schedule object:
69
+ a) define HouseFloorBills::Schedule class in 'schedule.rb' and
70
+ b) add dependency to environment file (house_floor_bills.rb)
71
+ - require_relative "./house_floor_bills/schedule"
72
+
73
+ 16. Made HouseFloorBills::Scraper responsible for all scraping
74
+
75
+ 17. Made HouseFloorBills::Schedule responsible for containing bills
76
+
77
+ 18. Made HouseFloorBills::Bill responsible for containing bill data
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ["dalma.boros@gmail.com"]
12
12
 
13
13
  spec.summary = %q{Bills to be considered on the house floor.}
14
- spec.description = %q{Bills scheduled for debate this week on the House of Representatives floor.}
14
+ spec.description = %q{Legislative bills scheduled for debate this week on the United States House of Representatives floor.}
15
15
  spec.homepage = "https://github.com/dalmaboros/house-floor-bills-cli-gem"
16
16
  spec.license = "MIT"
17
17
 
data/lib/.DS_Store ADDED
Binary file
@@ -1,4 +1,20 @@
1
1
  class HouseFloorBills::Bill
2
2
  attr_accessor :number, :name, :pdf, :url, :sponsor, :committees, :status, :summary
3
3
 
4
- end # class
4
+ @@bills = []
5
+
6
+ def initialize
7
+ @@bills << self
8
+ end
9
+
10
+ def self.all
11
+ @@bills.dup.freeze
12
+ end
13
+
14
+ def self.bills_by_status(status)
15
+ self.all.select do |bill|
16
+ bill.status.downcase == "#{status.downcase}"
17
+ end
18
+ end
19
+
20
+ end
@@ -7,14 +7,18 @@ class HouseFloorBills::CLI
7
7
  end
8
8
 
9
9
  def welcome
10
- puts "\n************* Welcome to House Floor Bills *************"
11
- puts "\nSee which bills are scheduled for debate on the House of Representatives floor."
10
+ puts "\n------ Welcome to House Floor Bills ------"
11
+ puts "\nBills to be considered on the U.S. House floor:"
12
12
  end
13
13
 
14
14
  def list_bills
15
15
  s = HouseFloorBills::Scraper.new
16
16
  @schedule = s.scrape
17
- puts "\n************* #{@schedule.title} *************\n "
17
+
18
+ puts "\n-------------------------------------------"
19
+ puts "#{@schedule.title}"
20
+ puts "-------------------------------------------\n "
21
+
18
22
  @schedule.bills.each.with_index(1) do |bill, i|
19
23
  puts "#{i}. #{bill.number} - #{bill.name}"
20
24
  end
@@ -22,7 +26,8 @@ class HouseFloorBills::CLI
22
26
 
23
27
  def print_bill(the_bill)
24
28
  puts "\n[#{the_bill.number}] #{the_bill.name}"
25
- puts "\nStatus: #{the_bill.status}"
29
+ puts "----------------------------------------------------------------------\n "
30
+ puts "Status: #{the_bill.status}"
26
31
  puts "Sponsor: #{the_bill.sponsor}"
27
32
  puts "Committees: #{the_bill.committees}"
28
33
  puts "URL: #{the_bill.url}"
@@ -31,9 +36,10 @@ class HouseFloorBills::CLI
31
36
  end
32
37
 
33
38
  def print_commands
34
- puts "\nCOMMANDS:"
39
+ puts "\nCOMMANDS"
40
+ puts "-------------------------------------------"
35
41
  puts "Enter 1-#{@schedule.bills.length} for more info on corresponding bill."
36
- puts "Enter 'open 1-#{@schedule.bills.length}' to open bill URL in browser."
42
+ puts "Enter 'open 1-#{@schedule.bills.length}' to open bill page in browser."
37
43
  puts "Enter 'pdf 1-#{@schedule.bills.length}' to open bill PDF in browser."
38
44
  puts "Enter 'list' to see the list of bills again."
39
45
  puts "Enter 'exit' to exit program."
@@ -41,12 +47,13 @@ class HouseFloorBills::CLI
41
47
 
42
48
  def menu
43
49
  input = nil
50
+
44
51
  while input != "exit"
45
52
  puts "\nEnter command (type 'commands' for list of commands):"
46
53
  print ">"
47
54
  input = gets.strip.downcase
48
55
 
49
- if input.to_i > 0 && input.to_i <= @schedule.bills.length
56
+ if input.to_i.between?(1, @schedule.bills.size)
50
57
  print_bill(@schedule.find_bill(input))
51
58
  elsif input == "commands"
52
59
  print_commands
@@ -22,5 +22,5 @@ class HouseFloorBills::Schedule
22
22
  @bills << bill
23
23
  end
24
24
  end
25
-
25
+
26
26
  end
@@ -26,13 +26,21 @@ class HouseFloorBills::Scraper
26
26
  b.number = floor_item.css("td.legisNum").text.strip
27
27
  b.name = floor_item.css("td.floorText").text.strip
28
28
  b.pdf = floor_item.css("td.files a").attr("href").text
29
- b.url = "https://www.congress.gov/bill/115th-congress/house-bill/#{b.number.split.last}"
29
+
30
+ # Set URL conditionally, based on type of bill:
31
+ if b.number.split.include? "H.R."
32
+ b.url = "https://www.congress.gov/bill/115th-congress/house-bill/#{b.number.split.last}"
33
+ elsif b.number.split.include? "H.Res."
34
+ b.url = "https://www.congress.gov/bill/115th-congress/house-resolution/#{b.number.split.last}"
35
+ elsif b.number.split.include? "S."
36
+ b.url = "https://www.congress.gov/bill/115th-congress/senate-bill/#{b.number.split.last}"
37
+ end
30
38
 
31
39
  doc_bill ||= Nokogiri::HTML(open(b.url))
32
40
  b.sponsor = doc_bill.search("table.standard01 > tr:first-child a").text.strip
33
41
  b.committees = doc_bill.search("table.standard01 > tr:nth-child(2) td").text.strip
34
42
  b.status = doc_bill.search("ol.bill_progress li.selected > text()").text.strip
35
- b.summary = doc_bill.search("div#bill-summary > p").to_s.gsub("</p>","\n\n").gsub(/<\/.+>/,"").gsub(/<.+>/,"")
43
+ b.summary = doc_bill.search("div#bill-summary > p, div#bill-summary li").to_s.gsub("</p>","\n\n").gsub("</li>","\n\n").gsub(/<\/.+>/,"").gsub(/<.+>/,"")
36
44
  if b.summary == ""
37
45
  b.summary = doc_bill.search("div#main > p").text
38
46
  end
@@ -1,3 +1,3 @@
1
1
  module HouseFloorBills
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: house_floor_bills
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dalma Boros
@@ -80,8 +80,8 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: Bills scheduled for debate this week on the House of Representatives
84
- floor.
83
+ description: Legislative bills scheduled for debate this week on the United States
84
+ House of Representatives floor.
85
85
  email:
86
86
  - dalma.boros@gmail.com
87
87
  executables:
@@ -89,6 +89,7 @@ executables:
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
+ - ".DS_Store"
92
93
  - ".gitignore"
93
94
  - ".rspec"
94
95
  - ".travis.yml"
@@ -103,6 +104,7 @@ files:
103
104
  - bin/setup
104
105
  - blog_post
105
106
  - house_floor_bills.gemspec
107
+ - lib/.DS_Store
106
108
  - lib/house_floor_bills.rb
107
109
  - lib/house_floor_bills/bill.rb
108
110
  - lib/house_floor_bills/cli.rb