-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
196 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FUNC_LIVE_TOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FUNC_LIVE_TOKEN= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
/spec/reports/ | ||
/tmp/ | ||
|
||
# rspec failure tracking | ||
.env.*local | ||
.rspec_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
func_live (0.1.0) | ||
httparty | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
ast (2.4.2) | ||
diff-lcs (1.5.0) | ||
dotenv (3.0.2) | ||
httparty (0.21.0) | ||
mini_mime (>= 1.0.0) | ||
multi_xml (>= 0.5.2) | ||
json (2.6.3) | ||
language_server-protocol (3.17.0.3) | ||
mini_mime (1.1.5) | ||
multi_xml (0.6.0) | ||
parallel (1.23.0) | ||
parser (3.2.2.3) | ||
ast (~> 2.4.1) | ||
racc | ||
racc (1.7.3) | ||
rainbow (3.1.1) | ||
rake (13.1.0) | ||
regexp_parser (2.9.0) | ||
rexml (3.2.6) | ||
rspec (3.12.0) | ||
rspec-core (~> 3.12.0) | ||
rspec-expectations (~> 3.12.0) | ||
rspec-mocks (~> 3.12.0) | ||
rspec-core (3.12.2) | ||
rspec-support (~> 3.12.0) | ||
rspec-expectations (3.12.3) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.12.0) | ||
rspec-mocks (3.12.6) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.12.0) | ||
rspec-support (3.12.1) | ||
rubocop (1.54.2) | ||
json (~> 2.3) | ||
language_server-protocol (>= 3.17.0) | ||
parallel (~> 1.10) | ||
parser (>= 3.2.2.3) | ||
rainbow (>= 2.2.2, < 4.0) | ||
regexp_parser (>= 1.8, < 3.0) | ||
rexml (>= 3.2.5, < 4.0) | ||
rubocop-ast (>= 1.28.0, < 2.0) | ||
ruby-progressbar (~> 1.7) | ||
unicode-display_width (>= 2.4.0, < 3.0) | ||
rubocop-ast (1.29.0) | ||
parser (>= 3.2.1.0) | ||
ruby-progressbar (1.13.0) | ||
unicode-display_width (2.4.2) | ||
|
||
PLATFORMS | ||
ruby | ||
x86_64-darwin-22 | ||
|
||
DEPENDENCIES | ||
dotenv | ||
func_live! | ||
rake (~> 13.0) | ||
rspec (~> 3.0) | ||
rubocop (~> 1.21) | ||
|
||
BUNDLED WITH | ||
2.5.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,17 +8,17 @@ Gem::Specification.new do |spec| | |
spec.authors = ["Dmitry Babenko"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = "TODO: Write a short summary, because RubyGems requires one." | ||
spec.description = "TODO: Write a longer description or delete this line." | ||
spec.homepage = "TODO: Put your gem's website or public repo URL here." | ||
spec.summary = "fund(live)" | ||
spec.description = "Allows you to import and call the functions on www.func.live." | ||
spec.homepage = "https://www.func.live/" | ||
spec.license = "MIT" | ||
spec.required_ruby_version = ">= 3.0.0" | ||
|
||
spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" | ||
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" | ||
|
||
spec.metadata["homepage_uri"] = spec.homepage | ||
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." | ||
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." | ||
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." | ||
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
|
@@ -32,9 +32,5 @@ Gem::Specification.new do |spec| | |
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
|
||
# Uncomment to register a new dependency of your gem | ||
# spec.add_dependency "example-gem", "~> 1.0" | ||
|
||
# For more information and examples about making a new gem, check out our | ||
# guide at: https://bundler.io/guides/creating_gem.html | ||
spec.add_dependency "httparty" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "func_live/client" | ||
require_relative "func_live/version" | ||
|
||
module FuncLive | ||
class Error < StandardError; end | ||
# Your code goes here... | ||
|
||
class << self | ||
def token=(token) # rubocop:disable Style/TrivialAccessors | ||
@token = token | ||
end | ||
|
||
def token | ||
@token || ENV["FUNC_LIVE_TOKEN"] | ||
end | ||
|
||
def client | ||
@client ||= FuncLive::Client.new(token) | ||
end | ||
|
||
def call(function_name, input = nil) | ||
response = client.functions(function_name, input) | ||
|
||
raise FuncLive::Error, response["error"] if response["success"] == false | ||
|
||
response["output"] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require "httparty" | ||
|
||
module FuncLive | ||
class Client | ||
include HTTParty | ||
|
||
base_uri "https://api.func.live" | ||
|
||
def initialize(token) | ||
@headers = { | ||
"Content-Type" => "application/json", | ||
"Authorization" => "Bearer #{token}" | ||
} | ||
end | ||
|
||
def functions(function_name, input = nil) | ||
body = { input: input } | ||
self.class.post( | ||
"/functions/#{function_name}", | ||
headers: @headers, | ||
body: body.to_json | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters