forked from hojberg/rack-combobot
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c6c6369
Showing
6 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
source :rubygems | |||
|
|||
gem "rack" | |||
|
|||
gem "rack-test" | |||
gem 'minitest' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
GEM | |||
remote: http://rubygems.org/ | |||
specs: | |||
minitest (2.6.0) | |||
rack (1.3.0) | |||
|
|||
PLATFORMS | |||
ruby | |||
|
|||
DEPENDENCIES | |||
minitest | |||
rack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
require 'yui_combot' | |||
run YUICombot.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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 |