<?xml version="1.0" encoding="UTF-8"?>
<article>
  <body>[Gist](http://gist.github.com/)
&#12399;&#12385;&#12423;&#12387;&#12392;&#12375;&#12383;&#12467;&#12540;&#12489;&#12398;&#20999;&#12428;&#31471;&#12434;&#36028;&#20184;&#12369;&#12390;&#12362;&#12367;&#12398;&#12395;&#20415;&#21033;&#12391;&#12377;&#12290;
&#20808;&#26085;&#32057;&#20171;&#12375;&#12383;Endless Ruby&#12398;&#12467;&#12540;&#12489;&#12418;Gist&#19978;&#12391;&#12398;&#12415;&#20844;&#38283;&#12373;&#12428;&#12390;&#12356;&#12414;&#12375;&#12383;&#12290;
Gem&#12434;&#20316;&#12427;&#12414;&#12391;&#12418;&#12394;&#12356;&#12467;&#12540;&#12489;&#12434;Gist&#12395;&#36028;&#20184;&#12369;&#12390;&#12289;&#12381;&#12398;&#12414;&#12414;require&#12375;&#12390;&#20351;&#12360;&#12427;&#12392;&#20415;&#21033;&#12381;&#12358;&#12384;&#12392;&#24605;&#12387;&#12383;&#12398;&#12391;&#12289;&#35430;&#12375;&#12390;&#12415;&#12414;&#12375;&#12383;&#12290;

ruby&gt;&gt;
module Gist
module_function
  def require(id, sha1 = &quot;HEAD&quot;)
    Kernel.require &quot;open-uri&quot;
    gist = &quot;http://gist.github.com&quot;
    eval(if sha1 == &quot;HEAD&quot;
      open(&quot;#{gist}/#{id}.txt&quot;).read
    else
      Kernel.require &quot;tmpdir&quot;
      cache = File.join(Dir.tmpdir, &quot;gist-#{id}-#{sha1}&quot;)
      if File.exist?(cache)
        open(cache).read
      else
        open(&quot;#{gist}/raw/#{id}/#{sha1}&quot;) do |i|
          code = i.read
          open(cache, &quot;w&quot;){|o| o.write code}
          code
        end
      end
    end)
  end
end

Gist.require(&quot;148479&quot;, &quot;a59ea9ec3e865bafd1e4413b43b6ccb7a38d76fc&quot;)
#=&gt; Hello, world!
&lt;&lt;--

Hash&#20516;&#12391;&#20869;&#23481;&#12398;&#22793;&#26356;&#12364;&#26908;&#20986;&#21487;&#33021;&#12394;&#12398;&#12391;&#12289;md5&#12398;&#12481;&#12455;&#12483;&#12463;&#12469;&#12512;&#12434;&#20449;&#29992;&#12375;&#12390;&#12356;&#12427;&#20154;&#12395;&#12392;&#12387;&#12390;&#12399;&#21516;&#31243;&#24230;&#12398;&#23433;&#20840;&#24615;&#12391;&#21033;&#29992;&#12391;&#12365;&#12381;&#12358;&#12391;&#12377;&#12290;</body>
  <cached-tag-list>gist memo</cached-tag-list>
  <comments-count type="integer">0</comments-count>
  <created-at type="datetime">2009-07-16T17:31:40+00:00</created-at>
  <daily-archive-id type="integer">1207</daily-archive-id>
  <filter-type>blue_stole</filter-type>
  <id type="integer">1551</id>
  <monthly-archive-id type="integer">179</monthly-archive-id>
  <pdf-digest nil="true"></pdf-digest>
  <permalink nil="true"></permalink>
  <published-at type="datetime">2009-07-16T16:57:00+00:00</published-at>
  <secret>7c688bd6-2627-41d7-aefe-79404957ae04</secret>
  <title>Gist&#12363;&#12425;require&#12377;&#12427;&#26041;&#27861;</title>
  <updated-at type="datetime">2009-07-16T17:32:24+00:00</updated-at>
  <user-id type="integer">1</user-id>
</article>
