kijkwijzer 0.1.4 → 0.1.5

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
- SHA1:
3
- metadata.gz: a1eef3b10869119fe141d42e5d75390e21876ad2
4
- data.tar.gz: 2b349974b172e52ddecfce7e4a56af80ea32fa37
2
+ SHA256:
3
+ metadata.gz: af0948d919a2baa520ea0fbe6850cd8a74b241a9e00bad76064d3aa723d0d8b4
4
+ data.tar.gz: 665557ad474bb0c71d7e747ea4af1e9a0d7a8271e9d6ca3984b771bbe3af43df
5
5
  SHA512:
6
- metadata.gz: 7af3c2818d785a49153bdd096211a5c9c02f3614e53a97f193ab233b87e9dda858a4d72f2e86d6d08c3e19f317a096e76ca60e2ee0c2fdc64a39b434ecb14388
7
- data.tar.gz: f36bad1f64533fc89a5153576306bd39112ed858b79750c26c24b6728105a5ea112ee6882deb463673415c55a7696891a891d744ace468790bde6571dd7a7b30
6
+ metadata.gz: 8e6967d69d49728712381248768c622906b4450471f73c78b62462d9452f6b2956fe407e418ad3dec4317d9ee52ff6dbcc1764f74444c92508c58d7447641aa1
7
+ data.tar.gz: 7fcde1ba4a440bf813418437eb8d65374d72528e73be52f017d123e37ea76583bed348b54521dbe3512cc1c631310d9151c0e1d33b0fe76361a790534856f601
data/kijkwijzer.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency "nokogiri"
23
- spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "bundler", "> 2"
24
24
  spec.add_development_dependency "rspec", "~> 3.4"
25
- spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "rake", "> 12"
26
26
  end
@@ -22,5 +22,25 @@ module Kijkwijzer
22
22
  def to_s
23
23
  "#<Kijkwijzer::Result @title=\"#{title}\", @year=#{year}>"
24
24
  end
25
+
26
+ # Filters use a key value hash to which the results should conform
27
+ #
28
+ # @return [TrueClass, FalseClass]
29
+ def match_filter?(filter)
30
+ !(filter.collect{|k, v| include_r = (self.send(k) == v)}.include? false)
31
+ end
32
+
33
+ class << self
34
+ def new_from_nokogiri_result_fragment nokogiri_result_fragment
35
+ r = self.new
36
+ r.title = nokogiri_result_fragment.css('b').text
37
+ production_type_match = nokogiri_result_fragment.text.match(/Productietype\:\s(.*)\.(\sProductie)/)
38
+ production_year_match = nokogiri_result_fragment.text.match(/\sProductiejaar\:\s(\d\d\d\d)\.\s/)
39
+ r.year = production_year_match[1].to_i if production_year_match
40
+ r.production_type = production_type_match[1] if production_type_match
41
+ r.ratings = nokogiri_result_fragment.css("img").collect{|a| a.attr("src").match(/\/upload\/pictogrammen\/\d*_\d*_(.*)\.png/)[1]}
42
+ return r
43
+ end
44
+ end
25
45
  end
26
46
  end
@@ -1,3 +1,3 @@
1
1
  module Kijkwijzer
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/kijkwijzer.rb CHANGED
@@ -34,18 +34,8 @@ module Kijkwijzer
34
34
  res = get_content(search)
35
35
  results = []
36
36
  res.css('.content_hok .nieuwsitem').each do |result|
37
- r = Result.new()
38
- r.title = result.css('b').text
39
- production_type_match = result.text.match(/Productietype\:\s(.*)\.(\sProductie)/)
40
- production_year_match = result.text.match(/\sProductiejaar\:\s(\d\d\d\d)\.\s/)
41
- r.year = production_year_match[1].to_i if production_year_match
42
- r.production_type = production_type_match[1] if production_type_match
43
- r.ratings = result.css("img").collect{|a| a.attr("src").match(/\/upload\/pictogrammen\/\d*_\d*_(.*)\.png/)[1]}
44
- include_r = true
45
- filter.each do |key, value|
46
- include_r = (r.send(key) == value)
47
- end
48
- results << r if include_r
37
+ r = Result.new_from_nokogiri_result_fragment(result)
38
+ results << r if r.match_filter?(filter)
49
39
  end
50
40
  results
51
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kijkwijzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maarten Brouwers
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-18 00:00:00.000000000 Z
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.9'
33
+ version: '2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.9'
40
+ version: '2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">"
60
60
  - !ruby/object:Gem::Version
61
- version: '12.0'
61
+ version: '12'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">"
67
67
  - !ruby/object:Gem::Version
68
- version: '12.0'
68
+ version: '12'
69
69
  description: Retrieves the kijkwijzer rating for a particular title and year
70
70
  email:
71
71
  - github.com@murb.nl
@@ -94,7 +94,7 @@ homepage: https://github.com/murb/kijkwijzer
94
94
  licenses:
95
95
  - MIT
96
96
  metadata: {}
97
- post_install_message:
97
+ post_install_message:
98
98
  rdoc_options: []
99
99
  require_paths:
100
100
  - lib
@@ -109,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.6.11
114
- signing_key:
112
+ rubygems_version: 3.2.29
113
+ signing_key:
115
114
  specification_version: 4
116
115
  summary: Retrieves the kijkwijzer rating for a particular title and year
117
116
  test_files: []