Permalink
Browse files

Put the directories in git

  • Loading branch information...
1 parent 5db5154 commit 8db273f1bf7a28c845da0e9985fc9b80c8adb126 Yehuda Katz committed Nov 13, 2009
Showing with 6,863 additions and 2 deletions.
  1. +0 −1 vendor/gems/dirs/multimap
  2. +20 −0 vendor/gems/dirs/multimap/MIT-LICENSE
  3. +1 −0 vendor/gems/dirs/multimap/README.rdoc
  4. +49 −0 vendor/gems/dirs/multimap/Rakefile
  5. +60 −0 vendor/gems/dirs/multimap/benchmarks/bm_nested_multimap_construction.rb
  6. +33 −0 vendor/gems/dirs/multimap/benchmarks/bm_nested_multimap_lookup.rb
  7. +2 −0 vendor/gems/dirs/multimap/ext/extconf.rb
  8. +17 −0 vendor/gems/dirs/multimap/ext/nested_multimap_ext.c
  9. +86 −0 vendor/gems/dirs/multimap/extras/graphing.rb
  10. +467 −0 vendor/gems/dirs/multimap/lib/multimap.rb
  11. +153 −0 vendor/gems/dirs/multimap/lib/multiset.rb
  12. +151 −0 vendor/gems/dirs/multimap/lib/nested_multimap.rb
  13. +20 −0 vendor/gems/dirs/multimap/multimap.gemspec
  14. +50 −0 vendor/gems/dirs/multimap/spec/enumerable_examples.rb
  15. +230 −0 vendor/gems/dirs/multimap/spec/hash_examples.rb
  16. +83 −0 vendor/gems/dirs/multimap/spec/multimap_spec.rb
  17. +172 −0 vendor/gems/dirs/multimap/spec/multiset_spec.rb
  18. +185 −0 vendor/gems/dirs/multimap/spec/nested_multimap_spec.rb
  19. +301 −0 vendor/gems/dirs/multimap/spec/set_examples.rb
  20. +0 −1 vendor/gems/dirs/rack-mount
  21. +20 −0 vendor/gems/dirs/rack-mount/LICENSE
  22. +28 −0 vendor/gems/dirs/rack-mount/README.rdoc
  23. +55 −0 vendor/gems/dirs/rack-mount/Rakefile
  24. +47 −0 vendor/gems/dirs/rack-mount/benchmark/bm_collisions_recognition.rb
  25. +41 −0 vendor/gems/dirs/rack-mount/benchmark/bm_nested_recognition.rb
  26. +10 −0 vendor/gems/dirs/rack-mount/benchmark/bm_optimizations_benchmark.rb
  27. +146 −0 vendor/gems/dirs/rack-mount/benchmark/helper.rb
  28. +11 −0 vendor/gems/dirs/rack-mount/benchmark/profile.rb
  29. +2 −0 vendor/gems/dirs/rack-mount/deps.rip
  30. +35 −0 vendor/gems/dirs/rack-mount/lib/rack/mount.rb
  31. +51 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/analysis/frequency.rb
  32. +25 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/analysis/histogram.rb
  33. +145 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/analysis/splitting.rb
  34. +45 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/const.rb
  35. +3 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/exceptions.rb
  36. +163 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/generatable_regexp.rb
  37. +57 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/generation/route.rb
  38. +163 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/generation/route_set.rb
  39. +104 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/meta_method.rb
  40. +47 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/mixover.rb
  41. +94 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/multimap.rb
  42. +31 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/prefix.rb
  43. +99 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/recognition/code_generation.rb
  44. +59 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/recognition/route.rb
  45. +88 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/recognition/route_set.rb
  46. +49 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/regexp_with_named_groups.rb
  47. +69 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/route.rb
  48. +109 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/route_set.rb
  49. +93 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/strexp.rb
  50. +260 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/utils.rb
  51. +466 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/vendor/multimap/multimap.rb
  52. +153 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/vendor/multimap/multiset.rb
  53. +156 −0 vendor/gems/dirs/rack-mount/lib/rack/mount/vendor/multimap/nested_multimap.rb
  54. +41 −0 vendor/gems/dirs/rack-mount/rack-mount.gemspec
  55. +89 −0 vendor/gems/dirs/rack-mount/test/abstract_unit.rb
  56. +3 −0 vendor/gems/dirs/rack-mount/test/dev.rip
  57. +6 −0 vendor/gems/dirs/rack-mount/test/fixtures.rb
  58. +1 −0 vendor/gems/dirs/rack-mount/test/fixtures/basic_set.rb
  59. +9 −0 vendor/gems/dirs/rack-mount/test/fixtures/basic_set_map.rb
  60. +93 −0 vendor/gems/dirs/rack-mount/test/fixtures/basic_set_map_19.rb
  61. +8 −0 vendor/gems/dirs/rack-mount/test/fixtures/default_set.rb
  62. +7 −0 vendor/gems/dirs/rack-mount/test/fixtures/echo_app.rb
  63. +18 −0 vendor/gems/dirs/rack-mount/test/fixtures/linear_basic_set.rb
  64. +1 −0 vendor/gems/dirs/rack-mount/test/fixtures/optimized_basic_set.rb
  65. +189 −0 vendor/gems/dirs/rack-mount/test/test_analyzer.rb
  66. +184 −0 vendor/gems/dirs/rack-mount/test/test_generatable_regexp.rb
  67. +106 −0 vendor/gems/dirs/rack-mount/test/test_generation.rb
  68. +139 −0 vendor/gems/dirs/rack-mount/test/test_meta_method.rb
  69. +40 −0 vendor/gems/dirs/rack-mount/test/test_mixover.rb
  70. +139 −0 vendor/gems/dirs/rack-mount/test/test_multimap.rb
  71. +66 −0 vendor/gems/dirs/rack-mount/test/test_prefix.rb
  72. +372 −0 vendor/gems/dirs/rack-mount/test/test_recognition.rb
  73. +28 −0 vendor/gems/dirs/rack-mount/test/test_regexp_with_named_groups.rb
  74. +100 −0 vendor/gems/dirs/rack-mount/test/test_route_set.rb
  75. +150 −0 vendor/gems/dirs/rack-mount/test/test_strexp.rb
  76. +70 −0 vendor/gems/dirs/rack-mount/test/test_utils.rb
Submodule multimap deleted from 648e87
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Joshua Peek
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
+= Multimap
@@ -0,0 +1,49 @@
+begin
+ require 'mg'
+ mg = MG.new('multimap.gemspec')
+ $spec = mg.spec
+rescue LoadError
+end
+
+
+require 'rake/rdoctask'
+
+Rake::RDocTask.new { |rdoc|
+ rdoc.title = 'Multimap'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.options << '--charset' << 'utf-8'
+
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+}
+
+namespace :rdoc do
+ task :publish => :rdoc do
+ Dir.chdir(File.dirname(__FILE__)) do
+ system "scp -r html/* joshpeek@rubyforge.org:/var/www/gforge-projects/multimap/"
+ end
+ end
+end
+
+task :default => :spec
+
+require 'spec/rake/spectask'
+
+Spec::Rake::SpecTask.new do |t|
+ t.libs << 'lib'
+ t.ruby_opts = ['-w']
+end
+
+
+begin
+ require 'rake/extensiontask'
+
+ Rake::ExtensionTask.new do |ext|
+ ext.name = 'nested_multimap_ext'
+ ext.gem_spec = $spec
+ end
+
+ desc "Run specs using C ext"
+ task "spec:ext" => [:compile, :spec, :clobber]
+rescue LoadError
+end
@@ -0,0 +1,60 @@
+$: << 'lib'
+require 'nested_multimap'
+
+tiny_mapping = {
+ ["a"] => 100
+}
+
+medium_mapping = {
+ ["a"] => 100,
+ ["a", "b", "c"] => 200,
+ ["b"] => 300,
+ ["b", "c"] => 400,
+ ["c"] => 500,
+ ["c", "d"] => 600,
+ ["c", "d", "e"] => 700,
+ ["c", "d", "e", "f"] => 800
+}
+
+huge_mapping = {}
+alpha = ("a".."zz").to_a
+100.times do |n|
+ keys = ("a"..alpha[n % alpha.length]).to_a
+ huge_mapping[keys] = n * 100
+end
+
+require 'benchmark'
+
+Benchmark.bmbm do |x|
+ x.report("base:") {
+ NestedMultimap.new
+ }
+
+ x.report("tiny:") {
+ map = NestedMultimap.new
+ tiny_mapping.each_pair { |keys, value|
+ map[*keys] = value
+ }
+ }
+
+ x.report("medium:") {
+ map = NestedMultimap.new
+ medium_mapping.each_pair { |keys, value|
+ map[*keys] = value
+ }
+ }
+
+ x.report("huge:") {
+ map = NestedMultimap.new
+ huge_mapping.each_pair { |keys, value|
+ map[*keys] = value
+ }
+ }
+end
+
+# Pure Ruby
+# user system total real
+# base: 0.000000 0.000000 0.000000 ( 0.000014)
+# tiny: 0.000000 0.000000 0.000000 ( 0.000054)
+# medium: 0.000000 0.000000 0.000000 ( 0.000186)
+# huge: 0.050000 0.000000 0.050000 ( 0.051302)
@@ -0,0 +1,33 @@
+$: << 'lib'
+require 'nested_multimap'
+
+hash = { "a" => true }
+
+map = NestedMultimap.new
+map["a"] = 100
+map["a", "b", "c"] = 200
+map["a", "b", "c", "d", "e", "f"] = 300
+
+require 'benchmark'
+
+TIMES = 100_000
+Benchmark.bmbm do |x|
+ x.report("base:") { TIMES.times { hash["a"] } }
+ x.report("best:") { TIMES.times { map["a"] } }
+ x.report("average:") { TIMES.times { map["a", "b", "c"] } }
+ x.report("worst:") { TIMES.times { map["a", "b", "c", "d", "e", "f"] } }
+end
+
+# Pure Ruby
+# user system total real
+# base: 0.050000 0.000000 0.050000 ( 0.049722)
+# best: 0.480000 0.010000 0.490000 ( 0.491012)
+# average: 0.770000 0.000000 0.770000 ( 0.773535)
+# worst: 1.120000 0.010000 1.130000 ( 1.139097)
+
+# C extension
+# user system total real
+# base: 0.050000 0.000000 0.050000 ( 0.050990)
+# best: 0.090000 0.000000 0.090000 ( 0.088981)
+# average: 0.130000 0.000000 0.130000 ( 0.132098)
+# worst: 0.150000 0.000000 0.150000 ( 0.158293)
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('nested_multimap_ext')
@@ -0,0 +1,17 @@
+#include "ruby.h"
+
+static VALUE rb_nested_multimap_aref(int argc, VALUE *argv, VALUE self)
+{
+ int i;
+ VALUE r, k;
+
+ for (i = 0, r = self, k = TYPE(self); TYPE(r) == k; i++)
+ r = (i < argc) ? rb_hash_aref(r, argv[i]) : RHASH(r)->ifnone;
+
+ return r;
+}
+
+void Init_nested_multimap_ext() {
+ VALUE cNestedMultimap = rb_const_get(rb_cObject, rb_intern("NestedMultimap"));
+ rb_define_method(cNestedMultimap, "[]", rb_nested_multimap_aref, -1);
+}
@@ -0,0 +1,86 @@
+require 'rubygems'
+
+gem 'ruby-graphviz'
+require 'graphviz'
+
+class Object
+ def to_graph_node
+ "node#{object_id}"
+ end
+
+ def to_graph_label
+ inspect.dot_escape
+ end
+
+ def add_to_graph(graph)
+ graph.add_node(to_graph_node, :label => to_graph_label)
+ end
+end
+
+class Array
+ def to_graph_label
+ "{#{map { |e| e.to_graph_label }.join('|')}}"
+ end
+end
+
+class String
+ DOT_ESCAPE = %w( \\ < > { } " " )
+ DOT_ESCAPE_REGEXP = Regexp.compile("(#{Regexp.union(*DOT_ESCAPE).source})")
+
+ def dot_escape
+ gsub(DOT_ESCAPE_REGEXP) {|s| "\\#{s}" }
+ end
+end
+
+class Multimap < Hash
+ def to_graph_label
+ label = []
+ hash_each_pair do |key, _|
+ label << "<#{key.to_graph_node}> #{key.to_graph_label}"
+ end
+ "#{label.join('|')}|<default>"
+ end
+
+ def add_to_graph(graph)
+ hash_node = super
+
+ hash_each_pair do |key, container|
+ node = container.add_to_graph(graph)
+ graph.add_edge("#{hash_node.name}:#{key.to_graph_node}", node)
+ end
+
+ unless default.nil?
+ node = default.add_to_graph(graph)
+ graph.add_edge("#{hash_node.name}:default", node)
+ end
+
+ hash_node
+ end
+
+ def to_graph
+ g = GraphViz::new('G')
+ g[:nodesep] = '.05'
+ g[:rankdir] = 'LR'
+
+ g.node[:shape] = 'record'
+ g.node[:width] = '.1'
+ g.node[:height] = '.1'
+
+ add_to_graph(g)
+
+ g
+ end
+
+ def open_graph!
+ to_graph.output(:path => '/opt/local/bin/', :file => '/tmp/graph.dot')
+ system('open /tmp/graph.dot')
+ end
+end
+
+if __FILE__ == $0
+ $: << 'lib'
+ require 'multimap'
+
+ map = Multimap['a' => 100, 'b' => [200, 300]]
+ map.open_graph!
+end
Oops, something went wrong.

0 comments on commit 8db273f

Please sign in to comment.