Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby Can Learn Something A Little

Shohei Umemoto
March 04, 2017
320

Ruby Can Learn Something A Little

Shohei Umemoto

March 04, 2017
Tweet

Transcript

  1. * 4QBJO + #FMHJVN , /FUIFSMBOET - *UBMZ ) 'SBODF

    <   > <   > <   > <   > <   >
  2. * 4QBJO + #FMHJVN , /FUIFSMBOET - *UBMZ  )

    'SBODF    <   > <   > <   > <   > <   >
  3.  LJOH  NBO    XPNBO  

    RVFFO <   > <   > <   > <   >
  4.  LJOH  NBO    XPNBO  

    RVFFO <   > <   > <   > <   >
  5. 3VCZך؝٦س׾䱱ׅ require 'linguist' files = [] Dir.entries('repos').each do |repo| next

    if repo == '.' || repo == '..' dirname = File.join(root, repo) files += Dir.glob("#{dirname}/**/*").select do |file| ¦ File.file?(file) end end files = files.select do |file| begin ¦ blob = Linguist::FileBlob.new(file) ¦ blob.language.name.downcase == 'ruby' rescue ¦ false end end
  6. ♶銲ז׮ך׾《׶ꤐֻ lists = lists.map do |list| list.select do |token| ¦

    !BLACKLIST.include?(token.first) end end lists = lists.map do |list| list.map { |token| token[1] }.join(' ') end File.open('text', 'wb') do |io| io.puts(lists.reject(&:empty?).join("\n")) end