openbeautyfacts 0.6.0 → 0.6.3
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/openbeautyfacts/product.rb +12 -1
- data/lib/openbeautyfacts/version.rb +1 -1
- data/test/test_openbeautyfacts.rb +1 -1
- 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: 101290dad91405b7afc40eace7e6621731eaf08add56549ad55af3912c55b3c2
|
4
|
+
data.tar.gz: a0708f6c073740c8534e9ba872f7f742c4ffe4b5a5be63a9ee4e828345fadfa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4b272685be3c8099c623e76c057ee00c67f86a1bda69fd24088a41263b3b37e117f1d6341a9d71bde99d640dc4c1da55fbd7277cb5b9fa84613ad706da2cb9e
|
7
|
+
data.tar.gz: 604f209cca866626667ae75bc1f873f11a73fe87adfd177e70ee449c627919aa42d57c4fb1f0a6b55451f7abef758908d4001f18b8cdbc2461a30764608326a1
|
data/README.md
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
# Open Beauty Facts
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/openbeautyfacts.svg)](https://badge.fury.io/rb/openbeautyfacts)
|
4
|
-
[![Build Status](https://
|
5
|
-
[![
|
6
|
-
[![Dependency Status](https://gemnasium.com/openfoodfacts/openbeautyfacts-ruby.svg)](https://gemnasium.com/openfoodfacts/openbeautyfacts-ruby)
|
7
|
-
[![Code Climate](https://codeclimate.com/github/openfoodfacts/openbeautyfacts-ruby/badges/gpa.svg)](https://codeclimate.com/github/openfoodfacts/openbeautyfacts-ruby)
|
8
|
-
[![Coverage Status](https://coveralls.io/repos/github/openfoodfacts/openbeautyfacts-ruby/badge.svg?branch=master)](https://coveralls.io/github/openfoodfacts/openbeautyfacts-ruby?branch=master)
|
4
|
+
[![Build Status](https://github.com/openfoodfacts/openbeautyfacts-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/openfoodfacts/openbeautyfacts-ruby/actions/workflows/ruby.yml)
|
5
|
+
[![RuboCop](https://github.com/openfoodfacts/openbeautyfacts-ruby/actions/workflows/rubocop-analysis.yml/badge.svg)](https://github.com/openfoodfacts/openbeautyfacts-ruby/actions/workflows/rubocop-analysis.yml)
|
9
6
|
[![Documentation](https://inch-ci.org/github/openfoodfacts/openbeautyfacts-ruby.svg?branch=master)](https://inch-ci.org/github/openfoodfacts/openbeautyfacts-ruby)
|
10
7
|
|
11
8
|
API Wrapper for [Open Beauty Facts](https://openbeautyfacts.org/), the open database about beauty products.
|
@@ -120,8 +120,19 @@ module Openbeautyfacts
|
|
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
|
})
|
@@ -104,7 +104,7 @@ class TestOpenbeautyfacts < Minitest::Test
|
|
104
104
|
def test_it_fetches_additives
|
105
105
|
VCR.use_cassette("additives") do
|
106
106
|
additives = ::Openbeautyfacts::Additive.all # World to have riskiness
|
107
|
-
assert_includes additives.map { |additive| additive['url'] }, "https://world.openbeautyfacts.org/additive/
|
107
|
+
assert_includes additives.map { |additive| additive['url'] }, "https://world.openbeautyfacts.org/additive/e470b-magnesium-salts-of-fatty-acids"
|
108
108
|
refute_nil additives.detect { |additive| !additive['riskiness'].nil? }
|
109
109
|
end
|
110
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openbeautyfacts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
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/openbeautyfacts-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 Beauty Facts API Wrapper
|
182
182
|
test_files: []
|