
Security News
Rspack Introduces Rslint, a TypeScript-First Linter Written in Go
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
Marshal Ruby classes in to and out of multiple formats (yaml, json, csv, tsv).
require 'storable'
class Machine < Storable
field :environment # Define field names for Machine. The
field :role # default type is String, but you can
field :position => Integer # specify a type using a hash syntax.
end
mac1 = Machine.new # Instances of Machine have accessors
mac1.environment = "stage" # just like regular attributes.
mac1.role = "app"
mac1.position = 1
puts "# YAML", mac1.to_yaml # Note: the field order is maintained
puts "# CSV", mac1.to_csv # => stage,app,1
puts "# JSON", mac1.to_json # Note: field order not maintained.
mac2 = Machine.from_yaml(mac1.to_yaml)
puts mac2.environment # => "stage"
puts mac2.position.class # => Fixnum
require 'storable'
class Calc < Storable
field :three
field :two
field :one
sensitive_fields :three
end
calc = Calc.new 3, 2, 1
calc.to_a # => [3, 2, 1]
calc.sensitive!
calc.to_a # => [2, 1]
Storable can also marshal Proc objects to and from their actual source code.
require 'storable'
class Maths < Storable
field :x => Float
field :y => Float
field :calculate => Proc
end
m1 = Maths.new 2.0, 3.0
m1.calculate = Proc.new { @x * @y }
m1.calculate.source # => "{ @x * @y }"
m1.call :calculate # => 6.0
dump = m1.to_json
m2 = Maths.from_json dump
m2.call :calculate # => 6.0
Anything is possible when you keep your mind open and you use Ruby.
Via Rubygems, one of:
$ sudo gem install storable
$ sudo gem install delano-storable --source http://gems.github.com/
or via download:
See: storable.gemspec
FAQs
Unknown package
We found that storable 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
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
Security News
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.