Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit

  • Loading branch information...
commit c6c63695348c3ef16c8e00a0de0609720425b2e3 0 parents
@hojberg hojberg authored
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
6 Gemfile
@@ -0,0 +1,6 @@
+source :rubygems
+
+gem "rack"
+
+gem "rack-test"
+gem 'minitest'
12 Gemfile.lock
@@ -0,0 +1,12 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ minitest (2.6.0)
+ rack (1.3.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ minitest
+ rack
2  config.ru
@@ -0,0 +1,2 @@
+require 'yui_combot'
+run YUICombot.new
41 rack_combot.rb
@@ -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
21 test/rack_combot_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.