プロジェクト

全般

プロフィール

バグ #285 » openimg.rb.diff

0.0.3用 #285 修正パッチ - Izumi Tsutsui, 2011-08-24 21:57

差分を表示:

0.0.3/core/addon/openimg.rb
79 79
    if dom
80 80
      attribute = {}
81 81
      catch(:imgtag_match){
82
        dom.each_matches(Regexp.new("<#{tag_name}.*?>")){ |str, pos|
82
        dom.gsub("\n", ' ').each_matches(Regexp.new("<#{tag_name}.*?>")){ |str, pos|
83 83
          attr = get_tag_by_attributes(str.to_s)
84 84
          if element_rule.all?{ |k, v| v === attr[k] }
85 85
            attribute = attr.freeze
86 86
            throw :imgtag_match end } }
87 87
      unless attribute.empty?
88 88
        return attr_name ? attribute[attr_name.to_s] : attribute end end
89
    notice 'not match'
89 90
    nil end
90 91

  
91 92
  def self.imgurlresolver(url, element_rule, &block)
......
98 99
      res = Net::HTTP.new(uri.host).get(uri.path, "User-Agent" => Environment::NAME + '/' + Environment::VERSION.to_s)
99 100
      if(res.is_a?(Net::HTTPResponse)) and (res.code == '200')
100 101
        result = get_tagattr(res.body, element_rule)
101
        notice result
102
        notice result.inspect
102 103
        result
103 104
      else
104 105
        warn "#{res.code} failed"
    (1-1/1)