{"id":13482989,"url":"https://github.com/torba-rb/torba","last_synced_at":"2025-04-05T02:12:30.061Z","repository":{"id":30816498,"uuid":"34373686","full_name":"torba-rb/torba","owner":"torba-rb","description":"Bundler for Sprockets","archived":false,"fork":false,"pushed_at":"2023-08-18T09:14:31.000Z","size":153,"stargazers_count":167,"open_issues_count":3,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-29T01:15:11.657Z","etag":null,"topics":["asset-pipeline","sprockets"],"latest_commit_sha":null,"homepage":null,"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/torba-rb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-04-22T06:43:30.000Z","updated_at":"2024-07-06T16:10:41.000Z","dependencies_parsed_at":"2024-01-05T21:58:28.355Z","dependency_job_id":null,"html_url":"https://github.com/torba-rb/torba","commit_stats":{"total_commits":74,"total_committers":9,"mean_commits":8.222222222222221,"dds":"0.20270270270270274","last_synced_commit":"9cbe8f751bbb299551fb1bb689e727c122fb7362"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torba-rb%2Ftorba","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torba-rb%2Ftorba/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torba-rb%2Ftorba/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/torba-rb%2Ftorba/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/torba-rb","download_url":"https://codeload.github.com/torba-rb/torba/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"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":["asset-pipeline","sprockets"],"created_at":"2024-07-31T17:01:07.287Z","updated_at":"2025-04-05T02:12:30.041Z","avatar_url":"https://github.com/torba-rb.png","language":"Ruby","readme":"# Torba\n\n[![Build Status](https://img.shields.io/travis/torba-rb/torba.svg)](https://travis-ci.org/torba-rb/torba)\n[![Gem version](https://img.shields.io/gem/v/torba.svg)](https://rubygems.org/gems/torba)\n\n**Torba** is a [Bower][bower]-less asset manager for [Sprockets][sprockets]. It makes a local copy\nof a JS/CSS library and puts it under Sprockets' [load path][sprockets-load-path].\n\n## Name origin\n\n\"Торба\" [[tǒːrba][torba-pronounce]] in Ukrainian and \"torba\" in Polish, Turkic languages can mean\n\"duffel bag\", \"gunny sack\" or, more generally, any flexible container.\n\n## Status\n\nProduction ready.\n\n## Documentation\n\n[Released version](http://rubydoc.info/gems/torba/1.2.0)\n\n## Why\n\nDe facto approach, i.e. wrapping JS and CSS libraries in a gem, requires a\nmaintainer to constantly track changes in an upstream repository. Even more so, if a gem\nmaintainer stops using that specific library, the gem will eventually become abandoned.\nAdditionally, many libraries still have no gem wrappers.\n\nOther alternatives:\n\n* [rails-assets][rails-assets] relies on Bower *and* it is quite complex,\n* [bower-rails][bower-rails] relies on Bower, see below for why this can be an issue.\n\nProblems with the Bower:\n\n* it is not a part of the Ruby ecosystem,\n* frontend JS libraries are usually standalone (except for a potential jQuery dependency), so there's\n  no need for a complex Bundler-like solution with tree-dependency resolution,\n* often we can't use optimistic version constraints, because the JavaScript community does not consistenly apply the principles of [Semver][semver]. By specifying strict versions we use Bower as a complex facade for functionality that could be accomplished with curl.\n\n## External dependencies\n\n* curl\n* unzip\n* gzip\n* tar\n\n## Design limitations\n\n* Torba doesn't do any version dependency resolution, it's up to you to specify the correct version of\n  each asset package,\n* Torba doesn't do any builds, you should use remote sources with pre-built assets.\n\n## Installation\n\n### Rails\n\nUse [torba-rails][torba-rails-github].\n\n### Sinatra\n\nSee this [example project][sinatra-example].\n\n### Other Ruby application\n\nAdd this line to your application's Gemfile and run bundle:\n\n```ruby\ngem 'torba'\n```\n\n## Usage\n\n1. Create Torbafile at the project root and commit it.\n\n2. Run `bundle exec torba pack`.\n\n3. Add \"require\" [Sprockets directives][sprockets-directives] to your \"application.js\"\nand/or \"@import\" [Sass directives][sass-import] to \"application.css\".\n\nIf any changes made to the Torbafile, run `bundle exec torba pack` again.\n\n### Torbafile\n\nTorbafile is an assets specification. It is a plain text file that contains one or more\nsections, each of them describes one remote source of assets.\n\nCurrently only zip, tar.gz archives, [Github releases][github-releases] and\n[npm packages][npm] are supported.\n\n#### Zip archive package\n\nAllows to download and unpack asset package from any source accessible by curl.\n\nThe syntax is:\n\n```ruby\nzip \"name\", url: \"...\" [, import: %w(...)]\n```\n\nwhere \"name\" is an arbitrary name for the package, more on \"import\" below. For example,\n\n```ruby\nzip \"scroll_magic\", url: \"https://github.com/janpaepke/ScrollMagic/archive/v2.0.0.zip\"\n```\n\n#### Tar.gz archive package\n\nThe syntax is same as for a zip package:\n\n```ruby\ntargz \"name\", url: \"...\" [, import: %w(...)]\n```\n\nfor example,\n\n```ruby\ntargz \"scroll_magic\", url: \"https://github.com/janpaepke/ScrollMagic/archive/v2.0.0.tar.gz\"\n```\n\n#### Github release package\n\nThis is a more readable version/shortcut for \"https://github.com/.../archive/...\" URLs.\n\nThe syntax is:\n\n```ruby\ngh_release \"name\", source: \"...\", tag: \"...\" [, import: %w(...)]\n```\n\nwhere \"source\" is the user + repository and \"tag\" is the repository tag (exactly as on Github,\ni.e. with \"v\" prefix if present), more on \"import\" below. For example,\n\n```ruby\ngh_release \"scroll_magic\", source: \"janpaepke/ScrollMagic\", tag: \"v.2.0.0\"\n```\n\nYou can omit the name, it will be equal to the repository name:\n\n```ruby\ngh_release source: \"janpaepke/ScrollMagic\", tag: \"v.2.0.0\" # \"ScrollMagic\" is assumed\n```\n\n#### npm package\n\nAllows to download packages from npm registry.\n\nThe syntax is:\n\n```ruby\nnpm \"name\", package: \"...\", version: \"...\" [, import: %w(...)]\n```\n\nwhere \"package\" is the package name as published on npm registry and \"version\" is its version,\nmore on \"import\" below. For example,\n\n```ruby\nnpm \"coffee\", package: \"coffee-script\", version: \"1.9.2\"\n```\n\nYou can omit the name, it will be equal to the package name:\n\n```ruby\nnpm package: \"coffee-script\", version: \"1.9.2\"\n```\n\n### Examples\n\nSee [Torbafiles][torbafile-examples] used for testing.\n\n### \"Packing the torba\" process\n\nWhen you run `torba pack` the following happens:\n\n1.  All remote sources are cached locally.\n\n2.  Archives are unpacked with top level directory removed. This is done for good because it\nusually contains the package version in the name, e.g. \"react-0.13.2\", and you don't want to have to reference versions\ninside your application code (except Torbafile).\n\n3.  Remote source's content is copied as is to the `Torba.home_path` location with **package name used\nas a namespace**.\n\n    This is also done for good reason in order to avoid name collisions (since many JS projects can have\nassets with the same names and all packages are placed into Sprockets' shared virtual filesystem).\nThe downside is that you have to use namespaces in each require directive, which can lead to\nduplication:\n\n    ```javascript\n    // application.js\n    //= require 'underscore/underscore'\n    ```\n\n    Hint: use \"require_directory\" if you're strongly against such duplication:\n\n    ```javascript\n    //= require_directory 'underscore'\n    ```\n\n4.  Stylesheets (if any) are converted to \".css.erb\" with \"asset_path\" helpers used in \"url(...)\"\nstatements.\n\n### :import option\n\nCopying whole remote source's content has the disadvantage of using remote source specific paths in your\nrequire/import directives. For example, if an archive contains files in the \"dist/css\" directory, you'll have\nto mention it:\n\n```css\n/* application.css */\n@import 'lightslider/dist/css/lightslider';\n```\n\nTo mitigate this you can cherry-pick files from the source via the \"import\" option, for example:\n\n```ruby\ngh_release \"lightslider\", source: \"sachinchoolur/lightslider\", tag: \"1.1.2\", import: %w[\n  dist/css/lightslider.css\n]\n```\n\nSuch files will be copied directly to the package root (i.e. file tree becomes flatten), thus you\ncan omit unnecessary paths:\n\n```css\n@import 'lightslider/lightslider';\n```\n\nYou can use any Dir.glob pattern:\n\n```ruby\ngh_release \"lightslider\", source: \"sachinchoolur/lightslider\", tag: \"1.1.2\", import: %w[\n  dist/css/lightslider.css\n  dist/img/*.png\n]\n```\n\nIn addition to this \"path/\" is treated as a shortcut for \"path/**/*\" glob pattern.\n\n[bower]: http://bower.io/\n[sprockets]: https://github.com/rails/sprockets/\n[sprockets-load-path]: https://github.com/rails/sprockets#the-load-path\n[torba-pronounce]: http://upload.wikimedia.org/wikipedia/commons/2/28/Uk-%D1%82%D0%BE%D1%80%D0%B1%D0%B0.ogg\n[github-releases]: https://help.github.com/articles/about-releases/\n[sprockets-directives]: https://github.com/rails/sprockets#the-directive-processor\n[sass-import]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#import\n[rails-assets]: https://rails-assets.org/\n[bower-rails]: https://github.com/rharriso/bower-rails\n[semver]: http://semver.org/\n[npm]: https://npmjs.com\n[torba-rails-github]: https://github.com/torba-rb/torba-rails\n[sinatra-example]: https://github.com/xfalcox/sinatra-assets-seed\n[torbafile-examples]: https://github.com/torba-rb/torba/tree/master/test/fixtures/torbafiles\n","funding_links":[],"categories":["Assets"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorba-rb%2Ftorba","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftorba-rb%2Ftorba","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorba-rb%2Ftorba/lists"}