
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
chuck-configurator
Advanced tools
A pseudo DI factory for the [ChucK language](http://chuck.cs.princeton.edu/).
A pseudo DI factory for the ChucK language.
You can register any type as part of the ObjectFactory
by calling the Register
static method. For example:
public class ThingBase { }
public class JustAThing extends ThingBase { }
public class SuperCoolThing extends ThingBase { }
ObjectFactory.Register("JustAThing", new JustAThing);
ObjectFactory.Register("SuperCoolThing", new SuperCoolThing);
Note: since ChucK (as far as I know) doesn't have reflection, registration uses magic strings and and concrete instances. You should be careful that what you register won't interfere with normal execution by handling/creating events or by using a large chuck of memory.
The ObjectFactory
has two non-public methods _GetInstance
and _GetConfiguredInstance
.
Since these are non-public you will have to sub-class the ObjectFactory
with your own strongly-typed implementation.
For example:
public class ThingFactory extends ObjectFactory
{
fun ThingBase GetConfiguredThing()
{
return _GetConfiguredInstance("Thing") $ ThingBase;
}
fun SuperCoolThing GetSuperCoolThing()
{
return _GetInstance("SuperCoolThing") $ SuperCoolThing;
}
fun JustAThing GetJustAThing()
{
return _GetInstance("JustAThing") $ JustAThing;
}
static ThingFactory @ _thingFactory;
fun static ThingFactory Instance()
{
if(_thingFactory == null)
{
new ThingFactory @=> _thingFactory;
}
return _thingFactory;
}
}
ThingFactory.Instance();
Note: I'm fairly unhappy with the whole registration/retrieval thing so it is fairly likely to change in an upcoming release
Before/During/After ObjectFactory
registration you can set the default implementations.
This is done by calling the UseDefault
static method. For example:
// Note: "Thing" is pretty arbitrary. It could be "things", or "t" or even "I miss reflection..."
ObjectFactory.UseDefault("Thing", "SuperCoolThing");
The default implementation will only be used if a non-default implementation is not chosen. For example:
ObjectFactory.UseDefault("Thing", "SuperCoolThing");
ThingFactory.Instance().GetConfiguredThing() // returns SuperCoolThing implementation
ObjectFactory.UseDefault("Thing", "SuperCoolThing");
ObjectFactory.Use("Thing", "JustAThing");
ObjectFactory.UseDefault("Thing", "SuperCoolThing");
ThingFactory.Instance().GetConfiguredThing() // returns JustAThing implementation
Basically just a wrapper for code I found myself commonly writing around configuration and DI. It has a single static method Configure
which parses an options array and configures the ObjectFactory
. For example:
[ "Thing", "JustAThing",
"AnotherKey", "AnotherValue" ] @=> string args[];
Configurator.Configure(args);
/* ObjectFactory will have received the following calls
* ObjectFactory.Use("Thing", "JustAThing");
* ObjectFactory.Use("AnotherKey", "AnotherValue");
*/
This makes it easy to configure ChucK from the command line. For example:
string args[0];
for(int i; i < me.args(); i++)
{
args << me.arg(i);
}
Configurator.Configure(args);
FAQs
A pseudo DI factory for the [ChucK language](http://chuck.cs.princeton.edu/).
We found that chuck-configurator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.