quattro_4 scribble

scribble 落書き (調べた事をただ落書きする)

RubyTapas #100 - #105

100 Screen Scraping Gateway

★★

DPD – Digital Product Delivery | Sell Downloads and Content Subscriptions | Sell Downloads and Subscriptions

Screen scraping

Mechanize

page.search('table').detect {|t|
row.search('td')

vcr test

エピソードを個別販売するのかな?

101 Intention Revealing Message

ちょっとしたことでもメソッドにすると意図が分かる
コメントより良い

content_post_rows[0..-2].reverse_each do.map { |row|

def select_content_post_data_rows(rows)
  rows[0..-2]
end

chronological_rows = order_content_post_rows_chronologically(data_rows)

102 Gem-Love Part 10

内容はよくわからない

それよりvimでいろいろやってると思った
画面分けてテストを走らせて結果表示とか

103 Gem-Love Part 11

最後のTODO

responsibility, dependency, injection

ついていけない

テストにスコープを使ってる

module GemLove do
  describe GemLove do

104 Parsing Time

DateTime.strptime

.strptimeはタイムゾーンで問題ある

DateTime._strptime
# => {:mon=>4, :mday=>28, :year=>2013, :hour=>9, :min=>0}

これは良さそう

chronicというgemもある

Chronic.parse

105 Checking for a Terminal

pager = ENV.fetch('PAGER') { 'more' }

ターミナルを判別

if $stdout.tty?
  exec "ruby #{$0} | #{pager}"
end