Comments (6)
I'd love this feature, btw. It would require a more complex (thus potentially slower) data structure, since you'd actually have to generate a new Pattern object from the Expander.
I think building a separate PartialExpander along side Expander would allow people to opt into the added computational and/or memory cost (I think it would be very easy to sacrifice memory for performance).
from mustermann.
Care to pair on this? Friday maybe, or next week?
from mustermann.
I'd like to. I'm pretty busy right now until I get back from Israel November 8, unfortunately.
from mustermann.
ok, no rush. I'll ping you in a couple weeks then :)
from mustermann.
Which features do you expect?
Things that could be possible but will influence the API, internals and performance:
- Generating URI template strings.
- Generating objects that support further expanding.
- Generating full pattern objects (ie, that support matching).
- Generating string representations in the actual pattern type (ie, expand
/:a/:b
to/foo/:b
).
Of these, 2 would probably be easiest to implement (since it's just a proxy) and can be combined with any of the other, 1 is likely what you want. 3 should be feasible, 4 might be too much work for a feature people will rarely if ever use.
The most complex pattern type to implement this for would be URI templates itself (at least if level 4 expansion is the goal), it would share quite some logic with the full expansion, which also has some broken edge cases right now (see #4 and #5).
I could also imagine a partial expander to use the same logic as the full expander, but this might come at high memory cost (though I'm not 100% sure that's true, since for patterns with a reasonable number of variables, keeping the AST around would probably use more memory - the expander currently only needs the AST when generating expansion rules).
from mustermann.
Links in Yaks have the option to only expand none, all, or some of the placeholders
link :self, '/api/posts/{id}'
link "/rel/comment", '/api/posts/{id}/comments/{comment_id}', expand: [:id]
link "/rel/search", '/api/search{?q}', expand: false
Which would render as (using HAL as an example)
"_links": {
"self": {"href": "/api/posts/7"},
"/rel/comment": {"href": "/api/posts/7/comments/{comment_id}", "template": true},
"/rel/search": {"href": "/api/serach{?q}", "template": true},
}
So I guess that's 4?
from mustermann.
Related Issues (20)
- undefined method `ruby2_keywords' with version 1.1.0
- Ruby 2.7 Deprecation Warnings HOT 1
- Mustermann is not compatible with JRuby --enable=frozen-string-literal param HOT 11
- Support Ruby 3.0 HOT 9
- Fix circular require with mustermann primary reference
- Ruby 3.2 compat of `Mustermann::Rails#expand` HOT 2
- Routers HOT 4
- Infinite loop handling regexps built with Regxp::EXTENDED HOT 12
- Expand hash and array HOT 4
- Shorthand Error Syntax HOT 2
- NameError: uninitialized constant Mustermann::VERSION when VERSION is already defined HOT 2
- Improve performance of `Mustermann.new` HOT 4
- Mustermann-1.0.1 HOT 3
- Jruby Support HOT 3
- Anchors HOT 5
- v1.0.3 HOT 1
- Expanding with unused empty array values HOT 4
- Fallback to Hash for Mustermann::EqualityMap produces warnings and seems incorrect HOT 3
- Use WeakRef instead of ObjectSpace::WeakMap? HOT 2
- Hash expansion needs removed from `**options` in call to `#pattern_from`. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mustermann.