Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit c6c63695348c3ef16c8e00a0de0609720425b2e3 @hojberg hojberg committed Sep 27, 2011
Showing with 83 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +6 −0 Gemfile
  3. +12 −0 Gemfile.lock
  4. +2 −0 config.ru
  5. +41 −0 rack_combot.rb
  6. +21 −0 test/rack_combot_spec.rb
@@ -0,0 +1 @@
+.DS_Store
@@ -0,0 +1,6 @@
+source :rubygems
+
+gem "rack"
+
+gem "rack-test"
+gem 'minitest'
@@ -0,0 +1,12 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ minitest (2.6.0)
+ rack (1.3.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ minitest
+ rack
@@ -0,0 +1,2 @@
+require 'yui_combot'
+run YUICombot.new
@@ -0,0 +1,41 @@
+class RackCombot
+ @@combinations = {}
+
+ def call(env)
+ qa = env["QUERY_STRING"]
+
+ if @@combinations.has_key? qs
+ combination = @@combinations[qs]
+ else
+ combination = Combination.new(qs.split("&"))
+ @@combinations[qs] = combination
+ end
+
+ [
+ 200,
+ {"Content-Type" => "application/javascript"},
+ combination.combine
+ ]
+ end
+
+private
+
+ class Combination
+
+ def initialize(file_names)
+ @file_contents = []
+
+ file_names.each do |file_name|
+ @file_contents << File.open(file_name, 'r') { |f| f.read }
+ end
+
+ @files = files
+ end
+
+ def combine
+ @combo ||= @files.join
+ end
+
+ end
+
+end
@@ -0,0 +1,21 @@
+require 'rubygems'
+require 'rack/test'
+require 'minitest/spec'
+require 'minitest/autorun'
+require File.expand_path(File.dirname(__FILE__) + '/../rack_combot')
+
+describe "something" do
+ include Rack::Test::Methods
+
+ before do
+ @app = RackCombo.new
+ end
+
+ it "combines files" do
+
+ 3.must_equal(4)
+ end
+
+ after(:each) do
+ end
+end

0 comments on commit c6c6369

Please sign in to comment.