fatsecret_lite 0.2.3 → 0.2.5

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: f7584e18f7582144db2d123d875f0be9f69dd01ac2fa7debb0d66adc8b9acb1e
4
- data.tar.gz: 81208a3c4486882ab4c9c4b8974dec4fcb2e4661f6eee776826bef32a509e429
3
+ metadata.gz: 8a173a429e88edc9e5ce1532dc053e558e6c7618c4762f94e424611cdbbff411
4
+ data.tar.gz: c473ea90439d2d1d3b6cd23f87d0e516594a0515bc832d0efc8febbe2d4bc311
5
5
  SHA512:
6
- metadata.gz: 27b122bb6edbc1bd797e8ccf07909f4fe3edc0bbb3c25934f1785a0d1115865c1ea14a43489099989f46970dcdc2aeef8bb8e957230c63f577ff1b10a6bfce7b
7
- data.tar.gz: 7e747ea866a35c162eee409c71d5e3ec04ff6bba70e86f1bef431dd4ea808c4c68cb0d56f09111bccd8e5dbf23b9f201e06205b79e113b274597b8f558463bfa
6
+ metadata.gz: 7f3464c9270330f3bac9f4d52a06d6ad44be44be3b8c42974f6ca1af42bf8cbb773245bf6bca8bbe05048995838ad78392005a79370876c749a8947f98397d91
7
+ data.tar.gz: 1348315971741c0cb110da9277d9487208eb460d391668306d0908cd87bd795a2eaafd0a6c00c9eb668b31f9ecb7a1a5693157cb57be420efaf84bd9b1f611bd
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-08-23
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at dev.kapildevpal@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
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/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 KapilDevPal
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ Here's the corrected and cleaned-up version of your README file:
2
+
3
+ markdown
4
+ Copy code
5
+ # FatsecretLite
6
+
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).
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'fatsecret_lite'
15
+ And then execute:
16
+
17
+ bash
18
+ Copy code
19
+ bundle install
20
+ Or install it yourself as:
21
+
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.
28
+
29
+ Example configuration:
30
+
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.
38
+
39
+ Fetching Food Details
40
+ To fetch food details by food ID, use the get_food_details method:
41
+
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.
47
+
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.
50
+
51
+ To install this gem onto your local machine, run:
52
+
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:
57
+
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.
62
+
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.
65
+
66
+ License
67
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
68
+
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
+
84
+
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/fatsecret_lite/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fatsecret_lite"
7
+ spec.version = FatsecretLite::VERSION
8
+ spec.authors = ["KapilDevPal"]
9
+ spec.email = ["dev.kapildevpal@gmail.com"]
10
+
11
+ spec.summary = "A lightweight Ruby gem for interacting with the FatSecret API"
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"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.5"
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+ # spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/KapilDevPal/fatsecret_lite"
20
+ spec.metadata["changelog_uri"] = "https://github.com/KapilDevPal/fatsecret_lite/CHANGELOG.md"
21
+
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (File.expand_path(f) == __FILE__) ||
25
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
26
+ end
27
+ end
28
+ spec.require_paths = ["lib"]
29
+
30
+ # Add dependencies for your gem
31
+ spec.add_dependency "oauth2", "~> 1.4"
32
+ spec.add_dependency "rest-client", "~> 2.1"
33
+ spec.add_dependency "json"
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
+
43
+ # No executable files to include
44
+ spec.bindir = "bin"
45
+ spec.executables = []
46
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FatsecretLite
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  end
@@ -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
@@ -0,0 +1,4 @@
1
+ module FatsecretLite
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ 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.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - KapilDevPal
@@ -60,15 +60,22 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - CHANGELOG.md
64
+ - CODE_OF_CONDUCT.md
65
+ - LICENSE
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - fatsecret_lite.gemspec
63
70
  - lib/fatsecret_lite.rb
64
71
  - lib/fatsecret_lite/configuration.rb
65
72
  - lib/fatsecret_lite/version.rb
66
- homepage: https://github.com/KapilDevPal/fatsecret_lite
73
+ - sig/fatsecret_lite.rbs
74
+ homepage:
67
75
  licenses:
68
76
  - MIT
69
77
  metadata:
70
78
  allowed_push_host: https://rubygems.org
71
- homepage_uri: https://github.com/KapilDevPal/fatsecret_lite
72
79
  source_code_uri: https://github.com/KapilDevPal/fatsecret_lite
73
80
  changelog_uri: https://github.com/KapilDevPal/fatsecret_lite/CHANGELOG.md
74
81
  post_install_message: |2