Ruby

Searchlight - Searching gem that minimizes magic. Comes with ActiveRecord integration module. Open Source Report Card - Analyze a GitHub user's activity for interesting patterns. Fargo - Online outliner that stores its files in your Dr...
Searchlight - Searching gem that minimizes magic. Comes with ActiveRecord integration module. Open Source Report Card - Analyze a GitHub user's activity for interesting patterns. Fargo - Online outliner that stores its files in your Dropbox.
43 minutes ago
Here's another shoulda backport I added recently. If you're still stuck using a legacy Rails system, this backport will let you use "in_array" in the "ensures_inclusion_of" Matcher. Save it into something like: config/initializers/sho...
Here's another shoulda backport I added recently. If you're still stuck using a legacy Rails system, this backport will let you use "in_array" in the "ensures_inclusion_of" Matcher. Save it into something like: config/initializers/shoulda_monkeypatches.rb, then use it like this: should ensure_inclusion_of(:widget_status).in_array(Widget::VALID_STATUSES).allow_blank.with_message(:is_invalid).use_integer_test_value # backport the "in_array" method for the ensure_inclusion_of matcher # While we're at it, add allow_blank and allow_nil too module Shoulda # :nodoc: module ActiveRecord # :nodoc: module Matchers class EnsureInclusionOfMatcher ARBITRARY_OUTSIDE_STRING = 'shouldamatchersteststring' ARBITRARY_OUTSIDE_INT = -999999999 # to initialize the options def initialize(attribute) super(attribute) @options = {} end # add the method we want to allow us to pass in arrays instead of # just ranges def in_array(array) @array = array self end # might as well also add the allow_blank and allow_nil methods too def allow_blank(allow_blank = true) @options[:allow_blank] = allow_blank self end def allow_nil(allow_nil = true) @options[:allow_nil] = allow_nil self end # This is a method of my own addition to point out that the # test-value must be an Int, not a String... because a string can # evaluate to 0 which is a valid Int... which will make the test # pass where it shouldn't :P def use_integer_test_value(only_integer = true) @options[:use_integer_test_value] = only_integer self end # override description so it doesn't just try to inspect the range def description "ensure inclusion of #{@attribute} in #{inspect_message}" end # override the matches method to allow arrays as well as ranges def matches?(subject) super(subject) if @range @low_message ||= :inclusion @high_message ||= :inclusion disallows_lower_value && allows_minimum_value && disallows_higher_value && allows_maximum_value elsif @array if allows_all_values_in_array? && allows_blank_value? && allows_nil_value? && disallows_value_outside_of_array? true else @failure_message_for_should = "#{@array} doesn't match array in validation" false end end end private # provide the message-inspect method to use either array or range def inspect_message @range.nil? ? @array.inspect : @range.inspect end # array helper methods def allows_all_values_in_array? @array.all? do |value| allows_value_of(value, @low_message) end end def disallows_value_outside_of_array? disallows_value_of(value_outside_of_array) end def value_outside_of_array test_val = @options[:use_integer_test_value] ? ARBITRARY_OUTSIDE_INT : ARBITRARY_OUTSIDE_STRING if @array.include?(test_val) raise CouldNotDetermineValueOutsideOfArray else test_val end end # blank and nil helper methods def allows_blank_value? if @options.key?(:allow_blank) blank_values = ['', ' ', "\n", "\r", "\t", "\f"] @options[:allow_blank] == blank_values.all? { |value|
about 4 hours ago
Send to Kindle Programming the Web with Ruby Registrations are now open for RubyLearning’s “Pay if you like”, online course on “Programming the Web with Ruby“. The first batch had over 2000 participants. We...
Send to Kindle Programming the Web with Ruby Registrations are now open for RubyLearning’s “Pay if you like”, online course on “Programming the Web with Ruby“. The first batch had over 2000 participants. Web-based applications offer many advantages, such as instant access, automatic upgrades, and opportunities for collaboration on a massive scale. However, creating Web applications requires different approaches than traditional applications and involves the integration of numerous technologies. The course topics would hopefully help those that have some knowledge of Ruby programming to get started with web programming (this does not cover Ruby on Rails). Who’s It For? Anyone with some knowledge of Ruby programming. Dates The course starts on Saturday, 29th June 2013 and runs for 2 weeks. Is the course really free? A lot of effort and time goes into building such a course and we would really love that you pay at least US$ 15 for the course. Since this is a “Pay if you Like” course, you are under no obligation to pay and hence the course would be free for you. For those who contribute US$ 15, we shall email them a copy of the book (.pdf) “Programming the Web with Ruby” – the course is based on this book. How do I register and pay the course fees? First, create an account on the site and then pay the fees of US$ 15 by clicking on the PayPal button After payment of the fees please send us your name to satish [at] rubylearning [dot] org so that we can send you the eBook, which normally takes place within 48 hours. If you want to take the course for free, please just create an account and send us your name (as mentioned above). Course Contents Using Git Using GitHub Using RVM (for *nix) Using pik (for Windows) Using bundler Using Heroku Creating a simple webpage using HTML5, CSS and JavaScript Store your webpage files on GitHub Understanding HTTP concepts Using cURL net/http library Using URI Using open-uri Using Nokogiri Creating one’s own Ruby Gem Learning Rack Deploying Pure Rack Apps to Heroku Deploying a static webpage to Heroku What’s JSON? Using MongoDB with Ruby Mongo driver MongoHQ the hosted database Using Sinatra Deploying Sinatra apps to Heroku Sinatra and SQLite3 interaction The course contents are subject to change. Mentors Satish Talim, Victor Goff III, Michele Garoche and others from the RubyLearning team. RubyLearning’s IRC Channel Mentors and students hang out at RubyLearning’s IRC (irc.freenode.net) channel (#RubyLearning.org) for both technical and non-technical discussions. Everyone benefits with the active discussions on Ruby with the mentors. Here are some details on how the course works: Important: Once the course starts, you can login and start with the lessons any day and time and post your queries in the forum under the relevant lessons. Just to set the expectations correctly, there is no real-time ‘webcasting’. Methodology: The Mentors shall give you URL’s of pages and sometimes some extra notes; you need to read through. Read the pre-class reading material at a convenient time of your choice – the dates mentioned are just for your guideline. While reading, please make a note of all your doubts, queries, questions, clarifications, comments about the lesson and after you have completed all the pages, post these on the forum under the relevant lesson. There could be some questions that relate to something that has not been mentioned or discussed by the mentors thus far; you could post the same too. Please remember that with every post, do mention the operating system of your computer. The mentor shall highlight the important points that you need to remember for that day’s session. There could be exercises every day. Please do them. Participate in the forum for asking and answering questions or starting discussions. Share knowledge, and exchange ideas among yourselves during the course period. Partici
about 9 hours ago
Week of May 13 - May 19, 2013 The master code is, as one would expect, in upheaval again. This week featured a big rewrite of callback internals, though I haven't sussed out whether it changes any features in that area. 3073c531 adds...
Week of May 13 - May 19, 2013 The master code is, as one would expect, in upheaval again. This week featured a big rewrite of callback internals, though I haven't sussed out whether it changes any features in that area. 3073c531 adds Minitest 5 compatibility to Rails 4.
1 day ago
migrating from iPhoto to Dropbox, from feature rich to future proof - I'm starting to think it's time to get off of OS/X. Walled gardens do not attract me. New gem released: Futuroscope! - Run selected operations on background threads w...
migrating from iPhoto to Dropbox, from feature rich to future proof - I'm starting to think it's time to get off of OS/X. Walled gardens do not attract me. New gem released: Futuroscope! - Run selected operations on background threads with very little change to your code.
1 day ago
I was asked to develop a prototype app for one of our clients lately. The basis for this app was an old Rails app:Rails 3.2.8 RailsAdmin MySQL rbenv + ruby-build I wanted to upgrade the stack to work with latest toys all cool kids are so...
I was asked to develop a prototype app for one of our clients lately. The basis for this app was an old Rails app:Rails 3.2.8 RailsAdmin MySQL rbenv + ruby-build I wanted to upgrade the stack to work with latest toys all cool kids are so thrilled about. I also didn’t have Rails console facility at my disposal since the Ruby version installed on the development machine hadn’t been compiled against libreadline.Not having root or sudo access on the machine I embarked on a sligthly hacky journey to make myself a better working environment.Ruby 2.0After reading Mike Farmer’s blog post about Ruby 2.0 and tons of other material about it on the Internet, I wanted to get a feeling of how faster & greater the new Ruby is. It’s always great also to stay up-to-date with latest technologies. It’s great for me as a developer, and more importantly - it’s great for our clients.Importance of libreadline in development with RubyTo be productive developing any Rails-based application, we have to have Rails-console available at any moment. It serves a multitude of purposes. It’s also a great scratch-pad when developing methods.While you don’t need your Ruby to support libreadline for basic uses of irb, you need it when using with Rails.Installing Ruby 2.0.0 with rbenv (ruby-build)If you’ve installed ruby-build some time ago, chances are that you need to update it in order to be able to install latest build of Ruby 2.0.0To do it:cd ~/.rbenv/plugins/ruby-build git pull And you should be able now to have available latest Ruby build to install:rbenv install 2.0.0-p195 If you want to install Ruby compiled with support for libreadline, you have to have it installed in your system before compiling the build with rbenv install.If you have access to root or sudo on your system, the easiest way is to e. g:on Debian-related Linuxes:apt-get install libreadline-dev or on Fedora:yum install readline-devel Installing libreadline from sourcesIn my case - I had to download sources and compile them myself. Luckily the system had all needed essential packages installed for building it.wget "ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz" tar xvf readline-6.2.tar.gz cd readline-6.2 ./configure --prefix=/home/kamil/libs make make install I had to specify –prefix option pointing at the path where I wanted the libreadline library to be installed after compilation.Then, I was able to actually build Ruby with readline support “on”:CONFIGURE_OPTS="--with-readline-dir=/home/kamil/libs" rbenv install 2.0.0-p195 Notice: I was making myself a development environment and compiling from sources was my last resort. It is not a good practice for production environments. Last thing I needed to do was to get rb-readline working with the project I was working on.It turnes out that latest rb-readline doesn’t play well with latest Ruby. Also, when using Ruby 2.0.0 one have to explicitely specify it in the Gemfile, or else it won’t be loaded for the console.Gemfile:gem 'rb-readline', '~> 0.4.2' This still isn’t perfectWhile this setup works, it won’t let you use arrow keys. The irb process crashes quickly after even first try to navigate through the text.For some reason, after upgrading Ruby, the RailsAdmin stylesheets stopped working. I noticed that they are being served with comments which should be replaced by other stylesheets like:/* ... *= require_self *= require_tree . */ I had to update Rails version in the Gemfile to have my admin back:Gemfile:gem 'rails', '3.2.13' Console:bundle Last thing I wanted to do, was to try if I could upgrade Rails even further and have a working Rails4 setup. This was impossible unfortunately since RailsAdmin isn’t yet compatible with it as stated here.I conclude that latest Ruby is quite usable right now. If you don't mind the quirks with the readline - you're pretty safe to upgrade. This assumes though that your app doesn't use any incompatibl
4 days ago
I spent this week with the team of engineers who made Riak on Engine Yard Cloud possible, attending RICON East: all Distributed Systems, all the time. Later in the week we took advantage of being in New York City to visit local customers...
I spent this week with the team of engineers who made Riak on Engine Yard Cloud possible, attending RICON East: all Distributed Systems, all the time. Later in the week we took advantage of being in New York City to visit local customers and discuss the various features we’re working on and field any technical, product, and data questions. Both our engineering and product teams love incorporating customer feedback into our direction. Speaking of which -- if you’re in San Francisco, I’m organizing customer UX feedback sessions! Hit me up :) --Tasha Drew, Product Manager Engineering Updates PHP is now GA on Engine Yard Cloud! Per Product Manager Noah Slater: “PHP has been an important part of Engine Yard’s growing family since the acquisition of Orchestra in 2011. And now, PHP on Engine Yard Cloud represents the culmination of our efforts to deliver the industry’s best Platform as a Service for PHP developers. The result of this work is a unified service offering for PHP, Node.js, and Ruby applications.” Read all about the GA launch announced by Davey Shafik at php[tek] in Chicago this week! Data Data Data Riak and Clusters are live! See our blogpost for more info - https://blog.engineyard.com/2013/riak-is-ga-engine-yard A cluster is a new way to organize and manage instances that share a specific function.  Clusters take much of the functionality that was once placed at the environment level, and moves it down to the cluster level. One environment can have many clusters, and each cluster can run different cookbooks and be in different regions. We drove the cluster model hand in hand with our productization of Riak on Cloud because the distributed model of Riak paired perfectly with where we wanted to drive the future of our platform. We can now take this underlying work and begin to re-productize other offerings to take advantage of its flexibility in many ways. Social Calendar (Come say hi!) Tuesday May 20th: Engine Yard Dublin hosts the PHP meetup where Eugene Kenny, Adverts.ie discusses his "Developer Toolbox", and then Matthew Weier O'Phinney of Zend Framework & Nate Abele of Lithium go head to head on the subject of Frameworks. Wednesday May 21st: Engine Yard’s San Francisco HQ will be hosting the monthly Riak meetup! Lead data engineer and fan favorite Ines Sombra will be presenting about Riak on Engine Yard Cloud, followed by Basho’s Mark Phillips discussing Riak CS. Wednesday May 21st: Our PDX office will be hosting Coder Dojo for students K-12 to learn about software! Grab a ticket and bring your parents for some software fun. Thursday May 22nd: Engine Yard Dublin plays host to Open Data Ireland, “Give us our health data!” Friday May 23rd: In which I talk about myself in the 3rd person? Tasha Drew will be speaking at Cloud East in Cambridge, UK, about deployments in the cloud, including various strategies we at Engine Yard see for environments of different sizes -- and concluding with sharing our own deployment strategy. Articles of Interest  Lightweight screenshot and annotation tool http://glui.me/ has gained some fans in our office! Engine Yard friend Daragh Curran, Head of Product Engineering, Intercom shared an awesome blog here. “Shipping brings life to your team, to your product, and to your customers. Shipping is your company’s heartbeat.”
4 days ago
Today's episode covers a major release for minitest, some JSON standards work, a tutorial on tagging with ActiveRecord and Postgres (plus an arduino to trigger the spray paint can), a RubyMotion tutorial and a little thing called CoVim t...
Today's episode covers a major release for minitest, some JSON standards work, a tutorial on tagging with ActiveRecord and Postgres (plus an arduino to trigger the spray paint can), a RubyMotion tutorial and a little thing called CoVim that will blow your mind. Listen to this episode on Ruby5 This episode is sponsored by New Relic New Relic is _the_ all-in-one web performance analytics product. It lets you manage and monitor web application performance, from the browser down to the line of code. With Real User Monitoring, New Relic users can see browser response times by geographical location of the user, or by browser type. Ruby Security Patches Ruby 1.9.3-p429 and Ruby 2.0.0-p195 were released, to fix the security issue: Object taint bypassing in DL and Fiddle in Ruby (CVE-2013-2065) minitest 5.0.0 released Minitest had a major release with a really important change. MiniTest is now Minitest. Check out all the breacking details in the release notes. jsonapi.org jsonapi.org proposes a work-in-progress standard for JSON APIs. See also Nathan Esquenazi's Conforming to jsonapi.org format wiki. Tagging With ActiveRecord and Postgres Use PostgreSQL's array feature, along with ActiveRecord 4's array support to implement tagging in your Rails app. RubyMotion Authentication Tutorial Luca Tironi has written part one of a tutorial post on using Devise for RubyMotion Authentication which includes an example of using Clay Allsop's Formotion. CoVim Can you believe it! Real-time, multi-user collaboration in vim. CoVim is a plugin that makes it possible.
4 days ago
Test::Page - Page-oriented integration testing for ruby. Upgrading to Sublime Text 3 - Step by step guide to getting on the beta version. Introducing ProMotion, a Full-Featured RobyMotion Application Framework - Abstracting screen and ...
Test::Page - Page-oriented integration testing for ruby. Upgrading to Sublime Text 3 - Step by step guide to getting on the beta version. Introducing ProMotion, a Full-Featured RobyMotion Application Framework - Abstracting screen and navigation handling in a rubylike way.
4 days ago
BubbleConf: One day of ideas and action with the most vocal minds from tech, design, UX and business. On october 12th 2012, we had the pleasure of co-organizing BubbleConf with our friends from Nedap and Teixido: the very first conferen...
BubbleConf: One day of ideas and action with the most vocal minds from tech, design, UX and business. On october 12th 2012, we had the pleasure of co-organizing BubbleConf with our friends from Nedap and Teixido: the very first conference in Amsterdam aimed at designers, developers and entrepreneurs that was actually affordable for (bootstrapped) startups to attend[1]. We were blown away by the positive reception for our very first conference: 400 people put their trust in us in delivering an unforgettable day full of ideas and inspiration to apply to their own worklife. After reviewing the post conference survey, we were super excited to see so many people demanding a 2013 edition. So without further ado, we’re pleased to announce that we’ll be doing a 2013 edition on September 27th 2013 so be sure to save the date! It will be held in Amsterdam once more, but we’ll be switching venues this time around to keep things exciting and fresh. The Tuschinski Theater had already set the bar quite
5 days ago