hotwire 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +82 -0
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/hotwire.gemspec +30 -23
- data/lib/hotwire.rb +13 -7
- data/lib/hotwire/base.rb +44 -0
- data/lib/hotwire/request.rb +60 -0
- data/lib/hotwire/response.rb +18 -0
- data/lib/hotwire/response/base.rb +54 -0
- data/lib/hotwire/response/csv.rb +17 -0
- data/lib/hotwire/response/html.rb +11 -0
- data/lib/hotwire/response/invalid.rb +16 -0
- data/lib/hotwire/response/json.rb +96 -0
- data/test/response/test_base.rb +46 -0
- data/test/response/test_csv.rb +27 -0
- data/test/response/test_html.rb +26 -0
- data/test/response/test_invalid.rb +24 -0
- data/test/response/test_json.rb +30 -0
- data/test/test_active_record_mixins.rb +61 -65
- data/test/test_helper.rb +12 -0
- data/test/test_request.rb +56 -0
- data/test/test_response.rb +42 -0
- metadata +31 -24
- data/README.makrdown +0 -46
- data/lib/hotwire/active_record_mixins.rb +0 -95
- data/lib/hotwire/column_headers.rb +0 -54
- data/lib/hotwire/core_extensions.rb +0 -11
- data/lib/hotwire/row.rb +0 -46
- data/lib/hotwire/table.rb +0 -27
- data/test/active_record_test_helper.rb +0 -14
- data/test/test_column_headers.rb +0 -20
- data/test/test_core_extensions.rb +0 -26
- data/test/test_row.rb +0 -17
- data/test/test_table.rb +0 -40
data/test/test_column_headers.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TestColumnHeaders < Test::Unit::TestCase
|
4
|
-
context "a Hotwire::ColumnHeaders instance" do
|
5
|
-
setup do
|
6
|
-
time = Time.utc(2010, 10, 19, 9, 38, 10)
|
7
|
-
@headers = Hotwire::ColumnHeaders.new({:columns => ['started at', 'name', 'years', 'location'], :rows => [[time, "bob", 21, nil]]})
|
8
|
-
end
|
9
|
-
|
10
|
-
context "to_wire" do
|
11
|
-
should "return a propperly formatted array" do
|
12
|
-
expected = [{"type"=>"datetime", "id"=>"started at", "label"=>"Started at"},
|
13
|
-
{"type"=>"string", "id"=>"name", "label"=>"Name"},
|
14
|
-
{"type"=>"number", "id"=>"years", "label"=>"Years"},
|
15
|
-
{"type"=>"string", "id"=>"location", "label"=>"Location"}]
|
16
|
-
assert_equal expected, @headers.to_wire
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TestCoreExtensions < Test::Unit::TestCase
|
4
|
-
context "a Hash" do
|
5
|
-
context "to_wire" do
|
6
|
-
context "with propper data" do
|
7
|
-
setup do
|
8
|
-
time = Time.local(2010, 10, 19, 9, 38, 10)
|
9
|
-
@hash = {:columns => ['started at', 'name', 'years', 'location'], :rows => [[time, "bob", 21, nil]]}
|
10
|
-
end
|
11
|
-
|
12
|
-
should "return a propperly formatted hash" do
|
13
|
-
expected = { "table"=> { "rows"=> [ {"c"=> [{"v"=>"Date(2010, 9, 19, 9, 38, 10)"},
|
14
|
-
{"v"=>"bob"},
|
15
|
-
{"v"=>21},
|
16
|
-
{"v"=>0}]}],
|
17
|
-
"cols"=> [{"type"=>"datetime", "id"=>"started at", "label"=>"Started at"},
|
18
|
-
{"type"=>"string", "id"=>"name", "label"=>"Name"},
|
19
|
-
{"type"=>"number", "id"=>"years", "label"=>"Years"},
|
20
|
-
{"type"=>"string", "id"=>"location", "label"=>"Location"}]}}
|
21
|
-
assert_equal expected, @hash.to_wire
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/test/test_row.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TestRow < Test::Unit::TestCase
|
4
|
-
context "a Hotwire::Row instance" do
|
5
|
-
setup do
|
6
|
-
time = Time.local(2010, 10, 19, 9, 38, 10)
|
7
|
-
@row = Hotwire::Row.new([time, "value1", nil])
|
8
|
-
end
|
9
|
-
|
10
|
-
context "to_wire" do
|
11
|
-
should "return a propperly formatted hash" do
|
12
|
-
expected = { 'c' => [{ 'v' => "Date(2010, 9, 19, 9, 38, 10)" }, { 'v' => "value1" }, { 'v' => 0 } ] }
|
13
|
-
assert_equal expected, @row.to_wire
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/test/test_table.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TestTable < Test::Unit::TestCase
|
4
|
-
context "inializing from a Hash" do
|
5
|
-
|
6
|
-
should "raise an ArgumentError if :columns are not specified" do
|
7
|
-
assert_raise ArgumentError do
|
8
|
-
Hotwire::Table.new({:rows => []})
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
should "raise an ArgumentError if :rows are not specified" do
|
13
|
-
assert_raise ArgumentError do
|
14
|
-
Hotwire::Table.new({:columns => []})
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
context "a Hotwire::Date instance" do
|
21
|
-
setup do
|
22
|
-
time = Time.local(2010, 10, 19, 9, 38, 10)
|
23
|
-
@data = Hotwire::Table.new({:columns => ['started at', 'name', 'years', 'location'], :rows => [[time, "bob", 21, nil]]})
|
24
|
-
end
|
25
|
-
|
26
|
-
context "to_wire" do
|
27
|
-
should "return a properly formatted hash" do
|
28
|
-
expected = { "table"=> { "rows"=> [ {"c"=> [{"v"=>"Date(2010, 9, 19, 9, 38, 10)"},
|
29
|
-
{"v"=>"bob"},
|
30
|
-
{"v"=>21},
|
31
|
-
{"v"=>0}]}],
|
32
|
-
"cols"=> [{"type"=>"datetime", "id"=>"started at", "label"=>"Started at"},
|
33
|
-
{"type"=>"string", "id"=>"name", "label"=>"Name"},
|
34
|
-
{"type"=>"number", "id"=>"years", "label"=>"Years"},
|
35
|
-
{"type"=>"string", "id"=>"location", "label"=>"Location"}]}}
|
36
|
-
assert_equal expected, @data.to_wire
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|