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 'wrest' | |
require 'pp' | |
Wrest.logger = Logger.new(STDOUT) | |
Wrest.logger.level = Logger::DEBUG # Set this to Logger::INFO or higher to disable request logging | |
# This example demonstrates the usage of GET, POST, PUT and | |
# DELETE over HTTPS. Its also shows how Wrest::Uris can have | |
# paths extended making accessing an API easy as pie. | |
# |
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
// We're going to pick on Mad Service today. If you had a hand in writing this once upon a time, do not fret. | |
// This isn't accusation or finger-poiniting -- I see everyone's name all over this code, including my own, which | |
// makes it a nice target. | |
// This code just needs some tenderness. Let's cook it a hot bowl of soup and play some soft Jazz. | |
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
How the time for dreams of the future seemed to slip past unnoticed, until in reviving them a man realized, with a shock, that the privilege was no longer his to entertain, that it belonged to those younger faces he saw on all sides, laughing in the tavern and on the streets, _running wild_. |
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
~ λ jruby -v | |
jruby 1.4.0dev (ruby 1.8.7p174) (2009-08-05 619cebe) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java] | |
~ λ jirb | |
irb(main):001:0> {}.eql?({}) | |
=> true | |
irb(main):002:0> [].eql?([]) | |
=> true |
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 'rubygems' | |
require 'rspec' | |
describe 'Int with scope' do | |
class Ooga | |
def initialize | |
@bar = 'woot' | |
end |
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
# > gem in wrest | |
# > wrest | |
# Type out the line below in the Wrest irb shell. | |
# Of course, we're assuming that you have ruby and that nobody has messed up the table on the wiki :) | |
"http://devcamp.in/index.php/Bangalore/2010/Registrations".to_uri.get.body.scan(/<tr>/).size |
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 -wKU | |
gemname = ARGV[0] | |
version = ARGV[1] | |
exit unless gemname | |
possible = `gem list #{gemname} | tail`.strip | |
versions = possible.gsub(/.*\(/, '').gsub(/\)$/, '').split(', ') | |
if versions.empty? | |
puts "#{gemname} not found" | |
exit |
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
class Resource | |
end | |
class Record | |
end | |
@resource = mock(Resource, :id => '1') | |
Resource.stub!(:find).and_return([@resource]) # works | |
Record.stub!(:serialize).and_return(true) | |
@record = mock(Record, :id => '1', :resource_ids => [1], :current_language => 'de') # fails later with: | |
# undefined method `serialize' for Spec::Mocks::Mock:Class |
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
~ λ wrest | |
ruby-1.8.7-p174 | |
Ruby 1.8.7, 2009-06-12, i686-darwin10.3.1 | |
Loading Wrest 1.0.0.beta2 | |
ruby-1.8.7-p174 > 'https://api.wordpress.org/secret-key/1.1/salt/'.to_uri.get.body | |
--> (GET 2164536540 2164536500) https://api.wordpress.org:443/secret-key/1.1/salt/ | |
<-- (GET 2164536540 2164536500) 200 OK (768 bytes 1.74s) | |
=> "define('AUTH_KEY', 'V|@ z>Iqm~ZugQ+BFG.i0L[%)u Vqi*7y!5-qOzwNkF>a$pfaXdJddR/iF8*U]0)');\ndefine('SECURE_AUTH_KEY', 'z[cv,EiUpJ-C;V+C{Za$WG38xOVUlG!V%4hj;h7xF![x$[1=4M5J/}@/}$NR#K]:');\ndefine('LOGGED_IN_KEY', 'SO~<GlF;(-nBh^9x |s XkYmq62(Ov&u^}DjaTjP kXoN(x*8`Hyv^&28Q.%v;Aa');\ndefine('NONCE_KEY', '[`FfSInp_A:;}.9QVF-2^cPzvz}%3OP:,yBV)xy)%w+V,PgRHO|Bo6lVQmj3_Unw');\ndefine('AUTH_SALT', 'YQdi+v0:=CA r$tU`6OFnN}xXAuayt<PJ&LNLWfSp]e%>KS[*ulU4&4+/RH#*@1<');\ndefine('SECURE_AUTH_SALT', '<{/]x&TsWU~TW7Ik/MCH @b;EEL6w5Z_9Ab!kg+ZPM!UnnL=FVn>gubQDVe]bB4e');\ndefine('LOGGED_IN_SALT', '<+|K{J|S4t`-b|UY4p?0P8<&NJen^>G^kt-Ljd!A1|70N2wzR(5-5o!%!m-?0%n?');\ndefine('NONCE_SALT', |
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
class ActiveRecord::Base | |
def self.ignore_fields(fields) | |
self.class_eval do | |
define_method(:ignore_fields) do | |
*fields | |
end | |
end | |
end | |
end |
OlderNewer