Skip to content

Commit

Permalink
Update to Elixir 0.2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Apr 24, 2011
1 parent d701014 commit dd0ab45
Show file tree
Hide file tree
Showing 26 changed files with 86 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*.exb
exbin/
erl_crash.dump
3 changes: 3 additions & 0 deletions elixirc.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib/*.ex
lib/*/*.ex
lib/*/*/*.ex
2 changes: 0 additions & 2 deletions lib/ex_bridge.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
% elixir: cache [ex_bridge/request, ex_bridge/response, ex_bridge/websocket]

module ExBridge
def request('mochiweb, request, options := {:})
ExBridge::Mochiweb::Request.new(request, options)
Expand Down
4 changes: 0 additions & 4 deletions lib/ex_bridge/misultin.ex

This file was deleted.

2 changes: 0 additions & 2 deletions lib/ex_bridge/misultin/request.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
% elixir: cache

object ExBridge::Misultin::Request
proto ExBridge::Request

Expand Down
2 changes: 0 additions & 2 deletions lib/ex_bridge/misultin/response.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
% elixir: cache

object ExBridge::Misultin::Response
proto ExBridge::Response

Expand Down
2 changes: 0 additions & 2 deletions lib/ex_bridge/misultin/websocket.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
% elixir: cache

object ExBridge::Misultin::Websocket
proto ExBridge::Websocket

Expand Down
3 changes: 0 additions & 3 deletions lib/ex_bridge/mochiweb.ex

This file was deleted.

4 changes: 1 addition & 3 deletions lib/ex_bridge/mochiweb/request.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
% elixir: cache

object ExBridge::Mochiweb::Request
proto ExBridge::Request

Expand All @@ -24,7 +22,7 @@ object ExBridge::Mochiweb::Request
def cookies
@cookies || begin
list = Erlang.apply(@request, 'parse_cookie, [])
OrderedDict.from_list list.map(-> ({x,y}) { String.new(x), String.new(y) })
OrderedDict.from_list list.map(-> ({x,y}) { x.to_bin, y.to_bin })
end
end
Expand Down
2 changes: 0 additions & 2 deletions lib/ex_bridge/mochiweb/response.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
% elixir: cache

object ExBridge::Mochiweb::Response
proto ExBridge::Response

Expand Down
2 changes: 0 additions & 2 deletions lib/ex_bridge/request.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
% elixir: cache

module ExBridge::Request
def initialize(request, options := {:})
@('request: request, 'options: options || {:})
Expand Down
4 changes: 1 addition & 3 deletions lib/ex_bridge/response.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
% elixir: cache [date_time]

module ExBridge::Response
% TODO: Maybe an ordered dict is not the best/fastest way to represent the headers
object Headers
Expand Down Expand Up @@ -94,7 +92,7 @@ module ExBridge::Response
else
joined = File.join(@docroot, path)
if File.regular?(joined)
function()
function.()
200
else
self.respond(404, {:}, "Not Found")
Expand Down
2 changes: 0 additions & 2 deletions lib/ex_bridge/websocket.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
% elixir: cache

module ExBridge::Websocket
def initialize(socket)
@('socket: socket)
Expand Down
34 changes: 0 additions & 34 deletions runner.ex

This file was deleted.

52 changes: 52 additions & 0 deletions runner.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module Runner
def start([])
process ["test"]
end

def start(other)
process other
end

def process ["compile"|t]
compile!
process t
end

def process ["setup"|t]
execute "git submodule update --init"
execute "cd deps/mochiweb && make"
execute "cd deps/ibrowse && make"
execute "cd deps/misultin && make"
process t
end

def process ["test"|t]
compile!
execute "time exunit -pa exbin test/*_test.exs test/*/*_test.exs"
process t
end

def process [other|t]
IO.new('standard_error).puts "Unknown command: #{other}"
self.exit(1)
process t
end

def process []
% Done
end

private

def compile!
execute "elixirc -s elixirc.spec -o exbin"
end

def execute command
IO.puts command
result = OS.cmd command
IO.puts result
end
end

Runner.start(Code.argv)
2 changes: 1 addition & 1 deletion test/ex_bridge_test.ex → test/ex_bridge_test.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Code.require File.expand_path("../test_helper", __FILE__)
Code.require_file "../test_helper", __FILE__

object ExBridgeTest
proto ExUnit::Case
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Code.require File.expand_path("../test_helper", __FILE__)
Code.require_file "../test_helper", __FILE__

object Misultin::ServerTest
proto ExUnit::Case
Expand Down
7 changes: 0 additions & 7 deletions test/misultin/test_helper.ex

This file was deleted.

5 changes: 5 additions & 0 deletions test/misultin/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Code.require_file "../../test_helper", __FILE__
Code.prepend_path "deps/misultin/ebin"

options = ServerCase.server_options('misultin, 3002)
{ 'ok, _ } = Erlang.misultin.start_link options.to_list
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Code.require File.expand_path("../test_helper", __FILE__)
Code.require_file "../test_helper", __FILE__

object Mochiweb::ServerTest
proto ExUnit::Case
Expand Down
7 changes: 0 additions & 7 deletions test/mochiweb/test_helper.ex

This file was deleted.

5 changes: 5 additions & 0 deletions test/mochiweb/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Code.require_file "../../test_helper", __FILE__
Code.prepend_path "deps/mochiweb/ebin"

options = ServerCase.server_options('mochiweb, 3001).merge 'name: 'mochiweb_test
{ 'ok, _ } = Erlang.mochiweb_http.start options.to_list
File renamed without changes.
14 changes: 7 additions & 7 deletions test/support/server_case.ex → test/support/server_case.exs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ module ServerCase
end

def respond_file_loop(_request, response)
response = response.file "test/test_helper.ex"
"test/test_helper.ex" = response.file
response = response.file "test/test_helper.exs"
"test/test_helper.exs" = response.file
response.respond
end
Expand All @@ -112,19 +112,19 @@ module ServerCase
end

def serve_file_loop(_request, response)
response.serve_file "test/test_helper.ex"
response.serve_file "test/test_helper.exs"
end

def serve_file_with_headers_loop(_request, response)
response.serve_file "test/test_helper.ex", "Content-Disposition": "attachment; filename=\"cool.ex\""
response.serve_file "test/test_helper.exs", "Content-Disposition": "attachment; filename=\"cool.ex\""
end

def serve_unavailable_file_loop(_request, response)
response.serve_file "test/test_helper.ex.unknown"
response.serve_file "test/test_helper.exs.unknown"
end

def serve_forbidden_file_loop(_request, response)
response.serve_file "test/../test/test_helper.ex"
response.serve_file "test/../test/test_helper.exs"
end
def response_cookies_loop(_request, response)
Expand All @@ -149,7 +149,7 @@ module ServerCase
end

def request_cookies_loop request, response
["127.0.0.1"] = request.cookies
{"key1": "value1", "key2": "value2"} = request.cookies
response.respond 200, {}, "Ok"
end
end
12 changes: 0 additions & 12 deletions test/test_helper.ex

This file was deleted.

8 changes: 8 additions & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Code.require_file "../support/http_client", __FILE__
Code.require_file "../support/server_case", __FILE__

% Configure ExUnit, no options supported yet.
ExUnit.configure {:}

% ASSERTION FLAG
% Flag above used in tests

0 comments on commit dd0ab45

Please sign in to comment.