http://edgar411.com

Google Custom Search



You are

|| Login | Register | Why Register? ||


Browse Authors Of Fragments And Output Reports

Browse Stock Symbols

Browse EDGAR Input Reports

Browse Output Reports

Browse Fragments Used To Create Output Reports


About Edgar411.com

Contact Edgar411.com

Terms and Conditions

Built by http://bikle.com
(Rails Development/Consulting)

RDoc of Edgar411.com

RDoc of ActiveScaffold Plugin

RDoc of Hpricot 0.6

RDoc of Ruby On Rails


Translations:
Built with:
GNU Emacs
Arorem
Subversion
Piston
FreeBSD
PostgreSQL
Rails 1.2
LoginSugar
Active Scaffold
Hpricot
Lighttpd
|| Home | Symbols | Input Reports | Output Reports | Fragments ||

Show Fragments Built From an EDGAR Report

Fragment Owner
bikle  
Fragment Name
GOOG-10K-2006-F102  
Output Report Built From Fragments
GOOG-10-K-2006-12-31-Balance Sheet  
Parent
GOOG-10K-2006-F101  
EDGAR Report Full of Fragments
nil  
Inputurl
-  
Expression Used To Build This Fragment
sub(/0/,"GOOG-10K-2006-12-31-Balance-Sheet")  
Type Of Expression (hpricot, string, gsub, ...)
sub  
Fragment Text Scraped From Input Source (Report, Parent, or URL)

Render The HTML Below:
<div class='hp-enum-divwrap'>GOOG-10K-2006-12-31-Balance-Sheet<p /><table cellspacing="0" border="0" cellpadding="0" align="center" width="100%"> <tr> <td width="76%"></td> <td valign="bottom" width="3%"></td> <td></td> <td></td> <td></td> <td valign="bottom" width="3%"></td> <td></td> <td></td></tr> <tr> <td valign="bottom"><font size="1">&nbsp;</font></td> <td valign="bottom"><font size="1">&nbsp;&nbsp;</font></td> <td valign="bottom" align="center" colspan="6" style="border-bottom:1px solid #000000"><font face="Times New Roman" size="1"><b>As&nbsp;of&nbsp;December&nbsp;31,</b></font></td></tr> <tr> <td valign="bottom"><font size="1">&nbsp;</font></td> <td valign="bottom"><font size="1">&nbsp;&nbsp;</font></td> <td valign="bottom" align="center" colspan="2" style="border-bottom:1px solid #000000"> <p align="center" style="margin-top:0px;margin-bottom:1px"><font face="Times New Roman" size="1"><b>2005</b></font></p></td> <td valign="bottom"><font size="1">&nbsp;</font></td> <td valign="bottom"><font size="1
SNIPPED at character number 1024. Use render and then browser-view-source to see all of it.
 

Source Code:

/controllers/asls/frgmnts_controller.rb

# Provides read-only view via active_scaffold
class Asls::FrgmntsController < ApplicationController

  skip_before_filter :authenticate_usr

  active_scaffold do |config|
    config.actions = [:list, :show, :search]
    config.label = "Fragments Built From an EDGAR Report"
    config.list.columns = [:usr, :name, :outputrpt, :parent, :rpt, :inputurl, :scrapeexpr, :exprtype, :frgtxt]
    config.show.columns = [:usr, :name, :outputrpt, :parent, :rpt, :inputurl, :scrapeexpr, :exprtype, :frgtxt]

    config.columns[:usr].label = "Fragment Owner"
    config.columns[:name].label = "Fragment Name"
    config.columns[:outputrpt].label = "Output Report Built From Fragments"
    config.columns[:rpt].label = "EDGAR Report Full of Fragments"
    config.columns[:frgtxt].label = "Fragment Text Scraped From Input Source (Report, Parent, or URL)"
    config.columns[:scrapeexpr].label = "Expression Used To Build This Fragment"
    config.columns[:exprtype].label = "Type Of Expression (hpricot, string, gsub, ...)"

  end # active_scaffold

  def rndr_frgmnt
    @myhpelem = Frgmnt.find(params[:id]).frgtxt
    render(:layout => "layouts/html_tag_only")
  end # rndr_frgmnt
end # class

/models/frgmnt.rb

# A Frgmnt is a fragment of HTML scraped from another fragment (a parent) or a URL.
class Frgmnt < ActiveRecord::Base
  acts_as_tree  :order => "name"
  belongs_to :rpt
  belongs_to :outputrpt
  belongs_to :exprtype
  belongs_to :usr

  # Validations come after associations
  validates_presence_of :name, :outputrpt, :exprtype
  validates_uniqueness_of :name, :message => " is already being used.  Pick a different name for the fragment."

  protected

  def validate
    case
    # Ensure we have some input
    when (parent == nil and rpt == nil and inputurl == nil)
      errors.add(:parent, ", Input Report, and Input URL are all nil.  You need one.")
    # We only want 1 input
    when (parent != nil and rpt != nil)
      errors.add(:parent, "and Input Report are both not nil.  A fragment needs 1 (and only 1!) source (usually a parent)")
    # We only want 1 input
    when (parent != nil and inputurl != nil)
      errors.add(:parent, "and Input URL are both not nil.  A fragment needs 1 (and only 1!) source (usually a parent)")
    # We only want 1 input
    when (rpt != nil and inputurl != nil)
      errors.add(:rpt, "and Input URL are both not nil.  A fragment needs 1 (and only 1!) source (usually a parent)")
    # If a parent has no HTML, why scrape no-HTML?
    when (parent != nil and parent.frgtxt == nil)
      errors.add(:parent, " of this Fragment contains no HTML.  Maybe you picked the wrong parent")
    # We should not scrape ourself
    when (parent == self)
      errors.add(:parent, " == self.  Pick a different parent.")
    when (parent == nil and ['string-sandwich', 'gsub', 'sub', 'regexp-enumerable'].include?(exprtype.name))
    # When we scrape something off the net, only use hpricot
      errors.add(:exprtype, " Problem. Use hpricot type of scrape expression when using Input Report or Input URL.")
    # Use regexp to ensure that scrapeexpr starts with double quotes when exprtype is string-sandwich
    when (exprtype.name == 'string-sandwich' and ((scrapeexpr =~ /(^")/) != 0))
      errors.add(:scrapeexpr, " Problem.  string-sandwich Needs To Start With Double Quotes.")
    # Use regexp to ensure that scrapeexpr is formatted correctly for exprtype of "sub"
    when (exprtype.name == 'sub' and ((scrapeexpr =~ /^sub\(\/.*\)$/) != 0))
      errors.add(:scrapeexpr, " Problem. Maybe sub spelled wrong?  Demo: sub(/changeme/,'to this')")
    # Use regexp to ensure that scrapeexpr is formatted correctly for exprtype of "gsub"
    when (exprtype.name == 'gsub' and ((scrapeexpr =~ /^gsub\(\/.*\)$/) != 0))
      errors.add(:scrapeexpr, " Problem. Maybe gsub spelled wrong?  Demo: gsub(/changeme/,'to this')")
    # Branch on regexp
    when (exprtype.name == 'regexp-enumerable' and ((scrapeexpr =~ /^\/.*?\/$/) != 0))
      errors.add(:scrapeexpr, ' Problem. A regular expression looks something like this: /^(abc)(xyz)(123)$/')
    # hpricot-enumerable needs format like this: table.some-class,[1,5]
    when (exprtype.name == 'hpricot-enumerable' and  ((scrapeexpr =~ /(.*)?(\,)(\[)(\d+)(,)(\d+)(\])$/) != 0))
      errors.add(:scrapeexpr, ' Problem. hpricot-enumerable needs format like this: table.some-class,[1,5]')
    # The controller will set name = "record_usr_id_ne_session_usr_id" if
    # I try to update a record I do not own.
    when name == "record_usr_id_ne_session_usr_id"
      errors.add_to_base "You can only update your records, not other's records."
    # Use AR to validate that a glue fragment name is valid
    when exprtype.name == 'glue-fragment-to-parent'
      errors.add(:scrapeexpr, ' Problem:  Invalid fragment name.  Pick a fragment which actually exists.') if (Frgmnt.find_by_name(scrapeexpr) == nil)
    # Ensure that if I want to peel-off-outer-tag, I am doing it to a parent.
    when ((exprtype.name == 'peel-off-outer-tag') and  (parent == nil))
      errors.add(:parent, ' Problem: You can only peel-off-outer-tag of a parent')
    end # case
  end # validate

end   # class

/helpers/asls/frgmnts_helper.rb

module Asls::FrgmntsHelper
end