José Valim josevalim

View 0_README.md

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

View gist:3408772
1 2 3 4 5 6 7 8 9
Expected:
 
[
[{"a","b"},{"c","d"}],
[{"a1","b1"},{"c1","d1"}],
[{"a2","b2"},{"c2","d2"}]
]
 
Actual:
View client.exs
1 2 3 4
host = 'localhost' # host needs to be a charlist
{:ok, sock} = :gen_tcp.connect(host, 5678, [:binary, {:packet, 0}])
:ok = :gen_tcp.send(sock, "Some Data")
:ok = :gen_tcp.close(sock)
View exp.md

This is an experiment for possible faster boot time (and consequently faster feedback) when running tests. I ask your help to try this in your apps (any Rails 3.x app) and let me know how well it works.

How to

Add the following lines inside the configuration block in config/environments/test.rb:

config.cache_classes = true
def eager_load!; end
View sample output
1 2 3 4 5 6 7 8 9
defmodule Chat.Client do
# In all of the following functions 'server' stands for the server's pid
def join(server) do
send server, :join
end
 
def say(server, message) do
send server, { :say, message }
end
View gist:2686886
1 2 3 4 5 6 7 8 9 10
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index 2457543..da55653 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -196,7 +196,7 @@ module ActiveModel
attribute_method_matchers.each do |matcher|
matcher_new = matcher.method_name(new_name).to_s
matcher_old = matcher.method_name(old_name).to_s
- define_optimized_call self, matcher_new, matcher_old
+ define_proxy_call false, self, matcher_new, matcher_old
View gist:2187439
1 2 3 4 5 6 7 8 9
defmodule Iter do
def b(<<x, y | binary>>) do
<<x + 1, b(y) | binary>>
end
 
def b(<<>>) do
<<>>
end
end
View elixir.rb
1 2 3 4 5 6 7 8 9 10 11 12 13
# Install this recipe with:
# brew install https://raw.github.com/gist/1968046/0302279edc972e9d147110bd69284d0e2becda41/elixir.rb
 
require 'formula'
 
class ErlangInstalled < Requirement
def message; <<-EOS.undent
Erlang is required to install.
 
You can install this with:
Erlang is required to install.
 
You can install this with:
View Gemfile
1 2 3 4 5 6 7 8 9 10
source :rubygems
 
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
 
# Let's use thin
View lint_test.rb
1 2 3 4 5 6 7 8 9
class LintTest < ActiveSupport::TestCase
include ActiveModel::Lint::Tests
 
class Model
# model.to_model
include ActiveModel::Conversion
 
# Implements Model.model_name
extend ActiveModel::Naming
Something went wrong with that request. Please try again.