{"id":16697011,"url":"https://github.com/seratch/scaruby","last_synced_at":"2025-04-10T02:52:35.459Z","repository":{"id":2597554,"uuid":"3579967","full_name":"seratch/scaruby","owner":"seratch","description":"Scala API in Ruby","archived":false,"fork":false,"pushed_at":"2014-08-02T01:30:47.000Z","size":196,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-23T22:19:38.014Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seratch.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-29T08:43:15.000Z","updated_at":"2019-08-13T14:58:02.000Z","dependencies_parsed_at":"2022-08-29T05:01:19.954Z","dependency_job_id":null,"html_url":"https://github.com/seratch/scaruby","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fscaruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fscaruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fscaruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seratch%2Fscaruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seratch","download_url":"https://codeload.github.com/seratch/scaruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248147132,"owners_count":21055482,"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":"2024-10-12T17:45:46.902Z","updated_at":"2025-04-10T02:52:35.425Z","avatar_url":"https://github.com/seratch.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scala API in Ruby\n\nhttps://rubygems.org/gems/scaruby\n\nSurely it works fine. \n\nBut it mainly serves as a Ruby reference for Scala programmers.\n\n\n## Supported Ruby versions\n\nScaruby runs on Ruby 1.9.2, 1.9.3.\n\n\n## Gemfile\n\n```\nsource \"http://rubygems.org/\"\n\ngem 'scaruby'\n```\n\n\n## Usage\n\nSee specs.\n\n\n## Trying on irb\n\n```sh\nbundle console\n```\n\n```ruby\nirb(main):008:0\u003e require 'scaruby'\n=\u003e false\n\nirb(main):009:0\u003e Option.new(nil).is_defined\n=\u003e false\nirb(main):010:0\u003e Option.apply(nil).is_defined\n=\u003e false\nirb(main):011:0\u003e Option.new(123).is_defined\n=\u003e true\n\nirb(main):012:0\u003e Seq.new([1,2,3]).filter {|e| e \u003c 2 }\n=\u003e #\u003cScaruby::Seq:0x9772424 @array=[1]\u003e\nirb(main):013:0\u003e Seq.new([1,2,3]).filter {|e| e \u003c 2 }.to_a\n=\u003e [1]\nirb(main):014:0\u003e Seq.new([1,2,3]).fold_left(0) {|z,x| z + x }\n=\u003e 6\n\nirb(main):025:0\u003e Map.new({123=\u003e'abc',23=\u003e'bc',345=\u003e'cde'}).filter {|k,v| k.to_s.size == 3 }\n=\u003e #\u003cScaruby::Map:0x94afa98 @hash={123=\u003e\"abc\", 345=\u003e\"cde\"}\u003e\nirb(main):026:0\u003e Map.new({123=\u003e'abc',23=\u003e'bc',345=\u003e'cde'}).filter {|k,v| k.to_s.size == 3 }.to_hash\n=\u003e {123=\u003e\"abc\", 345=\u003e\"cde\"}\n```\n\n`scaruby/converter` might be useful.\n\n```ruby\nirb(main):001:0\u003e require 'scaruby/converter'\n=\u003e true\nirb(main):002:0\u003e 'abc'.to_option.is_defined\n=\u003e true\nirb(main):003:0\u003e 'abc'.to_option.get_or_else('zzz')\n=\u003e \"abc\"\nirb(main):004:0\u003e nil.to_option.is_defined\n=\u003e false\nirb(main):005:0\u003e [1,2,3].to_scaruby.foreach do |e| puts e end\n1\n2\n3\n=\u003e [1, 2, 3]\n```\n\nIt is also possible to extend Ruby with Scaruby. \n\nIf the method is missing, the method in Scaruby will be invoked.\n\nIn this case, the methods already defined (i.e. flat_map, find and so on) are never replaced.\n\n```ruby\nirb(main):015:0\u003e require 'scaruby/core_ext'\n=\u003e true\nirb(main):016:0\u003e 1.upto(5).filter {|i| i \u003c 3 }\n=\u003e [1, 2]\nirb(main):020:0\u003e 1.upto(5).filter {|i| i \u003c 3 }.foreach do |i|\nirb(main):021:1*   puts i\nirb(main):022:1\u003e end\n1\n2\n=\u003e [1, 2]\n\nirb(main):027:0\u003e {123=\u003e'abc',23=\u003e'bc',345=\u003e'cde'}.filter {|k,v| k.to_s.size == 3 }\n=\u003e {123=\u003e\"abc\", 345=\u003e\"cde\"}\n```\n\n\n## Build Status\n\n[![Build Status](https://secure.travis-ci.org/seratch/scaruby.png)](http://travis-ci.org/seratch/scaruby)\n\n\n## License\n\nMIT License\n\nhttps://github.com/seratch/scaruby/blob/master/LICENSE.txt\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseratch%2Fscaruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseratch%2Fscaruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseratch%2Fscaruby/lists"}