In Linux, it is very easy "just" to add executable to a file, simply by input:
chmod +x
However, I have failed to find something as easy in the gems of Ruby. Of course, one could do a system call, i.e.
system( 'chmod +x' << fname…
In my Rails 3 app, I am fetching path_info by:
Rails.application.routes.recognize_path(url, { :method => request.request_method }) rescue {}
If a crawler hits a URL like "http://localhost:3000/admin_", the above code raises following…
Why would a unicode encoding get lost when sending it to an ODBC-interface via the dbi-gem?
We wrote an sinatra-application that connects via DBI to an SAP HANA database. The latter shouldn't matter as I can manually execute Statements with UTF8…
I have problem with using rspec-mocks.
bundle list shows:
Gems included by the bundle:
* CFPropertyList (2.2.8)
* builder (3.2.2)
* bundler (1.7.12)
* ci_reporter (1.9.3)
* diff-lcs (1.2.5)
* excon (0.44.0)
* facter (2.4.0)
* hiera…
I have a big hash with lots of nested key value pairs.
Eg.
h = {"foo" => {"bar" => {"hello" => {"world" => "result" } } } }
Now I want to access result and I have keys for that in array in proper sequence.
keys_arr = ["foo", "bar", "hello",…
I have certain classes that are implemented as decorators in my Rails app which is on Ruby 1.8.7 . I keep getting the warning - warning: already initialized constant ABC . Here ABC is the name of the constant.
To solve this, I'm using the…
When I try to install cucumber 0.93 this error is triggered.
I need to install this specific version.
trabajo@fernando-Inspiron-1545:~/cucumber-rspec$ gem install cucumber -v 0.9.3
Building native extensions. This could take a while...
ERROR: …
Im trying to implement google youtube api in my ruby on rails project as stated in youtube documentation https://developers.google.com/youtube/v3/code_samples/ruby#retrieve_my_uploads so this block of code
require 'google/api_client'
I get the…
I have a bit of code for escaping double-quotes from a string which may include pre-escaped quotes; e.g:
This is a \"string"
Using the following code with Ruby 1.8.7p374:
string.gsub!(/([^\\])"/, '\1\"')
However, I get some funny edge-case when…
Using Ruby 1.8.7, is there built-in functionality similar to Array.map which allows for the return of multiple values instead of just one? E.g. I have an array and each element contains an array - I want to end up with all values from the inner…
I know how select, collect and map work in Ruby. I was just wondering if there is a similar native Ruby method that can combine them & give results in a single iteration without having the need to remove nil from array?
For ex.
(1..10).map { |x| x*3…
I have the following method in our Ruby 1.8.7 project:
def self.ping_server
request_data = get_request_data
uri = 'another_server.our_company.com'
https = Net::HTTP.new(uri)
https.use_ssl = true
path = "/our_service"
data =…
Since I'm dealing quite a lot with durations in my Rails app, I would also like to use them as hash keys in some places. However, it does not seem to work as expected for me.
Creating the initial hash works fine. For example, the following will…
I have a regex that is used for matching unicode string and works pretty cool with all versions of Ruby newer than 1.8.7:
/[\p{L}\p{Space}]+/u
How it can be achieved with Ruby 1.8.7?
Here's the relevant part of my gemspec:
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 2.13.0"
spec.add_dependency "addressable"
spec.add_dependency…