{"id":17103162,"url":"https://github.com/helpermethod/gscope","last_synced_at":"2025-03-23T19:41:47.191Z","repository":{"id":146262362,"uuid":"124293191","full_name":"helpermethod/gscope","owner":"helpermethod","description":"Kotlin's scoping functions for Groovy.","archived":false,"fork":false,"pushed_at":"2018-07-05T13:53:47.000Z","size":74,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-05T03:36:35.585Z","etag":null,"topics":["extension-module","groovy","type-safe"],"latest_commit_sha":null,"homepage":"","language":"Groovy","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/helpermethod.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}},"created_at":"2018-03-07T20:53:28.000Z","updated_at":"2024-12-24T04:52:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"760a2886-0b91-4089-96a5-87fe96a1a7a3","html_url":"https://github.com/helpermethod/gscope","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helpermethod%2Fgscope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helpermethod%2Fgscope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helpermethod%2Fgscope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helpermethod%2Fgscope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helpermethod","download_url":"https://codeload.github.com/helpermethod/gscope/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245162031,"owners_count":20570691,"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":["extension-module","groovy","type-safe"],"created_at":"2024-10-14T15:32:10.725Z","updated_at":"2025-03-23T19:41:47.167Z","avatar_url":"https://github.com/helpermethod.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GScope\n\nKotlin's scoping functions for Groovy.\n\n## Features\n\n* **Typesafe** GScope is compatible with type checking and static compilation.\n* **Small** GScope has no external dependencies.\n\n## Setup\n\n### Gradle\n\n```groovy\nrepositories {\n    maven {\n        url 'http://dl.bintray.com/helpermethod/maven'\n    }\n}\n\ndependencies {\n    compile 'com.github.helpermethod:gscope:0.2.0'\n}\n```\n\n### Maven\n\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ebintray\u003c/id\u003e\n        \u003curl\u003ehttp://dl.bintray.com/helpermethod/maven\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.helpermethod\u003c/groupId\u003e\n    \u003cartifactId\u003egscope\u003c/artifactId\u003e\n    \u003cversion\u003e0.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Quickstart\n\n```groovy\nclass Person {\n    String firstName\n    String lastName\n}\n\ndef ash = new Person().apply {\n    firstName = 'Ash'\n    lastName = 'Williams'\n}\n```\n\n## API\n\n### apply\n\n\u003e `apply` calls the specified closure with `this` value as its delegate and returns `this`.\n\n`apply` is used for post-construction initialisation.\n\n```groovy\ndef ash = new Person().apply {\n    firstName = 'Ash'\n    lastName = 'Williams'\n}\n```\n\n`apply` may also be used to expose a fluent API for methods that would normally return `void`.\n\n```groovy\nclass Person {\n    String firstName\n    String lastName\n\n    def firstName(String firstName) {\n        apply { this.firstName = firstName }\n    }\n\n    def lastName(String lastName) {\n        apply { this.lastName = lastName }\n    }\n}\n\ndef ash = new Person().firstName('Ash').lastName('Williams')\n```\n\n### also\n\n\u003e `also` calls the specified closure with `this` as its argument and returns `this`.\n\n`also` is like `apply` except that `this` becomes the closure's argument instead of its delegate.\n\nLike `apply` it's used for initialisation.\n\n```groovy\ndef ash = new Person().also {\n    it.firstName = 'Ash'\n    it.lastName = 'Williams'\n}\n```\n\n`also` may also be used to assign calculated values to fields.\n\n```groovy\nclass Person {\n    Person father\n    List\u003cPerson\u003e children\n\n    def father(Person father) {\n        father.also {\n            this.father = it\n            it.children += this\n        }\n    }\n}\n```\n\n### run\n\n\u003e `run` calls the specified closure with `this` value as its delegate and returns its result.\n\n`run` is used for transforming values.\n\n```groovy\ndef ashWilliams = new Person(firstName: 'Ash', lastName: 'Williams').run {\n    \"$firstName $lastName\"\n}\n```\n\n### let\n\n\u003e `let` calls the specified closure with `this` as its argument and returns its result.\n\n`let` is like `run` except that `this` becomes the closure's argument instead of its delegate.\nLike `run` it's used for transforming values.\n\n```groovy\ndef ashWilliams = new Person(firstName: 'Ash', lastName: 'Williams').let {\n    \"$it.firstName $it.lastName\"\n}\n```\n\n`let` may also be used to execute a block of code when the delegate is non-null.\n\n```groovy\nclass PersonUtils {\n    static def fullName(Person person) {\n        person?.let {\n            println(it)\n            \"$it.firstName $it.lastName\"\n        } ?: 'John Doe'\n    }\n}\n\ndef ashWilliams = PersonUtils.fullName(ash)\ndef johnDoe = PersonUtils.fullName(null)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelpermethod%2Fgscope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelpermethod%2Fgscope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelpermethod%2Fgscope/lists"}