ruby

  • Ruby Curses getch in cbreak mode doesn't handle Ctrl+C automatically on Windows 2017-08-30

    In cbreak mode terminal should handle some control characters automatically, but it does not: require 'curses' Curses.init_screen() Curses.cbreak() loop { Curses.getch() } On GNU/Linux Ctrl+C interrupts the program. On Windows Ctrl+C just prints ^C a

    Tags: ruby, windows, curses
  • Trying to install ruby on rails on windows for three days now 2017-08-04

    This is how it goes: 1) I go to rubyinstaller.org everything is good here 2) I download the installer and devkit everything is good here 3) I install both in that order then run command to link to devkit to ruby. everything is good here 4) I create a

    Tags: ruby, sqlite3, ruby on rails 3
  • Improving algorithm execution time and prime numbers 2017-08-02

    I am trying to find the largest prime value of a big number, but it takes far too long. For example, to find the largest prime of 999999999, it takes about 55 seconds. How can I improve this? require 'prime' def highestprime num i = 1 counter = 0 cou

    Tags: ruby, algorithm, primes
  • Modularizing Test Script in Ruby(MiniTest Framework ) 2017-06-04

    Working script File name : test_data.rb" class TotalSample < MiniTest::Test @name = 'Arg1' @period = 'Arg2' @usage = 'Arg3' @siteName = Site.new(@name) test1_activedata = @siteName.getActiveData(@period) test1_sample = test1_activedata["sampl

    Tags: ruby, junit, minitest
  • Ruby: variable acting as nul when set to integer 2016-09-28

    After a good 10 minutes of trying to come up with a more informative title, I ran out of ideas. I have 2 prolems. The first is that whenever I try to input a position for pos_in, it registers as nul when run through the case statement that determines

    Tags: ruby, variables
  • RSpec thinks created file is empty 2016-09-21

    I've created a class that creates a new text file. When I try to compare it with an existing file it seems that RSpec thinks the created file is empty. expect(open @expected).to eq(open @result) The result: (compared using ==) Diff: @@ -1,2 +1,2 @@ -

    Tags: ruby, rspec
  • Travis CI is faling to run tests with **/*_test.rb pattern 2016-09-09

    My micro Ruby project tests works on my machine, on private VM, but fails on Travis CI bulid Project uses both rspec (+rspec-given) and minitest Full trace here: https://travis-ci.org/equivalent/code_katas/jobs/61321482 $ bundle exec rake MiniTest::U

    Tags:
  • Chris Pine Ch. 6 Deaf Grandma 2016-08-16

    I am following Chris Pine tutorial. In one of the exercises I have to write to "Grandma" BYE three times in a row to shut the program. But my program can shut even if I don't type "bye" three times in a row. Why? puts "Do you need

    Tags: ruby
  • if page has selector - Capybara 2016-08-02

    Im trying to implement a simple piece of logic that says if element exists on page do something The issue I am facing is that if the element doesnt exist then the find method provided returns an exception and will fail my test. (Capybara::ElementNotF

    Tags: ruby, rspec, capybara
  • How to stub whole module using Mocha? 2016-06-27

    I have a complex module used in my implementation with some functions in it. module A def function some_params #returns some chain object end end #implementation class SomeImplementation def some_function some_params A.function(some_params_other).fun

    Tags: unit testing, ruby
  • Chef conditional resource argument 2016-06-07

    I'm creating a user via Chef. His properties are stored in data bag: { "id": "developer", "home": "/home/developer", "shell": "/bin/zsh", "password": "s3cr3t" } The recipe is:

    Tags: ruby, chef, chef recipe
  • How to get option values from second select list?

    How to get option values from second select list? 2016-05-27

    I have a problem with Mechanize/Ruby. I can't get the second select list options when I am selecting the first ones. If I understood correctly from Google, there are some Ajax magic there. At the moment I have something like this: require 'rubygems'

    Tags: ruby, mechanize, web scraping
  • Ruby - Active Record Query - Comparing Variables Producing False Positive 2016-05-02

    Be warned this a newbie question as its first time using active recored and oracle db.Trying to get my head around active record returned values and its comparison operators. To summarise I want to get a offer id and then compare to the offer value s

    Tags: ruby, database, activerecord, watir webdriver
  • Gem Charlock_holmes installation error on Windows 7 2016-04-15

    I am using Ruby DevKit to install and build gems. A 3rd party tool requires the charlock_holmes gem. I get this error: C:\usr\dsc_test\environments\production\modules\dsc>bundle install Fetching https://github.com/msutter/librarian-repo.git Fetching

    Tags: ruby, gem, icu, windows 7 x64
  • Ruby short Socket.gethostname in RHEL6 2016-04-11

    in RHEL5, the default Ruby's Socket::gethostname returns short hostname without domain name. In RHEL6 it returns the hostname including the domain name. This is caused by different system hostname functionality in RHEL6 which can be fixed in SH scrip

    Tags: ruby, hostname, rhel6
  • aggregate values from specific key in an array of hashes 2016-03-25

    I'm trying to build an array of values that come from an array of hashes, at the moment my code looks like this: ids = array_of_hashes.inject([]) do |result,instance| result << instance[:id] result end I just want to know if there's a more efficient

    Tags: ruby
  • How to save a hash to a Sequel DB? 2016-02-26

    In my seed directory I have two files: a seed.rb and a file.csv. I parsed and cleaned up the CSV file. Then I selected the information I wanted (lines 1, 2, 3, etc) and put that into a hash: require 'csv' data = {} CSV.foreach("file.csv") do |li

    Tags: ruby, database, csv, hash, sequel
  • Error installing Ruby 2.2.2 with RVM on Ubuntu 14.04 2016-02-24

    Here's what. I first did: rvm get stable rvm install ruby-2.2.2 No deal. It shows me the following: $ rvm install ruby-2.2.2 Searching for binary rubies, this might take some time. No binary rubies available for: ubuntu/14.04/i386/ruby-2.2.2. Continu

    Tags: ruby, rvm, ubuntu 14.04, ruby 2.2
  • Getting undefined local variable or method error using Rails 3 2016-02-19

    Hi i am getting the following error when trying to render a table using Rails 3. Error: ActionView::Template::Error (undefined local variable or method `result' for #<# <Class:0x3460410>:0x2af4d10>): I am explaining my code snippets below. pay

    Tags: ruby, ruby on rails 3.2
  • ruby: Using local variable in methods 2016-02-03

    I have a local variable in my main program. Now i would llike to give it to a method so it can use it for it's work. What is the best way to do it? A Instance variable @test? --------------Solutions------------- You can give that variable as a method

    Tags: ruby, methods, variables

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.343 (s). 7 q(s)