SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
One project,
three gems
    Mike Williams
  Cogent Consulting

   in association with
Architecture

“Atlas”
            <stuff/>
arboreal

Growing Trees
    (restaurant)


                                                    (hotel)

           Melbourne
                                     Sydney
 Geelong
               Victoria        NSW                 (sight)

      WA           Australia
                                     New Zealand

                     Pacific

  Europe
                                          Asia
                    WORLD

      Americas                   Africa
arboreal


how do I select this?



                       Melbourne
                                               Sydney
             Geelong
                          Victoria       NSW


                  WA         Australia
                                               New Zealand

                                Pacific

              Europe
                                                    Asia
                               WORLD

                  Americas                 Africa
arboreal
Path Enumeration
@victoria = Place.find_by_name(“Victoria”)
@victoria.ancestry_string
#=> “-4-14-15-”




                          Melbourne
                                                     Sydney
                Geelong
                             Victoria          NSW


                                Australia 15
                     WA

                                                     New Zealand

                                   Pacific 14

                 Europe
                                  WORLD 4
                                                          Asia


                     Americas                    Africa
arboreal

@victoria.ancestors
SELECT * FROM places WHERE (id in (4,14,15))




                          Melbourne
                                                     Sydney
                Geelong
                             Victoria          NSW


                                Australia 15
                     WA

                                                     New Zealand

                                   Pacific 14

                 Europe
                                  WORLD 4
                                                          Asia


                     Americas                    Africa
arboreal
@australia = Place.find_by_name(“Australia”)

@australia.children
SELECT * FROM places WHERE (places.parent_id = 15)




                          Melbourne
                                                     Sydney
                Geelong
                             Victoria          NSW


                                Australia 15
                     WA

                                                     New Zealand

                                   Pacific

                 Europe
                                                          Asia
                                  WORLD

                     Americas                    Africa
arboreal

@australia.descendants
SELECT * FROM places
 WHERE (places.ancestry_string like ‘-4-14-15-%’)




     “-4-14-15-22-”
                             Melbourne
                                                     Sydney        “-4-14-15-16-”
                   Geelong
                                Victoria       NSW

     “-4-14-15-”
                        WA         Australia
                                                     New Zealand

                                      Pacific

                    Europe
                                                          Asia
                                     WORLD

                        Americas                 Africa
arboreal

@australia.subtree
SELECT * FROM places
 WHERE (places.id = 15 OR places.ancestry_string like ‘-4-14-15-%’)




     “-4-14-15-22-”
                             Melbourne
                                                        Sydney        “-4-14-15-16-”
                   Geelong
                                Victoria          NSW

     “-4-14-15-”
                                   Australia 15
                        WA

                                                        New Zealand

                                      Pacific

                    Europe
                                                             Asia
                                     WORLD

                        Americas                    Africa
arboreal

@australia.subtree.scope(:find, :conditions)
#=> [“places.id = ? OR places.ancestry_string like ?”, 15, “-4-14-15-%”]


class Place
 def contained_pois
   Poi.scoped(:include => :place,
               :conditions => subtree.scope(:find, :conditions))
 end
end


@australia.contained_pois
SELECT ... FROM pois
 LEFT OUTER JOIN places ON places.id = pois.place_id
 WHERE (places.id = 15 OR places.ancestry_string like ‘-4-14-15-%’)
arboreal
@australia.contained_pois
SELECT ... FROM pois
 LEFT OUTER JOIN places ON places.id = pois.place_id
 WHERE (places.id = 15 OR places.ancestry_string like ‘-4-14-15-%’)




                           Melbourne
                                                   Sydney
                 Geelong
                              Victoria       NSW


                      WA         Australia
                                                   New Zealand

                                    Pacific

                  Europe
                                                        Asia
                                   WORLD

                      Americas                 Africa
GET http://stuff.local/places/15/pois


 “Atlas”
                      <pois/>
<pois type="array">
  <poi>
    <created-at type="datetime">2010-08-25T23:35:59Z</created-at>
    <email nil="true"></email>
    <id type="integer">6</id>
    <latitude type="decimal">-37.8002389992226</latitude>
    <longitude type="decimal">144.901535511017</longitude>
    <name>Footscray Market</name>
    <place-id type="integer">26</place-id>
    <review>A frenetic covered food market.</review>
    <type>See</type>
    <updated-at type="datetime">2010-08-25T23:35:59Z</updated-at>
    <url nil="true"></url>
  </poi>
  <poi>
    <created-at type="datetime">2010-08-25T23:35:59Z</created-at>
    <email nil="true"></email>
    <id type="integer">7</id>
    <latitude type="decimal">-37.8020224141169</latitude>
    <longitude type="decimal">144.983611106873</longitude>
    <name>Panama Dining Room</name>
    <place-id type="integer">26</place-id>
    <review>Franco-Fitzroy pub grub and ersatz Manhattan views.</review>
    <type>Eat</type>
    <updated-at type="datetime">2010-08-25T23:35:59Z</updated-at>
    <url nil="true"></url>
  </poi>
  ...
<pois type="array">
  <poi href="http://stuff.local/pois/6">
    <name>Footscray Market</name>
    <type>See</type>
    <review>A frenetic covered food market.</review>
    <place href="http://stuff.local/places/26">
      <name>Melbourne</name>
    </place>
  </poi>
  <poi href="http://stuff.local/pois/7">
    <name>Panama Dining Room</name>
    <type>Eat</type>
    <review>Franco-Fitzroy pub grub and ersatz Manhattan views.</review>
    <place href="http://stuff.local/places/26">
      <name>Melbourne</name>
    </place>
  </poi>
  <poi href="http://stuff.local/pois/8">
    <name>Sydney Opera House</name>
    <type>See</type>
    <review/>
    <place href="http://stuff.local/places/17">
      <name>Sydney</name>
    </place>
  </poi>
</pois>
# BEFORE ...
xml.pois :type => “array” do
 @pois.each do |poi|
  xml.poi :href => poi_url(poi) do
   xml.name(poi.name)
   xml.type(poi.type)
   xml.review(poi.review)
   xml.place :href => place_url(poi.place) do
    xml.name poi.place.name
   end
  end
 end
end
# BEFORE ...                                                             representative
xml.pois :type => “array” do
 @pois.each do |poi|
  xml.poi :href => poi_url(poi) do
   xml.name(poi.name)
   xml.type(poi.type)
   xml.review(poi.review)
   xml.place :href => place_url(poi.place) do
    xml.name poi.place.name
   end
  end
 end
end

# AFTER ...
Representative::Xml.new(xml) do |r|
 r.list_of :pois, @pois, :item_attributes => {:href => method(:poi_url)} do
  r.element :name
  r.element :type
  r.element :review
  r.element :place, :href => method(:place_url) do
    r.element :name
  end
 end
end
# XML ...                                                                 representative
Representative::Xml.new(xml) do |r|
 r.list_of :pois, @pois, :item_attributes => {:href => method(:poi_url)} do
  r.element :name
  r.element :type
  r.element :review
  r.element :place, :href => method(:place_url) do
    r.element :name
  end
 end
end

# JSON ...
Representative::Json.new do |r|
 r.list_of :pois, @pois, :item_attributes => {:href => method(:poi_url)} do
  r.element :name
  r.element :type
  r.element :review
  r.element :place, :href => method(:place_url) do
    r.element :name
  end
 end
end.to_s
<pois type="array">
  <poi href="http://stuff.local/pois/6">
    <name>Footscray Market</name>
    <type>See</type>
    <review>A frenetic covered food market.</review>
    <place href="http://stuff.local/places/26">
      <name>Melbourne</name>
    </place>
  </poi>
  <poi href="http://stuff.local/pois/7">
    <name>Panama Dining Room</name>
    <type>Eat</type>
    <review>Franco-Fitzroy pub grub and ersatz Manhattan views.</review>
    <place href="http://stuff.local/places/26">
      <name>Melbourne</name>
    </place>
  </poi>
  <poi href="http://stuff.local/pois/8">
    <name>Sydney Opera House</name>
    <type>See</type>
    <review/>
    <place href="http://stuff.local/places/17">
      <name>Sydney</name>
    </place>
  </poi>
</pois>
representative
[
    {
        "name": "Footscray Market",
        "type": "See",
        "review": "A frenetic covered food market.",
        "place": {
          "name": "Melbourne"
        }
    },
    {
        "name": "Panama Dining Room",
        "type": "Eat",
        "review": "Franco-Fitzroy pub grub and ersatz Manhattan views.",
        "place": {
          "name": "Melbourne"
        }
    },
    {
        "name": "Sydney Opera House",
        "type": "See",
        "review": null,
        "place": {
          "name": "Sydney"
        }
    }
]
“Atlas”
          <pois/>
<pois/>   something
          that wants
           POI data
<pois/>   something
fake
                  that wants
Atlas
                   POI data
sham
                                                                                    rack


require ‘fakeweb’
FakeWeb.register_uri(:get, “http://www.example.com/hello”, :body => “Hello World!”)




require ‘webmock’
stub_request(:get, “www.example.com/hello”).to_return(:body => “Hello, World!”)




require ‘sham_rack’
ShamRack.at(“www.example.com”).stub.register_resource(“/hello”, “Hello, World!”)
sham
                             rack

It’s just Rack!

client   Net::HTTP



         Sham        Rack
         Rack        app
sham
                                            rack

It’s just Rack!
ShamRack.at("www.example.com”) do |env|
  [
     "200 OK",
     { "Content-type" => "text/plain" },
     "Hello, world!"
  ]
end



ShamRack.at("www.example.com").rackup do
  use Some::Middleware
  use Some::Other::Middleware
  run MyApp.new
end
sham
                                             rack

It’s just Rack!

ShamRack.at("www.example.com").sinatra do
  get "/hello/:subject" do
    "Hello, #{params[:subject]}"
  end
end
http://github.com/mdub/arboreal
http://github.com/mdub/representative
http://github.com/mdub/sham_rack

Contenu connexe

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Dernier (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

En vedette (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

One project, 3 gems

  • 1. One project, three gems Mike Williams Cogent Consulting in association with
  • 3. arboreal Growing Trees (restaurant) (hotel) Melbourne Sydney Geelong Victoria NSW (sight) WA Australia New Zealand Pacific Europe Asia WORLD Americas Africa
  • 4. arboreal how do I select this? Melbourne Sydney Geelong Victoria NSW WA Australia New Zealand Pacific Europe Asia WORLD Americas Africa
  • 5. arboreal Path Enumeration @victoria = Place.find_by_name(“Victoria”) @victoria.ancestry_string #=> “-4-14-15-” Melbourne Sydney Geelong Victoria NSW Australia 15 WA New Zealand Pacific 14 Europe WORLD 4 Asia Americas Africa
  • 6. arboreal @victoria.ancestors SELECT * FROM places WHERE (id in (4,14,15)) Melbourne Sydney Geelong Victoria NSW Australia 15 WA New Zealand Pacific 14 Europe WORLD 4 Asia Americas Africa
  • 7. arboreal @australia = Place.find_by_name(“Australia”) @australia.children SELECT * FROM places WHERE (places.parent_id = 15) Melbourne Sydney Geelong Victoria NSW Australia 15 WA New Zealand Pacific Europe Asia WORLD Americas Africa
  • 8. arboreal @australia.descendants SELECT * FROM places WHERE (places.ancestry_string like ‘-4-14-15-%’) “-4-14-15-22-” Melbourne Sydney “-4-14-15-16-” Geelong Victoria NSW “-4-14-15-” WA Australia New Zealand Pacific Europe Asia WORLD Americas Africa
  • 9. arboreal @australia.subtree SELECT * FROM places WHERE (places.id = 15 OR places.ancestry_string like ‘-4-14-15-%’) “-4-14-15-22-” Melbourne Sydney “-4-14-15-16-” Geelong Victoria NSW “-4-14-15-” Australia 15 WA New Zealand Pacific Europe Asia WORLD Americas Africa
  • 10. arboreal @australia.subtree.scope(:find, :conditions) #=> [“places.id = ? OR places.ancestry_string like ?”, 15, “-4-14-15-%”] class Place def contained_pois Poi.scoped(:include => :place, :conditions => subtree.scope(:find, :conditions)) end end @australia.contained_pois SELECT ... FROM pois LEFT OUTER JOIN places ON places.id = pois.place_id WHERE (places.id = 15 OR places.ancestry_string like ‘-4-14-15-%’)
  • 11. arboreal @australia.contained_pois SELECT ... FROM pois LEFT OUTER JOIN places ON places.id = pois.place_id WHERE (places.id = 15 OR places.ancestry_string like ‘-4-14-15-%’) Melbourne Sydney Geelong Victoria NSW WA Australia New Zealand Pacific Europe Asia WORLD Americas Africa
  • 13. <pois type="array"> <poi> <created-at type="datetime">2010-08-25T23:35:59Z</created-at> <email nil="true"></email> <id type="integer">6</id> <latitude type="decimal">-37.8002389992226</latitude> <longitude type="decimal">144.901535511017</longitude> <name>Footscray Market</name> <place-id type="integer">26</place-id> <review>A frenetic covered food market.</review> <type>See</type> <updated-at type="datetime">2010-08-25T23:35:59Z</updated-at> <url nil="true"></url> </poi> <poi> <created-at type="datetime">2010-08-25T23:35:59Z</created-at> <email nil="true"></email> <id type="integer">7</id> <latitude type="decimal">-37.8020224141169</latitude> <longitude type="decimal">144.983611106873</longitude> <name>Panama Dining Room</name> <place-id type="integer">26</place-id> <review>Franco-Fitzroy pub grub and ersatz Manhattan views.</review> <type>Eat</type> <updated-at type="datetime">2010-08-25T23:35:59Z</updated-at> <url nil="true"></url> </poi> ...
  • 14. <pois type="array"> <poi href="http://stuff.local/pois/6"> <name>Footscray Market</name> <type>See</type> <review>A frenetic covered food market.</review> <place href="http://stuff.local/places/26"> <name>Melbourne</name> </place> </poi> <poi href="http://stuff.local/pois/7"> <name>Panama Dining Room</name> <type>Eat</type> <review>Franco-Fitzroy pub grub and ersatz Manhattan views.</review> <place href="http://stuff.local/places/26"> <name>Melbourne</name> </place> </poi> <poi href="http://stuff.local/pois/8"> <name>Sydney Opera House</name> <type>See</type> <review/> <place href="http://stuff.local/places/17"> <name>Sydney</name> </place> </poi> </pois>
  • 15. # BEFORE ... xml.pois :type => “array” do @pois.each do |poi| xml.poi :href => poi_url(poi) do xml.name(poi.name) xml.type(poi.type) xml.review(poi.review) xml.place :href => place_url(poi.place) do xml.name poi.place.name end end end end
  • 16. # BEFORE ... representative xml.pois :type => “array” do @pois.each do |poi| xml.poi :href => poi_url(poi) do xml.name(poi.name) xml.type(poi.type) xml.review(poi.review) xml.place :href => place_url(poi.place) do xml.name poi.place.name end end end end # AFTER ... Representative::Xml.new(xml) do |r| r.list_of :pois, @pois, :item_attributes => {:href => method(:poi_url)} do r.element :name r.element :type r.element :review r.element :place, :href => method(:place_url) do r.element :name end end end
  • 17. # XML ... representative Representative::Xml.new(xml) do |r| r.list_of :pois, @pois, :item_attributes => {:href => method(:poi_url)} do r.element :name r.element :type r.element :review r.element :place, :href => method(:place_url) do r.element :name end end end # JSON ... Representative::Json.new do |r| r.list_of :pois, @pois, :item_attributes => {:href => method(:poi_url)} do r.element :name r.element :type r.element :review r.element :place, :href => method(:place_url) do r.element :name end end end.to_s
  • 18. <pois type="array"> <poi href="http://stuff.local/pois/6"> <name>Footscray Market</name> <type>See</type> <review>A frenetic covered food market.</review> <place href="http://stuff.local/places/26"> <name>Melbourne</name> </place> </poi> <poi href="http://stuff.local/pois/7"> <name>Panama Dining Room</name> <type>Eat</type> <review>Franco-Fitzroy pub grub and ersatz Manhattan views.</review> <place href="http://stuff.local/places/26"> <name>Melbourne</name> </place> </poi> <poi href="http://stuff.local/pois/8"> <name>Sydney Opera House</name> <type>See</type> <review/> <place href="http://stuff.local/places/17"> <name>Sydney</name> </place> </poi> </pois>
  • 19. representative [ { "name": "Footscray Market", "type": "See", "review": "A frenetic covered food market.", "place": { "name": "Melbourne" } }, { "name": "Panama Dining Room", "type": "Eat", "review": "Franco-Fitzroy pub grub and ersatz Manhattan views.", "place": { "name": "Melbourne" } }, { "name": "Sydney Opera House", "type": "See", "review": null, "place": { "name": "Sydney" } } ]
  • 20. “Atlas” <pois/>
  • 21. <pois/> something that wants POI data
  • 22. <pois/> something fake that wants Atlas POI data
  • 23. sham rack require ‘fakeweb’ FakeWeb.register_uri(:get, “http://www.example.com/hello”, :body => “Hello World!”) require ‘webmock’ stub_request(:get, “www.example.com/hello”).to_return(:body => “Hello, World!”) require ‘sham_rack’ ShamRack.at(“www.example.com”).stub.register_resource(“/hello”, “Hello, World!”)
  • 24. sham rack It’s just Rack! client Net::HTTP Sham Rack Rack app
  • 25. sham rack It’s just Rack! ShamRack.at("www.example.com”) do |env| [ "200 OK", { "Content-type" => "text/plain" }, "Hello, world!" ] end ShamRack.at("www.example.com").rackup do use Some::Middleware use Some::Other::Middleware run MyApp.new end
  • 26. sham rack It’s just Rack! ShamRack.at("www.example.com").sinatra do get "/hello/:subject" do "Hello, #{params[:subject]}" end end