{"id":18544045,"url":"https://github.com/swagdevops/stibium-bundled","last_synced_at":"2025-05-15T05:31:11.031Z","repository":{"id":59156487,"uuid":"328721694","full_name":"SwagDevOps/stibium-bundled","owner":"SwagDevOps","description":"Denote bundle state","archived":false,"fork":false,"pushed_at":"2021-02-22T20:45:27.000Z","size":134,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-25T00:42:04.350Z","etag":null,"topics":["bundle","bundler","standalone"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/stibium-bundled","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SwagDevOps.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}},"created_at":"2021-01-11T16:17:38.000Z","updated_at":"2021-03-20T18:15:40.000Z","dependencies_parsed_at":"2022-09-13T20:11:31.887Z","dependency_job_id":null,"html_url":"https://github.com/SwagDevOps/stibium-bundled","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwagDevOps%2Fstibium-bundled","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwagDevOps%2Fstibium-bundled/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwagDevOps%2Fstibium-bundled/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwagDevOps%2Fstibium-bundled/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwagDevOps","download_url":"https://codeload.github.com/SwagDevOps/stibium-bundled/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254281789,"owners_count":22045021,"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":["bundle","bundler","standalone"],"created_at":"2024-11-06T20:15:11.746Z","updated_at":"2025-05-15T05:31:11.004Z","avatar_url":"https://github.com/SwagDevOps.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ``stibium-bundled`` [![Gem Version](https://badge.fury.io/rb/stibium-bundled.svg)][rubygems:stibium-bundled] [![Maintainability](https://api.codeclimate.com/v1/badges/7121242b44c7a3cc4f61/maintainability)](https://codeclimate.com/github/SwagDevOps/stibium-bundled/maintainability)\n\nThis gem is intended to mimic Bundler's behavior and conform to [bundler configuration options][bundler:config].\n\n``stibium-bundled`` detects ``gems.rb`` and ``gems.locked``\n(or ``Gemfile`` and ``Gemfile.lock``)\nand [``bundler/setup``][bundler:setup] (for [standalone][man:install#options] installation).\n\n``standalone`` makes a bundle that can work __without depending__ on Bundler (or Rubygems) at runtime. Bundler generates\na ``bundler/setup.rb`` file to replace Bundler's own setup in the manner required.\n\n[Configuration settings][bundler:config] are loaded in this order:\n\n1. Local config (``.bundle/config`` or ``\"$BUNDLE_APP_CONFIG/config``)\n2. Environment variables (``ENV``)\n3. Global config (``~/.bundle/config``)\n4. Default config\n\n## Sample of use\n\n```ruby\n# file: lib/awesome_gem.rb\n\nrequire 'stibium/bundled'\n\nmodule AwesomeGem\n  include(Stibium::Bundled)\n\n  self.bundled_from(\"#{__dir__}/..\", setup: true)\nend\n```\n\nor more concise:\n\n```ruby\n# file: lib/awesome_gem.rb\n\nrequire 'stibium/bundled'\n\nmodule AwesomeGem\n  include(Stibium::Bundled).bundled_from(\"#{__dir__}/..\", setup: true)\nend\n```\n\nor load a gem depending on status:\n\n```ruby\n# file: lib/awesome_gem.rb\n\nrequire 'stibium/bundled'\n\nmodule AwesomeGem\n  include(Stibium::Bundled).bundled_from(\"#{__dir__}/..\", setup: true) do |bundle|\n    if Object.const_defined?(:Gem) and bundle.locked? and bundle.installed?\n      'foo-bar'.tap do |gem_name|\n        unless bundle.specifications.keep_if { |spec| spec.name == gem_name }.empty?\n          require gem_name.gsub('-', '/')\n        end\n      end\n    end\n  end\nend\n```\n\nif ``stibium-bundled`` is not system wide installed, it can be necessary to\nlocate it:\n\n```ruby\n# file: lib/awesome_gem.rb\n\nautoload(:Pathname, 'pathname')\nautoload(:RbConfig, 'rbconfig')\n\nmodule AwesomeGem\n  Pathname.new(\"#{__dir__}/..\").expand_path.yield_self do |basedir|\n    begin\n      require 'stibium/bundled'\n    rescue LoadError\n      [\n        [RUBY_ENGINE, RbConfig::CONFIG.fetch('ruby_version'), 'bundler/gems/*/stibium-bundled.gemspec'],\n        [RUBY_ENGINE, RbConfig::CONFIG.fetch('ruby_version'), 'gems/stibium-bundled-*/lib/'],\n      ].map { |parts| basedir.join(*['{**/,}bundle'].concat(parts)) }.yield_self do |patterns|\n        Pathname.glob(patterns).first\u0026.dirname.tap { |gem_dir| require gem_dir.join('lib/stibium/bundled') }\n      end\n    end\n\n    include(::Stibium::Bundled).bundled_from(basedir, setup: true) do |bundle|\n      if bundle.locked? and bundle.installed? and Object.const_defined?(:Gem)\n        require 'fabulous/feature' if bundle.specifications.keep_if { |s| s.name == 'fabulous' }.any?\n      end\n    end\n  end\nend\n```\n\n## Benchmarks\n\nUsing ``Stibium::Bundled`` setup leads to minor overhead compared to direct require for ``bundler/setup``,\non the other hand ``Stibium::Bundled`` setup is compatible with standalone's bundler setup without code change.\nAnd ``bundle exec`` is known to be [slow][stackoverflow/running-scripts-with-bundle-exec-is-slow].\n\nInstall [hypefine][sharkdp/hyperfine] and run benchmarks:\n\n```shell\nrake bench runs=20\n```\n\n| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |\n|:---|---:|---:|---:|---:|\n| `bundler/setup` | 205.7 ± 7.1 | 200.1 | 232.5 | 1.00 ± 0.05 |\n| `bundled` | 205.7 ± 6.2 | 196.8 | 222.4 | 1.00 |\n| `bundle exec` | 559.4 ± 13.0 | 543.2 | 587.8 | 2.72 ± 0.10 |\n\n## Install\n\n```sh\nbundle config set --local clean 'true'\nbundle config set --local path 'vendor/bundle'\nbundle install --standalone\n```\n\n\u003c!-- hyperlinks --\u003e\n\n[rubygems:stibium-bundled]: https://rubygems.org/gems/stibium-bundled\n[bundler:config]: https://bundler.io/v2.2/bundle_config.html\n[bundler:setup]: https://bundler.io/v1.5/bundler_setup.html\n[man:install#options]: https://bundler.io/man/bundle-install.1.html#OPTIONS\n[sharkdp/hyperfine]: https://github.com/sharkdp/hyperfine\n[stackoverflow/running-scripts-with-bundle-exec-is-slow]: https://stackoverflow.com/questions/13894966/running-scripts-with-bundle-exec-is-slow\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswagdevops%2Fstibium-bundled","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswagdevops%2Fstibium-bundled","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswagdevops%2Fstibium-bundled/lists"}