fatsecret_lite 0.2.0 → 0.2.1
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 +8 -0
- data/lib/fatsecret_lite/configuration.rb +11 -0
- data/lib/fatsecret_lite/version.rb +1 -1
- data/lib/fatsecret_lite.rb +27 -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: 5149013aa9d2cfe3fba8106c74c67744fc584bd3773f60795c46f4602bfc4360
|
4
|
+
data.tar.gz: 33ae4f1b63aa0d9648ba4e626c2fda5e56e80eb812fbffc56d64458674413c67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d206b7beec5f855509d03757c9b4a3c8196a5728cba5a1315ea21e4ffbb0e14dabed0c7aa321b83b0b885783c0bbea0eccc7524c976bcb3b9f7fac61eee00846
|
7
|
+
data.tar.gz: bf358c126d3c8a89635f84822ef6dab6d6e8fd11b31e4845232c9c541226255085fb76f37bb3b9353e2b868a0eac836dc067479470a23ce1bc72dd5849adbf75
|
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
@@ -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
@@ -44,8 +44,34 @@ module FatsecretLite
|
|
44
44
|
response = RestClient.post(
|
45
45
|
'https://platform.fatsecret.com/rest/server.api',
|
46
46
|
{
|
47
|
-
method: 'food.get.
|
47
|
+
method: 'food.get.v4',
|
48
48
|
food_id: food_id,
|
49
|
+
include_food_images: true,
|
50
|
+
include_food_attributes: true,
|
51
|
+
format: 'json'
|
52
|
+
},
|
53
|
+
{
|
54
|
+
content_type: :json,
|
55
|
+
Authorization: "Bearer #{access_token}"
|
56
|
+
}
|
57
|
+
)
|
58
|
+
|
59
|
+
JSON.parse(response.body)
|
60
|
+
rescue RestClient::ExceptionWithResponse => e
|
61
|
+
puts "Error: #{e.response}"
|
62
|
+
rescue StandardError => e
|
63
|
+
puts "An error occurred: #{e.message}"
|
64
|
+
end
|
65
|
+
|
66
|
+
# find food id by barcode
|
67
|
+
def find_food_by_barcode(barcode)
|
68
|
+
access_token = get_access_token
|
69
|
+
|
70
|
+
response = RestClient.post(
|
71
|
+
'https://platform.fatsecret.com/rest/server.api',
|
72
|
+
{
|
73
|
+
method: 'food.find_id_for_barcode',
|
74
|
+
barcode: barcode,
|
49
75
|
format: 'json'
|
50
76
|
},
|
51
77
|
{
|
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.1
|
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-03 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
|