openbeautyfacts 0.6.3 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -1
- data/Rakefile +5 -3
- data/lib/openbeautyfacts/additive.rb +9 -39
- data/lib/openbeautyfacts/allergen.rb +14 -22
- data/lib/openbeautyfacts/brand.rb +14 -22
- data/lib/openbeautyfacts/category.rb +14 -22
- data/lib/openbeautyfacts/city.rb +14 -22
- data/lib/openbeautyfacts/contributor.rb +14 -22
- data/lib/openbeautyfacts/country.rb +14 -22
- data/lib/openbeautyfacts/entry_date.rb +15 -23
- data/lib/openbeautyfacts/faq.rb +16 -41
- data/lib/openbeautyfacts/ingredient.rb +14 -22
- data/lib/openbeautyfacts/ingredient_that_may_be_from_palm_oil.rb +14 -22
- data/lib/openbeautyfacts/label.rb +14 -22
- data/lib/openbeautyfacts/last_edit_date.rb +15 -23
- data/lib/openbeautyfacts/locale.rb +8 -31
- data/lib/openbeautyfacts/manufacturing_place.rb +14 -22
- data/lib/openbeautyfacts/mission.rb +16 -63
- data/lib/openbeautyfacts/number_of_ingredients.rb +15 -23
- data/lib/openbeautyfacts/origin.rb +14 -22
- data/lib/openbeautyfacts/packager_code.rb +14 -22
- data/lib/openbeautyfacts/packaging.rb +14 -22
- data/lib/openbeautyfacts/period_after_opening.rb +14 -22
- data/lib/openbeautyfacts/press.rb +16 -47
- data/lib/openbeautyfacts/product.rb +18 -175
- data/lib/openbeautyfacts/product_state.rb +14 -22
- data/lib/openbeautyfacts/purchase_place.rb +14 -22
- data/lib/openbeautyfacts/store.rb +14 -22
- data/lib/openbeautyfacts/trace.rb +14 -22
- data/lib/openbeautyfacts/user.rb +15 -30
- data/lib/openbeautyfacts/version.rb +3 -1
- data/lib/openbeautyfacts.rb +6 -9
- metadata +29 -19
- data/test/minitest_helper.rb +0 -18
- data/test/test_openbeautyfacts.rb +0 -331
|
@@ -1,197 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
require 'hashie'
|
|
3
|
-
require 'net/http'
|
|
4
|
-
require 'nokogiri'
|
|
5
|
-
require 'open-uri'
|
|
1
|
+
# frozen_string_literal: true
|
|
6
2
|
|
|
7
3
|
module Openbeautyfacts
|
|
8
|
-
class Product <
|
|
4
|
+
class Product < Openfoodfacts::Product
|
|
5
|
+
# Override constants for openbeautyfacts domain
|
|
6
|
+
DEFAULT_LOCALE = Locale::GLOBAL
|
|
7
|
+
DEFAULT_DOMAIN = 'openbeautyfacts.org'
|
|
9
8
|
|
|
10
|
-
#
|
|
9
|
+
# OpenBeautyFacts uses the same URL prefixes as OpenFoodFacts
|
|
11
10
|
LOCALE_WEBURL_PREFIXES = {
|
|
12
11
|
'fr' => 'produit',
|
|
13
12
|
'uk' => 'product',
|
|
14
13
|
'us' => 'product',
|
|
15
14
|
'world' => 'product'
|
|
16
|
-
}
|
|
15
|
+
}.freeze
|
|
17
16
|
|
|
18
17
|
class << self
|
|
19
|
-
|
|
20
|
-
# Get product
|
|
21
|
-
#
|
|
22
|
-
def get(code, locale: DEFAULT_LOCALE)
|
|
23
|
-
if code
|
|
24
|
-
product_url = url(code, locale: locale)
|
|
25
|
-
json = URI.open(product_url).read
|
|
26
|
-
hash = JSON.parse(json)
|
|
27
|
-
|
|
28
|
-
new(hash["product"]) if !hash["status"].nil? && hash["status"] == 1
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
alias_method :find, :get
|
|
32
|
-
|
|
33
|
-
# Return product API URL
|
|
34
|
-
#
|
|
18
|
+
# Override URL method to use openbeautyfacts domain
|
|
35
19
|
def url(code, locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
|
|
36
|
-
|
|
37
|
-
path = "api/v0/produit/#{code}.json"
|
|
38
|
-
"https://#{locale}.#{domain}/#{path}"
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Search products
|
|
43
|
-
#
|
|
44
|
-
def search(terms, locale: DEFAULT_LOCALE, page: 1, page_size: 20, sort_by: 'unique_scans_n', domain: DEFAULT_DOMAIN)
|
|
45
|
-
terms = CGI.escape(terms)
|
|
46
|
-
path = "cgi/search.pl?search_terms=#{terms}&jqm=1&page=#{page}&page_size=#{page_size}&sort_by=#{sort_by}"
|
|
47
|
-
url = "https://#{locale}.#{domain}/#{path}"
|
|
48
|
-
json = URI.open(url).read
|
|
49
|
-
hash = JSON.parse(json)
|
|
50
|
-
html = hash["jqm"]
|
|
51
|
-
|
|
52
|
-
from_jquery_mobile_list(html)
|
|
53
|
-
end
|
|
54
|
-
alias_method :where, :search
|
|
55
|
-
|
|
56
|
-
def from_html_list(html, list_css_selector, code_from_link_regex, locale: 'world')
|
|
57
|
-
dom = Nokogiri::HTML.fragment(html)
|
|
58
|
-
dom.css(list_css_selector).map do |product|
|
|
59
|
-
attributes = {}
|
|
60
|
-
|
|
61
|
-
if link = product.css('a').first
|
|
62
|
-
attributes["product_name"] = link.inner_text.strip
|
|
63
|
-
|
|
64
|
-
if code = link.attr('href')[code_from_link_regex, 1]
|
|
65
|
-
attributes["_id"] = code
|
|
66
|
-
attributes["code"] = code
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
if image = product.css('img').first and image_url = image.attr('src')
|
|
71
|
-
attributes["image_small_url"] = image_url
|
|
72
|
-
attributes["lc"] = Locale.locale_from_link(image_url)
|
|
73
|
-
end
|
|
74
|
-
attributes["lc"] ||= locale
|
|
75
|
-
|
|
76
|
-
new(attributes)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def from_jquery_mobile_list(jqm_html)
|
|
82
|
-
from_html_list(jqm_html, 'ul#search_results_list li:not(#loadmore)', /code=(\d+)\Z/i)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def from_website_list(html, locale: 'world')
|
|
86
|
-
from_html_list(html, 'ul.products li', /\/(\d+)\/?/i, locale: 'world')
|
|
20
|
+
super(code, locale: locale, domain: domain)
|
|
87
21
|
end
|
|
88
22
|
|
|
89
|
-
#
|
|
90
|
-
def
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
pages_count = (products_count.to_f / 20).ceil
|
|
94
|
-
(1..pages_count).map { |page| from_website_page(page_url, page: page) }.flatten
|
|
95
|
-
else
|
|
96
|
-
products = []
|
|
97
|
-
|
|
98
|
-
page = 1
|
|
99
|
-
begin
|
|
100
|
-
products_on_page = from_website_page(page_url, page: page)
|
|
101
|
-
products += products_on_page
|
|
102
|
-
page += 1
|
|
103
|
-
end while products_on_page.any?
|
|
104
|
-
|
|
105
|
-
products
|
|
106
|
-
end
|
|
107
|
-
else
|
|
108
|
-
html = URI.open("#{page_url}/#{page}").read
|
|
109
|
-
from_website_list(html, locale: Locale.locale_from_link(page_url))
|
|
110
|
-
end
|
|
23
|
+
# Override search method to use openbeautyfacts domain
|
|
24
|
+
def search(terms, locale: DEFAULT_LOCALE, page: 1, page_size: 20, sort_by: 'unique_scans_n',
|
|
25
|
+
domain: DEFAULT_DOMAIN)
|
|
26
|
+
super(terms, locale: locale, page: page, page_size: page_size, sort_by: sort_by, domain: domain)
|
|
111
27
|
end
|
|
112
|
-
|
|
113
|
-
def tags_from_page(_klass, page_url, &custom_tag_parsing)
|
|
114
|
-
html = URI.open(page_url).read
|
|
115
|
-
dom = Nokogiri::HTML.fragment(html)
|
|
116
|
-
|
|
117
|
-
dom.css('table#tagstable tbody tr').map do |tag|
|
|
118
|
-
if custom_tag_parsing
|
|
119
|
-
custom_tag_parsing.call(tag)
|
|
120
|
-
else
|
|
121
|
-
link = tag.css('a').first
|
|
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
|
-
|
|
134
|
-
_klass.new({
|
|
135
|
-
"name" => name,
|
|
136
|
-
"url" => URI.join(page_url, link.attr('href')).to_s,
|
|
137
|
-
"products_count" => tag.css('td')[1].text.to_i
|
|
138
|
-
})
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
28
|
end
|
|
144
29
|
|
|
145
|
-
#
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (self.code)
|
|
149
|
-
product = self.class.get(self.code)
|
|
150
|
-
self.merge!(product)
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
self
|
|
30
|
+
# Override weburl method to use openbeautyfacts domain
|
|
31
|
+
def weburl(locale: nil, domain: DEFAULT_DOMAIN)
|
|
32
|
+
super(locale: locale, domain: domain)
|
|
154
33
|
end
|
|
155
|
-
alias_method :reload, :fetch
|
|
156
34
|
|
|
157
|
-
#
|
|
158
|
-
# Only product_name, brands and quantity fields seems to be updatable throught app / API.
|
|
159
|
-
# User can be nil
|
|
160
|
-
# Tested not updatable fields: countries, ingredients_text, purchase_places, purchase_places_tag, purchase_places_tags
|
|
161
|
-
#
|
|
35
|
+
# Override update method to use openbeautyfacts domain
|
|
162
36
|
def update(user: nil, domain: DEFAULT_DOMAIN)
|
|
163
|
-
|
|
164
|
-
subdomain = self.lc == 'world' ? 'world' : "world-#{self.lc}"
|
|
165
|
-
path = 'cgi/product_jqm.pl'
|
|
166
|
-
uri = URI("https://#{subdomain}.#{domain}/#{path}")
|
|
167
|
-
params = self.to_hash
|
|
168
|
-
params.merge!("user_id" => user.user_id, "password" => user.password) if user
|
|
169
|
-
response = Net::HTTP.post_form(uri, params)
|
|
170
|
-
|
|
171
|
-
data = JSON.parse(response.body)
|
|
172
|
-
data["status"] == 1
|
|
173
|
-
else
|
|
174
|
-
false
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
alias_method :save, :update
|
|
178
|
-
|
|
179
|
-
# Return Product API URL
|
|
180
|
-
#
|
|
181
|
-
def url(locale: DEFAULT_LOCALE)
|
|
182
|
-
self.class.url(self.code, locale: locale)
|
|
37
|
+
super(user: user, domain: domain)
|
|
183
38
|
end
|
|
184
|
-
|
|
185
|
-
# Return Product web URL according to locale
|
|
186
|
-
#
|
|
187
|
-
def weburl(locale: nil, domain: DEFAULT_DOMAIN)
|
|
188
|
-
locale ||= self.lc || DEFAULT_LOCALE
|
|
189
|
-
|
|
190
|
-
if self.code && prefix = LOCALE_WEBURL_PREFIXES[locale]
|
|
191
|
-
path = "#{prefix}/#{self.code}"
|
|
192
|
-
"https://#{locale}.#{domain}/#{path}"
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
39
|
end
|
|
197
40
|
end
|
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Openbeautyfacts
|
|
4
|
-
class ProductState <
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
'fr' => 'etats',
|
|
9
|
-
'uk' => 'states',
|
|
10
|
-
'us' => 'states',
|
|
11
|
-
'world' => 'states'
|
|
12
|
-
}
|
|
4
|
+
class ProductState < Openfoodfacts::ProductState
|
|
5
|
+
# Override constants for openbeautyfacts domain
|
|
6
|
+
DEFAULT_LOCALE = Locale::GLOBAL
|
|
7
|
+
DEFAULT_DOMAIN = 'openbeautyfacts.org'
|
|
13
8
|
|
|
14
9
|
class << self
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
|
|
21
|
-
end
|
|
10
|
+
# Override all method to use openbeautyfacts domain if it exists
|
|
11
|
+
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN, **options)
|
|
12
|
+
super(locale: locale, domain: domain, **options)
|
|
13
|
+
rescue NoMethodError
|
|
14
|
+
# Method doesn't exist in parent class, skip
|
|
22
15
|
end
|
|
23
|
-
|
|
24
16
|
end
|
|
25
17
|
|
|
26
|
-
#
|
|
27
|
-
#
|
|
18
|
+
# Override products method to use openbeautyfacts domain if it exists
|
|
28
19
|
def products(page: -1)
|
|
29
|
-
|
|
20
|
+
super(page: page)
|
|
21
|
+
rescue NoMethodError
|
|
22
|
+
# Method doesn't exist in parent class, skip
|
|
30
23
|
end
|
|
31
|
-
|
|
32
24
|
end
|
|
33
25
|
end
|
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Openbeautyfacts
|
|
4
|
-
class PurchasePlace <
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
'fr' => 'lieux-de-vente',
|
|
9
|
-
'uk' => 'purchase-places',
|
|
10
|
-
'us' => 'purchase-places',
|
|
11
|
-
'world' => 'purchase-places'
|
|
12
|
-
}
|
|
4
|
+
class PurchasePlace < Openfoodfacts::PurchasePlace
|
|
5
|
+
# Override constants for openbeautyfacts domain
|
|
6
|
+
DEFAULT_LOCALE = Locale::GLOBAL
|
|
7
|
+
DEFAULT_DOMAIN = 'openbeautyfacts.org'
|
|
13
8
|
|
|
14
9
|
class << self
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
|
|
21
|
-
end
|
|
10
|
+
# Override all method to use openbeautyfacts domain if it exists
|
|
11
|
+
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN, **options)
|
|
12
|
+
super(locale: locale, domain: domain, **options)
|
|
13
|
+
rescue NoMethodError
|
|
14
|
+
# Method doesn't exist in parent class, skip
|
|
22
15
|
end
|
|
23
|
-
|
|
24
16
|
end
|
|
25
17
|
|
|
26
|
-
#
|
|
27
|
-
#
|
|
18
|
+
# Override products method to use openbeautyfacts domain if it exists
|
|
28
19
|
def products(page: -1)
|
|
29
|
-
|
|
20
|
+
super(page: page)
|
|
21
|
+
rescue NoMethodError
|
|
22
|
+
# Method doesn't exist in parent class, skip
|
|
30
23
|
end
|
|
31
|
-
|
|
32
24
|
end
|
|
33
25
|
end
|
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Openbeautyfacts
|
|
4
|
-
class Store <
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
'fr' => 'magasins',
|
|
9
|
-
'uk' => 'stores',
|
|
10
|
-
'us' => 'stores',
|
|
11
|
-
'world' => 'stores'
|
|
12
|
-
}
|
|
4
|
+
class Store < Openfoodfacts::Store
|
|
5
|
+
# Override constants for openbeautyfacts domain
|
|
6
|
+
DEFAULT_LOCALE = Locale::GLOBAL
|
|
7
|
+
DEFAULT_DOMAIN = 'openbeautyfacts.org'
|
|
13
8
|
|
|
14
9
|
class << self
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
|
|
21
|
-
end
|
|
10
|
+
# Override all method to use openbeautyfacts domain if it exists
|
|
11
|
+
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN, **options)
|
|
12
|
+
super(locale: locale, domain: domain, **options)
|
|
13
|
+
rescue NoMethodError
|
|
14
|
+
# Method doesn't exist in parent class, skip
|
|
22
15
|
end
|
|
23
|
-
|
|
24
16
|
end
|
|
25
17
|
|
|
26
|
-
#
|
|
27
|
-
#
|
|
18
|
+
# Override products method to use openbeautyfacts domain if it exists
|
|
28
19
|
def products(page: -1)
|
|
29
|
-
|
|
20
|
+
super(page: page)
|
|
21
|
+
rescue NoMethodError
|
|
22
|
+
# Method doesn't exist in parent class, skip
|
|
30
23
|
end
|
|
31
|
-
|
|
32
24
|
end
|
|
33
25
|
end
|
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Openbeautyfacts
|
|
4
|
-
class Trace <
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
'fr' => 'traces',
|
|
9
|
-
'uk' => 'traces',
|
|
10
|
-
'us' => 'traces',
|
|
11
|
-
'world' => 'traces'
|
|
12
|
-
}
|
|
4
|
+
class Trace < Openfoodfacts::Trace
|
|
5
|
+
# Override constants for openbeautyfacts domain
|
|
6
|
+
DEFAULT_LOCALE = Locale::GLOBAL
|
|
7
|
+
DEFAULT_DOMAIN = 'openbeautyfacts.org'
|
|
13
8
|
|
|
14
9
|
class << self
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
|
|
21
|
-
end
|
|
10
|
+
# Override all method to use openbeautyfacts domain if it exists
|
|
11
|
+
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN, **options)
|
|
12
|
+
super(locale: locale, domain: domain, **options)
|
|
13
|
+
rescue NoMethodError
|
|
14
|
+
# Method doesn't exist in parent class, skip
|
|
22
15
|
end
|
|
23
|
-
|
|
24
16
|
end
|
|
25
17
|
|
|
26
|
-
#
|
|
27
|
-
#
|
|
18
|
+
# Override products method to use openbeautyfacts domain if it exists
|
|
28
19
|
def products(page: -1)
|
|
29
|
-
|
|
20
|
+
super(page: page)
|
|
21
|
+
rescue NoMethodError
|
|
22
|
+
# Method doesn't exist in parent class, skip
|
|
30
23
|
end
|
|
31
|
-
|
|
32
24
|
end
|
|
33
25
|
end
|
data/lib/openbeautyfacts/user.rb
CHANGED
|
@@ -1,40 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Openbeautyfacts
|
|
4
|
-
class User <
|
|
4
|
+
class User < Openfoodfacts::User
|
|
5
|
+
# Override constants for openbeautyfacts domain
|
|
6
|
+
DEFAULT_LOCALE = Locale::GLOBAL
|
|
7
|
+
DEFAULT_DOMAIN = 'openbeautyfacts.org'
|
|
5
8
|
|
|
6
9
|
class << self
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
uri = URI("https://#{locale}.#{domain}/#{path}")
|
|
13
|
-
params = {
|
|
14
|
-
"jqm" => "1",
|
|
15
|
-
"user_id" => user_id,
|
|
16
|
-
"password" => password
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
response = Net::HTTP.post_form(uri, params)
|
|
20
|
-
data = JSON.parse(response.body)
|
|
21
|
-
|
|
22
|
-
if data['user_id']
|
|
23
|
-
data.merge!(password: password)
|
|
24
|
-
new(data)
|
|
25
|
-
end
|
|
10
|
+
# Override all method to use openbeautyfacts domain if it exists
|
|
11
|
+
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN, **options)
|
|
12
|
+
super(locale: locale, domain: domain, **options)
|
|
13
|
+
rescue NoMethodError
|
|
14
|
+
# Method doesn't exist in parent class, skip
|
|
26
15
|
end
|
|
27
|
-
|
|
28
16
|
end
|
|
29
17
|
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
self
|
|
36
|
-
end
|
|
18
|
+
# Override products method to use openbeautyfacts domain if it exists
|
|
19
|
+
def products(page: -1)
|
|
20
|
+
super(page: page)
|
|
21
|
+
rescue NoMethodError
|
|
22
|
+
# Method doesn't exist in parent class, skip
|
|
37
23
|
end
|
|
38
|
-
|
|
39
24
|
end
|
|
40
25
|
end
|
data/lib/openbeautyfacts.rb
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'openfoodfacts'
|
|
4
|
+
|
|
5
|
+
require_relative 'openbeautyfacts/version'
|
|
6
|
+
require_relative 'openbeautyfacts/locale'
|
|
1
7
|
require_relative 'openbeautyfacts/additive'
|
|
2
8
|
require_relative 'openbeautyfacts/brand'
|
|
3
9
|
require_relative 'openbeautyfacts/category'
|
|
@@ -10,7 +16,6 @@ require_relative 'openbeautyfacts/ingredient'
|
|
|
10
16
|
require_relative 'openbeautyfacts/ingredient_that_may_be_from_palm_oil'
|
|
11
17
|
require_relative 'openbeautyfacts/label'
|
|
12
18
|
require_relative 'openbeautyfacts/last_edit_date'
|
|
13
|
-
require_relative 'openbeautyfacts/locale'
|
|
14
19
|
require_relative 'openbeautyfacts/manufacturing_place'
|
|
15
20
|
require_relative 'openbeautyfacts/mission'
|
|
16
21
|
require_relative 'openbeautyfacts/number_of_ingredients'
|
|
@@ -25,19 +30,12 @@ require_relative 'openbeautyfacts/purchase_place'
|
|
|
25
30
|
require_relative 'openbeautyfacts/store'
|
|
26
31
|
require_relative 'openbeautyfacts/trace'
|
|
27
32
|
require_relative 'openbeautyfacts/user'
|
|
28
|
-
require_relative 'openbeautyfacts/version'
|
|
29
|
-
|
|
30
|
-
require 'json'
|
|
31
|
-
require 'nokogiri'
|
|
32
|
-
require 'open-uri'
|
|
33
33
|
|
|
34
34
|
module Openbeautyfacts
|
|
35
|
-
|
|
36
35
|
DEFAULT_LOCALE = Locale::GLOBAL
|
|
37
36
|
DEFAULT_DOMAIN = 'openbeautyfacts.org'
|
|
38
37
|
|
|
39
38
|
class << self
|
|
40
|
-
|
|
41
39
|
# Return locale from link
|
|
42
40
|
#
|
|
43
41
|
def locale_from_link(link)
|
|
@@ -61,6 +59,5 @@ module Openbeautyfacts
|
|
|
61
59
|
def product_url(barcode, locale: DEFAULT_LOCALE)
|
|
62
60
|
Product.url(barcode, locale: locale)
|
|
63
61
|
end
|
|
64
|
-
|
|
65
62
|
end
|
|
66
63
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openbeautyfacts
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nicolas Leger
|
|
8
|
-
|
|
8
|
+
- Pierre Slamich
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: openfoodfacts
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.10.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.10.0
|
|
13
27
|
- !ruby/object:Gem::Dependency
|
|
14
28
|
name: hashie
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -36,14 +50,14 @@ dependencies:
|
|
|
36
50
|
requirements:
|
|
37
51
|
- - "~>"
|
|
38
52
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '1.
|
|
53
|
+
version: '1.16'
|
|
40
54
|
type: :runtime
|
|
41
55
|
prerelease: false
|
|
42
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
57
|
requirements:
|
|
44
58
|
- - "~>"
|
|
45
59
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '1.
|
|
60
|
+
version: '1.16'
|
|
47
61
|
- !ruby/object:Gem::Dependency
|
|
48
62
|
name: bundler
|
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -59,33 +73,33 @@ dependencies:
|
|
|
59
73
|
- !ruby/object:Gem::Version
|
|
60
74
|
version: '2.1'
|
|
61
75
|
- !ruby/object:Gem::Dependency
|
|
62
|
-
name:
|
|
76
|
+
name: minitest
|
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
|
64
78
|
requirements:
|
|
65
79
|
- - "~>"
|
|
66
80
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
81
|
+
version: '5.25'
|
|
68
82
|
type: :development
|
|
69
83
|
prerelease: false
|
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
85
|
requirements:
|
|
72
86
|
- - "~>"
|
|
73
87
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '
|
|
88
|
+
version: '5.25'
|
|
75
89
|
- !ruby/object:Gem::Dependency
|
|
76
|
-
name:
|
|
90
|
+
name: rake
|
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
|
78
92
|
requirements:
|
|
79
93
|
- - "~>"
|
|
80
94
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
95
|
+
version: '13.0'
|
|
82
96
|
type: :development
|
|
83
97
|
prerelease: false
|
|
84
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
99
|
requirements:
|
|
86
100
|
- - "~>"
|
|
87
101
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
102
|
+
version: '13.0'
|
|
89
103
|
- !ruby/object:Gem::Dependency
|
|
90
104
|
name: vcr
|
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -106,17 +120,17 @@ dependencies:
|
|
|
106
120
|
requirements:
|
|
107
121
|
- - "~>"
|
|
108
122
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '3.
|
|
123
|
+
version: '3.11'
|
|
110
124
|
type: :development
|
|
111
125
|
prerelease: false
|
|
112
126
|
version_requirements: !ruby/object:Gem::Requirement
|
|
113
127
|
requirements:
|
|
114
128
|
- - "~>"
|
|
115
129
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '3.
|
|
130
|
+
version: '3.11'
|
|
117
131
|
description: Open Beauty Facts API Wrapper, the open database about beauty products.
|
|
118
132
|
email:
|
|
119
|
-
-
|
|
133
|
+
- contact@openfoodfacts.org
|
|
120
134
|
executables: []
|
|
121
135
|
extensions: []
|
|
122
136
|
extra_rdoc_files: []
|
|
@@ -154,13 +168,10 @@ files:
|
|
|
154
168
|
- lib/openbeautyfacts/trace.rb
|
|
155
169
|
- lib/openbeautyfacts/user.rb
|
|
156
170
|
- lib/openbeautyfacts/version.rb
|
|
157
|
-
- test/minitest_helper.rb
|
|
158
|
-
- test/test_openbeautyfacts.rb
|
|
159
171
|
homepage: https://github.com/openfoodfacts/openbeautyfacts-ruby
|
|
160
172
|
licenses:
|
|
161
173
|
- MIT
|
|
162
174
|
metadata: {}
|
|
163
|
-
post_install_message:
|
|
164
175
|
rdoc_options: []
|
|
165
176
|
require_paths:
|
|
166
177
|
- lib
|
|
@@ -175,8 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
175
186
|
- !ruby/object:Gem::Version
|
|
176
187
|
version: '0'
|
|
177
188
|
requirements: []
|
|
178
|
-
rubygems_version: 3.
|
|
179
|
-
signing_key:
|
|
189
|
+
rubygems_version: 3.6.9
|
|
180
190
|
specification_version: 4
|
|
181
191
|
summary: Open Beauty Facts API Wrapper
|
|
182
192
|
test_files: []
|
data/test/minitest_helper.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
2
|
-
require 'openbeautyfacts'
|
|
3
|
-
|
|
4
|
-
require 'minitest/autorun'
|
|
5
|
-
|
|
6
|
-
require 'webmock/minitest'
|
|
7
|
-
require 'vcr'
|
|
8
|
-
|
|
9
|
-
# Avoid OpenSSL certificate verify failed error
|
|
10
|
-
if ENV.has_key?('APPVEYOR') && Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4')
|
|
11
|
-
require 'openssl'
|
|
12
|
-
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
VCR.configure do |c|
|
|
16
|
-
c.cassette_library_dir = "test/fixtures"
|
|
17
|
-
c.hook_into :webmock
|
|
18
|
-
end
|