everypolitician-popolo 0.4.0 → 0.5.0

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: 06d7ef4f90694c7c3bb3dd1b0c3c3d625ddb3b2b
4
- data.tar.gz: 522b022a34eba1f04a62cf095fc13c4d32c73d49
3
+ metadata.gz: 02929dc6bc5bd531b724d07047844435bfd223ad
4
+ data.tar.gz: aa9c71d31ff43c43cd5edc4ea5b043b90f494213
5
5
  SHA512:
6
- metadata.gz: 90aeb9436dd7897f98cf8c79932d68d3b78482de94e56d3fc23b49df30a6172e43582b0bf0b5c34ed92b606fd240f798d97764de2c066ee87346b04f8c0729e1
7
- data.tar.gz: a202df2c86a1eaf3d5005c010c87a8361904a5c75b3c4a36b2b9927d960970f0f0195dcb6301e74e356ae6cef50a032a60bdd824e738b11df2269f14c6850c31
6
+ metadata.gz: 80c7c8dfa484a3c3f6e6533edb8099fbd5887bcf7562199c75035050cf508ec616f1c8d2a09e0030874275749b2dec51688330267760f688651a5b12407f766e
7
+ data.tar.gz: 243c3f25a16496072e70a326ace166fc91d73f50a8dc102cbe3239fd81cbdecf8251fb98b32163aed0f2ab96543e1c396ccddbdba6cf2ac2dd6945a5aca482d4
@@ -0,0 +1,53 @@
1
+ Style/AlignHash:
2
+ EnforcedHashRocketStyle: table
3
+ EnforcedColonStyle: table
4
+
5
+ Style/ClassAndModuleCamelCase:
6
+ Enabled: false
7
+
8
+ Style/CollectionMethods:
9
+ Enabled: true
10
+
11
+ Style/Documentation:
12
+ Enabled: false
13
+
14
+ Style/FormatString:
15
+ EnforcedStyle: percent
16
+
17
+ Style/HashSyntax:
18
+ EnforcedStyle: ruby19_no_mixed_keys
19
+
20
+ Style/RescueModifier:
21
+ Enabled: false
22
+
23
+ Style/SignalException:
24
+ Enabled: false
25
+
26
+ Style/SymbolArray:
27
+ Enabled: true
28
+
29
+ Style/TrailingCommaInLiteral:
30
+ EnforcedStyleForMultiline: consistent_comma
31
+
32
+
33
+ Metrics/ClassLength:
34
+ Max: 250
35
+
36
+ Metrics/MethodLength:
37
+ Max: 20
38
+
39
+ Metrics/LineLength:
40
+ Max: 150
41
+
42
+ Metrics/AbcSize:
43
+ Max: 50
44
+
45
+ Metrics/CyclomaticComplexity:
46
+ Max: 7
47
+
48
+ Metrics/PerceivedComplexity:
49
+ Max: 8
50
+
51
+
52
+ # Temporarily! (2016-08-01)
53
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,7 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-08-01 14:20:19 +0100 using RuboCop version 0.42.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
@@ -1,4 +1,7 @@
1
1
  language: ruby
2
+ script:
3
+ - bundle exec rake test
4
+ - bundle exec rake rubocop
2
5
  cache: bundler
3
6
  rvm:
4
7
  - 2.0.0
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.5.0] - 2016-08-01
7
+
8
+ ### Added
9
+
10
+ - Added `Person#link(type)`
11
+
6
12
  ## [0.4.0] - 2016-07-04
7
13
 
8
14
  ### Added
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in everypolitician-popolo.gemspec
4
4
  gemspec
5
+
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
+ require 'rubocop/rake_task'
4
+
5
+ RuboCop::RakeTask.new
3
6
 
4
7
  Rake::TestTask.new(:test) do |t|
5
8
  t.libs << 'test'
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
23
23
  spec.add_development_dependency 'minitest', '~> 5.0'
24
24
  spec.add_development_dependency 'pry', '~> 0.10'
25
+ spec.add_development_dependency 'rubocop', '~> 0.42.0'
25
26
  end
@@ -56,12 +56,12 @@ module Everypolitician
56
56
  def legislative_periods
57
57
  events.where(classification: 'legislative period').sort_by(&:start_date)
58
58
  end
59
- alias_method :terms, :legislative_periods
59
+ alias terms legislative_periods
60
60
 
61
61
  def current_legislative_period
62
62
  legislative_periods.last
63
63
  end
64
- alias_method :current_term, :current_legislative_period
64
+ alias current_term current_legislative_period
65
65
  end
66
66
  end
67
67
  end
@@ -25,7 +25,7 @@ module Everypolitician
25
25
  end
26
26
 
27
27
  def where(attributes = {})
28
- find_all do |object|
28
+ select do |object|
29
29
  attributes.all? { |k, v| object.send(k) == v }
30
30
  end
31
31
  end
@@ -35,21 +35,21 @@ module Everypolitician
35
35
  # TODO: This feels pretty nasty, is there a better way of working out the
36
36
  # class name?
37
37
  def klass
38
- case self.class.to_s.split("::").last
39
- when "People"
38
+ case self.class.to_s.split('::').last
39
+ when 'People'
40
40
  Person
41
- when "Organizations"
41
+ when 'Organizations'
42
42
  Organization
43
- when "Memberships"
43
+ when 'Memberships'
44
44
  Membership
45
- when "Events"
45
+ when 'Events'
46
46
  Event
47
- when "Posts"
47
+ when 'Posts'
48
48
  Post
49
- when "Areas"
49
+ when 'Areas'
50
50
  Area
51
51
  else
52
- raise "Unknown class: #{self.class.to_s}"
52
+ raise "Unknown class: #{self.class}"
53
53
  end
54
54
  end
55
55
  end
@@ -1,7 +1,6 @@
1
1
  module Everypolitician
2
2
  module Popolo
3
3
  class Entity
4
-
5
4
  attr_accessor :id
6
5
  attr_reader :document
7
6
  attr_reader :popolo
@@ -33,7 +32,7 @@ module Everypolitician
33
32
  alias eql? ==
34
33
 
35
34
  def identifier(scheme)
36
- identifiers.find(->{{}}) { |i| i[:scheme] == scheme }[:identifier]
35
+ identifiers.find(-> { {} }) { |i| i[:scheme] == scheme }[:identifier]
37
36
  end
38
37
  end
39
38
  end
@@ -1,7 +1,7 @@
1
1
  module Everypolitician
2
2
  module Popolo
3
3
  class Events < Collection; end
4
- class Event < Entity;
4
+ class Event < Entity
5
5
  attr_accessor :start_date, :end_date
6
6
  end
7
7
  end
@@ -11,6 +11,10 @@ module Everypolitician
11
11
  document.fetch(:links, [])
12
12
  end
13
13
 
14
+ def link(type)
15
+ links.find(-> { {} }) { |i| i[:note] == type }[:url]
16
+ end
17
+
14
18
  def identifiers
15
19
  document.fetch(:identifiers, [])
16
20
  end
@@ -20,7 +24,7 @@ module Everypolitician
20
24
  end
21
25
 
22
26
  def contact(type)
23
- contact_details.find(->{{}}) { |i| i[:type] == type }[:value]
27
+ contact_details.find(-> { {} }) { |i| i[:type] == type }[:value]
24
28
  end
25
29
 
26
30
  def phone
@@ -32,21 +36,11 @@ module Everypolitician
32
36
  end
33
37
 
34
38
  def twitter
35
- if key?(:contact_details)
36
- if twitter_contact = self[:contact_details].find { |d| d[:type] == 'twitter' }
37
- return twitter_contact[:value].strip
38
- end
39
- end
40
- if key?(:links)
41
- if twitter_link = self[:links].find { |d| d[:note][/twitter/i] }
42
- return twitter_link[:url].strip
43
- end
44
- end
39
+ contact('twitter') || link('twitter')
45
40
  end
46
41
 
47
42
  def facebook
48
- facebook_link = links.find { |d| d[:note] == 'facebook' }
49
- facebook_link[:url] if facebook_link
43
+ link('facebook')
50
44
  end
51
45
 
52
46
  def wikidata
@@ -59,9 +53,9 @@ module Everypolitician
59
53
 
60
54
  def name_at(date)
61
55
  return name unless key?(:other_names)
62
- historic = other_names.find_all { |n| n.key?(:end_date) }
56
+ historic = other_names.select { |n| n.key?(:end_date) }
63
57
  return name if historic.empty?
64
- at_date = historic.find_all do |n|
58
+ at_date = historic.select do |n|
65
59
  n[:end_date] >= date && (n[:start_date] || '0000-00-00') <= date
66
60
  end
67
61
  return name if at_date.empty?
@@ -1,5 +1,5 @@
1
1
  module Everypolitician
2
2
  module Popolo
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everypolitician-popolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Mytton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-26 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.42.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.42.0
69
83
  description:
70
84
  email:
71
85
  - chrismytton@gmail.com
@@ -75,6 +89,8 @@ extra_rdoc_files: []
75
89
  files:
76
90
  - ".github/ISSUE_TEMPLATE.md"
77
91
  - ".gitignore"
92
+ - ".rubocop.yml"
93
+ - ".rubocop_todo.yml"
78
94
  - ".travis.yml"
79
95
  - CHANGELOG.md
80
96
  - Gemfile
@@ -119,4 +135,3 @@ signing_key:
119
135
  specification_version: 4
120
136
  summary: Makes it easy to work with EveryPolitician's Popolo output files from Ruby
121
137
  test_files: []
122
- has_rdoc: