confidence 0.5 → 0.5.1

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.
@@ -0,0 +1 @@
1
+ *.gem
data/Manifest CHANGED
@@ -1,6 +1,8 @@
1
+ .gitignore
1
2
  Manifest
2
3
  README
3
4
  Rakefile
5
+ confidence.gemspec
4
6
  lib/confidence.rb
5
7
  specs.watchr
6
8
  test/confidence_test.rb
@@ -0,0 +1,13 @@
1
+ require 'lib/confidence'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "confidence"
5
+ s.summary = "MP voting record scraper"
6
+ s.description = "MP voting record scraper."
7
+ s.authors = %w( chebuctonian mynyml )
8
+ s.require_path = "lib"
9
+ s.version = Confidence::VERSION
10
+ s.files = File.read("Manifest").strip.split("\n")
11
+
12
+ s.add_development_dependency 'minitest'
13
+ end
@@ -1,7 +1,7 @@
1
1
  require 'httparty'
2
2
 
3
3
  module Confidence
4
- VERSION = '0.5'
4
+ VERSION = '0.5.1'
5
5
 
6
6
  class Vote
7
7
  def self.fetch(attrs={})
@@ -26,9 +26,30 @@ module Confidence
26
26
  @doc = attrs[:doc]
27
27
  end
28
28
 
29
+ def decision
30
+ @doc['Decision']
31
+ end
32
+
33
+ def context
34
+ @doc['Context']['Para']
35
+ end
36
+
29
37
  def participants
30
38
  @doc['Participant'].map {|p| Participant.new(p) }
31
39
  end
40
+
41
+ def bill
42
+ Bill.new(@doc['RelatedBill'])
43
+ end
44
+ end
45
+
46
+ class Bill
47
+ def initialize(attrs={})
48
+ @attrs = attrs
49
+ end
50
+
51
+ def number; @attrs['number']; end
52
+ def title; @attrs['Title']; end
32
53
  end
33
54
 
34
55
  class Participant
@@ -48,24 +69,3 @@ module Confidence
48
69
  end
49
70
  end
50
71
 
51
- __END__
52
- module Apathy
53
- class Vote < Nokogiri
54
- end
55
-
56
- class Participant
57
- end
58
- end
59
-
60
- vote = Apathy::Vote.fetch(
61
- :parliament => 40,
62
- :session => 2,
63
- :number => 45
64
- )
65
-
66
- vote.participants.first.recorded_vote #=> yea
67
- vote.related_bill
68
-
69
-
70
- #Bill.create(:number => vote.related_bill.number, :title => vote.related_bill.title)
71
-
@@ -17,6 +17,8 @@ VOTE_DATA = Crack::XML.parse(
17
17
  assert_respond_to @vote, :parliament
18
18
  assert_respond_to @vote, :session
19
19
  assert_respond_to @vote, :number
20
+ assert_respond_to @vote, :decision
21
+ assert_respond_to @vote, :context
20
22
  assert_respond_to @vote, :doc
21
23
  end
22
24
 
@@ -37,10 +39,24 @@ VOTE_DATA = Crack::XML.parse(
37
39
  assert_equal :doc, vote.doc
38
40
  end
39
41
 
42
+ test "vote decision" do
43
+ assert_equal "Agreed to", @vote.decision
44
+ end
45
+
46
+ test "vote context" do
47
+ assert_match /^That the Bill/, @vote.context
48
+ end
49
+
40
50
  test "vote participants" do
41
51
  assert_equal 271, @vote.participants.size
42
52
  assert_kind_of Participant, @vote.participants.first
43
53
  end
54
+
55
+ test "vote bill" do
56
+ assert_equal 'C-2', @vote.bill.number
57
+ assert_match /^An Act to implement the/, @vote.bill.title
58
+ assert_kind_of Bill, @vote.bill
59
+ end
44
60
  end
45
61
 
46
62
  class ParticipantTest < MiniTest::Unit::TestCase
@@ -59,3 +75,17 @@ class ParticipantTest < MiniTest::Unit::TestCase
59
75
  assert_equal "yea", @participant.recorded_vote
60
76
  end
61
77
  end
78
+
79
+ class BillTest < MiniTest::Unit::TestCase
80
+ include Confidence
81
+
82
+ def setup
83
+ @vote = Vote.new(:doc => VOTE_DATA)
84
+ @bill = @vote.bill
85
+ end
86
+
87
+ test "api" do
88
+ assert_respond_to @bill, :number
89
+ assert_respond_to @bill, :title
90
+ end
91
+ end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confidence
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.5"
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 5
8
+ - 1
9
+ version: 0.5.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - chebuctonian
@@ -15,14 +20,16 @@ default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: minitest
18
- type: :development
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
24
30
  version: "0"
25
- version:
31
+ type: :development
32
+ version_requirements: *id001
26
33
  description: MP voting record scraper.
27
34
  email:
28
35
  executables: []
@@ -32,9 +39,11 @@ extensions: []
32
39
  extra_rdoc_files: []
33
40
 
34
41
  files:
42
+ - .gitignore
35
43
  - Manifest
36
44
  - README
37
45
  - Rakefile
46
+ - confidence.gemspec
38
47
  - lib/confidence.rb
39
48
  - specs.watchr
40
49
  - test/confidence_test.rb
@@ -53,18 +62,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
62
  requirements:
54
63
  - - ">="
55
64
  - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
56
67
  version: "0"
57
- version:
58
68
  required_rubygems_version: !ruby/object:Gem::Requirement
59
69
  requirements:
60
70
  - - ">="
61
71
  - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
62
74
  version: "0"
63
- version:
64
75
  requirements: []
65
76
 
66
77
  rubyforge_project:
67
- rubygems_version: 1.3.5
78
+ rubygems_version: 1.3.6
68
79
  signing_key:
69
80
  specification_version: 3
70
81
  summary: MP voting record scraper