Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
module Newman
Runner = Object.new
class << Runner
def from_file(filename, config)
self.basepath = File.dirname(filename)
self.config = config
eval(File.read(filename), binding)
end
require_relative "ping_pong"
run Newman::Examples::PingPong
# This method does AMAZING STUFF, check it out
#
# [ great example here]
#
# :internal
#
# It does so by using NeverSayDie to deal with the
# horrible segfaults library X causes.
#
# Here is a bunch of complicated stuff that'd scare
>> def foo
>> yield(1)
>> end
=> nil
>> foo { }
=> nil
>> bar = ->() { }
=> #<Proc:0x00000100a70f98@(irb):5 (lambda)>
>> foo(&bar)
ArgumentError: wrong number of arguments (1 for 0)
class A
def initialize(array)
@data = array
end
def eql?(other)
hash == other.hash
end
alias_method :==, :eql?
I miss my Ruby friends, but I don't miss Twitter / HN / Reddit / etc.
Here's how you can reach me:
1) You can hang out in the public #mendicant channel. General Ruby
discussion or even OT discussion is welcome, as long as you keep in
mind that it's meant to be a safe environment of Ruby learners
from all different backgrounds. I'm <seacreature> there.
2) You can participate in the mendicant-research mailing list.
seacreature:newman$ cd examples/
seacreature:examples$ ruby live_test.rb
Checking in...
5. 4. 3. 2. 1.
I, [2012-03-08T15:39:53.443525 #6322] INFO -- REQUEST: {:from=>["test@mendicantuniversity.org"], :to=>["test+ping@mendicantuniversity.org"], :bcc=>nil, :subject=>nil, :reply_to=>nil}
I, [2012-03-08T15:39:53.445468 #6322] INFO -- RESPONSE: {:from=>["test@mendicantuniversity.org"], :to=>["test@mendicantuniversity.org"], :bcc=>nil, :subject=>"pong", :reply_to=>nil}
OK
Gregory sends an email to c+town-hall-1.event-new with the subject "Availability for Town Hall Meeting #1" and a free-form-body
Gregory receives an email that tells him he can send a request to c+town-hall-1.event-schedule-1 to
see what the current optimized schedule is. (We may also want to add a feature that does this automatically
once all participants have responded or on DATE, whichever happens first)
Participants receive an email with Gregory's original content plus the following footer:
---
This email was generated by newman-scheduler

DISCLAIMER: The examples in this article are Rails-based, and I'm only an intermediate Rails developer at best. The focus of this article is on general maintenance patterns rather than specific implementation details, but if you see something ugly in the code samples, please give me some feedback!

When I launched the Practicing Ruby journal back in August 2011, I was just as excited about designing my own publishing software as I was about working on new articles. After several unsuccessful attempts at using existing services, I had finally thrown in the towel and decided that for this journal to be what I wanted it to be, it needed to run on its own custom software.

For the first few weeks, I was adding new bits of functionality as quickly as Jordan Byron and I could code them up. However, by mid-October we had built a tool that was good enough for day-to-day use, and I was generally happy with our progress. The unfortunate consequence of rea

Refactoring

+ R1: A good test suite increases confidence that code changes won't cause 
+ unexpected side effects without being noticed.

+ R2: Tests reduce the cost of structural changes in later stages of a project 
+ because fewer bugs sneak into a system unnoticed.

- R3: Brittle tests can increase the cost of refactoring if they focus on