func_live 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 12ec2355a1a97d223b6ea865062f1696ceba791f622f63062ec2e6cb73ef38f8
4
+ data.tar.gz: 7f3e88126af179960ee9cbc8c0432ada64dc44f86440c9cf1412ba300ea13ac9
5
+ SHA512:
6
+ metadata.gz: f1b78f17d7fc7c572969444d7c57aa7a1b0e2828d3b376fe3e16e3c4158a590c81113eabfedea5f73cbea0936bf27171c5d96ba686a4cf16579a19926fa02bd9
7
+ data.tar.gz: ef24d32bf9d43ac8e25a292861538ba3db3b2cee0a8c74bb269dd5880198a0e262100902a79906dc18619b3ba74ba086089429b7bb9983f98d56dac41128d83e
data/.env ADDED
@@ -0,0 +1 @@
1
+ FUNC_LIVE_TOKEN=
data/.env.development ADDED
@@ -0,0 +1 @@
1
+ FUNC_LIVE_TOKEN=
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Style/IfUnlessModifier:
5
+ Enabled: false
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Style/StringLiterals:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+
14
+ Style/StringLiteralsInInterpolation:
15
+ Enabled: true
16
+ EnforcedStyle: double_quotes
17
+
18
+ Layout/LineLength:
19
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.1] - 2024-02-22
4
+
5
+ - Better empty token handling
6
+
7
+ ## [0.1.0] - 2024-02-21
8
+
9
+ - 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 dmitry@ergoserv.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.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Dmitry Babenko
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,88 @@
1
+ # func(live)
2
+
3
+ This gem allows you to call functions available on https://func.live.
4
+
5
+ ## Installation
6
+
7
+
8
+ Install the gem and add to the application's `Gemfile` by executing:
9
+
10
+ $ bundle add func_live
11
+
12
+ Or add one of these lines to your application's `Gemfile` manually:
13
+
14
+ ```ruby
15
+ # version released to RubyGems (recommended)
16
+ gem 'func_live'
17
+
18
+ # or latest version from the repository
19
+ gem 'func_live', git: 'https://github.com/ergoserv/func_live'
20
+ # or from a specific branch of the GitHub repository
21
+ gem 'func_live', git: 'https://github.com/ergoserv/func_live', branch: 'develop'
22
+ # or from a local path (for development and testing purposes)
23
+ gem 'func_live', path: '../func_live'
24
+ ```
25
+
26
+ If bundler is not being used to manage dependencies, install the gem by executing:
27
+
28
+ $ gem install func_live
29
+
30
+ ### Get and set the token
31
+
32
+ You can get your token at https://tokens.wakeflow.io.
33
+
34
+ Set token in environment variable `ENV["FUNC_LIVE_TOKEN"]`
35
+ or in code using the `FuncLive.token` writer:
36
+
37
+ ```ruby
38
+ FuncLive.token = 'your_func_token'
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ There are many functions available on https://www.func.live,
44
+ the code snippet below demonstrates the usage of several of them.
45
+
46
+ ```ruby
47
+ # Generate UUID - https://www.func.live/functions/uuid
48
+ FuncLive.("uuid")
49
+ # => "09ccfa6a-805e-46f5-ae4d-790988bec443"
50
+
51
+ # Get currency exchange rate for USD to EUR - https://www.func.live/functions/usdToEur
52
+ FuncLive.("usdToEur", 100)
53
+ # => 92.44
54
+
55
+ # Translate text to another language - https://www.func.live/functions/translate
56
+ FuncLive.(:translate, { text: "Hello World!", to: "FR" })
57
+ # => "Bonjour le monde!"
58
+
59
+ # Access OpenAI's GPT API with single line of code - https://www.func.live/functions/askGPT
60
+ FuncLive.(:askGPT, "Who are you?")
61
+ # => "I am a language model AI developed by OpenAI, created to assist and interact with users in generating human-like text based on the prompts given to me. How can I assist you today?"
62
+ ```
63
+
64
+ You can browse all available functions at https://www.func.live/functions.
65
+
66
+ ## Development
67
+
68
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
69
+
70
+ 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).
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ergoserv/func_live. 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/ergoserv/func_live/blob/master/CODE_OF_CONDUCT.md).
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
79
+
80
+ ## Code of Conduct
81
+
82
+ Everyone interacting in the FuncLive project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ergoserv/func_live/blob/master/CODE_OF_CONDUCT.md).
83
+
84
+ ---
85
+
86
+ This gem was created and is maintained by [ErgoServ](https://www.ergoserv.com).
87
+
88
+ If you like what you see and would like to hire us or join us, [get in touch](https://www.ergoserv.com)!
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "httparty"
4
+
5
+ module FuncLive
6
+ class Client
7
+ include HTTParty
8
+
9
+ base_uri "https://api.func.live"
10
+
11
+ def initialize(token)
12
+ @headers = {
13
+ "Content-Type" => "application/json",
14
+ "Authorization" => "Bearer #{token}"
15
+ }
16
+ end
17
+
18
+ def functions(function_name, input = nil)
19
+ body = { input: input }
20
+ self.class.post(
21
+ "/functions/#{function_name}",
22
+ headers: @headers,
23
+ body: body.to_json
24
+ )
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FuncLive
4
+ VERSION = "0.1.1"
5
+ end
data/lib/func_live.rb ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "func_live/client"
4
+ require_relative "func_live/version"
5
+
6
+ module FuncLive
7
+ class Error < StandardError; end
8
+
9
+ class << self
10
+ def default_token
11
+ ENV["FUNC_LIVE_TOKEN"]
12
+ end
13
+
14
+ def token=(token) # rubocop:disable Style/TrivialAccessors
15
+ @token = token
16
+ end
17
+
18
+ def token
19
+ if @token.to_s.empty? && default_token.to_s.empty?
20
+ raise FuncLive::Error, "FuncLive.token is empty"
21
+ end
22
+
23
+ @token || default_token
24
+ end
25
+
26
+ def client
27
+ @client ||= FuncLive::Client.new(token)
28
+ end
29
+
30
+ def call(function_name, input = nil)
31
+ response = client.functions(function_name, input)
32
+
33
+ if response["success"] == false
34
+ raise FuncLive::Error, response["error"]
35
+ end
36
+
37
+ response["output"]
38
+ end
39
+ end
40
+ end
data/sig/func_live.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module FuncLive
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: func_live
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dmitry Babenko
8
+ - ErgoServ
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2024-02-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ description: Allows you to import and call the functions on www.func.live.
29
+ email:
30
+ - dmitry@ergoserv.com
31
+ - hello@ergoserv.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".env"
37
+ - ".env.development"
38
+ - ".rspec"
39
+ - ".rubocop.yml"
40
+ - CHANGELOG.md
41
+ - CODE_OF_CONDUCT.md
42
+ - LICENSE.txt
43
+ - README.md
44
+ - Rakefile
45
+ - lib/func_live.rb
46
+ - lib/func_live/client.rb
47
+ - lib/func_live/version.rb
48
+ - sig/func_live.rbs
49
+ homepage: https://www.func.live/
50
+ licenses:
51
+ - MIT
52
+ metadata:
53
+ homepage_uri: https://www.func.live/
54
+ source_code_uri: https://github.com/ergoserv/func_live
55
+ changelog_uri: https://github.com/ergoserv/func_live/blob/master/CHANGELOG.md
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.6.0
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubygems_version: 3.4.15
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: fund(live)
75
+ test_files: []