19 June 2013

The Ruby Reflector

Topic

String

  Source Favicon
On James on Software 2 months ago.
Email

But Ruby is dynamic, so those caches can't necessarily live forever. If we call String#gsub , for example, and then undef it without expiring the method cache, it'll still be reachable. Cache invalidation is hard, as we know, so MRI takes a somewhat brute force approach.

How MRI's Method Caches Work

Currently, MRI has two types of method caches. Ruby code is compiled down to MRI's instructions . Each instruction has some data associated with it. The send …

jamesgolick.com Read
  Source Favicon
By wycats of Katz Got Your Tongue? almost 2 years ago.
Email

…reason for unspecified behaviors is a failure to specify Ruby's coercion protocol, so String#+ is unspecified if the other is not a String, even though all Ruby implementations will call to_str on the other to attempt to coerce it. The coercion protocol has been underspecified for a long time, and it's understandable that the group punted on it, but because it is heavily relied on by real-life code, it is important that we actually describe the behavior.

This week, I am in …

yehudakatz.com Read
  Source Favicon
Email

…the program.

These ruby_eval commands will output into the tempfile that redirect_stdout created, so you'll need to tail -f that file in a different console. Now, with that small headache over with, you can see exactly where your program is and if there is a stupid loop where you forgot to check a boundary condition, or what thing you're doing with a regular expression on where you should have just used String#index .

Written by Jon Yurek .

robots.thoughtbot.com Read
  Source Favicon
By Mike Gunderloy of A Fresh Cup 3 months ago.
Email

Upgrade to Rails 4 - An ebook from Philip De Smedt covering what you'll need to change on the way from Rails 3.

sidr - jQuery plugin for developing responsive side menus.

Awesome Print for RubyMotion - Dump RubyMotion objects in a pretty format.

fast_blank - String#blank reimplemented in C for speed.

afreshcup.com Read
  Source Favicon
By Charles Nutter of Headius 5 months ago.
Email

…variable that starts with a capital letter. Class and module names like Object, Kernel, String, are all constants defined under the Object class. When I say constants are both lexical and hierarchically accessed, what I mean is that at access time we first search outward through lexically-enclosing scopes, and failing that we search through the class hierarchy of the innermost scope. For example:

Here, the first two constant accesses inside class B are successful; the first ( IN FOO) is located …

blog.headius.com Read
  Source Favicon
By Peter Cooper of Ruby Inside 7 months ago.
Email

…suggested checking $; (it's a special global variable that defines the default separator for String#split ). It was OK.

In an attempt to look smarter than I am, I suggested reply.method(:split).source_location to see if the String class had been monkey-patched by something annoying. Nope. (Though this is a handy trick if you do want to detect if anyone's tampered with something.)

Someone suggested Mr. Ysr23 show us reply.codepoints.to_a : # reply.codepoints.to_a …

rubyinside.com Read
  Source Favicon
By Charles Nutter of Headius 7 months ago.
Email

The "refine" method takes a class or module (the String class, in this case) and a block. Within the block, methods defined (camelize) are added to what might be called a patch set (a la monkey-patching) that can be applied to specific scopes in the future. The methods are not actually added to the refined class ( String) except in a "virtual" sense when a body of code activates the refinement via the "using" method.

The "using" method takes a refinement-containing …

blog.headius.com Read
  Source Favicon
By James Mead of Blog - James Mead 7 months ago.
Email

…for issue #101 - Mock#respond_to? doesn't work with a String argument - thanks to @ urbanautomaton .

Fix for issue #105 - Travis CI link in the README - thanks to @ cknadler .

Various improvements to automated testing of integration with test libraries.

Make deprecation warnings more prominent.

blog.floehopper.org Read
  Source Favicon
On Ruby News 7 months ago.
Email

…collide their hash values each other . This fix changes the Hash function of String object from the MurmurHash to SipHash 2-4 .

Solution

Please update to ruby-1.9.3 patchlevel 327 if you are using ruby 1.9 versions. Please update to trunk revision 37575 or later if you are using ruby 2.0.0 preview1 or ruby trunk. In addition to it, all ruby applications that accept input data from untrusted entity for parsing should restrict the size of the input data to reasonable …

ruby-lang.org Read
  Source Favicon
On Ruby News 8 months ago.
Email

OSes and other libraries tend not. They usually treat a NUL as an End of String mark. So to interface them with Ruby, NUL chars should properly be avoided.

However methods like IO#open did not check the filename passed to them, and just passed those strings to lower layer routines. This led to create unintentional files like this: p File.exists?("foo") #=> false open("foo\0bar", "w") { |f| f.puts "hai" } p File.exists?("foo") …

ruby-lang.org Read