Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
= Using Yaml
This Gem allows you to easily associate YAML files with classes
== Installation
From Gemcutter:
sudo gem install using_yaml
== Usage
require 'rubygems' require 'using_yaml'
class ExampleUsage include UsingYAML
using_yaml :some, :settings
end
example = ExampleUsage.new
example.some #=> { "key" => "value" }
example.some['key'] #=> "value"
example.some.key #=> "value"
example.some.key = "another value"
example.save #=> writes
example.settings #=> "{ ... }"
== Pathname
By default, UsingYAML will look for .yml files in your home directory. There are several ways to configure this:
=== With strings:
class ExampleUsage include UsingYAML
using_yaml :example, :path => '/your/path/here'
end
=== Using a Proc:
class ExampleUsage include UsingYAML
using_yaml :example, :path => lambda { |c| c.pathname }
attr_accessor :pathname
end
example = ExampleUsage.new example.pathname = '/your/path/here'
=== Overriding using_yaml_path:
class ExampleUsage include UsingYAML
using_yaml :example
def using_yaml_path
'/your/code/here'
end
end
== Error messages
By default, UsingYAML will return nil for missing files. It will also complain on STDERR. If you want to disable the complaint:
UsingYAML.squelch!
== Benchmark
There are two extremes when navigating hashes. Either we hit a nil
early, or we traverse successfully to the end. UsingYAML performs well regardless. Here are results using ruby-1.8.7-p249 [ x86_64 ]
=== Testing chains of nils
user system total real
normal 0.920000 0.040000 0.960000 ( 0.980095) chained 0.900000 0.060000 0.960000 ( 0.973219)
=== Testing where the keys exist
user system total real
normal 2.780000 0.150000 2.930000 ( 2.930808) chained 0.960000 0.060000 1.020000 ( 1.031477)
=== Results
While there are certainly other things to test, these benchmarks show that the method chaining performs either almost as well (in the case of nil.nil..) or significantly better (in the case of key.key..).
I'd definitely like to do some more testing. However, this is primarily a convenience library to improve programmer happiness, so these tests have made me happy enough for now.
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2010 Marc Bowes. See LICENSE for details.
FAQs
Unknown package
We found that using_yaml 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.