openfoodfacts 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -5
- data/lib/openfoodfacts/product.rb +12 -1
- data/lib/openfoodfacts/version.rb +1 -1
- data/test/test_openfoodfacts.rb +2 -2
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5bba81d2fa5eba4c502cdd6b59ddee3b504addc298f0a0ebaf254b0c2885641
|
4
|
+
data.tar.gz: c9bb2c4266aaeac2c606e741f44a4d60d81d919be29f587a6abc15ef15c74fcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7201788f4331aacbe1406f67a91432ce0b1493ce635f5359781a0bd9d2645a3740499c2a263e60f7ecd94ceb1e81df0e54d306c92cbfd2b14010c69c9ffab83b
|
7
|
+
data.tar.gz: 25d08f6c5a61a7db159c7c36efbfcd31363bf7b97ca77cc910ff1f45795bc091aa3e106354fe8f9e7585f6ef05e63b825ca1f1c651a6f987aa16ea1063a36e3b
|
data/README.md
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
# Open Food Facts
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/openfoodfacts.svg)](https://badge.fury.io/rb/openfoodfacts)
|
4
|
-
[![Build Status](https://
|
5
|
-
[![
|
6
|
-
[![Dependency Status](https://gemnasium.com/openfoodfacts/openfoodfacts-ruby.svg)](https://gemnasium.com/openfoodfacts/openfoodfacts-ruby)
|
7
|
-
[![Code Climate](https://codeclimate.com/github/openfoodfacts/openfoodfacts-ruby/badges/gpa.svg)](https://codeclimate.com/github/openfoodfacts/openfoodfacts-ruby)
|
8
|
-
[![Coverage Status](https://coveralls.io/repos/github/openfoodfacts/openfoodfacts-ruby/badge.svg?branch=master)](https://coveralls.io/github/openfoodfacts/openfoodfacts-ruby?branch=master)
|
4
|
+
[![Build Status](https://github.com/openfoodfacts/openfoodfacts-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/openfoodfacts/openfoodfacts-ruby/actions/workflows/ruby.yml)
|
5
|
+
[![RuboCop](https://github.com/openfoodfacts/openfoodfacts-ruby/actions/workflows/rubocop-analysis.yml/badge.svg)](https://github.com/openfoodfacts/openfoodfacts-ruby/actions/workflows/rubocop-analysis.yml)
|
9
6
|
[![Documentation](https://inch-ci.org/github/openfoodfacts/openfoodfacts-ruby.svg?branch=master)](https://inch-ci.org/github/openfoodfacts/openfoodfacts-ruby)
|
10
7
|
|
11
8
|
API Wrapper for [Open Food Facts](https://openfoodfacts.org/), the open database about food.
|
@@ -120,8 +120,19 @@ module Openfoodfacts
|
|
120
120
|
else
|
121
121
|
link = tag.css('a').first
|
122
122
|
|
123
|
+
name = link.text.strip
|
124
|
+
img_alt = link.css('img').attr('alt')
|
125
|
+
if (name.nil? || name == '') && img_alt
|
126
|
+
img_alt_text = img_alt.to_s.strip
|
127
|
+
name = if img_alt_text.include?(':')
|
128
|
+
img_alt_text.split(':').last.strip
|
129
|
+
else
|
130
|
+
img_alt_text[/\s+([^\s]+)$/, 1]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
123
134
|
_klass.new({
|
124
|
-
"name" =>
|
135
|
+
"name" => name,
|
125
136
|
"url" => URI.join(page_url, link.attr('href')).to_s,
|
126
137
|
"products_count" => tag.css('td')[1].text.to_i
|
127
138
|
})
|
data/test/test_openfoodfacts.rb
CHANGED
@@ -201,14 +201,14 @@ class TestOpenfoodfacts < Minitest::Test
|
|
201
201
|
def test_it_fetches_product_states
|
202
202
|
VCR.use_cassette("product_states") do
|
203
203
|
product_states = ::Openfoodfacts::ProductState.all
|
204
|
-
|
204
|
+
assert_includes product_states.map { |product_state| product_state['url'] }, "https://world.openfoodfacts.org/state/to-be-completed"
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
208
|
def test_it_fetches_product_states_for_locale
|
209
209
|
VCR.use_cassette("product_states_locale") do
|
210
210
|
product_states = ::Openfoodfacts::ProductState.all(locale: 'fr')
|
211
|
-
|
211
|
+
assert_includes product_states.map { |product_state| product_state['url'] }, "https://fr.openfoodfacts.org/etat/a-completer"
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openfoodfacts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Leger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '3.4'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '6.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '3.4'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '6.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: nokogiri
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,14 +64,14 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '13.0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '13.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: minitest
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '6.0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '6.0'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: webmock
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,7 +160,7 @@ homepage: https://github.com/openfoodfacts/openfoodfacts-ruby
|
|
160
160
|
licenses:
|
161
161
|
- MIT
|
162
162
|
metadata: {}
|
163
|
-
post_install_message:
|
163
|
+
post_install_message:
|
164
164
|
rdoc_options: []
|
165
165
|
require_paths:
|
166
166
|
- lib
|
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
178
|
rubygems_version: 3.2.3
|
179
|
-
signing_key:
|
179
|
+
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: Open Food Facts API Wrapper
|
182
182
|
test_files: []
|