SlideShare uma empresa Scribd logo
1 de 61
a Tour on Ruby and Friends
Minqi Pan (P.S.V.R)
“A Programmer’s Best Friend”
3 Keywords:
   Dynamic...
     Ruby executes at runtime many common behaviors
     that other languages might perform during

   Reflective...
     Ruby can observe (do type introspection) and modify
     its own structure and behavior at runtime.

   Humanity...
     Ruby is designed for programmer productivity and
     fun.
Snippet #1. OO
   # The Greeter class
class Greeter
  def initialize(name)
    @name = name.capitalize
  end
 
  def salute
    puts "Hello #{@name}!"
  end
end
 
# Create a new object
g = Greeter.new("world")
 
Snippet #2.
Everything is an object
 Applying an action on a number...



 5.times do
   print "We *love* Ruby -- it's outrageous!"
 end
Snippet #3. Flexibility
 Essential parts of Ruby can be removed or redefined,
 at will...


           class Numeric
             def plus(x)
               self.+(x)
             end
           end

           y = 5.plus 6
           # y is now equal to 11
Snippet #4. closures
  creating a function together with a referencing
  environment for the non-local variables of that
# In an object instance variable (denoted with '@'), remember
a block.
def remember(&a_block)
  @block = a_block
end

# Invoke the above method, giving it a block which takes a
name.
remember {|name| puts "Hello, #{name}!"}

# When the time is right (for the object) -- call the
closure!
@block.call("Jon")
# => "Hello, Jon!"
Snippet #5. closures (cont.)
  creating a function together with a referencing
  environment for the non-local variables of that

def create_set_and_get(initial_value=0) # Note the default value of 0
  closure_value = initial_value
  return Proc.new {|x| closure_value = x}, Proc.new { closure_value }
end

setter, getter = create_set_and_get   # ie. returns two values
setter.call(21)
getter.call # => 21

#You can also use a parameter variable as a binding for the closure.
#So the above can be rewritten as...

def create_set_and_get(closure_value=0)
  return proc {|x| closure_value = x } , proc { closure_value }
end
Snippet #6. anonymous func
 4 ways to create a function (or a subroutine) defined,
 and possibly called, without being bound to an

proc {|arg| print arg}

Proc.new {|arg| print arg}

lambda {|arg| print arg}

->(arg) {print arg}
Snippet #7. meta-programming
 writing of programs that write or manipulate other
 programs (or themselves) as their data...
 COLORS = { :black     =>   "000",
            :red       =>   "f00",
            :green     =>   "0f0",
            :yellow    =>   "ff0",
            :blue      =>   "00f",
            :magenta   =>   "f0f",
            :cyan      =>   "0ff",
            :white     =>   "fff" }

 class String
   COLORS.each do |color,code|
     define_method "in_#{color}" do
       "<span style="color: ##{code}">#{self}</span>"
     end
   end
 end

                                       "Hello, World!".in_blue
                                       => "<span style="color: #00f">Hello, World!</span>"
Snippet #8. meta-prog (cont)
 specialising the behaviour of methods called on a
 specific object...

 a = 'foo'
 class << a #opens up a’s singleton class (eigenclass)
   def inspect
     '"bar"'
   end
 end
 a.inspect   # => "bar"

 a = 'foo'   # new object, new singleton class
 a.inspect   # => "foo"
                                   "Hello, World!".in_blue
                                   => "<span style="color: #00f">Hello, World!</span>"
Snippet #9. eval
# Defining a class method with instance_eval
Fixnum.instance_eval { def ten; 10; end }
Fixnum.ten #=> 10

# Defining an instance method with class_eval
Fixnum.class_eval { def number; self; end }
7.number #=> 7

Fixnum.instance_eval treats Fixnum as an instance
(an instance of the Class class)

Fixnum.class_eval treats Fixnum as a class and
executes the code in the context of that class
Snippet #10. eval (cont.)
  class BindingTest
   def initialize(n)
    @value = n
   end
  def getBinding
   return binding() # using Kernel#binding
   end
  end
  obj1 = BindingTest.new(10)
  binding1 = obj1.getBinding
  obj2 = BindingTest.new(“Binding Test”)
  binding2 = obj2.getBinding
  puts eval(“@value”, binding1) #=> 10
  puts eval(“@value”, binding2) #=> Binding Test
  puts eval(“@value”) #=> nil
I made this!




(                    )
Yukihiro Matsumoto
“Often people, especially computer engineers, focus on the machines. They
think, "By doing this, the machine will run faster. By doing this, the machine will
run more effectively. By doing this, the machine will something something
something." They are focusing on machines. But in fact we need to focus on
humans, on how humans care about doing programming or operating the
application of the machines. We are the masters. They are the slaves.
 ”
Rails
2 Keywords:
   Convention over Configuration...
      a developer only needs to specify unconventional
      aspects of the application.

   Don't repeat yourself...
      information is located in a single, unambiguous
      place..
how to build a blog engine in
15 minutes with Ruby on Rails
Rails was created in 2003 by
David Heinemeier Hansson
                    I made that!
 In 2005 he was
 recognized by Google
 and O'Reilly with the
 Hacker of the Year
 award for his creation
 of Ruby on Rails.
 Hansson appeared on
 the cover of the July
 2006 issue of Linux
 Journal
“ Flexibility is not free. It’s overrated. And if you trade that
flexibility in for some constraints, you get a lot of complexity
removed from the equation, you get a lot of productivity back
from all the stuff you don’t have to do.”
How many source code does it take
         to make rails?
4 lines

#!/usr/bin/env ruby

if File.exists?(File.join(File.expand_path('../..', __FILE__), '.git'))
  railties_path = File.expand_path('../../railties/lib', __FILE__)
  $:.unshift(railties_path)
end
require "rails/cli"
It’s dependencies that matter
  s.add_dependency('activesupport',    version)
  s.add_dependency('actionpack',       version)
  s.add_dependency('activerecord',     version)
  s.add_dependency('activeresource',   version)
  s.add_dependency('actionmailer',     version)
  s.add_dependency('railties',         version)
  s.add_dependency('bundler',          '~> 1.0')
railties
Rails internals: application bootup, plugins,
generators, and rake tasks.


http://rubygems.org/gems/railties
require 'rails/ruby_version_check'

require 'pathname'

require 'active_support'
require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/logger'

require 'rails/application'
require 'rails/version'

require 'active_support/railtie'
require 'action_dispatch/railtie'
module Rails
 autoload :Info, 'rails/info'
 autoload :InfoController, 'rails/info_controller'

 class << self
  def application
    @@application ||= nil
  end
  def initialized?
    @@initialized || false
  end
  ...
 end
end
module Rails
 class Application < Engine
  autoload :Bootstrap,     'rails/application/bootstrap'
  autoload :Configuration, 'rails/application/configuration'

 end
end

module Rails
 module Generators
  autoload :Actions,    'rails/generators/actions'
  autoload :ActiveModel, 'rails/generators/active_model'
  ...
 end
end
Railties
Railties is responsible for gluing all frameworks together.
Overall, it:

* handles the bootstrapping process for a Rails application;

* manages the +rails+ command line interface;

* and provides Rails generators core.
activesupport
A toolkit of support libraries and Ruby core extensions extracted
from the Rails framework. Rich support for multibyte strings,
internationalization, time zones, and testing.


http://rubygems.org/gems/activesupport
irb(main):001:0> require 'active_support/all'
=> true
irb(main):002:0> 'person'.pluralize
=> "people"

2.even? # => true

irb(main):004:0> Time.now.in_time_zone('Alaska')
=> Sun, 11 Dec 2011 03:17:21 AKST -09:00
activesupport
Active Support is a collection of utility classes and standard library
extensions that were found useful for the Rails framework. These additions
reside in this package so they can be loaded as needed in Ruby projects
outside of Rails.


of great use to ruby learners!
actionpack
Action Pack is a framework for handling and responding to web
requests. It provides mechanisms for *routing* (mapping
request URLs to actions), defining *controllers* that implement
actions, and generating responses by rendering *views*, which
are templates of various formats. In short, Action Pack provides
the view and controller layers in the MVC paradigm.


http://rubygems.org/gems/actionpack
module ActionController
  class Base < Metal
    abstract!
     ...
  end
end
actionpack
* Action Dispatch, which parses information about the web request, handles
  routing as defined by the user, and does advanced processing related to HTTP
  such as MIME-type negotiation, decoding parameters in POST/PUT bodies,
  handling HTTP caching logic, cookies and sessions.

* Action Controller, which provides a base controller class that can be
  subclassed to implement filters and actions to handle requests. The result
  of an action is typically content generated from views.

* Action View, which handles view template lookup and rendering, and provides
  view helpers that assist when building HTML forms, Atom feeds and more.
  Template formats that Action View handles are ERB (embedded Ruby, typically
  used to inline short Ruby snippets inside HTML), and XML Builder.
activerecord
Active Record connects classes to relational database tables to establish an
almost zero-configuration persistence layer for applications. The library
provides a base class that, when subclassed, sets up a mapping between the new
class and an existing table in the database. In the context of an application,
these classes are commonly referred to as *models*. Models can also be
connected to other models; this is done by defining *associations*.



(c.f. mongoid)
http://rubygems.org/gems/activerecord
module ActiveRecord
  module Associations # :nodoc:
    extend ActiveSupport::Concern
    module ClassMethods
     def has_many
...
activerecord
 Automated mapping between classes and tables, attributes and columns.

 Associations between objects defined by simple class methods.

 Aggregations of value objects.

 Validation rules that can differ for new or existing objects.

 Callbacks available for the entire life cycle (instantiation, saving, destroying, validating, etc.).

 Observers that react to changes in a model.

 Inheritance hierarchies.

 Transactions

 Reflections on columns, associations, and aggregations.

 Database abstraction through simple adapters.

 Logging support

 Database agnostic schema management with Migrations.
activeresource
Active Resource (ARes) connects business objects and
Representational State Transfer (REST)
web services. It implements object-relational mapping for REST
web services to provide transparent
proxying capabilities between a client (ActiveResource) and a
RESTful service (which is provided by Simply RESTful routing
in ActionController::Resources).


http://rubygems.org/gems/activeresource
how it works

Model classes are mapped to remote REST resources
by Active Resource much the same way Active Record
maps model classes to databasetables. When a
request is made to a remote resource, a REST XML
request is generated, transmitted, and the result
received and serialized into a usable Ruby object.
models/product.rb

class Product < ActiveResource::Base
 self.site = "http://localhost:3000"
end

models/post.rb

class Post < ActiveRecord::Base
 def product
   @product ||= Product.find(product_id) unless product_id.blank?
 end
end

views/posts/edit.html.erb

<p>
 <%= f.label :product_id %>
 <%= f.collection_select :product_id, Product.find(:all), :id, :name %>
</p>

views/posts/show.html.erb

<% if @post.product %>
 <strong><%=h @post.product.name %></strong>
<% end %>
Philosiphy
 Active Resource attempts to provide a coherent
 wrapper object-relational mapping for REST web
 services. It follows the same philosophy as Active
 Record, in that one of its prime aims is to reduce the
 amount of code needed to map to these resources.
 This is made possible by relying on a number of code-
 and protocol-based conventions that make it easy for
 Active Resourceto infer complex relations and
 structures.
Philosophy (cont.)

class Person < ActiveResource::Base
 self.site = "http://api.people.com:3000/"
end

<->

http://api.people.com:3000/people/
# Expects a response of
  #
  # <person><id type="integer">1</id><attribute1>value1</
attribute1><attribute2>..</attribute2></person>
  #
  # for GET http://api.people.com:3000/people/1.xml
  #
  ryan = Person.find(1)
# <person><first>Ryan</first></person>
#
# is submitted as the body on
#
# POST http://api.people.com:3000/people.xml
#
# when save is called on a new Person object. An empty response is
# is expected with a 'Location' header value:
#
# Response (201): Location: http://api.people.com:3000/people/2
#
ryan = Person.new(:first => 'Ryan')
ryan.new? # => true
ryan.save # => true
ryan.new? # => false
ryan.id # => 2
actionmailer
Action Mailer is a framework for designing email-service layers.
These layers are used to consolidate code for sending out
forgotten passwords, welcome wishes on signup, invoices for
billing, and any other use case that requires a written notification
to either a person or another system.
class Notifier < ActionMailer::Base
 delivers_from 'system@loudthinking.com'

 def welcome(recipient)
  @recipient = recipient
  mail(:to => recipient,
     :subject => "[Signed up] Welcome #{recipient}")
 end
end
message = Notifier.welcome # => Returns a Mail::Message object
message.deliver        # => delivers the email




                           View!

                         Hello there,

                  Mr. <%= @recipient %>

                 Thank you for signing up!
and we get...
Date: Mon, 25 Jan 2010 22:48:09 +1100
From: system@loudthinking.com
To: david@loudthinking.com
Message-ID: <4b5d84f9dd6a5_7380800b81ac29578@void.loudthinking.com.mail>
Subject: [Signed up] Welcome david@loudthinking.com
Mime-Version: 1.0
Content-Type: text/plain;
	 charset="US-ASCII";
Content-Transfer-Encoding: 7bit

Hello there,

Mr. david@loudthinking.com

Thank you for signing up!
why directly calling on the class?
module ActionMailer #:nodoc:
 class Base < AbstractController::Base
  class << self
    def method_missing(method, *args) #:nodoc:
     return super unless respond_to?(method)
     new(method, *args).message
    end
  end
 end
end
Wait! where is activemodel?

 activerecord relies on this!
 activepack also relies on this!!!
 A toolkit for building modeling frameworks like Active
 Record and Active Resource. Rich support for
 attributes, callbacks, validations, observers,
 serialization, internationalization, and testing.
activemodel
  Used to build mongoid,etc
  as long as test is passed, free validation,callbacks,etc
  provided
module ActiveModel
 module Lint
  module Tests
def test_model_naming
 assert model.class.respond_to?(:model_name), "The model should respond to model_name"
 model_name = model.class.model_name
 assert_kind_of String, model_name
 assert_kind_of String, model_name.human
 assert_kind_of String, model_name.singular
 assert_kind_of String, model_name.plural
end

...
end
all those are free
 Add attribute magic to objects

 Callbacks for certain operations

 Tracking value changes

 Adding +errors+ interface to objects

 Model name introspection

 Observer support

 Making objects serializable

 Internationalization (i18n) support

 Validation support

 Custom validators
Other Web Frameworks of Ruby?
Sinatra
small and flexible

NO MVC

"quickly creating web-applications in Ruby with
minimal effort."

                    require 'sinatra'

                    get '/hi' do
                      "Hello World!"
                    end
Nitro
 it does not dictate
 how a web
 application should be
 structured.


<select name="day">
  <option for="day in 1..31" selected_if="day == Time.now.day">#{day}</option>
</select>

                One could use templates with embedded code!
Camping
Camping is a web
application framework
written in Ruby which
consistently stays under
4kb - the complete
source code can be
viewed on a single page.
require "uri";require "rack";class Object;def meta_def m,&b;(class<<self;self
end).send:define_method,m,&b end end;module Camping;C=self;S=IO.read(__FILE__
)rescue nil;P="<h1>Camping Problem!</h1><h2>%s</h2>";U=Rack::Utils;O={};Apps=[]
class H<Hash;def method_missing m,*a;m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m.
to_s]:super end;undef id,type if ??==63 end;class Cookies<H;attr_accessor :_p;
def _n;@n||={}end;alias :_s :[]=;def set k,v,o={};_s(j=k.to_s,v);_n[j]=
{:value=>v,:path=>_p}.update o;end;def []=(k,v)set(k,v,v.is_a?(Hash)?v:{})end
end;module Helpers;def R c,*g;p,h=
/(.+?)/,g.grep(Hash);g-=h;raise"bad route"unless u=c.urls.find{|x|break x if
x.scan(p).size==g.size&&/^#{x}/?$/=~(x=g.inject(x){|x,a|x.sub p,U.escape((a.
to_param rescue a))}.gsub(/(.)/){$1})};h.any?? u+"?"+U.build_query(h[0]):u
end;def / p;p[0]==?/?@root+p :p end;def URL c='/',*a;c=R(c,*a) if c.respond_to?(
:urls);c=self/c;c=@request.url[/.{8,}?(?=/|$)/]+c if c[0]==?/;URI c end end
module Base;attr_accessor:env,:request,:root,:input,:cookies,:state,:status,
:headers,:body;T={};L=:layout;def lookup n;T.fetch(n.to_sym){|k|t=Views.
method_defined?(k)||(t=O[:_t].keys.grep(/^#{n}./)[0]and Template[t].new{
O[:_t][t]})||(f=Dir[[O[:views]||"views","#{n}.*"]*'/'][0])&&Template.
new(f,O[f[/.(w+)$/,1].to_sym]||{});O[:dynamic_templates]?t:T[k]=t} end
def render v,*a,&b;if t=lookup(v);r,@_r=@_r,o=Hash===a[-1]?a.pop: {};s=(t==true)?mab{
send v,*a,&b}: t.render(self,o[:locals]||{},&b);s=render(L,o.merge(L=>false)){s
}if o[L]or o[L].nil?&&lookup(L)&&!r&&v.to_s[0]!=?_;s;else;raise"no template: #{v}"
end;end;def mab &b;(@mab||=Mab.new({},self)).capture(&b) end;def r s,b,h={};b,h=
h,b if Hash===b;@status=s;@headers.merge!(h);@body=b end;def redirect *a;r 302,
'','Location'=>URL(*a).to_s end;def r404 p;P%"#{p} not found"end;def r500 k,m,e
raise e end;def r501 m;P%"#{m.upcase} not implemented"end;def serve(p,c)
(t=Rack::Mime.mime_type p[/..*$/],nil)&&@headers["Content-Type"]=t;c;end;def to_a;@env[
'rack.session']=Hash[@state];r=Rack::Response.new(@body,@status,@headers)
@cookies._n.each{|k,v|r.set_cookie k,v};r.to_a end;def initialize env,m
r=@request=Rack:: Request.new(@env=env);@root,@input,@cookies,@state,@headers,
@status,@method=r.script_name.sub(//$/,''),n(r.params),Cookies[r.cookies],
H[r.session.to_hash],{},m=~/r(d+)/?$1.to_i: 200,m;@cookies._p=self/"/" end
def n h;Hash===h ?h.inject(H[]){|m,(k,v)|m[k]=
n(v);m}: h end;def service *a;r=catch(:halt){send(@method,*a)};@body||=r;self
end end;module Controllers;@r=[];class<<self;def R *u;r=@r;Class.
new{meta_def(:urls){u};meta_def(:inherited){|x|r<<x}}end;def D p,m,e;p='/'if
!p||!p[0];(a=O[:_t].find{|n,_|n==p}) and return [I,:serve,*a]
@r.map{|k|k.urls.map{|x|return(k.method_defined? m)?[k,m,*$~[1..-1]]:
[I, 'r501',m]if p=~/^#{x}/?$/}};[I,'r404',p] end;N=H.new{|_,x|x.downcase}.
merge!("N"=>'(d+)',"X"=>'([^/]+)',"Index"=>'');def M;def M;end;constants.
map{|c|k=const_get(c);k.send:include,C,X,Base,Helpers,Models
@r=[k]+@r if @r-[k]==@r;k.meta_def(:urls){["/#{c.to_s.scan(/.[^A-Z]*/).map(&
N.method(:[]))*'/'}"]}if !k.respond_to?:urls}end end;I=R()end;X=
Controllers;class<<self;def
goes m;Apps<<a=eval(S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING);caller[0]=~/:/
IO.read(a.set:__FILE__,$`)=~/^__END__/&&(b=$'.split /^@@s*(.+?)s*r?n/m).shift rescue nil
a.set :_t,H[*b||[]];end;def call e;X.M
p=e['PATH_INFO']=U.unescape(e['PATH_INFO']);k,m,*a=X.D p,e['REQUEST_METHOD'].
downcase,e;k.new(e,m).service(*a).to_a;rescue;r500(:I,k,m,$!,:env=>e).to_a end
def method_missing m,c,*a;X.M;h=Hash===a[-1]?a.pop: {};e=H[Rack::MockRequest.
env_for('',h.delete(:env)||{})];k=X.const_get(c).new(e,m.to_s);h.each{|i,v|k.
send"#{i}=",v};k.service(*a) end;def use*a,&b;m=a.shift.new(method(:call),*a,&b)
meta_def(:call){|e|m.call(e)}end;def options;O end;def set k,v;O[k]=v end end
module Views;include X,Helpers end;module Models;autoload:Base,'camping/ar'
Helpers.send:include,X,self end;autoload:Mab,'camping/mab'
autoload:Template,'camping/template';C end
== A Camping Skeleton                             module Blog::Views
                                                    def layout
A skeletal Camping blog could look like this:
                                                      html do
  require 'camping'                                     head { title "My Blog" }
                                                        body do
  Camping.goes :Blog
                                                          h1 "My Blog"
  module Blog::Models                                     self << yield
    class Post < Base; belongs_to :user; end            end
    class Comment < Base; belongs_to :user; end       end
    class User < Base; end
  end                                               end

  module Blog::Controllers                          def index
    class Index
                                                      @posts.each do |post|
      def get
        @posts = Post.find :all                         h1 post.title
        render :index                                 end
      end                                           end
    end
  end
                                                  end
Further Research
http://www.ruby-lang.org/
http://www.rubyonrails.org/
http://www.railscasts.com/
Thank you!

Mais conteúdo relacionado

Mais procurados

Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Wen-Tien Chang
 
JS Level Up: Prototypes
JS Level Up: PrototypesJS Level Up: Prototypes
JS Level Up: PrototypesVernon Kesner
 
Backbone js
Backbone jsBackbone js
Backbone jsrstankov
 
Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationKirill Chebunin
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRaimonds Simanovskis
 
Converting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginConverting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginthehoagie
 
Clojure and the Web
Clojure and the WebClojure and the Web
Clojure and the Webnickmbailey
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Wen-Tien Chang
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Aaron Gustafson
 
Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8Wilson Su
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
(Parameterized) Roles
(Parameterized) Roles(Parameterized) Roles
(Parameterized) Rolessartak
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Pythonkwatch
 
Javascript Common Design Patterns
Javascript Common Design PatternsJavascript Common Design Patterns
Javascript Common Design PatternsPham Huy Tung
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentationadamcookeuk
 

Mais procurados (20)

Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
JS Level Up: Prototypes
JS Level Up: PrototypesJS Level Up: Prototypes
JS Level Up: Prototypes
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Dispatch in Clojure
Dispatch in ClojureDispatch in Clojure
Dispatch in Clojure
 
Java Script Best Practices
Java Script Best PracticesJava Script Best Practices
Java Script Best Practices
 
Why ruby
Why rubyWhy ruby
Why ruby
 
Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 Application
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
 
Converting your JS library to a jQuery plugin
Converting your JS library to a jQuery pluginConverting your JS library to a jQuery plugin
Converting your JS library to a jQuery plugin
 
Rails on Oracle 2011
Rails on Oracle 2011Rails on Oracle 2011
Rails on Oracle 2011
 
Clojure and the Web
Clojure and the WebClojure and the Web
Clojure and the Web
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
 
Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
(Parameterized) Roles
(Parameterized) Roles(Parameterized) Roles
(Parameterized) Roles
 
Fantastic DSL in Python
Fantastic DSL in PythonFantastic DSL in Python
Fantastic DSL in Python
 
Javascript Common Design Patterns
Javascript Common Design PatternsJavascript Common Design Patterns
Javascript Common Design Patterns
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 

Destaque

Rails 快速上手攻略(Rails Getting Started)
Rails 快速上手攻略(Rails Getting Started)Rails 快速上手攻略(Rails Getting Started)
Rails 快速上手攻略(Rails Getting Started)旻琦 潘
 
lotus让我们写出更solid的ruby工程
lotus让我们写出更solid的ruby工程lotus让我们写出更solid的ruby工程
lotus让我们写出更solid的ruby工程旻琦 潘
 
Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it...
Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it...Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it...
Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it...旻琦 潘
 
Tracing a Memory-leak in a Long Running Eventmachine Application
Tracing a Memory-leak in a Long Running Eventmachine ApplicationTracing a Memory-leak in a Long Running Eventmachine Application
Tracing a Memory-leak in a Long Running Eventmachine Application旻琦 潘
 
Tracing a memory leaki in a long-running eventmachine application
Tracing a memory leaki in a long-running eventmachine applicationTracing a memory leaki in a long-running eventmachine application
Tracing a memory leaki in a long-running eventmachine applicationMinqi Pan
 
Embedding mruby into c and an actual example
Embedding mruby into c and an actual exampleEmbedding mruby into c and an actual example
Embedding mruby into c and an actual exampleMinqi Pan
 
How we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee companyHow we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee companyMinqi Pan
 
01 specchio specchio delle mie brame atelofobia-maggio2013
01   specchio specchio delle mie brame atelofobia-maggio201301   specchio specchio delle mie brame atelofobia-maggio2013
01 specchio specchio delle mie brame atelofobia-maggio2013Carmen Giordano
 
07 marzo 2011_sensi_feto
07 marzo 2011_sensi_feto07 marzo 2011_sensi_feto
07 marzo 2011_sensi_fetoCarmen Giordano
 
11 luglio agosto_2011_mi_è_nato_un_fratellino
11 luglio agosto_2011_mi_è_nato_un_fratellino11 luglio agosto_2011_mi_è_nato_un_fratellino
11 luglio agosto_2011_mi_è_nato_un_fratellinoCarmen Giordano
 
Sms English version
Sms English versionSms English version
Sms English versionjojoharsono
 
الأهداف السلوكية
الأهداف السلوكيةالأهداف السلوكية
الأهداف السلوكيةHashim ElHadi
 
Evaluation question 1[1]
Evaluation question 1[1]Evaluation question 1[1]
Evaluation question 1[1]melvCooalge
 
13 spazio associazione_bambiniincorso
13 spazio associazione_bambiniincorso13 spazio associazione_bambiniincorso
13 spazio associazione_bambiniincorsoCarmen Giordano
 

Destaque (20)

Rails 快速上手攻略(Rails Getting Started)
Rails 快速上手攻略(Rails Getting Started)Rails 快速上手攻略(Rails Getting Started)
Rails 快速上手攻略(Rails Getting Started)
 
lotus让我们写出更solid的ruby工程
lotus让我们写出更solid的ruby工程lotus让我们写出更solid的ruby工程
lotus让我们写出更solid的ruby工程
 
Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it...
Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it...Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it...
Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it...
 
Tracing a Memory-leak in a Long Running Eventmachine Application
Tracing a Memory-leak in a Long Running Eventmachine ApplicationTracing a Memory-leak in a Long Running Eventmachine Application
Tracing a Memory-leak in a Long Running Eventmachine Application
 
Tracing a memory leaki in a long-running eventmachine application
Tracing a memory leaki in a long-running eventmachine applicationTracing a memory leaki in a long-running eventmachine application
Tracing a memory leaki in a long-running eventmachine application
 
Embedding mruby into c and an actual example
Embedding mruby into c and an actual exampleEmbedding mruby into c and an actual example
Embedding mruby into c and an actual example
 
C++ 11
C++ 11C++ 11
C++ 11
 
How we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee companyHow we scaled git lab for a 30k employee company
How we scaled git lab for a 30k employee company
 
Www way2 wheeltheworld
Www way2 wheeltheworldWww way2 wheeltheworld
Www way2 wheeltheworld
 
01 specchio specchio delle mie brame atelofobia-maggio2013
01   specchio specchio delle mie brame atelofobia-maggio201301   specchio specchio delle mie brame atelofobia-maggio2013
01 specchio specchio delle mie brame atelofobia-maggio2013
 
DivyANSH GOUR
DivyANSH GOURDivyANSH GOUR
DivyANSH GOUR
 
07 marzo 2011_sensi_feto
07 marzo 2011_sensi_feto07 marzo 2011_sensi_feto
07 marzo 2011_sensi_feto
 
Spring integration
Spring integrationSpring integration
Spring integration
 
11 luglio agosto_2011_mi_è_nato_un_fratellino
11 luglio agosto_2011_mi_è_nato_un_fratellino11 luglio agosto_2011_mi_è_nato_un_fratellino
11 luglio agosto_2011_mi_è_nato_un_fratellino
 
Just For Kids Game
Just For Kids GameJust For Kids Game
Just For Kids Game
 
Sms English version
Sms English versionSms English version
Sms English version
 
الأهداف السلوكية
الأهداف السلوكيةالأهداف السلوكية
الأهداف السلوكية
 
La caramellabuona
La caramellabuonaLa caramellabuona
La caramellabuona
 
Evaluation question 1[1]
Evaluation question 1[1]Evaluation question 1[1]
Evaluation question 1[1]
 
13 spazio associazione_bambiniincorso
13 spazio associazione_bambiniincorso13 spazio associazione_bambiniincorso
13 spazio associazione_bambiniincorso
 

Semelhante a A Tour on Ruby and Friends: Dynamic, Reflective, and Fun

JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Racksickill
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...bobmcwhirter
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developergicappa
 
Ruby for C# Developers
Ruby for C# DevelopersRuby for C# Developers
Ruby for C# DevelopersCory Foy
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Clinton Dreisbach
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortegaarman o
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 
What's new in Ruby 2.0
What's new in Ruby 2.0What's new in Ruby 2.0
What's new in Ruby 2.0Kartik Sahoo
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on railsPriceen
 
Ruby — An introduction
Ruby — An introductionRuby — An introduction
Ruby — An introductionGonçalo Silva
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 
TDC 2012 - Patterns e Anti-Patterns em Ruby
TDC 2012 - Patterns e Anti-Patterns em RubyTDC 2012 - Patterns e Anti-Patterns em Ruby
TDC 2012 - Patterns e Anti-Patterns em RubyFabio Akita
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012rivierarb
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Coxlachie
 

Semelhante a A Tour on Ruby and Friends: Dynamic, Reflective, and Fun (20)

JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
The Joy Of Ruby
The Joy Of RubyThe Joy Of Ruby
The Joy Of Ruby
 
Ruby for C# Developers
Ruby for C# DevelopersRuby for C# Developers
Ruby for C# Developers
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
What's new in Ruby 2.0
What's new in Ruby 2.0What's new in Ruby 2.0
What's new in Ruby 2.0
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on rails
 
Ruby — An introduction
Ruby — An introductionRuby — An introduction
Ruby — An introduction
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 
Ruby
RubyRuby
Ruby
 
TDC 2012 - Patterns e Anti-Patterns em Ruby
TDC 2012 - Patterns e Anti-Patterns em RubyTDC 2012 - Patterns e Anti-Patterns em Ruby
TDC 2012 - Patterns e Anti-Patterns em Ruby
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Cox
 

Último

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Último (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

A Tour on Ruby and Friends: Dynamic, Reflective, and Fun

  • 1. a Tour on Ruby and Friends Minqi Pan (P.S.V.R)
  • 2. “A Programmer’s Best Friend” 3 Keywords: Dynamic... Ruby executes at runtime many common behaviors that other languages might perform during Reflective... Ruby can observe (do type introspection) and modify its own structure and behavior at runtime. Humanity... Ruby is designed for programmer productivity and fun.
  • 3. Snippet #1. OO # The Greeter class class Greeter   def initialize(name)     @name = name.capitalize   end     def salute     puts "Hello #{@name}!"   end end   # Create a new object g = Greeter.new("world")  
  • 4. Snippet #2. Everything is an object Applying an action on a number... 5.times do print "We *love* Ruby -- it's outrageous!" end
  • 5. Snippet #3. Flexibility Essential parts of Ruby can be removed or redefined, at will... class Numeric   def plus(x)     self.+(x)   end end y = 5.plus 6 # y is now equal to 11
  • 6. Snippet #4. closures creating a function together with a referencing environment for the non-local variables of that # In an object instance variable (denoted with '@'), remember a block. def remember(&a_block) @block = a_block end # Invoke the above method, giving it a block which takes a name. remember {|name| puts "Hello, #{name}!"} # When the time is right (for the object) -- call the closure! @block.call("Jon") # => "Hello, Jon!"
  • 7. Snippet #5. closures (cont.) creating a function together with a referencing environment for the non-local variables of that def create_set_and_get(initial_value=0) # Note the default value of 0 closure_value = initial_value return Proc.new {|x| closure_value = x}, Proc.new { closure_value } end setter, getter = create_set_and_get # ie. returns two values setter.call(21) getter.call # => 21 #You can also use a parameter variable as a binding for the closure. #So the above can be rewritten as... def create_set_and_get(closure_value=0) return proc {|x| closure_value = x } , proc { closure_value } end
  • 8. Snippet #6. anonymous func 4 ways to create a function (or a subroutine) defined, and possibly called, without being bound to an proc {|arg| print arg} Proc.new {|arg| print arg} lambda {|arg| print arg} ->(arg) {print arg}
  • 9. Snippet #7. meta-programming writing of programs that write or manipulate other programs (or themselves) as their data... COLORS = { :black => "000", :red => "f00", :green => "0f0", :yellow => "ff0", :blue => "00f", :magenta => "f0f", :cyan => "0ff", :white => "fff" } class String COLORS.each do |color,code| define_method "in_#{color}" do "<span style="color: ##{code}">#{self}</span>" end end end "Hello, World!".in_blue => "<span style="color: #00f">Hello, World!</span>"
  • 10. Snippet #8. meta-prog (cont) specialising the behaviour of methods called on a specific object... a = 'foo' class << a #opens up a’s singleton class (eigenclass)   def inspect     '"bar"'   end end a.inspect   # => "bar" a = 'foo'   # new object, new singleton class a.inspect   # => "foo" "Hello, World!".in_blue => "<span style="color: #00f">Hello, World!</span>"
  • 11. Snippet #9. eval # Defining a class method with instance_eval Fixnum.instance_eval { def ten; 10; end } Fixnum.ten #=> 10 # Defining an instance method with class_eval Fixnum.class_eval { def number; self; end } 7.number #=> 7 Fixnum.instance_eval treats Fixnum as an instance (an instance of the Class class) Fixnum.class_eval treats Fixnum as a class and executes the code in the context of that class
  • 12. Snippet #10. eval (cont.) class BindingTest def initialize(n) @value = n end def getBinding return binding() # using Kernel#binding end end obj1 = BindingTest.new(10) binding1 = obj1.getBinding obj2 = BindingTest.new(“Binding Test”) binding2 = obj2.getBinding puts eval(“@value”, binding1) #=> 10 puts eval(“@value”, binding2) #=> Binding Test puts eval(“@value”) #=> nil
  • 13. I made this! ( ) Yukihiro Matsumoto
  • 14. “Often people, especially computer engineers, focus on the machines. They think, "By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, the machine will something something something." They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves. ”
  • 15. Rails 2 Keywords: Convention over Configuration... a developer only needs to specify unconventional aspects of the application. Don't repeat yourself... information is located in a single, unambiguous place..
  • 16. how to build a blog engine in 15 minutes with Ruby on Rails
  • 17. Rails was created in 2003 by David Heinemeier Hansson I made that! In 2005 he was recognized by Google and O'Reilly with the Hacker of the Year award for his creation of Ruby on Rails. Hansson appeared on the cover of the July 2006 issue of Linux Journal
  • 18. “ Flexibility is not free. It’s overrated. And if you trade that flexibility in for some constraints, you get a lot of complexity removed from the equation, you get a lot of productivity back from all the stuff you don’t have to do.”
  • 19. How many source code does it take to make rails?
  • 20. 4 lines #!/usr/bin/env ruby if File.exists?(File.join(File.expand_path('../..', __FILE__), '.git')) railties_path = File.expand_path('../../railties/lib', __FILE__) $:.unshift(railties_path) end require "rails/cli"
  • 21. It’s dependencies that matter   s.add_dependency('activesupport', version)   s.add_dependency('actionpack', version)   s.add_dependency('activerecord', version)   s.add_dependency('activeresource', version)   s.add_dependency('actionmailer', version)   s.add_dependency('railties', version)   s.add_dependency('bundler', '~> 1.0')
  • 22. railties Rails internals: application bootup, plugins, generators, and rake tasks. http://rubygems.org/gems/railties
  • 23. require 'rails/ruby_version_check' require 'pathname' require 'active_support' require 'active_support/core_ext/kernel/reporting' require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/logger' require 'rails/application' require 'rails/version' require 'active_support/railtie' require 'action_dispatch/railtie'
  • 24. module Rails autoload :Info, 'rails/info' autoload :InfoController, 'rails/info_controller' class << self def application @@application ||= nil end def initialized? @@initialized || false end ... end end
  • 25. module Rails class Application < Engine autoload :Bootstrap, 'rails/application/bootstrap' autoload :Configuration, 'rails/application/configuration' end end module Rails module Generators autoload :Actions, 'rails/generators/actions' autoload :ActiveModel, 'rails/generators/active_model' ... end end
  • 26. Railties Railties is responsible for gluing all frameworks together. Overall, it: * handles the bootstrapping process for a Rails application; * manages the +rails+ command line interface; * and provides Rails generators core.
  • 27. activesupport A toolkit of support libraries and Ruby core extensions extracted from the Rails framework. Rich support for multibyte strings, internationalization, time zones, and testing. http://rubygems.org/gems/activesupport
  • 28.
  • 29. irb(main):001:0> require 'active_support/all' => true irb(main):002:0> 'person'.pluralize => "people" 2.even? # => true irb(main):004:0> Time.now.in_time_zone('Alaska') => Sun, 11 Dec 2011 03:17:21 AKST -09:00
  • 30. activesupport Active Support is a collection of utility classes and standard library extensions that were found useful for the Rails framework. These additions reside in this package so they can be loaded as needed in Ruby projects outside of Rails. of great use to ruby learners!
  • 31. actionpack Action Pack is a framework for handling and responding to web requests. It provides mechanisms for *routing* (mapping request URLs to actions), defining *controllers* that implement actions, and generating responses by rendering *views*, which are templates of various formats. In short, Action Pack provides the view and controller layers in the MVC paradigm. http://rubygems.org/gems/actionpack
  • 32. module ActionController class Base < Metal abstract! ... end end
  • 33.
  • 34. actionpack * Action Dispatch, which parses information about the web request, handles routing as defined by the user, and does advanced processing related to HTTP such as MIME-type negotiation, decoding parameters in POST/PUT bodies, handling HTTP caching logic, cookies and sessions. * Action Controller, which provides a base controller class that can be subclassed to implement filters and actions to handle requests. The result of an action is typically content generated from views. * Action View, which handles view template lookup and rendering, and provides view helpers that assist when building HTML forms, Atom feeds and more. Template formats that Action View handles are ERB (embedded Ruby, typically used to inline short Ruby snippets inside HTML), and XML Builder.
  • 35. activerecord Active Record connects classes to relational database tables to establish an almost zero-configuration persistence layer for applications. The library provides a base class that, when subclassed, sets up a mapping between the new class and an existing table in the database. In the context of an application, these classes are commonly referred to as *models*. Models can also be connected to other models; this is done by defining *associations*. (c.f. mongoid) http://rubygems.org/gems/activerecord
  • 36. module ActiveRecord module Associations # :nodoc: extend ActiveSupport::Concern module ClassMethods def has_many ...
  • 37. activerecord Automated mapping between classes and tables, attributes and columns. Associations between objects defined by simple class methods. Aggregations of value objects. Validation rules that can differ for new or existing objects. Callbacks available for the entire life cycle (instantiation, saving, destroying, validating, etc.). Observers that react to changes in a model. Inheritance hierarchies. Transactions Reflections on columns, associations, and aggregations. Database abstraction through simple adapters. Logging support Database agnostic schema management with Migrations.
  • 38. activeresource Active Resource (ARes) connects business objects and Representational State Transfer (REST) web services. It implements object-relational mapping for REST web services to provide transparent proxying capabilities between a client (ActiveResource) and a RESTful service (which is provided by Simply RESTful routing in ActionController::Resources). http://rubygems.org/gems/activeresource
  • 39. how it works Model classes are mapped to remote REST resources by Active Resource much the same way Active Record maps model classes to databasetables. When a request is made to a remote resource, a REST XML request is generated, transmitted, and the result received and serialized into a usable Ruby object.
  • 40. models/product.rb class Product < ActiveResource::Base self.site = "http://localhost:3000" end models/post.rb class Post < ActiveRecord::Base def product @product ||= Product.find(product_id) unless product_id.blank? end end views/posts/edit.html.erb <p> <%= f.label :product_id %> <%= f.collection_select :product_id, Product.find(:all), :id, :name %> </p> views/posts/show.html.erb <% if @post.product %> <strong><%=h @post.product.name %></strong> <% end %>
  • 41. Philosiphy Active Resource attempts to provide a coherent wrapper object-relational mapping for REST web services. It follows the same philosophy as Active Record, in that one of its prime aims is to reduce the amount of code needed to map to these resources. This is made possible by relying on a number of code- and protocol-based conventions that make it easy for Active Resourceto infer complex relations and structures.
  • 42. Philosophy (cont.) class Person < ActiveResource::Base self.site = "http://api.people.com:3000/" end <-> http://api.people.com:3000/people/
  • 43. # Expects a response of # # <person><id type="integer">1</id><attribute1>value1</ attribute1><attribute2>..</attribute2></person> # # for GET http://api.people.com:3000/people/1.xml # ryan = Person.find(1)
  • 44. # <person><first>Ryan</first></person> # # is submitted as the body on # # POST http://api.people.com:3000/people.xml # # when save is called on a new Person object. An empty response is # is expected with a 'Location' header value: # # Response (201): Location: http://api.people.com:3000/people/2 # ryan = Person.new(:first => 'Ryan') ryan.new? # => true ryan.save # => true ryan.new? # => false ryan.id # => 2
  • 45. actionmailer Action Mailer is a framework for designing email-service layers. These layers are used to consolidate code for sending out forgotten passwords, welcome wishes on signup, invoices for billing, and any other use case that requires a written notification to either a person or another system.
  • 46. class Notifier < ActionMailer::Base delivers_from 'system@loudthinking.com' def welcome(recipient) @recipient = recipient mail(:to => recipient, :subject => "[Signed up] Welcome #{recipient}") end end
  • 47. message = Notifier.welcome # => Returns a Mail::Message object message.deliver # => delivers the email View! Hello there, Mr. <%= @recipient %> Thank you for signing up!
  • 48. and we get... Date: Mon, 25 Jan 2010 22:48:09 +1100 From: system@loudthinking.com To: david@loudthinking.com Message-ID: <4b5d84f9dd6a5_7380800b81ac29578@void.loudthinking.com.mail> Subject: [Signed up] Welcome david@loudthinking.com Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII"; Content-Transfer-Encoding: 7bit Hello there, Mr. david@loudthinking.com Thank you for signing up!
  • 49. why directly calling on the class? module ActionMailer #:nodoc: class Base < AbstractController::Base class << self def method_missing(method, *args) #:nodoc: return super unless respond_to?(method) new(method, *args).message end end end end
  • 50. Wait! where is activemodel? activerecord relies on this! activepack also relies on this!!! A toolkit for building modeling frameworks like Active Record and Active Resource. Rich support for attributes, callbacks, validations, observers, serialization, internationalization, and testing.
  • 51. activemodel Used to build mongoid,etc as long as test is passed, free validation,callbacks,etc provided module ActiveModel module Lint module Tests def test_model_naming assert model.class.respond_to?(:model_name), "The model should respond to model_name" model_name = model.class.model_name assert_kind_of String, model_name assert_kind_of String, model_name.human assert_kind_of String, model_name.singular assert_kind_of String, model_name.plural end ... end
  • 52. all those are free Add attribute magic to objects Callbacks for certain operations Tracking value changes Adding +errors+ interface to objects Model name introspection Observer support Making objects serializable Internationalization (i18n) support Validation support Custom validators
  • 54.
  • 55. Sinatra small and flexible NO MVC "quickly creating web-applications in Ruby with minimal effort." require 'sinatra' get '/hi' do "Hello World!" end
  • 56. Nitro it does not dictate how a web application should be structured. <select name="day"> <option for="day in 1..31" selected_if="day == Time.now.day">#{day}</option> </select> One could use templates with embedded code!
  • 57. Camping Camping is a web application framework written in Ruby which consistently stays under 4kb - the complete source code can be viewed on a single page.
  • 58. require "uri";require "rack";class Object;def meta_def m,&b;(class<<self;self end).send:define_method,m,&b end end;module Camping;C=self;S=IO.read(__FILE__ )rescue nil;P="<h1>Camping Problem!</h1><h2>%s</h2>";U=Rack::Utils;O={};Apps=[] class H<Hash;def method_missing m,*a;m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m. to_s]:super end;undef id,type if ??==63 end;class Cookies<H;attr_accessor :_p; def _n;@n||={}end;alias :_s :[]=;def set k,v,o={};_s(j=k.to_s,v);_n[j]= {:value=>v,:path=>_p}.update o;end;def []=(k,v)set(k,v,v.is_a?(Hash)?v:{})end end;module Helpers;def R c,*g;p,h= /(.+?)/,g.grep(Hash);g-=h;raise"bad route"unless u=c.urls.find{|x|break x if x.scan(p).size==g.size&&/^#{x}/?$/=~(x=g.inject(x){|x,a|x.sub p,U.escape((a. to_param rescue a))}.gsub(/(.)/){$1})};h.any?? u+"?"+U.build_query(h[0]):u end;def / p;p[0]==?/?@root+p :p end;def URL c='/',*a;c=R(c,*a) if c.respond_to?( :urls);c=self/c;c=@request.url[/.{8,}?(?=/|$)/]+c if c[0]==?/;URI c end end module Base;attr_accessor:env,:request,:root,:input,:cookies,:state,:status, :headers,:body;T={};L=:layout;def lookup n;T.fetch(n.to_sym){|k|t=Views. method_defined?(k)||(t=O[:_t].keys.grep(/^#{n}./)[0]and Template[t].new{ O[:_t][t]})||(f=Dir[[O[:views]||"views","#{n}.*"]*'/'][0])&&Template. new(f,O[f[/.(w+)$/,1].to_sym]||{});O[:dynamic_templates]?t:T[k]=t} end def render v,*a,&b;if t=lookup(v);r,@_r=@_r,o=Hash===a[-1]?a.pop: {};s=(t==true)?mab{ send v,*a,&b}: t.render(self,o[:locals]||{},&b);s=render(L,o.merge(L=>false)){s }if o[L]or o[L].nil?&&lookup(L)&&!r&&v.to_s[0]!=?_;s;else;raise"no template: #{v}" end;end;def mab &b;(@mab||=Mab.new({},self)).capture(&b) end;def r s,b,h={};b,h= h,b if Hash===b;@status=s;@headers.merge!(h);@body=b end;def redirect *a;r 302, '','Location'=>URL(*a).to_s end;def r404 p;P%"#{p} not found"end;def r500 k,m,e raise e end;def r501 m;P%"#{m.upcase} not implemented"end;def serve(p,c) (t=Rack::Mime.mime_type p[/..*$/],nil)&&@headers["Content-Type"]=t;c;end;def to_a;@env[ 'rack.session']=Hash[@state];r=Rack::Response.new(@body,@status,@headers) @cookies._n.each{|k,v|r.set_cookie k,v};r.to_a end;def initialize env,m r=@request=Rack:: Request.new(@env=env);@root,@input,@cookies,@state,@headers, @status,@method=r.script_name.sub(//$/,''),n(r.params),Cookies[r.cookies], H[r.session.to_hash],{},m=~/r(d+)/?$1.to_i: 200,m;@cookies._p=self/"/" end def n h;Hash===h ?h.inject(H[]){|m,(k,v)|m[k]= n(v);m}: h end;def service *a;r=catch(:halt){send(@method,*a)};@body||=r;self end end;module Controllers;@r=[];class<<self;def R *u;r=@r;Class. new{meta_def(:urls){u};meta_def(:inherited){|x|r<<x}}end;def D p,m,e;p='/'if !p||!p[0];(a=O[:_t].find{|n,_|n==p}) and return [I,:serve,*a] @r.map{|k|k.urls.map{|x|return(k.method_defined? m)?[k,m,*$~[1..-1]]: [I, 'r501',m]if p=~/^#{x}/?$/}};[I,'r404',p] end;N=H.new{|_,x|x.downcase}. merge!("N"=>'(d+)',"X"=>'([^/]+)',"Index"=>'');def M;def M;end;constants. map{|c|k=const_get(c);k.send:include,C,X,Base,Helpers,Models @r=[k]+@r if @r-[k]==@r;k.meta_def(:urls){["/#{c.to_s.scan(/.[^A-Z]*/).map(& N.method(:[]))*'/'}"]}if !k.respond_to?:urls}end end;I=R()end;X= Controllers;class<<self;def goes m;Apps<<a=eval(S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING);caller[0]=~/:/ IO.read(a.set:__FILE__,$`)=~/^__END__/&&(b=$'.split /^@@s*(.+?)s*r?n/m).shift rescue nil a.set :_t,H[*b||[]];end;def call e;X.M p=e['PATH_INFO']=U.unescape(e['PATH_INFO']);k,m,*a=X.D p,e['REQUEST_METHOD']. downcase,e;k.new(e,m).service(*a).to_a;rescue;r500(:I,k,m,$!,:env=>e).to_a end def method_missing m,c,*a;X.M;h=Hash===a[-1]?a.pop: {};e=H[Rack::MockRequest. env_for('',h.delete(:env)||{})];k=X.const_get(c).new(e,m.to_s);h.each{|i,v|k. send"#{i}=",v};k.service(*a) end;def use*a,&b;m=a.shift.new(method(:call),*a,&b) meta_def(:call){|e|m.call(e)}end;def options;O end;def set k,v;O[k]=v end end module Views;include X,Helpers end;module Models;autoload:Base,'camping/ar' Helpers.send:include,X,self end;autoload:Mab,'camping/mab' autoload:Template,'camping/template';C end
  • 59. == A Camping Skeleton module Blog::Views def layout A skeletal Camping blog could look like this: html do require 'camping' head { title "My Blog" } body do Camping.goes :Blog h1 "My Blog" module Blog::Models self << yield class Post < Base; belongs_to :user; end end class Comment < Base; belongs_to :user; end end class User < Base; end end end module Blog::Controllers def index class Index @posts.each do |post| def get @posts = Post.find :all h1 post.title render :index end end end end end end

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n