Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hojberg committed Sep 27, 2011
0 parents commit c6c6369
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.DS_Store
6 changes: 6 additions & 0 deletions Gemfile
@@ -0,0 +1,6 @@
source :rubygems

gem "rack"

gem "rack-test"
gem 'minitest'
12 changes: 12 additions & 0 deletions 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 changes: 2 additions & 0 deletions config.ru
@@ -0,0 +1,2 @@
require 'yui_combot'
run YUICombot.new
41 changes: 41 additions & 0 deletions 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 changes: 21 additions & 0 deletions 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

0 comments on commit c6c6369

Please sign in to comment.