{"id":28003154,"url":"https://github.com/fnproject/fdk-ruby","last_synced_at":"2025-07-06T16:38:55.082Z","repository":{"id":47034085,"uuid":"105182347","full_name":"fnproject/fdk-ruby","owner":"fnproject","description":"Ruby Function Developer Kit","archived":false,"fork":false,"pushed_at":"2025-04-29T13:43:38.000Z","size":252,"stargazers_count":9,"open_issues_count":5,"forks_count":3,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-06-15T02:18:45.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://fnproject.github.io","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnproject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-09-28T18:04:50.000Z","updated_at":"2025-04-29T13:43:40.000Z","dependencies_parsed_at":"2025-02-02T19:23:26.203Z","dependency_job_id":"f1b34496-3479-475e-8cea-f58ae7c46920","html_url":"https://github.com/fnproject/fdk-ruby","commit_stats":null,"previous_names":[],"tags_count":63,"template":false,"template_full_name":null,"purl":"pkg:github/fnproject/fdk-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Ffdk-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Ffdk-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Ffdk-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Ffdk-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnproject","download_url":"https://codeload.github.com/fnproject/fdk-ruby/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnproject%2Ffdk-ruby/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263937915,"owners_count":23532805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-09T01:59:13.561Z","updated_at":"2025-07-06T16:38:54.966Z","avatar_url":"https://github.com/fnproject.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Function Development Kit for Ruby\nThe Function Development Kit for Ruby (FDK for Ruby) provides a Ruby framework for developing functions for use with [Fn](https://fnproject.github.io).\n\n[![CircleCI](https://circleci.com/gh/fnproject/fdk-ruby.svg?style=svg)](https://circleci.com/gh/fnproject/fdk-ruby)\n\n## Function Handler\nTo use this FDK, you simply need to require this gem.\n\n```ruby\nrequire 'fdk'\n```\n\nThen create a function with with the following syntax:\n\n```ruby\ndef myfunction(context:, input:)\n    # Do some work here\n    return output\nend\n```\n\n* context - provides runtime information for your function, such as configuration values, headers, etc.\n* input – This parameter is a string containing body of the request.\n* output - is where you can return data back to the caller. Whatever you return will be sent back to the caller. If `async`, this value is ignored.\n* Default output format should be in JSON, as Content-Type header will be `application/json` by default. You can be more flexible if you create and return\nan FDK::Response object instead of a string.\n\nThen simply pass that function to the FDK:\n\n```ruby\nFDK.handle(target: :myfunction)\n```\n\n## Examples\n\nSee the [examples](examples) folder of this repo for code examples.\n\n### Hello World Example\n\nIn the [hello-ruby](examples/hello-ruby) folder there is a traditional \"Hello  World\" example.  The code is found in [func.rb](examples/hello-ruby/func.rb):\n\n```ruby\nrequire 'fdk'\n\ndef myfunction(context:, input:)\n  input_value = input.respond_to?(:fetch) ? input.fetch('name') : input\n  name = input_value.to_s.strip.empty? ? 'World' : input_value\n  { message: \"Hello #{name}!\" }\nend\n\nFDK.handle(target: :myfunction)\n```\n\n## Deploying functions\n\nTo use a function we need to deploy it to an fn server.\n\nIn fn an _app_ consist of one or more functions and each function is\ndeployed as part of an app.\n\nWe're going to deploy the hello world example as part of the app\n`examples`.\n\nWith an fn server running (see\n[Quickstart](https://github.com/fnproject/fn/blob/master/README.md) if you need instructions):\n\n`cd` to the [hello-ruby](examples/hello-ruby) folder and run:\n\n```sh\nfn deploy --app examples --local\n```\n\nThe `--app examples` option tells fn to deploy the function as part of\nthe _app_ named _examples_.\n\nThe `--local` option tells fn not to push the function image to Docker\nHub.\n\n## Invoking functions\nOnce we have deployed a function we can invoke it using `fn invoke`.\n\nRunning the [Hello World](examples/hello-ruby) example:\n```sh\n$ fn invoke examples hello\n{\"message\":\"Hello World!\"}\n```\nTo get a more personal message, send a name in a JSON format and set the\n`content-type 'application/json'`:\n```\necho '{\"name\":\"Joe\"}' | fn invoke examples hello --content-type 'application/json'\n{\"message\":\"Hello Joe!\"}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnproject%2Ffdk-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnproject%2Ffdk-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnproject%2Ffdk-ruby/lists"}