fatsecret_lite 0.2.2 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fatsecret_lite.gemspec +2 -2
- data/lib/fatsecret_lite/version.rb +1 -1
- data/lib/fatsecret_lite.rb +24 -3
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a173a429e88edc9e5ce1532dc053e558e6c7618c4762f94e424611cdbbff411
|
4
|
+
data.tar.gz: c473ea90439d2d1d3b6cd23f87d0e516594a0515bc832d0efc8febbe2d4bc311
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f3464c9270330f3bac9f4d52a06d6ad44be44be3b8c42974f6ca1af42bf8cbb773245bf6bca8bbe05048995838ad78392005a79370876c749a8947f98397d91
|
7
|
+
data.tar.gz: 1348315971741c0cb110da9277d9487208eb460d391668306d0908cd87bd795a2eaafd0a6c00c9eb668b31f9ecb7a1a5693157cb57be420efaf84bd9b1f611bd
|
data/fatsecret_lite.gemspec
CHANGED
@@ -10,12 +10,12 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary = "A lightweight Ruby gem for interacting with the FatSecret API"
|
12
12
|
spec.description = "This gem provides a simple interface to interact with the FatSecret API using OAuth2 and RestClient."
|
13
|
-
spec.homepage = "https://github.com/KapilDevPal/fatsecret_lite"
|
13
|
+
# spec.homepage = "https://github.com/KapilDevPal/fatsecret_lite"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 2.5"
|
16
16
|
|
17
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
19
19
|
spec.metadata["source_code_uri"] = "https://github.com/KapilDevPal/fatsecret_lite"
|
20
20
|
spec.metadata["changelog_uri"] = "https://github.com/KapilDevPal/fatsecret_lite/CHANGELOG.md"
|
21
21
|
|
data/lib/fatsecret_lite.rb
CHANGED
@@ -2,10 +2,8 @@
|
|
2
2
|
require "oauth2"
|
3
3
|
require "rest-client"
|
4
4
|
require "json"
|
5
|
-
require_relative 'fatsecret_search'
|
6
5
|
|
7
6
|
module FatsecretLite
|
8
|
-
extend FatsecretSearch
|
9
7
|
class Configuration
|
10
8
|
attr_accessor :client_id, :client_secret
|
11
9
|
|
@@ -88,6 +86,29 @@ module FatsecretLite
|
|
88
86
|
rescue StandardError => e
|
89
87
|
puts "An error occurred: #{e.message}"
|
90
88
|
end
|
89
|
+
|
90
|
+
def find_food_by_search(search_value, max_results= 10)
|
91
|
+
access_token = get_access_token
|
92
|
+
|
93
|
+
response = RestClient.post(
|
94
|
+
'https://platform.fatsecret.com/rest/server.api',
|
95
|
+
{
|
96
|
+
method: 'foods.search.v3',
|
97
|
+
max_results: max_results,
|
98
|
+
search_expression: search_value,
|
99
|
+
format: 'json'
|
100
|
+
},
|
101
|
+
{
|
102
|
+
content_type: :json,
|
103
|
+
Authorization: "Bearer #{access_token}"
|
104
|
+
}
|
105
|
+
)
|
106
|
+
|
107
|
+
JSON.parse(response.body)
|
108
|
+
rescue RestClient::ExceptionWithResponse => e
|
109
|
+
puts "Error: #{e.response}"
|
110
|
+
rescue StandardError => e
|
111
|
+
puts "An error occurred: #{e.message}"
|
112
|
+
end
|
91
113
|
end
|
92
|
-
include FatsecretLite::Search
|
93
114
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fatsecret_lite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KapilDevPal
|
@@ -71,12 +71,11 @@ files:
|
|
71
71
|
- lib/fatsecret_lite/configuration.rb
|
72
72
|
- lib/fatsecret_lite/version.rb
|
73
73
|
- sig/fatsecret_lite.rbs
|
74
|
-
homepage:
|
74
|
+
homepage:
|
75
75
|
licenses:
|
76
76
|
- MIT
|
77
77
|
metadata:
|
78
78
|
allowed_push_host: https://rubygems.org
|
79
|
-
homepage_uri: https://github.com/KapilDevPal/fatsecret_lite
|
80
79
|
source_code_uri: https://github.com/KapilDevPal/fatsecret_lite
|
81
80
|
changelog_uri: https://github.com/KapilDevPal/fatsecret_lite/CHANGELOG.md
|
82
81
|
post_install_message: |2
|