2012年12月6日木曜日

YAML入門

3年の羽毛田です.
今日は,学内企業説明会がありました.

今回,RubyでTwitterのクローラを書いてた際にトークンとかをYAMLデータとして,ほかのところに保持して,それを読み込んで使用しました.
Rubyを使って書いたのが初めてで,YAMLがなにかわかっていなかったので,ここでまとめつつ理解を深めようと思います.

YAMLとは

構造化されたデータを表現するためのフォーマットで,目的はXMLと似ています.
特徴として,XMLと比べて書きやすく,わかりやすいという点があります.
Rubyでは,Ruby 1.8から標準ライブラリに含まれています.他にもいろんな言語でライブラリを用いて使うことができるみたいです.
詳しい書き方とかは下のURLを参照してみてください.
http://jp.rubyist.net/magazine/?0009-YAML

例としてXMLより書きやすく,わかりやすいと書いているので,実際に比較してしてみます.

yaml
users:
  - name: haketa
    mail: haketa@example.com
  - name: watanabe
    mail: watanabe@example.com
  - name: nishizaki
    mail: nishizaki@example.com

xml

  
    haketa
    haketa@example.com
  
  
    watanabe
    watanabe@example.com
  
  
    nishizaki
    nishizaki@example.com
  

このようにxmlよりyamlのほうが簡潔に記述することができたと思います.
各種設定ファイルやログファイルなどの用途に向いているみたいです.

調べているとよくXMLと比較されていますが,まったく別ものと考えるのがよいみたいです.

おわりに

私は,今までXMLやJSONについては学んできましたが,今回はじめて,YAMLというものを扱ってみたことで,これからなにかプログラムを書く際に,どのデータ表現をつかってみたらいいのかを考える選択肢がひろがりました.どんどん新しい知識をつけ,その時に適材適所につかっていけるように努力していきたいです.

そういえば,googleのナレッジグラフが日本でも公開されました!
昨日は,タレントの名前とかスポーツ選手の名前で検索をかけると,横にいろんな情報でてきたのに,さっきためしてもなにもでてこなくなってしまった...

30 件のコメント:

  1. คาสิโนออนไลน์ที่น่าเชื่อถือและมีความเป็นมืออาชีพที่สุดในตอนนี้
    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร สล็อตออนไลน์ กับทางทีมงานของเราเพียงเท่านั้น
    ร่วมมาเป็นส่วนหนึ่งกับเว็บไซต์คาสิโนออนไลน์ของเราได้เลยค่ะ
    สมัครสล็อตออนไลน์ >>> Goldenslot
    สนใจร่วมสนุกกับ คาสิโนออนไลน์ คลิ๊กได้เลย
    มีทั้งคาสิโนออนไลน์ หวยออนไลน์ ฟุตบอลออนไลน์ สล็อตออนไลน์ และอื่นๆอีกมากมาย

    返信削除
  2. E-commerce research paper writers are hard to come across them for those in need of E-commerce Essay Writing Services and trade and e-commerce writing services.

    返信削除
  3. Medical coursework writing service seekers have been on the rise lately since most learners need Medical Research Paper Services, nursing research writing services and medical essay writing services.

    返信削除
  4. Do you have norton antivirus and facing problem while scanning through norton antivirus and get norton error 8504

    返信削除
  5. Finding the best powerpoint presentation online services and PowerPoint Presentation Writing Services is not easy unless one is keen to establish a reputable powerpoint presentation assignment writing service provider & powerpoint presentation coursework writing services.

    返信削除
  6. Custom biology coursework writing service seekers have been on the rise lately since most learners need Biology Assignment Writing Services, biology essay writing services and biology research writing services.

    返信削除

  7. watching your favorite movies and shows on a bigger screen. Here’s how you can watch Amazon Prime Video on
    TV! amazon.com/mytv

    返信削除


  8. Users can install mcafee antivirus on their computer and keep protected by this kind of infection. Download and Install Mcafee through mcafee.com/activate . Sign in to your Mcafee account, activate Mcafee and enter Mcafee 25 digit activation code. create your Mcafee account to manage your Mcafee subscriptions.

    返信削除

  9. Watch Prime Video on Amazon My TV, users have to enter a 6-digit registration which you can visiting Amazon.com/mytv .Amazon Prime video is amazon streaming platform which is the main competitor of Netflix and other global streaming channels. You can watch your favorite movies and shows without any ads using amazon prime video. With the help of your Amazon Activation Code , users can easily activate their subscriptions on their smart TVs.


    返信削除
  10. Just dial 1-877-916-7666 irrespective of your location to reach our popular and trusted tech support centre. Your call is attended by our qualified engineer who gives authentic resolutions in a step by step manner.

    返信削除
  11. If you are unsure, it is prudent to contact our Malwarebytes tech support center and talk to our engineer. Our toll free number is 1-844-249-4536 and the service remains active at all times on all 7 days of the week. The same number is applicable to all parts of the country.

    返信削除
  12. Amazon.com/mytv is a registration portal of Amazon Prime from which members can watch thousands of movies and TV shows for free from their device some features require a premium subscription. The instant video service can only be watched after registering your device with a simple subscription code. The website for registering on Amazon prime is www.amazon.com/mytv. Amazon Prime Video is one of the most amazing and interesting platforms to watch. With Amazon Prime you can stream unlimited movies and TV episodes on Amazon prime video app.

    amazon com mytv

    返信削除
  13. Now you can Easily Activate Amazon by Amazon.com/mytv. It is a registration portal of Amazon Prime from which members can watch thousands of movies and TV shows for free from their device some features require a premium subscription. The instant video service can only be watched after registering your device with a simple subscription code. The website for registering on Amazon prime is amazon.com/mytv. Amazon Prime Video is one of the most amazing and interesting platforms to watch. With Amazon Prime you can stream unlimited movies and TV episodes on Amazon prime video app. You can Easily Fix Troubleshoot by visiting here.

    amazon com mytv

    返信削除
  14. Activate amazon by visiting our website. Amazon Prime Video allows you to watch on-demand movies and TV shows via an app that you must install on your Samsung TV . You will also get original films, television series, and other entertaining content. To begin with any use of the advantages that come with your www.amazon.com/mytv nomination, it is important that you create a record on a similar platform. However, customers are likewise presented with the option to create a record in the hours of actuating from their membership. Visit here amazon.com/mytv

    www.amazon.com/mytv
    amazon.com/mytv

    返信削除
  15. It is an Application It is very useful for clients in installing all the software and guide updates. At whatever point new updates are accessible, it gives you warnings. Clients can save their ideal guides and areas with Garmin Express and can see the information on the navigation device. Thus, garmin.com/express guarantees fast and exact navigation. This Software gives you Warnings, Offers and item Support. For Setup Garmin Express you need to Visit our website.

    garmin.com/express

    It is an Application It is very useful for clients in installing all the software and guide updates. At whatever point new updates are accessible, it gives you warnings. Clients can save their ideal guides and areas with Garmin Express and can see the information on the navigation device. Thus, garmin.com/express guarantees fast and exact navigation. This Software gives you Warnings, Offers and item Support. For Setup Garmin Express you need to Visit our website.

    garmin.com/express







    返信削除


  16. Most importantly, switch on your Smart TV. Then visit amazon.com/mytv enter code Simple process to activate your Amazon prime video on your smart device or phone. Enter code mytv and click on the enter button. Then you see your Amazon prime account activate and you can easily watch your web shows, movies and videos. it is also essential to enter the application stores and download the official Amazon Prime Video application My TV is an Amazon program that offers a simple interface to the My TV service through Amazon's own websites and software programs. As previously noted, the program uses a simple web interface which enables the user to watch various television stations in the United States and Canada.


    amazon.com/mytv
    amazon.com/mytv enter code



    返信削除
  17. Garmin Express is gps tool which enable you to manage your Garmin GPS device from your computer.


    kindle-com-help in during registration error and My kindle account login are the most common kindle errors, so if you are facing these troubles you simply call.


    hp printer driver download and installation setup · Turn on the HP printer and computer for the first time. · Go to the 123hpcom-printer-setup now, open the search Engine.


    Manage your crypto assets and navigate the markets while on the go. Get full Bitfinex platform functionality on your fingertips with one click bitfinex-login.

    返信削除
  18. Here is the step by step guide to ij.start.canon/setup with screenshots for mac and windows Easy setup process to download Canon Drivers!!

    check out the features of Support.brother.com/windows and also know how to install best USB connection for windows10

    norton.com/setup is a website which will help you to setup Norton antivirus product, Norton security download for windows 10.

    help.microsoft.com is a website which will help you for solving your Microsoft account problems, check out the contact details method for Microsoft talk to a person

    office.com/setup

    返信削除
  19. Webroot Setup SecureAnywhere AntiVirus delivers protection against viruses, spyware, and other online threats.
    Webroot Setup

    Despite the ease with which Venmo sign in allows you to pay rent or split the bill.
    Venmo sign

    What is support.brother.com/windows? Common issues with Brother printers and its solutions.
    support.brother.com/windows

    TD Bank Login gives you 24/7 access and support, whether you're at home or on-the-go.
    TD bank login

    Banking products are provided by Boa Login and affiliated banking services.
    Boa Login

    Go through microsoft365.com/setup webpage, Sign in, and enter the product key.
    microsoft365.com/setup

    help.microsoft.com talk to a person help you with products including Office, Windows, Surface, and more.
    help.microsoft.com talk to a person

    返信削除

  20. help.microsoft.com talk to a person Microsoft is here to help you with products including Office, Windows, Surface, and more. Find articles, videos, training, tutorials, and more.

    Garmin Express is gps tool which enable you to manage your Garmin GPS device from your computer.


    www.kindle.com/support in during registration error and My kindle account login are the most common kindle errors, so if you are facing these troubles you simply call.


    hp printer driver download and installation setup · Turn on the HP printer and computer for the first time. · Go to the 123hpcom-printer-setup now, open the search Engine.


    Manage your crypto assets and navigate the markets while on the go. Get full Bitfinex platform functionality on your fingertips with one click bitfinex-login.

    capital one login to manage your BuyPower Card Earnings or Capital One account.

    To activate mcafee visit www.mcafee.com/activate in browser and Enter your 25 digits McAfee Activation Product Key

    返信削除
  21. AVG AntiVirus FREE is a super-lightweight and advanced cybersecurity solution that won't slow down your Windows PC or drain its battery. www.avg.com/retail anti-virus software, offering protection against viruses and various other malicious threats.

    返信削除
  22. For installing Norton in your PC, Go to the Norton Web link that is www.norton.com/setup and then click install button.

    返信削除
  23. Norton 360 Setup is an all-in-one computer software security suite and provides powerful layers of protection for your Android device against viruses, ransomware, malware, and other online threats.

    返信削除
  24. Contact for help.microsoft.com talk to a person to find solutions to common problems, or get help from an agent. Get help through chat or request a call.

    返信削除
  25. Whenever we all try to find the solution online for something, we always want the easy way so if you got somewhere in micorosft and want a quick solution, you need to contact help.microsoft.com talk to a person.

    返信削除
  26. Kucoin is one of the fastest growing cryptocurrency exchanges in the world that you can buy and sell bitcoin securely. kucoin login to find the next crypto gem.

    KuCoin is an international cryptocurrency exchange based out of Seychelle that currently supports the trading of 250 digital assets. Kkucoin login to find the next crypto gem.

    返信削除
  27. Help getting started with Roku devices, including setup, connecting your device to your TV, linking a Roku device to your account at www.roku.com/link.

    返信削除
  28. youtube com activate you have just go to www.youtube.com/activate. Opening youtube com in tablet, laptop, phone etc. Just go to browser And enter the information they asked through browser then connnect your T.V to youtube.

    返信削除
  29. webroot setup can be completed with insertion of 20-digit Webroot keycode. Webroot SecureAnywhere is one of the popular and widely accepted antivirus software in homes and offices.
    If you're having trouble logging in to microsoft365.com/setup, consider using one of your other Microsoft accounts, such as OneDrive, Xbox Live, Outlook.com, or Skype (if you've already subscribed to these products.
    If your printer is showing offline status and you want to change printerremove offline status for printer then here is a complete guide you have landed upon.
    quickbooks support number For Smooth Working As Accounting & Finance Software
    Download and install or reinstall office.com/setup home and student 2019r

    返信削除
  30. Your blogs are amazing. Keep sharing. I love them Are you also searching for help with my assignment? we are the best solution for you. We are best known for delivering the best urgent assignment help.

    返信削除