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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0924759e4dc52520a8ba072c3ed7403279f09209f7a9f9a3d3e12ee5d62fe43
4
- data.tar.gz: d12122964da73e71fd1d09e4d3a6fbcc2a88fcc3641f8430cc029772f48924b4
3
+ metadata.gz: 5149013aa9d2cfe3fba8106c74c67744fc584bd3773f60795c46f4602bfc4360
4
+ data.tar.gz: 33ae4f1b63aa0d9648ba4e626c2fda5e56e80eb812fbffc56d64458674413c67
5
5
  SHA512:
6
- metadata.gz: '0191eb1af3c3d91f5e6ee1a85216e6de35977c21342f67ec808cf4e14cbf62c0e1fafa573e4fc1b3da33ff8231e29a3165f1d23a088b7a6a8743dfa155d2da9f'
7
- data.tar.gz: a7c03c77ead8c1df7386e77d352a23c952185c8606034901b0710bd803d54e277f699d80a7bb532cb7a62c4d478ff743d130386e48d771c318e3aea4916e6270
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
- # FatsecretLite
1
+ Here's the corrected and cleaned-up version of your README file:
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ markdown
4
+ Copy code
5
+ # FatsecretLite
4
6
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fatsecret_lite`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
11
+ Add this line to your application's Gemfile:
10
12
 
11
- Install the gem and add to the application's Gemfile by executing:
13
+ ```ruby
14
+ gem 'fatsecret_lite'
15
+ And then execute:
12
16
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
17
+ bash
18
+ Copy code
19
+ bundle install
20
+ Or install it yourself as:
14
21
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
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
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
29
+ Example configuration:
18
30
 
19
- ## Usage
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
- TODO: Write usage instructions here
39
+ Fetching Food Details
40
+ To fetch food details by food ID, use the get_food_details method:
22
41
 
23
- ## Development
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
- 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.
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 `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+ To install this gem onto your local machine, run:
28
52
 
29
- ## Contributing
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
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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](https://github.com/[USERNAME]/fatsecret_lite/blob/master/CODE_OF_CONDUCT.md).
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
- ## License
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
- ## Code of Conduct
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).
@@ -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 = []
@@ -0,0 +1,11 @@
1
+ module FatsecretLite
2
+ class Configuration
3
+ attr_accessor :client_id, :client_secret
4
+
5
+ def initialize
6
+ @client_id = nil
7
+ @client_secret = nil
8
+ end
9
+ end
10
+ end
11
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FatsecretLite
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -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.v2',
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.0
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-08-23 00:00:00.000000000 Z
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