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

16 件のコメント:

  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



    返信削除