Skip to content

Commit 94b377f

Browse files
committed
add cassettes
1 parent 1d29c63 commit 94b377f

42 files changed

Lines changed: 1968 additions & 28 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/openfoodfacts.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class << self
4141
# Centralized HTTP client method with User-Agent header
4242
#
4343
def http_get(url)
44-
URI.parse(url).open("User-Agent" => ENV.fetch('OPENFOODFACTS_USER_AGENT', nil))
44+
user_agent = ENV.fetch('OPENFOODFACTS_USER_AGENT', nil)
45+
headers = user_agent ? {"User-Agent" => user_agent} : {}
46+
URI.parse(url).open(headers)
4547
end
4648

4749
# Return locale from link

lib/openfoodfacts/additive.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class << self
1717
#
1818
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
1919
if path = LOCALE_PATHS[locale]
20-
page_url = "https://#{locale}.#{domain}/#{path}"
20+
page_url = "https://#{locale}.#{domain}/facets/#{path}"
2121

2222
Product.tags_from_page(self, page_url) do |tag|
2323
columns = tag.css('td')

lib/openfoodfacts/brand.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class << self
1717
#
1818
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
1919
if path = LOCALE_PATHS[locale]
20-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
20+
Product.tags_from_page(self, "https://#{locale}.#{domain}/facets/#{path}")
2121
end
2222
end
2323

lib/openfoodfacts/entry_date.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class << self
1717
#
1818
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
1919
if path = LOCALE_PATHS[locale]
20-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
20+
Product.tags_from_page(self, "https://#{locale}.#{domain}/facets/#{path}")
2121
end
2222
end
2323

lib/openfoodfacts/language.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class << self
1717
#
1818
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
1919
if path = LOCALE_PATHS[locale]
20-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
20+
Product.tags_from_page(self, "https://#{locale}.#{domain}/facets/#{path}")
2121
end
2222
end
2323

lib/openfoodfacts/last_edit_date.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class << self
1717
#
1818
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
1919
if path = LOCALE_PATHS[locale]
20-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
20+
Product.tags_from_page(self, "https://#{locale}.#{domain}/facets/#{path}")
2121
end
2222
end
2323

lib/openfoodfacts/number_of_ingredients.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class << self
1717
#
1818
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
1919
if path = LOCALE_PATHS[locale]
20-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
20+
Product.tags_from_page(self, "https://#{locale}.#{domain}/facets/#{path}")
2121
end
2222
end
2323

lib/openfoodfacts/nutrition_grade.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class << self
1717
#
1818
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
1919
if path = LOCALE_PATHS[locale]
20-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
20+
Product.tags_from_page(self, "https://#{locale}.#{domain}/facets/#{path}")
2121
end
2222
end
2323

lib/openfoodfacts/product_state.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class << self
1717
#
1818
def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN)
1919
if path = LOCALE_PATHS[locale]
20-
Product.tags_from_page(self, "https://#{locale}.#{domain}/#{path}")
20+
Product.tags_from_page(self, "https://#{locale}.#{domain}/facets/#{path}")
2121
end
2222
end
2323

test/fixtures/additives.yml

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)