Permalink
Browse files

no .svn, blah

  • Loading branch information...
1 parent 4be923b commit 19c5724f45a0c66a05571341889fae10e3183e39 @defunkt committed Jan 22, 2008
Showing with 0 additions and 8,461 deletions.
  1. +0 −58 lib/.svn/entries
  2. +0 −1 lib/.svn/format
  3. +0 −319 lib/.svn/text-base/microformat.rb.svn-base
  4. +0 −3 lib/.svn/text-base/mofo.rb.svn-base
  5. +0 −76 lib/microformat/.svn/entries
  6. +0 −1 lib/microformat/.svn/format
  7. +0 −5 lib/microformat/.svn/text-base/array.rb.svn-base
  8. +0 −30 lib/microformat/.svn/text-base/simple.rb.svn-base
  9. +0 −24 lib/microformat/.svn/text-base/string.rb.svn-base
  10. +0 −11 lib/microformat/.svn/text-base/time.rb.svn-base
  11. +0 −172 lib/mofo/.svn/entries
  12. +0 −1 lib/mofo/.svn/format
  13. +0 −10 lib/mofo/.svn/text-base/adr.rb.svn-base
  14. +0 −6 lib/mofo/.svn/text-base/geo.rb.svn-base
  15. +0 −15 lib/mofo/.svn/text-base/hcalendar.rb.svn-base
  16. +0 −35 lib/mofo/.svn/text-base/hcard.rb.svn-base
  17. +0 −15 lib/mofo/.svn/text-base/hentry.rb.svn-base
  18. +0 −6 lib/mofo/.svn/text-base/hfeed.rb.svn-base
  19. +0 −17 lib/mofo/.svn/text-base/hresume.rb.svn-base
  20. +0 −14 lib/mofo/.svn/text-base/hreview.rb.svn-base
  21. +0 −6 lib/mofo/.svn/text-base/rel_bookmark.rb.svn-base
  22. +0 −6 lib/mofo/.svn/text-base/rel_tag.rb.svn-base
  23. +0 −92 lib/mofo/.svn/text-base/xfn.rb.svn-base
  24. +0 −54 lib/mofo/.svn/text-base/xoxo.rb.svn-base
  25. +0 −130 site/.svn/entries
  26. +0 −1 site/.svn/format
  27. +0 −5 site/.svn/prop-base/favicon.ico.svn-base
  28. +0 −5 site/.svn/prop-base/mofo-logo.png.svn-base
  29. +0 −5 site/.svn/prop-base/spinner.gif.svn-base
  30. BIN site/.svn/text-base/favicon.ico.svn-base
  31. +0 −384 site/.svn/text-base/index.html.svn-base
  32. BIN site/.svn/text-base/mofo-logo.png.svn-base
  33. +0 −2 site/.svn/text-base/mootools.v1.00.js.svn-base
  34. +0 −181 site/.svn/text-base/p.js.svn-base
  35. BIN site/.svn/text-base/spinner.gif.svn-base
  36. +0 −159 site/.svn/text-base/style.css.svn-base
  37. +0 −6 site/.svn/text-base/try.html.svn-base
  38. +0 −89 site/try/.svn/entries
  39. +0 −1 site/try/.svn/format
  40. +0 −5 site/try/.svn/prop-base/spinner.gif.svn-base
  41. +0 −6 site/try/.svn/text-base/index.html.svn-base
  42. +0 −181 site/try/.svn/text-base/p.js.svn-base
  43. BIN site/try/.svn/text-base/spinner.gif.svn-base
  44. +0 −86 site/try/.svn/text-base/template.html.svn-base
  45. +0 −66 site/try/.svn/text-base/trymofo.rb.svn-base
  46. +0 −187 test/.svn/entries
  47. +0 −1 test/.svn/format
  48. +0 −22 test/.svn/text-base/base_url_test.rb.svn-base
  49. +0 −80 test/.svn/text-base/ext_test.rb.svn-base
  50. +0 −38 test/.svn/text-base/hatom_test.rb.svn-base
  51. +0 −33 test/.svn/text-base/hcalendar_test.rb.svn-base
  52. +0 −152 test/.svn/text-base/hcard_test.rb.svn-base
  53. +0 −23 test/.svn/text-base/hresume_test.rb.svn-base
  54. +0 −37 test/.svn/text-base/hreview_test.rb.svn-base
  55. +0 −27 test/.svn/text-base/include_pattern_test.rb.svn-base
  56. +0 −40 test/.svn/text-base/reltag_test.rb.svn-base
  57. +0 −34 test/.svn/text-base/subclass_test.rb.svn-base
  58. +0 −24 test/.svn/text-base/test_helper.rb.svn-base
  59. +0 −81 test/.svn/text-base/xfn_test.rb.svn-base
  60. +0 −49 test/.svn/text-base/xoxo_test.rb.svn-base
  61. +0 −208 test/fixtures/.svn/entries
  62. +0 −1 test/fixtures/.svn/format
  63. +0 −72 test/fixtures/.svn/text-base/bob.html.svn-base
  64. +0 −1,052 test/fixtures/.svn/text-base/chowhound.html.svn-base
  65. +0 −403 test/fixtures/.svn/text-base/corkd.html.svn-base
  66. +0 −26 test/fixtures/.svn/text-base/event_addr.html.svn-base
  67. +0 −39 test/fixtures/.svn/text-base/events.html.svn-base
  68. +0 −1 test/fixtures/.svn/text-base/fake.html.svn-base
  69. +0 −535 test/fixtures/.svn/text-base/fauxtank.html.svn-base
  70. +0 −1,101 test/fixtures/.svn/text-base/hatom.html.svn-base
  71. +0 −409 test/fixtures/.svn/text-base/hresume.html.svn-base
  72. +0 −246 test/fixtures/.svn/text-base/include_pattern_single_attribute.html.svn-base
  73. +0 −5 test/fixtures/.svn/text-base/simple.html.svn-base
  74. +0 −225 test/fixtures/.svn/text-base/stoneship.html.svn-base
  75. +0 −335 test/fixtures/.svn/text-base/upcoming.html.svn-base
  76. +0 −479 test/fixtures/.svn/text-base/upcoming_single.html.svn-base
  77. +0 −207 test/fixtures/.svn/text-base/xfn.html.svn-base
View
@@ -1,58 +0,0 @@
-8
-
-dir
-354
-svn+ssh://chris@errtheblog.com/svn/projects/mofo/lib
-svn+ssh://chris@errtheblog.com/svn/projects
-
-
-
-2007-08-18T02:43:33.265118Z
-273
-chris
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-cf301c5b-d72e-0410-996c-ed4829982077
-
-mofo
-dir
-
-microformat
-dir
-
-mofo.rb
-file
-
-
-
-
-2007-11-19T21:58:51.000000Z
-a8fef6b4c5a5e110bd4b81063a044cdd
-2007-04-24T08:22:53.936924Z
-4
-chris
-
-microformat.rb
-file
-
-
-
-
-2007-11-19T21:58:51.000000Z
-9a66d9c6d1cb561a4c4c9b085dfef599
-2007-08-04T03:11:23.094019Z
-270
-chris
-
View
@@ -1 +0,0 @@
-8
@@ -1,319 +0,0 @@
-%w(rubygems set hpricot microformat/string microformat/array open-uri ostruct timeout).each { |f| require f }
-gem 'hpricot', '>=0.4.59'
-
-class Microformat
- module Base
- @@subclasses = Set.new
- @@timeout = 5
-
- ##
- # The Gateway
- #
- def find(*args)
- return find_in_children(*args) if self == Microformat
-
- target, @options = args
- @options ||= target.is_a?(Hash) ? target : {}
- [:first, :all].each { |key| target = @options[key] if @options[key] }
-
- extract_base_url! target
-
- @doc = build_doc(@options[:text] ? @options : target)
-
- microformats = find_occurences(@doc)
- raise MicroformatNotFound if @options[:strict] && microformats.empty?
- return @options[:first] ? nil : [] if microformats.empty?
-
- if @options[:first] || @options[:all]
- return @options[:first] ? find_first(microformats) : find_every(microformats)
- end
-
- object = find_every(microformats)
- case object.size
- when 1 then object.first
- when 0 then nil
- else object
- end
- end
-
- def find_in_children(*args)
- @@subclasses.map do |klass|
- klass.find(*args)
- end.flatten
- end
-
- # i have no idea what the hell this is doing
- names_and_keys = proc do |attributes|
- attributes.map do |att|
- att.respond_to?(:keys) ? att.keys.first : att
- end
- end
-
- define_method :attributes do
- names_and_keys[@attributes[:many] + @attributes[:one]]
- end
-
- %w(many one).each do |type|
- define_method("#{type}s") do
- names_and_keys[@attributes[type.intern]]
- end
- end
-
- def timeout=(timeout)
- @@timeout = timeout
- end
-
- protected
- ##
- # DSL Related
- #
- def after_find(&block)
- @after_find_procs ||= Hash.new { |h,k| h[k] = [] }
- @after_find_procs[name] << block if block_given?
- @after_find_procs[name]
- end
- alias :after_finds :after_find
-
- def inherited(klass)
- @@subclasses << klass
- define_cute_class_name(klass)
- current_container = @container
- klass.class_eval do
- @container = current_container || name.downcase
- @attributes = Hash.new { |h,k| h[k] = [] }
- end
- end
-
- def define_cute_class_name(klass)
- return unless (name = klass.name) =~ /^H/
- Object.send(:define_method, name.sub(/^H/, 'h')) { klass }
- end
-
- def collector
- collector = Hash.new([])
- def collector.method_missing(method, *classes)
- super unless %w(one many).include? method.to_s
- self[method] += Microformat.send(:break_out_hashes, classes)
- end
- collector
- end
-
- def container(container)
- @container = container.to_s
- end
-
- def method_missing(method, *args, &block)
- super unless %w(one many).include? method.to_s
- (collected = collector).instance_eval(&block) if block_given?
- classes = block_given? ? [args.first => collected] : break_out_hashes(args)
- @attributes[method] += classes
- end
-
- def break_out_hashes(array)
- array.inject([]) do |memo, element|
- memo + (element.is_a?(Hash) ? [element.map { |k,v| { k => v } }].flatten : [element])
- end
- end
-
- def aliases(hash)
- define_method(hash.keys.first) do
- send(hash[hash.keys.first])
- end
- end
-
- ##
- # The Functionality
- #
- def find_first(doc)
- build_class(doc.first)
- end
-
- def find_every(doc)
- doc.inject([]) do |array, entry|
- array + [build_class(entry)]
- end
- end
-
- def build_doc(source)
- case source
- when String, File, StringIO
- result = ''
- Timeout.timeout(@@timeout) { result = open(source) }
- Hpricot(result)
- when Hpricot, Hpricot::Elements
- source
- when Hash
- Hpricot(source[:text]) if source[:text]
- end
- end
-
- def find_occurences(doc)
- doc/".#{@container}"
- end
-
- def build_class(microformat)
- hash = build_hash(microformat)
- class_eval { attr_reader *(hash.keys << :properties) }
-
- klass = new
- klass.instance_variable_set(:@properties, hash.keys.map { |i| i.to_s } )
-
- hash.each do |key, value|
- klass.instance_variable_set("@#{key}", prepare_value(value) )
- end
-
- after_find_callbacks! klass
-
- klass
- end
-
- def after_find_callbacks!(object)
- original_ivars = object.instance_variables.dup
-
- after_finds.each do |block|
- object.instance_eval &block
- end
-
- Array(object.instance_variables - original_ivars).each do |ivar|
- object.properties << ivar.gsub('@','')
- end
- end
-
- def build_hash(doc, attributes = @attributes)
- hash = {}
-
- # rel="bookmark" pattern
- if bookmark = extract_bookmark(doc)
- hash[:bookmark] = bookmark
- end
-
- # rel="license" pattern
- if license = extract_license(doc)
- hash[:license] = license
- end
-
- # rel="tag" pattern
- if tags = extract_tags(doc)
- hash[:tags] = tags
- end
-
- [:one, :many].each do |name|
- attributes[name].each do |attribute|
- is_hash = attribute.is_a? Hash
- key = is_hash ? attribute.keys.first : attribute
-
- found = doc/".#{key.no_bang.to_s.gsub('_','-')}"
- raise InvalidMicroformat if found.empty? && key.to_s =~ /!/
- next if found.empty?
-
- if is_hash && attribute[key].is_a?(Hash)
- built_hash = build_hash(found, attribute[key])
- key = key.no_bang
- if built_hash.size.zero? && found.size.nonzero?
- hash[key] = found.map { |f| parse_element(f) }
- hash[key] = hash[key].first if name == :one
- else
- hash[key] = built_hash
- end
- else
- target = is_hash ? attribute[key] : nil
- key = key.no_bang
- if name == :many
- hash[key] ||= []
- hash[key] += found.map { |f| parse_element(f, target) }
- else
- hash[key] = parse_element(found.first, target)
- end
- end
- hash[key] = hash[key].first if hash[key].is_a?(Array) && hash[key].size == 1
- end
- end
-
- hash.merge extract_includes(doc)
- end
-
- def extract_includes(doc)
- @includes ||= {}
-
- doc.search(".include").inject({}) do |hash, element|
- target = element.attributes['data'] || element.attributes['href']
-
- return @includes[target] if @includes[target]
-
- unless (includes = @doc/target).empty?
- hash.merge @includes[target] = build_hash(includes)
- else
- hash
- end
- end
- end
-
- def extract_bookmark(doc)
- bookmark = (doc.at("[@rel=bookmark]") || doc.at("[@rel='self bookmark']")) rescue nil
- bookmark.attributes['href'] if bookmark.respond_to? :attributes
- end
-
- def extract_license(doc)
- license = doc.at("[@rel=license]") rescue nil
- license.attributes['href'] if license.respond_to? :attributes
- end
-
- def extract_tags(doc)
- return unless (tags = doc.search("[@rel=tag]")).size.nonzero?
- tags.inject([]) { |array, tag| array + [tag.innerText] }
- end
-
- def parse_element(element, target = nil)
- if target == :url
- url = case element.name
- when 'img' then element['src']
- when 'a' then element['href']
- when 'object' then element['value']
- end
- url[/^http/] ? url : @options[:base_url].to_s + url if url.respond_to?(:[])
- elsif target.is_a? Array
- target.inject(nil) do |found, klass|
- klass = klass.respond_to?(:find) ? klass : nil
-
- found || parse_element(element, klass)
- end
- elsif target.is_a? Class
- target.find(@options.merge(:first => element))
- else
- value = case element.name
- when 'abbr' then element['title']
- when 'img' then element['alt']
- end || ''
-
- (value.empty? ? element.innerHTML : value).strip.strip_html.coerce
- end
- end
-
- def prepare_value(value)
- value.is_a?(Hash) ? OpenStruct.new(value) : value
- end
-
- def extract_base_url!(target)
- @options[:base_url] ||= @options[:base] || @options[:url]
- @options[:base_url] ||= target[/^(http:\/\/[^\/]+)/] if target.respond_to?(:scan)
- end
- end
-
- def method_missing(method, *args, &block)
- return super unless method == :properties || @properties.include?(method.to_s)
- self.class.class_eval { define_method(method) { instance_variable_get("@#{method}") } }
- instance_variable_get("@#{method}")
- end
-
- extend Base
-end
-
-class InvalidMicroformat < Exception; end
-class MicroformatNotFound < Exception; end
-
-# oh what the hell, let's do it
-Mofo = Microformat
-
-# type & id are used a lot in uformats and deprecated in ruby. no loss.
-OpenStruct.class_eval { undef :type, :id }
-Symbol.class_eval { def no_bang() to_s.sub('!','').to_sym end }
@@ -1,3 +0,0 @@
-$:.unshift File.dirname(__FILE__)
-
-Dir["#{File.dirname(__FILE__)}/mofo/*.rb"].each { |format| require "mofo/#{File.basename format}" }
Oops, something went wrong.

0 comments on commit 19c5724

Please sign in to comment.