{"id":19474562,"url":"https://github.com/tomasc/dragonfly_svg","last_synced_at":"2025-04-25T12:31:50.073Z","repository":{"id":18452393,"uuid":"21645915","full_name":"tomasc/dragonfly_svg","owner":"tomasc","description":"Dragonfly SVG plugin.","archived":false,"fork":false,"pushed_at":"2021-03-22T09:06:55.000Z","size":37,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T06:08:12.904Z","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/tomasc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2014-07-09T09:01:16.000Z","updated_at":"2021-03-22T09:06:58.000Z","dependencies_parsed_at":"2022-09-09T02:22:58.799Z","dependency_job_id":null,"html_url":"https://github.com/tomasc/dragonfly_svg","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/tomasc%2Fdragonfly_svg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fdragonfly_svg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fdragonfly_svg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomasc%2Fdragonfly_svg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomasc","download_url":"https://codeload.github.com/tomasc/dragonfly_svg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250817778,"owners_count":21492220,"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-11-10T19:25:41.899Z","updated_at":"2025-04-25T12:31:46.650Z","avatar_url":"https://github.com/tomasc.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dragonfly SVG\n\n[![Build Status](https://travis-ci.org/tomasc/dragonfly_svg.svg)](https://travis-ci.org/tomasc/dragonfly_svg) [![Gem Version](https://badge.fury.io/rb/dragonfly_svg.svg)](http://badge.fury.io/rb/dragonfly_svg) [![Coverage Status](https://img.shields.io/coveralls/tomasc/dragonfly_svg.svg)](https://coveralls.io/r/tomasc/dragonfly_svg)\n\n[Dragonfly](https://github.com/markevans/dragonfly) analyser and processors for SVGs.\n\nUses the [nokogiri](http://nokogiri.org) gem for SVG parsing.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'dragonfly_svg'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install dragonfly_svg\n\n## Usage\nThe analyser and processors are added by configuring the plugin\n\n```ruby\nDragonfly.app.configure do\n  plugin :svg\nend\n```\n\n## Supported Formats\n\nList of supported formats is available as:\n\n```ruby\nDragonflySvg::SUPPORTED_FORMATS # =\u003e [\"svg\", \"svgz\", \"svg.gz\"]\n```\n\n## Analyser\nThe analyser supplies the following methods:\n\n```ruby\nsvg.width\nsvg.height\nsvg.aspect_ratio\nsvg.id\nsvg.portrait?\nsvg.landscape?\n```\n\n## Processors\n\n### ExtendIds\n\nAdds a random string to the `id`. Helpful when embedding SVGs, in which case the `id` should be unique. You can also supply your own String.\n\n```ruby\nsvg.extend_ids\nsvg.extend_ids('foo')\n```\n\n### RemoveNamespaces\n\nRemoves the `xmlns` namespace from the SVG.\n\n```ruby\nsvg.remove_namespaces\n```\n\n### SetAttribute\n\nAllows to set attribute for specified `xpath`:\n\n```ruby\nsvg.set_attribute('./*[name()=\"svg\"]', 'style', 'margin: 50px;')\n```\n\n### SetTagValue\n\nAllows to set tag value for specified `xpath`:\n\n```ruby\nsvg.set_tag_value('./*[name()=\"text\"]', 'Updated text')\n```\n\n### SetDimensions\n\nSets the dimensions of the SVG. Takes two parameters: `width` and `height`\n\n```ruby\nsvg.set_dimensions(210, 297)\n```\n\n### SetNamespace\n\nSets the `xmlns` namespace of the SVG. Default is `http://www.w3.org/2000/svg` unless something is supplied.\n\n```ruby\nsvg.set_namespace                     # xmlns=\"http://www.w3.org/2000/svg\"\nsvg.set_namespace('foo')              # xmlns=\"foo\"\n```\n\n### SetPreserveAspectRatio\n\nSets the `preserveAspectRatio` attribute of the SVG. Default is `xMinYMin meet` unless something is supplied.\n\n```ruby\nsvg.set_preserve_aspect_ratio         # preserveAspectRatio=\"xMinYMin meet\"\nsvg.set_preserve_aspect_ratio('foo')  # preserveAspectRatio=\"foo\"\n```\n\n### SetViewBox\n\nSets the `viewBox` attribute of the SVG. Takes four parameters: `min_x`, `min_y`, `width` and `height`.\n\n```ruby\nsvg.set_view_box(0, 0, 400, 600)       # viewBox=\"0 0 400 600\"\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/tomasc/dragonfly_svg/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasc%2Fdragonfly_svg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomasc%2Fdragonfly_svg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomasc%2Fdragonfly_svg/lists"}