Skip to content

Instantly share code, notes, and snippets.

View chikamichi's full-sized avatar
🙈
You good?

Jean-Denis Vauguet chikamichi

🙈
You good?
View GitHub Profile
@chikamichi
chikamichi / apotomo_builders.rb
Created March 19, 2011 19:31
Apotomo support for builders
# in lib/apotomo/widget.rb
# This comes redundant with Cells internals, but this is due to what may be a flaw in current Apotomo's design,
# which bypass Cells workflow (render_cell_for) and hook directly into AbstractController::Rendering #render_state
# Renders the +widget+ (instance or id).
def render_widget(widget_id, state=:display, *args)
if widget_id.kind_of?(Widget)
widget = widget_id
else
widget = find_widget(widget_id) or raise "Couldn't render non-existent widget `#{widget_id}`"
@chikamichi
chikamichi / apotomo_example.rb
Created February 24, 2011 14:09
an example of Apotomo structure
class MyController < ApplicationController
include Apotomo::Rails::ControllerMethods
has_widgets do |root|
if must_attach_a_wigdet?
# current_widget_data is anything that the Cell needs to build
# the widget (say, a User record…)
root << widget('my_widget',
"widget_#{@current_widget_data.id}",
module Bar
def do_sth
puts "@proxy: #{@proxy.inspect}"
end
end
class Foo
include Bar
def initialize
@chikamichi
chikamichi / Notes-on-Cassandra.md
Created April 17, 2010 22:49
Notes on using Cassandra latest release with the Ruby binding
@chikamichi
chikamichi / apotomo-12mn.md
Created April 17, 2010 15:02
revamped, cleaned-up version of the 12 minutes tutorials serie

Remarks on apotomo 12mn tutorials

Meet the StatefulWidget! (Part 1)

1.

git clone git://github.com/apotonick/dumdidoo.git
cd dumdidoo/
git submodule init

git submodule update

@chikamichi
chikamichi / do.rb
Created March 26, 2010 13:57
dynamic instances extending mechanism for Metamorphosis
require 'facets/kernel/constant'
require 'active_support/core_ext/module/attribute_accessors'
module Metamorphosis
module Injector
@@receiver = "Foo"
def clutch cst_path, *directives, &blk
raise ArgumentError unless cst = Object.constant([@@receiver, cst_path].join("::"))
raise ArgumentError unless cst.is_a? Class or cst.is_a? Module
module Base
module Plugins
def self.plugins
@plugins ||= []
end
def self.activate plugin_name
begin
plugin = Base::Plugins.const_get(plugin_name.capitalize)
rescue
@chikamichi
chikamichi / base.rb
Created March 21, 2010 02:12
plugins system: nested
# ./base.rb
require 'base/plugins'
module Base
class Server
include Plugins
def say(what)
p "say: #{what}"
@chikamichi
chikamichi / plugins_standalone.rb
Created March 21, 2010 02:07
plugins system: standalone
module Base
class Server
def blabla(argument)
@config ||= "default"
if @config == "default"
p "Server says: #{argument}"
end
puts "config: #{@config}"
# no explicit reference to web_steps
# that is, features/authentication/step_definitions/authentication_steps.rb contains:
Given /^I am not authenticated$/ do
# do nothing
end
$ cucumber features/authentication/authentication.feature
Using the default profile...
Feature: User authentication
To ensure the safety of the application