Questions about Ruby, dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features.
2
votes
1answer
40 views
Is a guardfile part of the private developers environment or the public OSS project?
Let us say I have an open source project on github. Now I wish to include tools required to develop the project so others can easily contribute. It is hard for me to tell when these tools should be ...
1
vote
1answer
40 views
Create a collection with “average points” of N items from a pool with items of various points
Let's say I have a question pool to generate exams out of it. Each question contains a difficulty from 1 (hard) to 99 (easy). The questions are available in a hash / array (adapt to your favorite ...
0
votes
1answer
26 views
How do rails project know about rake tasks from other repositories
We have a rake task called db:sanity_check which exists in a 'core' repo.
Other repositories that we have also show this rake task.
But they do not define the rake task. It 'comes' from core'
How ...
0
votes
1answer
60 views
Should I use expect or should when writing RSpec specs? [closed]
Please can someone explain to me how I should go about deciding whether to use expect or should syntax for my rspec examples.
From my understanding we should no longer be using the 'should' syntax.
...
-1
votes
1answer
97 views
Unevenly distributed random number generation [duplicate]
Let's say I have to generate random number from 1 to 100, however, the probability of each number is not 1/100, but a predefined probability.
How to generate that number? I use Ruby/Python.
0
votes
1answer
51 views
Calculate which quantity packages to use based on quantity of bookings
In my app, many appointments can be booked for activities. Each activity has many price packages with a price and a quantity.
On showing the cart, I need to work out what combination of packages ...
0
votes
1answer
28 views
Ruby on Rails application interfacing with a Datamax barcode printer [closed]
I am trying to find a standalone way to interface with a Datamax M-Class Mark2 label printer through a Ruby on Rails application. I currently have a solution that is working, which i use javascript to ...
0
votes
0answers
60 views
Splitting up a Rails/Ruby app onto multiple servers
We recently moved a large application to two machines, both running the same codebase.
I. Machine A
Web server for public facing application
Receives web hook call backs from our ESP
Handles a ...
0
votes
0answers
66 views
Run RSpec from within a ruby script while refreshing all ruby configs etc
I'm working with a very large project with tons of established tests that include some reasonably complicated environment setups and what not. I've recently run into a situation testing some ...
4
votes
1answer
247 views
Why don't Python and Ruby make a distinction between declaring and assigning a value to variables?
Two of the most popular dynamically typed scripting languages, Python and Ruby, do not make a distinction in syntax between the declaration of a variable and assignation of a value to it.
That is in ...
22
votes
2answers
1k views
Do modern languages still use parser generators?
I was researching about the gcc compiler suite on wikipedia here, when this came up:
GCC started out using LALR parsers generated with Bison, but gradually switched to hand-written ...
0
votes
1answer
85 views
Refactoring a Single Rails Model with large methods & long join queries trying to do everything
I have a working Ruby on Rails Model that I suspect is inefficient, hard to maintain, and full of unnecessary SQL join queries. I want to optimize and refactor this Model (Quiz.rb) to comply with ...
2
votes
2answers
99 views
What kind of exception to ask for out of range arguments?
What type of exception should I throw?
I have a console class which describes rectangle of cells which a user can index by passing in a coordinate:
width, height = 80, 25
console = ...
0
votes
1answer
121 views
How can I rank teams based off of head to head wins/losses
I'm trying to write an algorithm (specifically in Ruby) that will rank teams based on their record against each other. If a team A and team B have won the same amount of games against each other, then ...
0
votes
1answer
67 views
Android -> Ruby Server Interface -> Mongodb
I've been wrecking my brain about this for a few days. I'll run my scenario by you and hopefully you can help me. In my head this is how it goes:
I have an Android App.
I want my Android App to make ...
0
votes
2answers
707 views
Why doesn't Ruby have implicit conversion of Fixnum into String?
Ruby normally makes things easy. However, it doesn't allow implicitely converting a number to a string:
2.0.0p247 :010 > "a"+1
TypeError: no implicit conversion of Fixnum into String
Why is this ...
0
votes
0answers
17 views
Is Resque appropriate for an evented application?
As the title says, is Resque appropriate for an evented application that requires a decent amount of speed? I'm working on a server application that emulates the default Minecraft server, and I was ...
3
votes
1answer
82 views
What does it mean that file IO binary flag is only relevant on Windows
I was reading a question and one of the comments mentioned that "The binary flag is only relevant on Windows". Given the context of the question and answer, I interpret this statement as on ...
0
votes
2answers
222 views
What happened to VM based deployments?
Watched some MountainWest RubyConf 2014 talks and noticed an interesting theme. Many dynamic programming environments back in the old days used to be self-contained VM images, e.g. SmallTalk, ...
0
votes
0answers
86 views
Ruby on Rails Development: updating model attribute using f.association collection
Im currently working on a rails program. It contains many different databases but to keep things simple I have a people, student, and faculty table.
A person can be a student or faculty member and ...
-3
votes
1answer
173 views
Is there a purely technical term for 'monkey patching' [closed]
EDIT The original title of the question was Is there a non-derogatory term for 'monkey patching'. As I have learned that the term is actually not derogatory, or is at least not meant to be, I changed ...
0
votes
1answer
138 views
JSON - Ruby objects key naming
Ruby object has method/property:
def tentakles_count
8
end
JavaScript object has key/property:
{ justEnough: true }
Now, when JavaScript gets serialised ruby object via XHR or WebSocket, ...
0
votes
0answers
65 views
Ruby on Rails - branding
I am working on a website, which is to have multiple brands. The core functionality for all brands will be the same, however there will be a number of differences between them. Those differences may ...
1
vote
2answers
228 views
Need advice on design in Ruby On Rails
For personal educational purposes I am making a site for a conference. One of the object that exist in a conference is a session, which has different states and in each state it has slightly different ...
1
vote
1answer
156 views
Why many Ruby gems won't work on Windows [duplicate]
Most of the gems out there work fine on *nix but not on Windows. First I tried WySQL2, then dosu which shows incompatibility with Ruby 2.0. I tried things on github issues, but no luck.
I never had ...
2
votes
2answers
113 views
How to check robustness in a service that includes multiple points of failure in workflow, including FTP
As part of my workflow, I need to do all these steps in one transaction
- I need to ftp files to 2 different FTP servers.
- There is also a spreadsheet that gets generated which needs to be FTP'ed. ...
2
votes
4answers
255 views
Test Doubles, Mocks and Stubs - when not to use & why, for Ruby, Rspec
I've learned about mocking and stubbing and I've seen how they can help me create great test suites that run blindingly fast and thus speed up my development process hugely.
However I've also seen ...
-2
votes
1answer
3k views
Advantages and disadvantages of PHP/Ruby [closed]
I've been a front-end developer for about two years now, and I'm attempting to break into the server side of things. Ideally I'd like to work for a startup social network on the back-end side so I ...
1
vote
2answers
64 views
Auxiliary space complexity of map vs map!
I'm curious about the difference in space complexity between map and map! in ruby.
If I have the methods:
def mult_by_two(arr)
arr.map {|i| i * 2 }
end
def mult_by_two!(arr)
arr.map! {|i| i * 2 ...
32
votes
11answers
4k views
Is it okay to make coding style changes on an open source project that doesn't follow best practices?
Recently, I came across a number of open source Ruby (or majority of it was Ruby) projects on GitHub that when checked with a code analyzing tool like Rubocop, create a lot of offenses.
Now, most of ...
2
votes
1answer
67 views
scoping concern when dealing with coupling
I'm learning ruby (and OOP in the process) and I find keep having to write the same patterns when logging progress so I want to wrap this up in a logging library that my other code can then just pass ...
0
votes
6answers
266 views
How do I explain a ruby method with a real-world analogy? [closed]
I am looking for a good analogy to help the concept of a method in ruby stick in my head. When I truly understand a concept, an image flashes in my mind that relates something physical to the abstract ...
0
votes
0answers
423 views
Ruby module namespacing advice
in my current project have:
module Stats
class Site
...
end
class Product
def initialize(product_id)
@product_id = product_id
end
end
class Profile
...
end
end
...
1
vote
1answer
184 views
Dealing with 'dirty' Ruby on Rails client
I had to leave a startup about a month ago because of lack of funding. Basically, this client wanted an application to allow contractors to create, update, read, and delete yardsigns. Straight forward ...
1
vote
2answers
117 views
In Ruby, change global in thread safe block
In Ruby, I have a use case for a few common configuration options, e.g. NOOP, TRACE, SILENT. Right now I am using local vars instead of globals and passing them around all over the place and it's a ...
0
votes
1answer
414 views
ruby for desktop app or web app development [closed]
i am a beginner to ruby . i just did some
minor research about why RUBY ? why choose RUBY ? whats new in it.
Whenever i do type in a word RUBY in google search there comes a
suggestion like RUBY on ...
18
votes
3answers
1k views
Why do so many languages treat numbers starting with 0 as octal?
I've read Where are octals useful? and it seems like octals are something that were once upon a time useful.
Many languages treat numbers preceding with a 0 as octal, so the literal 010 is actually ...
2
votes
1answer
125 views
How to create html pages which don't change very much and not very often?
I have a Rails server that connects to a json API on another server to get data to build the pages dynamically. These pages, however, don't change very much and not very often.
I was thinking I could ...
1
vote
0answers
29 views
Should I refactor a F class from code climate? [duplicate]
According to code climate, a class is F, aka the worst mark you could be granted.
I did submit a pull request to rearrange it here
Which has been refused because the new code is supposedly too ...
1
vote
1answer
85 views
Should I use the new method/action to retrieve records? (Rails)
I have an admin controller that is just used for its index action which renders a view with the most recent updates to certain resources:
class AdminController < ApplicationController
...
-1
votes
2answers
173 views
Programming beginner: Options for small program interfaces? [closed]
I have been a Rails developer for a year now, and I really want to start diving in to Ruby and pure programming without using a framework. However I am having trouble conceptualizing little programs I ...
2
votes
3answers
175 views
Is there a reason for the crossover from the Ruby community to the Clojure Community?
When we look at the the overlap between the Ruby Community - we see the following overlaps:
Think Relevance (now Cognitect) has switched from Ruby to Clojure
Jay Fields has switched from Ruby to ...
0
votes
2answers
231 views
help me understand Rails and attributes as class methods
This is from the Hartl Rails tutorial. We are automatically logging in a user in the process of creating that user with a callback to #create_remember_token. It works great but there are some things, ...
4
votes
2answers
319 views
Is using static-typing the solution to domain-driven design and decreasing the number of errors?
We are using PHP (a dynamically-typed language) in our project. However, I have found my colleagues asking questions such as ...
1
vote
3answers
232 views
How do I set up pairing email addresses?
Our team uses the Ruby gem hitch to manage pairing. You set it up with a group email address (e.g. [email protected]) and then tell it who is pairing:
$ hitch james tiffany
Hitch then sets your Git ...
2
votes
1answer
414 views
Is there a representation for mixins or traits on UML?
Is there a representation for modern programming constructs that are becoming common in modern OOP/hybrid languages like mixins/traits/categories/partial classes ?
0
votes
1answer
142 views
Refactoring this code that produces a reverse-lookup hash from another hash
This code is based on the idea of a Form Object
http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
(see #3 if unfamiliar with the concept).
My actual code in ...
1
vote
1answer
210 views
How to build an API on top of an existing Rails app with NodeJs and what architecture to use? [closed]
The explanation
I was recently hired by a company that has an old RoR 2.3 application with more than 100k users, a strong SEO strategy with more than 170k indexed urls, native android and ios ...
1
vote
1answer
96 views
Inherit one instance variable from the global scope
I'm using Curses to create a command line GUI with Ruby. Everything's going well, but I have hit a slight snag. I don't think Curses knowledge (esoteric to be fair) is required to answer this ...
2
votes
2answers
2k views
Ruby - when to use instance variables vs parameters between methods?
I'm writing several methods that call other methods.
To pass the information I have a couple of choices:
Pass the information as parameters
Set instance variables so that other methods can access ...