fatsecret_lite 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +63 -18
- data/fatsecret_lite.gemspec +9 -1
- data/lib/fatsecret_lite/configuration.rb +11 -0
- data/lib/fatsecret_lite/version.rb +1 -1
- data/lib/fatsecret_lite.rb +30 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36eaf7148c1397b728204bfedee7d091c219ad1c1eb65ef695c50f8e41073690
|
4
|
+
data.tar.gz: ba55fa1869f9858aa55a563c56857574f3878a32d5fb61f480801b7926e79865
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4b7f6dc249d9954a4d0c52e6fb02d1ec93788be923668383627991368aee059f096b9343312818f8c9a05adb128cac956d7e81a7dcb47be7065f51a8c6a5078
|
7
|
+
data.tar.gz: d8472d6dd06b8b8488ce93b3a93c79f544a09a01001921bb88037eb9e39e41f8cf018b78bb5d91d156b670581eee629318f7da60c81ec91479cb26b2dc3e5aed
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Kapil Dev Pal
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,39 +1,84 @@
|
|
1
|
-
|
1
|
+
Here's the corrected and cleaned-up version of your README file:
|
2
2
|
|
3
|
-
|
3
|
+
markdown
|
4
|
+
Copy code
|
5
|
+
# FatsecretLite
|
4
6
|
|
5
|
-
|
7
|
+
`fatsecret_lite` is a Ruby gem for interacting with the FatSecret API. It provides an easy way to retrieve food details using OAuth2 authentication. The gem is available at: [https://rubygems.org/gems/fatsecret_lite](https://rubygems.org/gems/fatsecret_lite).
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
9
|
-
|
11
|
+
Add this line to your application's Gemfile:
|
10
12
|
|
11
|
-
|
13
|
+
```ruby
|
14
|
+
gem 'fatsecret_lite'
|
15
|
+
And then execute:
|
12
16
|
|
13
|
-
|
17
|
+
bash
|
18
|
+
Copy code
|
19
|
+
bundle install
|
20
|
+
Or install it yourself as:
|
14
21
|
|
15
|
-
|
22
|
+
bash
|
23
|
+
Copy code
|
24
|
+
gem install fatsecret_lite
|
25
|
+
Usage
|
26
|
+
Configuration
|
27
|
+
Before using the gem, you need to configure it with your FatSecret API credentials. You can do this in an initializer or before making any API calls.
|
16
28
|
|
17
|
-
|
29
|
+
Example configuration:
|
18
30
|
|
19
|
-
|
31
|
+
ruby
|
32
|
+
Copy code
|
33
|
+
FatsecretLite.configure do |config|
|
34
|
+
config.client_id = 'your_client_id'
|
35
|
+
config.client_secret = 'your_client_secret'
|
36
|
+
end
|
37
|
+
Replace 'your_client_id' and 'your_client_secret' with your actual FatSecret API credentials.
|
20
38
|
|
21
|
-
|
39
|
+
Fetching Food Details
|
40
|
+
To fetch food details by food ID, use the get_food_details method:
|
22
41
|
|
23
|
-
|
42
|
+
ruby
|
43
|
+
Copy code
|
44
|
+
food_details = FatsecretLite.get_food_details(12345)
|
45
|
+
puts food_details
|
46
|
+
This will return the details for the food item with the specified ID in a JSON format.
|
24
47
|
|
25
|
-
|
48
|
+
Development
|
49
|
+
After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.
|
26
50
|
|
27
|
-
To install this gem onto your local machine, run
|
51
|
+
To install this gem onto your local machine, run:
|
28
52
|
|
29
|
-
|
53
|
+
bash
|
54
|
+
Copy code
|
55
|
+
bundle exec rake install
|
56
|
+
To release a new version, update the version number in lib/fatsecret_lite/version.rb, and then run:
|
30
57
|
|
31
|
-
|
58
|
+
bash
|
59
|
+
Copy code
|
60
|
+
bundle exec rake release
|
61
|
+
This will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
|
32
62
|
|
33
|
-
|
63
|
+
Contributing
|
64
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/KapilDevPal/fatsecret_lite. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
|
34
65
|
|
66
|
+
License
|
35
67
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
36
68
|
|
37
|
-
|
69
|
+
Code of Conduct
|
70
|
+
Everyone interacting in the FatsecretLite project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the code of conduct.
|
71
|
+
|
72
|
+
markdown
|
73
|
+
Copy code
|
74
|
+
|
75
|
+
### Key Changes:
|
76
|
+
1. Fixed formatting and indentation issues.
|
77
|
+
2. Added missing headings and clear sections.
|
78
|
+
3. Corrected URLs to GitHub and Rubygems links.
|
79
|
+
4. Adjusted code blocks for proper syntax highlighting.
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
38
84
|
|
39
|
-
Everyone interacting in the FatsecretLite project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fatsecret_lite/blob/master/CODE_OF_CONDUCT.md).
|
data/fatsecret_lite.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "This gem provides a simple interface to interact with the FatSecret API using OAuth2 and RestClient."
|
13
13
|
spec.homepage = "https://github.com/KapilDevPal/fatsecret_lite"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.5"
|
15
|
+
spec.required_ruby_version = ">= 2.5"
|
16
16
|
|
17
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
18
|
spec.metadata["homepage_uri"] = spec.homepage
|
@@ -32,6 +32,14 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency "rest-client", "~> 2.1"
|
33
33
|
spec.add_dependency "json"
|
34
34
|
|
35
|
+
# Post-installation message
|
36
|
+
spec.post_install_message = <<-MESSAGE
|
37
|
+
Thank you for installing the FatSecret Lite gem!
|
38
|
+
Hey! My name is Kapil Dev Pal incase if haveing any issue installing this gem please:
|
39
|
+
contact me @email: dev.KapilDev@gmail.com
|
40
|
+
Happy coding!
|
41
|
+
MESSAGE
|
42
|
+
|
35
43
|
# No executable files to include
|
36
44
|
spec.bindir = "bin"
|
37
45
|
spec.executables = []
|
data/lib/fatsecret_lite.rb
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
require "oauth2"
|
3
3
|
require "rest-client"
|
4
4
|
require "json"
|
5
|
+
require_relative 'fatsecret_search'
|
5
6
|
|
6
7
|
module FatsecretLite
|
8
|
+
extend FatsecretSearch
|
7
9
|
class Configuration
|
8
10
|
attr_accessor :client_id, :client_secret
|
9
11
|
|
@@ -44,8 +46,34 @@ module FatsecretLite
|
|
44
46
|
response = RestClient.post(
|
45
47
|
'https://platform.fatsecret.com/rest/server.api',
|
46
48
|
{
|
47
|
-
method: 'food.get.
|
49
|
+
method: 'food.get.v4',
|
48
50
|
food_id: food_id,
|
51
|
+
include_food_images: true,
|
52
|
+
include_food_attributes: true,
|
53
|
+
format: 'json'
|
54
|
+
},
|
55
|
+
{
|
56
|
+
content_type: :json,
|
57
|
+
Authorization: "Bearer #{access_token}"
|
58
|
+
}
|
59
|
+
)
|
60
|
+
|
61
|
+
JSON.parse(response.body)
|
62
|
+
rescue RestClient::ExceptionWithResponse => e
|
63
|
+
puts "Error: #{e.response}"
|
64
|
+
rescue StandardError => e
|
65
|
+
puts "An error occurred: #{e.message}"
|
66
|
+
end
|
67
|
+
|
68
|
+
# find food id by barcode
|
69
|
+
def find_food_by_barcode(barcode)
|
70
|
+
access_token = get_access_token
|
71
|
+
|
72
|
+
response = RestClient.post(
|
73
|
+
'https://platform.fatsecret.com/rest/server.api',
|
74
|
+
{
|
75
|
+
method: 'food.find_id_for_barcode',
|
76
|
+
barcode: barcode,
|
49
77
|
format: 'json'
|
50
78
|
},
|
51
79
|
{
|
@@ -61,4 +89,5 @@ module FatsecretLite
|
|
61
89
|
puts "An error occurred: #{e.message}"
|
62
90
|
end
|
63
91
|
end
|
92
|
+
include FatsecretLite::Search
|
64
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KapilDevPal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|
@@ -62,11 +62,13 @@ extra_rdoc_files: []
|
|
62
62
|
files:
|
63
63
|
- CHANGELOG.md
|
64
64
|
- CODE_OF_CONDUCT.md
|
65
|
+
- LICENSE
|
65
66
|
- LICENSE.txt
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
68
69
|
- fatsecret_lite.gemspec
|
69
70
|
- lib/fatsecret_lite.rb
|
71
|
+
- lib/fatsecret_lite/configuration.rb
|
70
72
|
- lib/fatsecret_lite/version.rb
|
71
73
|
- sig/fatsecret_lite.rbs
|
72
74
|
homepage: https://github.com/KapilDevPal/fatsecret_lite
|
@@ -77,7 +79,11 @@ metadata:
|
|
77
79
|
homepage_uri: https://github.com/KapilDevPal/fatsecret_lite
|
78
80
|
source_code_uri: https://github.com/KapilDevPal/fatsecret_lite
|
79
81
|
changelog_uri: https://github.com/KapilDevPal/fatsecret_lite/CHANGELOG.md
|
80
|
-
post_install_message:
|
82
|
+
post_install_message: |2
|
83
|
+
Thank you for installing the FatSecret Lite gem!
|
84
|
+
Hey! My name is Kapil Dev Pal incase if haveing any issue installing this gem please:
|
85
|
+
contact me @email: dev.KapilDev@gmail.com
|
86
|
+
Happy coding!
|
81
87
|
rdoc_options: []
|
82
88
|
require_paths:
|
83
89
|
- lib
|