This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/kbennett/.rvm/rubies/ruby-2.1.2/bin/ruby -S rspec spec/avatar_spec.rb spec/basic_session_spec.rb spec/comment_spec.rb spec/configuration_spec.rb spec/field_parser_spec.rb spec/issue_spec.rb spec/jiralicious_spec.rb spec/project_avatar_spec.rb spec/project_spec.rb spec/search_result_spec.rb spec/search_spec.rb spec/user_avatar_spec.rb spec/user_spec.rb spec/watchers_spec.rb | |
FF..FF..F............F.F.FFFF..FFFFF......FF...FFF...F...FF...FFFFFF.. | |
Failures: | |
1) Jiralicious avatar obtain system avatar list | |
Failure/Error: avatar = Jiralicious::Avatar.system('user') | |
NoMethodError: | |
The property 'system' is not defined for Jiralicious::Avatar. | |
# ./lib/jiralicious/avatar.rb:19:in `initialize' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the source code included in the Ruby Lambdas presentation | |
# given at Steel City Ruby Conf in Pittsburgh, Pennsylvania, USA on August 15, 2014. | |
# This file is available at: | |
# https://gist.github.com/keithrbennett/0df037c29198ab401cf8 | |
# and the presentation slides PDF is at: | |
# https://speakerdeck.com/keithrbennett/ruby-lambdas | |
# -- Keith Bennett (@keithrbennett) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.1.2 :001 > require 'dot_notation' | |
=> true | |
2.1.2 :002 > h = { a: { b: 3 }} | |
=> {:a=>{:b=>3}} | |
2.1.2 :004 > DotNotation.dot(h, 'a.b') | |
NoMethodError: undefined method `dot' for DotNotation:Module | |
from (irb):4 | |
from /Users/kbennett/.rvm/rubies/ruby-2.1.2/bin/irb:11:in `<main>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DotNotation | |
# ... | |
def dot_lambda(a_hash) | |
->(dotted_string) { DotNotation.dot(a_hash, dotted_string)} | |
end | |
end | |
dl = dot_lambda(my_hash) | |
dl.('a.b') | |
dl.('c.d') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Modification of @tbloncar's script at | |
# https://gist.github.com/tbloncar/05265cb74762754b812d. | |
# @tbloncar, thank you for the gist. I see now that I should | |
# mention the performance cost of defining lambdas in methods | |
# in my presentation. | |
# Added ConstantLambdaApproach. Results I got with Ruby 2.1.2 were: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'diffy' | |
s1 = "apple\npear\npapaya\nmango\n" | |
s2 = "apple\npapaya\nmango\njackfruit\n" | |
diff = Diffy::Diff.new(s1, s2).to_s | |
puts diff | |
=begin | |
Output is: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(take 10 (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ruby 1.9.3: | |
➜ dnsruby git:(master) ✗ ruby test/ts_dnsruby.rb | |
/Users/kbennett/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- test/ts_online.rb (LoadError) | |
from /Users/kbennett/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require' | |
from test/ts_dnsruby.rb:16:in `<main>' | |
➜ dnsruby git:(master) ✗ rake test | |
ruby setup.rb | |
setup.rb:789: Use RbConfig instead of obsolete and deprecated Config. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ dnsruby git:(lowercase-dnsruby-dirname) gem build *gemspec | |
WARNING: no description specified | |
WARNING: deprecated autorequire specified | |
WARNING: pessimistic dependency on rake (~> 10.3.2, development) may be overly strict | |
if rake is semantically versioned, use: | |
add_development_dependency 'rake', '~> 10.3', '>= 10.3.2' | |
WARNING: See http://guides.rubygems.org/specification-reference/ for help | |
Successfully built RubyGem | |
Name: dnsruby | |
Version: 1.56.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I need to test a type-parameterized data structure | |
basically, I want to loop through various types | |
such as Long or BigInt, and run the same unit test suite with them: | |
[fake syntax] Seq(Long, BigInt).foreach(runTestSuite[_]) | |
that is, I don't want to copy-paste code only because | |
I want to test CMS[Long], CMS[BigInt], etc. | |
Is there any (easy) way to do this? |