https://github.com/hannesg/uri_template
A URI template library for ruby.
https://github.com/hannesg/uri_template
Last synced: about 14 hours ago
JSON representation
Repository metadata
A URI template library for ruby.
- Host: GitHub
- URL: https://github.com/hannesg/uri_template
- Owner: hannesg
- Created: 2011-10-30T20:21:57.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2024-04-29T23:03:39.000Z (over 1 year ago)
- Last Synced: 2025-11-28T10:46:46.618Z (19 days ago)
- Language: Ruby
- Homepage:
- Size: 1.14 MB
- Stars: 170
- Watchers: 32
- Forks: 90
- Open Issues: 10
- Releases: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
README.md
URITemplate - a uri template library
With URITemplate you can generate URIs based on simple templates and extract variables from URIs using the same templates. There are currently two syntaxes defined. Namely the one defined in RFC 6570 and a colon based syntax, similiar to the one used by sinatra.
From version 0.2.0, it will use escape_utils if available. This will significantly boost uri-escape/unescape performance if more characters need to be escaped ( may be slightly slower in trivial cases. working on that ... ), but does not run everywhere. To enable this, do the following:
# escape_utils has to be loaded when uri_templates is loaded
gem 'escape_utils'
require 'escape_utils'
gem 'uri_template'
require 'uri_template'
URITemplate::Utils.using_escape_utils? #=> true
Examples
require 'uri_template'
tpl = URITemplate.new('http://{host}{/segments*}/{file}{.extensions*}')
# This will give: http://www.host.com/path/to/a/file.x.y
tpl.expand('host'=>'www.host.com','segments'=>['path','to','a'],'file'=>'file','extensions'=>['x','y'])
# This will give: { 'host'=>'www.host.com','segments'=>['path','to','a'],'file'=>'file','extensions'=>['x','y']}
tpl.extract('http://www.host.com/path/to/a/file.x.y')
# If you like colon templates more:
tpl2 = URITemplate.new(:colon, '/:x/y')
# This will give: {'x' => 'z'}
tpl2.extract('/z/y')
# This will give a new uri template with just the host expanded:
tpl.expand_partial(host: "www.host.com")
RFC 6570 Syntax
The syntax defined by RFC 6570 is pretty straight forward. Basically anything surrounded by curly brackets is interpreted as variable.
URITemplate.new('{variable}').expand('variable' => 'value') #=> "value"
The way variables are inserted can be modified using operators. The operator is the first character between the curly brackets. There are seven operators defined #, +, ;, ?, &, / and .. So if you want to create a form-style query do this:
URITemplate.new('{?variable}').expand('variable' => 'value') #=> "?variable=value"
Benchmarks
I have assembled one benchmark based on the uritemplate-test examples. You can find them in the "benchmarks" folder. The short result: uri_template is 2-10x faster than addressable on ruby 1.9.3.
Owner metadata
- Name: Hannes Voigt-Georg
- Login: hannesg
- Email:
- Kind: user
- Description:
- Website: https://hannesg.github.io/
- Location: Hamburg, Germany
- Twitter:
- Company: @freiheit-com
- Icon url: https://avatars.githubusercontent.com/u/143148?v=4
- Repositories: 64
- Last ynced at: 2023-04-10T11:40:48.492Z
- Profile URL: https://github.com/hannesg
GitHub Events
Total
- Watch event: 4
- Fork event: 4
Last Year
- Watch event: 3
- Fork event: 3
Committers metadata
Last synced: about 19 hours ago
Total Commits: 195
Total Committers: 7
Avg Commits per committer: 27.857
Development Distribution Score (DDS): 0.436
Commits in past year: 0
Committers in past year: 0
Avg Commits per committer in past year: 0.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Hannes Georg | h****g@g****m | 110 |
| HannesG | h****g@i****e | 48 |
| Hannes Georg | h****g@x****m | 33 |
| Peter Hellberg | p****r@c****e | 1 |
| Bjørn Arild Mæland | b****d@g****m | 1 |
| Ben Hollis | b****n@b****t | 1 |
| Philip Vieira | p****p@v****e | 1 |
Committer domains:
- vallin.se: 1
- benhollis.net: 1
- c7.se: 1
- xing.com: 1
- informatik.uni-kiel.de: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 9
Total pull requests: 13
Average time to close issues: over 1 year
Average time to close pull requests: about 2 months
Total issue authors: 8
Total pull request authors: 12
Average comments per issue: 3.0
Average comments per pull request: 1.31
Merged pull request: 4
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- bhollis (2)
- mnot (1)
- mateomurphy (1)
- andrewpthorp (1)
- peterhellberg (1)
- andreypopp (1)
- dblock (1)
- plexus (1)
Top Pull Request Authors
- Top-Chief (2)
- Survivedabuse (1)
- JsonXjames (1)
- zeevallin (1)
- bmaland (1)
- bhollis (1)
- jabulile99 (1)
- tas50 (1)
- miguel-botelho (1)
- peterhellberg (1)
- ivoanjo (1)
- mslovelymiaboo (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 2
-
Total downloads:
- rubygems: 92,976,618 total
- Total docker downloads: 974,898,608
- Total dependent packages: 43 (may contain duplicates)
- Total dependent repositories: 1,845 (may contain duplicates)
- Total versions: 34
- Total maintainers: 1
gem.coop: uri_template
A templating system for URIs, which implements RFC6570 and Colon based URITemplates in a clean and straight forward way.
- Homepage: http://github.com/hannesg/uri_template
- Documentation: http://www.rubydoc.info/gems/uri_template/
- Licenses: MIT
- Latest release: 0.7.0 (published over 11 years ago)
- Last Synced: 2025-12-15T10:10:18.047Z (1 day ago)
- Versions: 17
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 46,488,309 Total
- Docker Downloads: 487,449,304
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.183%
- Docker downloads count: 0.205%
- Downloads: 0.528%
- Maintainers (1)
rubygems.org: uri_template
A templating system for URIs, which implements RFC6570 and Colon based URITemplates in a clean and straight forward way.
- Homepage: http://github.com/hannesg/uri_template
- Documentation: http://www.rubydoc.info/gems/uri_template/
- Licenses: MIT
- Latest release: 0.7.0 (published over 11 years ago)
- Last Synced: 2025-12-15T10:10:15.241Z (1 day ago)
- Versions: 17
- Dependent Packages: 43
- Dependent Repositories: 1,845
- Downloads: 46,488,309 Total
- Docker Downloads: 487,449,304
-
Rankings:
- Docker downloads count: 0.268%
- Downloads: 0.488%
- Dependent packages count: 0.611%
- Dependent repos count: 0.725%
- Average: 1.475%
- Forks count: 2.397%
- Stargazers count: 4.358%
- Maintainers (1)
Dependencies
- addressable >= 0 development
- coveralls >= 0 development
- escape_utils >= 0 development
- mutant >= 0 development
- redcarpet >= 0 development
- simplecov-console >= 0 development
- abstract_type 0.0.7
- adamantium 0.2.0
- addressable 2.3.5
- anima 0.2.0
- ast 1.1.0
- atomic 1.1.16
- colorize 0.7.0
- concord 0.1.4
- coveralls 0.7.0
- descendants_tracker 0.0.3
- diff-lcs 1.2.5
- docile 1.1.3
- equalizer 0.0.9
- escape_utils 1.0.1
- hirb 0.7.1
- ice_nine 0.11.0
- inflecto 0.0.2
- memoizable 0.4.1
- mime-types 2.2
- morpher 0.2.0
- multi_json 1.9.2
- mutant 0.5.6
- parser 2.1.7
- procto 0.0.2
- rake 10.1.1
- redcarpet 3.1.1
- rest-client 1.6.7
- rspec 2.14.1
- rspec-core 2.14.8
- rspec-expectations 2.14.5
- rspec-mocks 2.14.6
- simplecov 0.8.2
- simplecov-console 0.1.3
- simplecov-html 0.8.0
- slop 3.5.0
- term-ansicolor 1.3.0
- thor 0.18.1
- thread_safe 0.2.0
- tins 1.0.1
- unparser 0.1.9
- uri_template 0.7.0
- yard 0.8.7.3
- bundler >= 0 development
- multi_json >= 0 development
- rake >= 0 development
- rspec >= 0 development
- yard >= 0 development
Score: 27.927806038099025



