SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Kürzlich hochgeladen

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
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
 
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
 
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
 
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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
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
 
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
 
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
 

Kürzlich hochgeladen (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
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
 
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.
 
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
 
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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
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
 
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?
 
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
 

Empfohlen

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
 

Empfohlen (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