Where is Rubinius' Actor API? - actor

I got the following output from pry when trying out the example from http://rubini.us/doc/en/systems/concurrency/ with Rubinius 2.2.9:
2.1.0 (main):0 > RUBY_VERSION
=> "2.1.0"
2.1.0 (main):0 > RUBY_PATCHLEVEL
=> 0
2.1.0 (main):0 > RUBY_PLATFORM
=> "x86_64-darwin13.2.0"
2.1.0 (main):0 > RUBY_ENGINE
=> "rbx"
2.1.0 (main):0 > require 'actor'
LoadError: no such file to load -- actor
from kernel/common/code_loader.rb:441:in `load_error'
Is the documentation outdated?

It looks like the documentation is slightly outdated.
Commit 79bd4c30 appears to remove the Actor api from the Rubinius standard library and extract it into the rubinius-actor gem. As far as I can tell with a quick glance, it's the exact same API as the documentation describes.

Related

ruby OCI8 slow initialization

I'm developing API for product based on Oracle database and I tried to use ruby-oci8 gem, but I faced a strange problem - OCI8.new is very slow, it takes 1,2-1,5 second to connect to database.
For example:
~ mmulev$ irb
2.1.1 :001 > require 'oci8'
=> true
2.1.1 :002 > def test
2.1.1 :003?> t0 = Time.now
2.1.1 :004?> OCI8.new('SCHEMA', 'STRONG_PASS', '//db_host:port/service_name')
2.1.1 :005?> Time.now - t0
2.1.1 :006?> end
=> :test
2.1.1 :007 > test
=> 1.217809
2.1.1 :008 >
The same thing in php (oci_new_connect) needs approximately 0,1-0,2 second to establish connection and return handler.
Is there any other solutions besides connection pooling?
P.S. ruby API code was profiled by method_profiler and by Benchmark, oracle v - 11g
You can also use this gem to connect to oracle
https://github.com/rsim/oracle-enhanced
Make sure that you have installed oracle properly you can install this by following link : How to install ruby-oci8?

Ruby Fog gem usage

I'm mucking about with the Fog gem and have figured out how to get started:
1.9.3-p545 :008 > c = Fog::Compute::Ecloud.new({
1.9.3-p545 :009 > :base_path => '/cloudapi/spec',
1.9.3-p545 :010 > ecloud_authentication_method: 'basic_auth',
1.9.3-p545 :011 > ecloud_username: 'user#terremark.com',
1.9.3-p545 :012 > ecloud_password: 'password'
1.9.3-p545 :013?> })
[fog][WARNING] Unrecognized arguments: base_path
=> #<Fog::Compute::Ecloud::Real:25681720 #base_path="/cloudapi/spec" #connections={} #connection_options={} #host="https://services.enterprisecloud.terremark.com" #persistent=false #version="2013-06-01" #authentication_method=:basic_auth #access_key=nil #private_key=nil #username="user#terremark.com" #password="password">
I don't know what to do after this, though. How do I get the object to do anything useful? I'm new to Ruby so a lot of the code in the Fog Ecloud source doesn't make sense to me.
I've tried using different methods, but each tends to result in an error.
Can someone provide an example and explanation indicating where I need to go from here?
It looks like you have found a bug!
Fog is giving you this error because base_url is not present in the recognizes line.
I went ahead and fixed it for you. If you are using bundler you can use the latest master by updating your Gemfile to include the following
gem 'fog', :git => 'https://github.com/fog/fog.git'
Or alternatively you can just patch it in your code by executing the following code prior to using fog
require 'fog'
module Fog
module Compute
class Ecloud < Fog::Service
recognizes :ecloud_username, :ecloud_password, :ecloud_version,
:ecloud_access_key, :ecloud_private_key,
:ecloud_authentication_method, :base_path
end
end
end
For information about how to use fog, I would recommend reading the following page.

require "soap/wsdlDriver" can't load with soap4r gem

I am using ruby version 2.0.0, and Using soap4r (1.5.8).
But i couldn't able to load require "soap/wsdlDriver".
I am trying to use with in rails console,
irb(main):001:0> require 'soap/rpc/driver'
=> false
irb(main):002:0> require 'soap/rpc/driver'
=> false
irb(main):003:0> require "soap/wsdlDriver"
=> false
The standard soap library was removed from Ruby. You will need to find an other solution. Perhaps this gem: https://rubygems.org/gems/soap4r-ruby1.9
Or you refactor you code to use a more up-to-date client. Find a list here: https://www.ruby-toolbox.com/categories/soap

Ruby 1.8 BigDecimal

I remember the words said by Matz: Ruby 1.8 will be dead soon. But I have no option. Here, I am using Ruby 1.8.7. Big Decimal is behaving differently compare to later version of Ruby.
For example:
ree-1.8.7-2011.12 :001 > require 'bigdecimal'
=> true
ree-1.8.7-2011.12 :002 > b=BigDecimal('0.0')
=> #<BigDecimal:9ce7148,'0.0',4(8)>
ree-1.8.7-2011.12 :003 > b
=> #<BigDecimal:9ce7148,'0.0',4(8)>
ree-1.8.7-2011.12 :004 > b==0
=> true
ree-1.8.7-2011.12 :005 > [b,b,0,0].uniq
=> [#<BigDecimal:9ce7148,'0.0',4(8)>, #<BigDecimal:9ce7148,'0.0',4(8)>] #Integer 0 is removed
ree-1.8.7-2011.12 :008 > [b,b,0,0].uniq.uniq
=> [#<BigDecimal:9ce7148,'0.0',4(8)>] #Applying two times uniq gives desired result for given array
Is there any patch to fix this issue? Sorry I don't have option to upgrade Ruby. Any help?
Thank you.
You might try https://github.com/marcandre/backports, which claims to provide "The latest features of Ruby backported to older versions". I didn't see anything in there regarding BigDecimal, at a glance, but who knows what it might be using internally. I've used it before for arrays, it's at least worth a shot.

How does require rubygems help find rubygem files?

While trying to solve Gem found in irb, not in Ruby , I tried seeing what effect require 'rubygems' had on my own installation:
$ irb
irb(main):001:0> RUBY_VERSION
=> "1.8.7"
irb(main):002:0> $:
["/usr/local/lib/site_ruby/1.8", "/usr/local/lib/site_ruby/1.8/x86_64-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/vendor_ruby/1.8", "/usr/lib/ruby/vendor_ruby/1.8/x86_64-linux", "/usr/lib/ruby/vendor_ruby", "/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/x86_64-linux", "."]
=> nil
irb(main):003:0> require "rubygems" # Hasn't been required already
=> true
irb(main):004:0> require "rubygems" # Will return false, because it's already been required
=> false
irb(main):005:0> $: # Same as before
=> ["/usr/local/lib/site_ruby/1.8", "/usr/local/lib/site_ruby/1.8/x86_64-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/vendor_ruby/1.8", "/usr/lib/ruby/vendor_ruby/1.8/x86_64-linux", "/usr/lib/ruby/vendor_ruby", "/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/x86_64-linux", "."]
If requring rubygems doesn't modify $:, then how does it help find files? Does it monkeypatch require? If so, what variable does it use to find rubygem-installed libraries?
Here's the current version of the relevant source: https://github.com/rubygems/rubygems/blob/02ead548e38ff90923444fa7c0ff9f6a5dbd87b0/lib/rubygems/custom_require.rb. (Edit: here's an earlier version (1.5.2) that more clearly expresses what happens.)
The docs say:
When RubyGems is required, Kernel#require is replaced with our own which
is capable of loading gems on demand.
When you call require 'x', this is what happens:
If the file can be loaded from the existing Ruby loadpath, it
is.
Otherwise, installed gems are searched for a file that matches.
If it's found in gem 'y', that gem is activated (added to the
loadpath).
The normal require functionality of returning false if
that file has already been loaded is preserved.
It does this by opening up module Kernel and aliasing the original require with alias gem_original_require require, then redefining require to first call the original version, and look at the gems if that doesn't work.
So the load path is only changed when you require a gem:
ruby-1.8.7-p330 :002 > $:.length
=> 9
ruby-1.8.7-p330 :003 > require 'rubygems'
=> true
ruby-1.8.7-p330 :004 > $:.length
=> 9
ruby-1.8.7-p330 :005 > require 'haml'
=> true
ruby-1.8.7-p330 :006 > $:.length
=> 10

Resources