pupa 0.2.3 → 0.2.4

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: c0b3361fdbe89fad7482ffc7661a04f6a610351e
4
- data.tar.gz: 49066676fd5b7519c300eb9e3dfc05655bb6d864
3
+ metadata.gz: e4c9018ed669280a1194d4994489478c00425c8e
4
+ data.tar.gz: 3b9b3e8f9d3848544fcec2742a22d64015e63df7
5
5
  SHA512:
6
- metadata.gz: 97f44c06bae5f107264135b2fb82a84fc17cf9ac521903e75fd4653c1a975bc5516f8f33711be9e9d1063a2be1178e728a1ff83752554074b32d895172c768d8
7
- data.tar.gz: 330535ef6392fb0990a28ca8e0b30e0ce217ab68407d4afdf7f917a65d0fc8349b1a953547b5be7158f372c85aefd611c7d4e1e480f8d287f63195b3b09cdc82
6
+ metadata.gz: cbb606d5a3b65f8d2a0da7ad8807fb5b43c0c7da0972da461c88c72b267ef686bb8ca81be74860705c23db90f09ecf7b4e3fc822ae7616f5eb476f7bdd118572
7
+ data.tar.gz: a6185283e2645adb2c3455a2a53ad723f347d64cee0e4a505cc819a6027d3bad76d60426430082f966fac837a4370a7421c3e0483268fd9df621865d14a3e136
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in the gemspec
4
4
  gemspec
5
+
6
+ # Remove once vcr 2.9.4 released.
7
+ gem 'vcr', git: 'https://github.com/vcr/vcr.git'
data/Rakefile CHANGED
@@ -19,18 +19,20 @@ namespace :popolo do
19
19
  desc 'Update Popolo schemas'
20
20
  task :schemas do
21
21
  require 'base64'
22
+ require 'json'
22
23
 
23
24
  require 'octokit'
24
25
 
25
26
  Octokit.contents('popolo-project/popolo-spec', path: 'schemas', ref: 'gh-pages').each do |file|
26
27
  response = Octokit.contents('popolo-project/popolo-spec', path: file.path, ref: 'gh-pages')
27
28
  if response.encoding == 'base64'
28
- content = Base64.decode64(response.content)
29
+ content = JSON.load(Base64.decode64(response.content))
29
30
  else
30
31
  raise "Can't handle #{response.encoding} encoding"
31
32
  end
33
+ content['id'] = content['id'].sub('http://www.popoloproject.com/schemas/', '')
32
34
  File.open(File.expand_path(File.join('schemas', 'popolo', file.name), __dir__), 'w') do |f|
33
- f.write(content)
35
+ f.write(JSON.dump(content))
34
36
  end
35
37
  end
36
38
  end
@@ -3,7 +3,7 @@ module Pupa
3
3
  class Area
4
4
  include Model
5
5
 
6
- self.schema = 'popolo/area'
6
+ self.schema = File.expand_path(File.join('..', '..', '..', 'schemas', 'popolo', 'area.json'), __dir__)
7
7
 
8
8
  include Concerns::Timestamps
9
9
  include Concerns::Sourceable
@@ -3,7 +3,7 @@ module Pupa
3
3
  class Membership
4
4
  include Model
5
5
 
6
- self.schema = 'popolo/membership'
6
+ self.schema = File.expand_path(File.join('..', '..', '..', 'schemas', 'popolo', 'membership.json'), __dir__)
7
7
 
8
8
  include Concerns::Timestamps
9
9
  include Concerns::Sourceable
@@ -78,14 +78,7 @@ module Pupa
78
78
  # @param [Hash,String] value a hash or a relative or absolute path
79
79
  # @note `JSON::Validator#initialize_schema` runs fastest if given a hash.
80
80
  def schema=(value)
81
- self.json_schema = if Hash === value
82
- value
83
- elsif Pathname.new(value).absolute?
84
- JSON.load(File.read(value))
85
- else
86
- JSON.load(File.read(File.expand_path(File.join('..', '..', '..', 'schemas', "#{value}.json"), __dir__)))
87
- end
88
-
81
+ self.json_schema = value
89
82
  self.validator = JSON::Validator.new(self.json_schema, {}, {
90
83
  clear_cache: false,
91
84
  parse_data: false,
@@ -3,7 +3,7 @@ module Pupa
3
3
  class Motion
4
4
  include Model
5
5
 
6
- self.schema = 'popolo/motion'
6
+ self.schema = File.expand_path(File.join('..', '..', '..', 'schemas', 'popolo', 'motion.json'), __dir__)
7
7
 
8
8
  include Concerns::Timestamps
9
9
  include Concerns::Sourceable
@@ -4,7 +4,7 @@ module Pupa
4
4
  class Organization
5
5
  include Model
6
6
 
7
- self.schema = 'popolo/organization'
7
+ self.schema = File.expand_path(File.join('..', '..', '..', 'schemas', 'popolo', 'organization.json'), __dir__)
8
8
 
9
9
  include Concerns::Timestamps
10
10
  include Concerns::Sourceable
@@ -3,7 +3,7 @@ module Pupa
3
3
  class Person
4
4
  include Model
5
5
 
6
- self.schema = 'popolo/person'
6
+ self.schema = File.expand_path(File.join('..', '..', '..', 'schemas', 'popolo', 'person.json'), __dir__)
7
7
 
8
8
  include Concerns::Timestamps
9
9
  include Concerns::Sourceable
@@ -3,7 +3,7 @@ module Pupa
3
3
  class Post
4
4
  include Model
5
5
 
6
- self.schema = 'popolo/post'
6
+ self.schema = File.expand_path(File.join('..', '..', '..', 'schemas', 'popolo', 'post.json'), __dir__)
7
7
 
8
8
  include Concerns::Timestamps
9
9
  include Concerns::Sourceable
@@ -3,7 +3,7 @@ module Pupa
3
3
  class Vote
4
4
  include Model
5
5
 
6
- self.schema = 'popolo/vote'
6
+ self.schema = File.expand_path(File.join('..', '..', '..', 'schemas', 'popolo', 'vote.json'), __dir__)
7
7
 
8
8
  include Concerns::Timestamps
9
9
  include Concerns::Sourceable
@@ -3,7 +3,7 @@ module Pupa
3
3
  class VoteEvent
4
4
  include Model
5
5
 
6
- self.schema = 'popolo/vote_event'
6
+ self.schema = File.expand_path(File.join('..', '..', '..', 'schemas', 'popolo', 'vote_event.json'), __dir__)
7
7
 
8
8
  include Concerns::Timestamps
9
9
  include Concerns::Sourceable
@@ -1,3 +1,3 @@
1
1
  module Pupa
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/area.json#",
3
+ "id": "area.json#",
4
4
  "title": "Area",
5
5
  "description": "A geographic area whose geometry may change over time",
6
6
  "type": "object",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "parent": {
29
29
  "description": "The area that contains this area",
30
- "$ref": "http://www.popoloproject.com/schemas/area.json#"
30
+ "$ref": "area.json#"
31
31
  },
32
32
  "geometry": {
33
33
  "description": "A geometry",
@@ -47,7 +47,7 @@
47
47
  "description": "URLs to documents from which the area is derived",
48
48
  "type": "array",
49
49
  "items": {
50
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
50
+ "$ref": "link.json#"
51
51
  }
52
52
  }
53
53
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/contact_detail.json#",
3
+ "id": "contact_detail.json#",
4
4
  "title": "Contact detail",
5
5
  "description": "A means of contacting an entity",
6
6
  "type": "object",
@@ -47,7 +47,7 @@
47
47
  "description": "URLs to documents from which the contact detail is derived",
48
48
  "type": "array",
49
49
  "items": {
50
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
50
+ "$ref": "link.json#"
51
51
  }
52
52
  }
53
53
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/count.json#",
3
+ "id": "count.json#",
4
4
  "title": "Count",
5
5
  "description": "The number of votes for an option in a vote event",
6
6
  "type": "object",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/group_result.json#",
3
+ "id": "group_result.json#",
4
4
  "title": "Group result",
5
5
  "description": "A result of a vote event within a group of voters",
6
6
  "type": "object",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/identifier.json#",
3
+ "id": "identifier.json#",
4
4
  "title": "Identifier",
5
5
  "description": "An issued identifier",
6
6
  "type": "object",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/link.json#",
3
+ "id": "link.json#",
4
4
  "title": "Link",
5
5
  "description": "A URL",
6
6
  "type": "object",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/membership.json#",
3
+ "id": "membership.json#",
4
4
  "title": "Membership",
5
5
  "description": "A relationship between a member and an organization",
6
6
  "type": "object",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "person": {
29
29
  "description": "The person who is a member of the organization",
30
- "$ref": "http://www.popoloproject.com/schemas/person.json#"
30
+ "$ref": "person.json#"
31
31
  },
32
32
  "organization_id": {
33
33
  "description": "The ID of the organization in which the person or organization is a member",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "organization": {
37
37
  "description": "The organization in which the person or organization is a member",
38
- "$ref": "http://www.popoloproject.com/schemas/organization.json#"
38
+ "$ref": "organization.json#"
39
39
  },
40
40
  "post_id": {
41
41
  "description": "The ID of the post held by the member in the organization through this membership",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "post": {
45
45
  "description": "The post held by the member in the organization through this membership",
46
- "$ref": "http://www.popoloproject.com/schemas/post.json#"
46
+ "$ref": "post.json#"
47
47
  },
48
48
  "on_behalf_of_id": {
49
49
  "description": "The ID of the organization on whose behalf the person is a member of the organization",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "on_behalf_of": {
53
53
  "description": "The organization on whose behalf the person is a member of the organization",
54
- "$ref": "http://www.popoloproject.com/schemas/organization.json#"
54
+ "$ref": "organization.json#"
55
55
  },
56
56
  "area_id": {
57
57
  "description": "The ID of the geographic area to which this membership is related",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "area": {
61
61
  "description": "The geographic area to which this membership is related",
62
- "$ref": "http://www.popoloproject.com/schemas/area.json#"
62
+ "$ref": "area.json#"
63
63
  },
64
64
  "start_date": {
65
65
  "description": "The date on which the relationship began",
@@ -75,14 +75,14 @@
75
75
  "description": "Means of contacting the member of the organization",
76
76
  "type": "array",
77
77
  "items": {
78
- "$ref": "http://www.popoloproject.com/schemas/contact_detail.json#"
78
+ "$ref": "contact_detail.json#"
79
79
  }
80
80
  },
81
81
  "links": {
82
82
  "description": "URLs to documents about the membership",
83
83
  "type": "array",
84
84
  "items": {
85
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
85
+ "$ref": "link.json#"
86
86
  }
87
87
  },
88
88
  "created_at": {
@@ -99,7 +99,7 @@
99
99
  "description": "URLs to documents from which the membership is derived",
100
100
  "type": "array",
101
101
  "items": {
102
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
102
+ "$ref": "link.json#"
103
103
  }
104
104
  }
105
105
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/motion.json#",
3
+ "id": "motion.json#",
4
4
  "title": "Motion",
5
5
  "description": "A formal step to introduce a matter for consideration by an organization",
6
6
  "type": "object",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "organization": {
17
17
  "description": "The organization in which the motion is proposed",
18
- "$ref": "http://www.popoloproject.com/schemas/organization.json#"
18
+ "$ref": "organization.json#"
19
19
  },
20
20
  "legislative_session_id": {
21
21
  "description": "The ID of the legislative session in which the motion is proposed",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "creator": {
33
33
  "description": "The person who proposed the motion",
34
- "$ref": "http://www.popoloproject.com/schemas/person.json#"
34
+ "$ref": "person.json#"
35
35
  },
36
36
  "text": {
37
37
  "description": "The transcript or text of the motion",
@@ -58,7 +58,7 @@
58
58
  "description": "Events at which people vote on the motion",
59
59
  "type": "array",
60
60
  "items": {
61
- "$ref": "http://www.popoloproject.com/schemas/vote_event.json#"
61
+ "$ref": "vote_event.json#"
62
62
  }
63
63
  },
64
64
  "created_at": {
@@ -75,7 +75,7 @@
75
75
  "description": "URLs to documents from which the motion is derived",
76
76
  "type": "array",
77
77
  "items": {
78
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
78
+ "$ref": "link.json#"
79
79
  }
80
80
  }
81
81
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/organization.json#",
3
+ "id": "organization.json#",
4
4
  "title": "Organization",
5
5
  "description": "A group with a common purpose or reason for existence that goes beyond the set of people belonging to it",
6
6
  "type": "object",
@@ -17,14 +17,14 @@
17
17
  "description": "Alternate or former names",
18
18
  "type": "array",
19
19
  "items": {
20
- "$ref": "http://www.popoloproject.com/schemas/other_name.json#"
20
+ "$ref": "other_name.json#"
21
21
  }
22
22
  },
23
23
  "identifiers": {
24
24
  "description": "Issued identifiers",
25
25
  "type": "array",
26
26
  "items": {
27
- "$ref": "http://www.popoloproject.com/schemas/identifier.json#"
27
+ "$ref": "identifier.json#"
28
28
  }
29
29
  },
30
30
  "classification": {
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "parent": {
39
39
  "description": "The organization that contains this organization",
40
- "$ref": "http://www.popoloproject.com/schemas/organization.json#"
40
+ "$ref": "organization.json#"
41
41
  },
42
42
  "area_id": {
43
43
  "description": "The ID of the geographic area to which this organization is related",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "area": {
47
47
  "description": "The geographic area to which this organization is related",
48
- "$ref": "http://www.popoloproject.com/schemas/area.json#"
48
+ "$ref": "area.json#"
49
49
  },
50
50
  "founding_date": {
51
51
  "description": "A date of founding",
@@ -66,28 +66,28 @@
66
66
  "description": "Means of contacting the organization",
67
67
  "type": "array",
68
68
  "items": {
69
- "$ref": "http://www.popoloproject.com/schemas/contact_detail.json#"
69
+ "$ref": "contact_detail.json#"
70
70
  }
71
71
  },
72
72
  "links": {
73
73
  "description": "URLs to documents about the organization",
74
74
  "type": "array",
75
75
  "items": {
76
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
76
+ "$ref": "link.json#"
77
77
  }
78
78
  },
79
79
  "memberships": {
80
80
  "description": "Memberships",
81
81
  "type": "array",
82
82
  "items": {
83
- "$ref": "http://www.popoloproject.com/schemas/membership.json#"
83
+ "$ref": "membership.json#"
84
84
  }
85
85
  },
86
86
  "posts": {
87
87
  "description": "Posts within the organization",
88
88
  "type": "array",
89
89
  "items": {
90
- "$ref": "http://www.popoloproject.com/schemas/post.json#"
90
+ "$ref": "post.json#"
91
91
  }
92
92
  },
93
93
  "created_at": {
@@ -104,7 +104,7 @@
104
104
  "description": "URLs to documents from which the organization is derived",
105
105
  "type": "array",
106
106
  "items": {
107
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
107
+ "$ref": "link.json#"
108
108
  }
109
109
  }
110
110
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/other_name.json#",
3
+ "id": "other_name.json#",
4
4
  "title": "Other name",
5
5
  "description": "An alternate or former name",
6
6
  "type": "object",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/person.json#",
3
+ "id": "person.json#",
4
4
  "title": "Person",
5
5
  "description": "A real person, alive or dead",
6
6
  "type": "object",
@@ -17,14 +17,14 @@
17
17
  "description": "Alternate or former names",
18
18
  "type": "array",
19
19
  "items": {
20
- "$ref": "http://www.popoloproject.com/schemas/other_name.json#"
20
+ "$ref": "other_name.json#"
21
21
  }
22
22
  },
23
23
  "identifiers": {
24
24
  "description": "Issued identifiers",
25
25
  "type": "array",
26
26
  "items": {
27
- "$ref": "http://www.popoloproject.com/schemas/identifier.json#"
27
+ "$ref": "identifier.json#"
28
28
  }
29
29
  },
30
30
  "family_name": {
@@ -95,21 +95,21 @@
95
95
  "description": "Means of contacting the person",
96
96
  "type": "array",
97
97
  "items": {
98
- "$ref": "http://www.popoloproject.com/schemas/contact_detail.json#"
98
+ "$ref": "contact_detail.json#"
99
99
  }
100
100
  },
101
101
  "links": {
102
102
  "description": "URLs to documents about the person",
103
103
  "type": "array",
104
104
  "items": {
105
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
105
+ "$ref": "link.json#"
106
106
  }
107
107
  },
108
108
  "memberships": {
109
109
  "description": "Memberships",
110
110
  "type": "array",
111
111
  "items": {
112
- "$ref": "http://www.popoloproject.com/schemas/membership.json#"
112
+ "$ref": "membership.json#"
113
113
  }
114
114
  },
115
115
  "created_at": {
@@ -126,7 +126,7 @@
126
126
  "description": "URLs to documents from which the person is derived",
127
127
  "type": "array",
128
128
  "items": {
129
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
129
+ "$ref": "link.json#"
130
130
  }
131
131
  }
132
132
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/post.json#",
3
+ "id": "post.json#",
4
4
  "title": "Post",
5
5
  "description": "A position that exists independent of the person holding it",
6
6
  "type": "object",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "organization": {
32
32
  "description": "The organization in which the post is held",
33
- "$ref": "http://www.popoloproject.com/schemas/organization.json#"
33
+ "$ref": "organization.json#"
34
34
  },
35
35
  "area_id": {
36
36
  "description": "The ID of the geographic area to which this post is related",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "area": {
40
40
  "description": "The geographic area to which this post is related",
41
- "$ref": "http://www.popoloproject.com/schemas/area.json#"
41
+ "$ref": "area.json#"
42
42
  },
43
43
  "start_date": {
44
44
  "description": "The date on which the post was created",
@@ -54,21 +54,21 @@
54
54
  "description": "Means of contacting the holder of the post",
55
55
  "type": "array",
56
56
  "items": {
57
- "$ref": "http://www.popoloproject.com/schemas/contact_detail.json#"
57
+ "$ref": "contact_detail.json#"
58
58
  }
59
59
  },
60
60
  "links": {
61
61
  "description": "URLs to documents about the post",
62
62
  "type": "array",
63
63
  "items": {
64
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
64
+ "$ref": "link.json#"
65
65
  }
66
66
  },
67
67
  "memberships": {
68
68
  "description": "The memberships through which people hold the post in the organization",
69
69
  "type": "array",
70
70
  "items": {
71
- "$ref": "http://www.popoloproject.com/schemas/membership.json#"
71
+ "$ref": "membership.json#"
72
72
  }
73
73
  },
74
74
  "created_at": {
@@ -85,7 +85,7 @@
85
85
  "description": "URLs to documents from which the post is derived",
86
86
  "type": "array",
87
87
  "items": {
88
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
88
+ "$ref": "link.json#"
89
89
  }
90
90
  }
91
91
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/vote.json#",
3
+ "id": "vote.json#",
4
4
  "title": "Vote",
5
5
  "description": "A voter's vote in a vote event",
6
6
  "type": "object",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "vote_event": {
17
17
  "description": "A vote event",
18
- "$ref": "http://www.popoloproject.com/schemas/vote_event.json#"
18
+ "$ref": "vote_event.json#"
19
19
  },
20
20
  "voter_id": {
21
21
  "description": "The ID of the person or organization that is voting",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "group": {
37
37
  "description": "The voter's primary political group",
38
- "$ref": "http://www.popoloproject.com/schemas/organization.json#"
38
+ "$ref": "organization.json#"
39
39
  },
40
40
  "role": {
41
41
  "description": "The voter's role in the event",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "pair": {
53
53
  "description": "The person with whom the voter is paired",
54
- "$ref": "http://www.popoloproject.com/schemas/person.json#"
54
+ "$ref": "person.json#"
55
55
  }
56
56
  }
57
57
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-03/schema#",
3
- "id": "http://www.popoloproject.com/schemas/vote_event.json#",
3
+ "id": "vote_event.json#",
4
4
  "title": "Vote event",
5
5
  "description": "An event at which people's votes are recorded",
6
6
  "type": "object",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "motion": {
21
21
  "description": "The motion being decided",
22
- "$ref": "http://www.popoloproject.com/schemas/motion.json#"
22
+ "$ref": "motion.json#"
23
23
  },
24
24
  "organization_id": {
25
25
  "description": "The ID of the organization whose members are voting",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "organization": {
29
29
  "description": "The organization whose members are voting",
30
- "$ref": "http://www.popoloproject.com/schemas/organization.json#"
30
+ "$ref": "organization.json#"
31
31
  },
32
32
  "legislative_session_id": {
33
33
  "description": "The ID of the legislative session in which the vote occurs",
@@ -55,21 +55,21 @@
55
55
  "description": "The result of the vote event within groups of voters",
56
56
  "type": "array",
57
57
  "items": {
58
- "$ref": "http://www.popoloproject.com/schemas/group_result.json#"
58
+ "$ref": "group_result.json#"
59
59
  }
60
60
  },
61
61
  "counts": {
62
62
  "description": "The number of votes for options",
63
63
  "type": "array",
64
64
  "items": {
65
- "$ref": "http://www.popoloproject.com/schemas/count.json#"
65
+ "$ref": "count.json#"
66
66
  }
67
67
  },
68
68
  "votes": {
69
69
  "description": "Voters' votes",
70
70
  "type": "array",
71
71
  "items": {
72
- "$ref": "http://www.popoloproject.com/schemas/vote.json#"
72
+ "$ref": "vote.json#"
73
73
  }
74
74
  },
75
75
  "created_at": {
@@ -86,7 +86,7 @@
86
86
  "description": "URLs to documents from which the vote event is derived",
87
87
  "type": "array",
88
88
  "items": {
89
- "$ref": "http://www.popoloproject.com/schemas/link.json#"
89
+ "$ref": "link.json#"
90
90
  }
91
91
  }
92
92
  }
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://httpbin.org/get
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Accept-Encoding:
13
+ - gzip,deflate
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ server:
20
+ - nginx
21
+ date:
22
+ - Sun, 29 Nov 2015 03:42:22 GMT
23
+ content-type:
24
+ - application/json
25
+ content-length:
26
+ - '230'
27
+ connection:
28
+ - close
29
+ access-control-allow-origin:
30
+ - "*"
31
+ access-control-allow-credentials:
32
+ - 'true'
33
+ body:
34
+ encoding: UTF-8
35
+ string: "{\n \"args\": {}, \n \"headers\": {\n \"Accept\": \"*/*\", \n
36
+ \ \"Accept-Encoding\": \"gzip,deflate\", \n \"Host\": \"httpbin.org\",
37
+ \n \"User-Agent\": \"Faraday v0.9.1\"\n }, \n \"origin\": \"124.111.242.66\",
38
+ \n \"url\": \"http://httpbin.org/get\"\n}\n"
39
+ http_version:
40
+ recorded_at: Sun, 29 Nov 2015 03:42:22 GMT
41
+ recorded_with: VCR 3.0.0
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://httpbin.org/get?foo=bar
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Accept-Encoding:
13
+ - gzip,deflate
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ server:
20
+ - nginx
21
+ date:
22
+ - Sun, 29 Nov 2015 03:42:21 GMT
23
+ content-type:
24
+ - application/json
25
+ content-length:
26
+ - '258'
27
+ connection:
28
+ - close
29
+ access-control-allow-origin:
30
+ - "*"
31
+ access-control-allow-credentials:
32
+ - 'true'
33
+ body:
34
+ encoding: UTF-8
35
+ string: "{\n \"args\": {\n \"foo\": \"bar\"\n }, \n \"headers\": {\n \"Accept\":
36
+ \"*/*\", \n \"Accept-Encoding\": \"gzip,deflate\", \n \"Host\": \"httpbin.org\",
37
+ \n \"User-Agent\": \"Faraday v0.9.1\"\n }, \n \"origin\": \"124.111.242.66\",
38
+ \n \"url\": \"http://httpbin.org/get?foo=bar\"\n}\n"
39
+ http_version:
40
+ recorded_at: Sun, 29 Nov 2015 03:42:21 GMT
41
+ recorded_with: VCR 3.0.0
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://httpbin.org/post
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip,deflate
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Sun, 29 Nov 2015 03:42:23 GMT
25
+ content-type:
26
+ - application/json
27
+ content-length:
28
+ - '380'
29
+ connection:
30
+ - close
31
+ access-control-allow-origin:
32
+ - "*"
33
+ access-control-allow-credentials:
34
+ - 'true'
35
+ body:
36
+ encoding: UTF-8
37
+ string: "{\n \"args\": {}, \n \"data\": \"\", \n \"files\": {}, \n \"form\":
38
+ {}, \n \"headers\": {\n \"Accept\": \"*/*\", \n \"Accept-Encoding\":
39
+ \"gzip,deflate\", \n \"Content-Length\": \"0\", \n \"Content-Type\":
40
+ \"application/x-www-form-urlencoded\", \n \"Host\": \"httpbin.org\", \n
41
+ \ \"User-Agent\": \"Faraday v0.9.1\"\n }, \n \"json\": null, \n \"origin\":
42
+ \"124.111.242.66\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
43
+ http_version:
44
+ recorded_at: Sun, 29 Nov 2015 03:42:23 GMT
45
+ recorded_with: VCR 3.0.0
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://httpbin.org/post
6
+ body:
7
+ encoding: UTF-8
8
+ string: foo=bar
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept-Encoding:
15
+ - gzip,deflate
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx
23
+ date:
24
+ - Sun, 29 Nov 2015 03:42:22 GMT
25
+ content-type:
26
+ - application/json
27
+ content-length:
28
+ - '400'
29
+ connection:
30
+ - close
31
+ access-control-allow-origin:
32
+ - "*"
33
+ access-control-allow-credentials:
34
+ - 'true'
35
+ body:
36
+ encoding: UTF-8
37
+ string: "{\n \"args\": {}, \n \"data\": \"\", \n \"files\": {}, \n \"form\":
38
+ {\n \"foo\": \"bar\"\n }, \n \"headers\": {\n \"Accept\": \"*/*\",
39
+ \n \"Accept-Encoding\": \"gzip,deflate\", \n \"Content-Length\": \"7\",
40
+ \n \"Content-Type\": \"application/x-www-form-urlencoded\", \n \"Host\":
41
+ \"httpbin.org\", \n \"User-Agent\": \"Faraday v0.9.1\"\n }, \n \"json\":
42
+ null, \n \"origin\": \"124.111.242.66\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
43
+ http_version:
44
+ recorded_at: Sun, 29 Nov 2015 03:42:22 GMT
45
+ recorded_with: VCR 3.0.0
@@ -67,7 +67,7 @@ describe Pupa::Model do
67
67
  let :klass_with_relative_path do
68
68
  Class.new do
69
69
  include Pupa::Model
70
- self.schema = 'schema'
70
+ self.schema = 'schema.json'
71
71
  end
72
72
  end
73
73
 
@@ -91,12 +91,12 @@ describe Pupa::Model do
91
91
 
92
92
  it 'should accept an absolute path' do
93
93
  expect(File).to receive(:read).and_return('{}')
94
- expect(klass_with_absolute_path.json_schema).to eq({})
94
+ expect(klass_with_absolute_path.json_schema).to eq('/path/to/schema.json')
95
95
  end
96
96
 
97
97
  it 'should accept a relative path' do
98
98
  expect(File).to receive(:read).and_return('{}')
99
- expect(klass_with_relative_path.json_schema).to eq({})
99
+ expect(klass_with_relative_path.json_schema).to eq('schema.json')
100
100
  end
101
101
  end
102
102
 
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe Pupa::Processor::Client do
4
- describe '.new' do
4
+ describe '.new', vcr: {cassette_name: 'cache'} do
5
5
  it 'should use the filesystem' do
6
6
  expect(ActiveSupport::Cache::FileStore).to receive(:new).and_call_original
7
7
  Pupa::Processor::Client.new(cache_dir: '/tmp', level: 'UNKNOWN').get('http://httpbin.org/')
@@ -37,21 +37,29 @@ describe Pupa::Processor do
37
37
 
38
38
  describe '#get' do
39
39
  it 'should send a GET request' do
40
- expect(processor.get('http://httpbin.org/get', 'foo=bar')['args']).to eq({'foo' => 'bar'})
40
+ VCR.use_cassette('get_params') do
41
+ expect(processor.get('http://httpbin.org/get', 'foo=bar')['args']).to eq({'foo' => 'bar'})
42
+ end
41
43
  end
42
44
 
43
45
  it 'should automatically parse the response' do
44
- expect(processor.get('http://httpbin.org/get')).to be_a(Hash)
46
+ VCR.use_cassette('get') do
47
+ expect(processor.get('http://httpbin.org/get')).to be_a(Hash)
48
+ end
45
49
  end
46
50
  end
47
51
 
48
52
  describe '#post' do
49
53
  it 'should send a POST request' do
50
- expect(processor.post('http://httpbin.org/post', 'foo=bar')['form']).to eq({'foo' => 'bar'})
54
+ VCR.use_cassette('post_params') do
55
+ expect(processor.post('http://httpbin.org/post', 'foo=bar')['form']).to eq({'foo' => 'bar'})
56
+ end
51
57
  end
52
58
 
53
59
  it 'should automatically parse the response' do
54
- expect(processor.post('http://httpbin.org/post')).to be_a(Hash)
60
+ VCR.use_cassette('post') do
61
+ expect(processor.post('http://httpbin.org/post')).to be_a(Hash)
62
+ end
55
63
  end
56
64
  end
57
65
 
@@ -7,6 +7,14 @@ SimpleCov.start do
7
7
  add_filter 'spec'
8
8
  end
9
9
 
10
+ require 'vcr'
11
+ VCR.configure do |c|
12
+ c.cassette_library_dir = 'spec/cassettes'
13
+ c.hook_into :faraday
14
+ c.allow_http_connections_when_no_cassette = true
15
+ c.configure_rspec_metadata!
16
+ end
17
+
10
18
  require 'multi_xml'
11
19
  require 'nokogiri'
12
20
  require 'redis-store'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pupa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James McKinney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-25 00:00:00.000000000 Z
11
+ date: 2015-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -346,6 +346,10 @@ files:
346
346
  - schemas/popolo/post.json
347
347
  - schemas/popolo/vote.json
348
348
  - schemas/popolo/vote_event.json
349
+ - spec/cassettes/get.yml
350
+ - spec/cassettes/get_params.yml
351
+ - spec/cassettes/post.yml
352
+ - spec/cassettes/post_params.yml
349
353
  - spec/fixtures/bar.json
350
354
  - spec/fixtures/baz.json
351
355
  - spec/fixtures/foo.json
@@ -411,6 +415,10 @@ signing_key:
411
415
  specification_version: 4
412
416
  summary: A data scraping framework
413
417
  test_files:
418
+ - spec/cassettes/get.yml
419
+ - spec/cassettes/get_params.yml
420
+ - spec/cassettes/post.yml
421
+ - spec/cassettes/post_params.yml
414
422
  - spec/fixtures/bar.json
415
423
  - spec/fixtures/baz.json
416
424
  - spec/fixtures/foo.json