panic_board_data 0.0.5 → 0.0.6

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.
@@ -3,8 +3,22 @@ require 'csv'
3
3
  module PanicBoardData
4
4
  class Table
5
5
 
6
+ attr_accessor :data
7
+
6
8
  def to_html
7
- "<table></table>"
9
+ result = "<table>"
10
+
11
+ if data
12
+ data.each do |record|
13
+ result << "<tr>"
14
+ record.each do |item|
15
+ result << "<td>#{item}</td>"
16
+ end
17
+ result << "</tr>"
18
+ end
19
+ end
20
+
21
+ result << "</table>"
8
22
  end
9
23
 
10
24
  def self.to_csv data
@@ -1,3 +1,3 @@
1
1
  module PanicBoardData
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,18 +1,15 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe PanicBoardData::Table do
4
- it "should exist" do
5
- PanicBoardData::Table.nil?.must_equal false
4
+
5
+ let(:table) do
6
+ PanicBoardData::Table.new
6
7
  end
7
8
 
8
9
  describe "to_html" do
9
10
 
10
11
  describe "empty table" do
11
12
 
12
- let(:table) do
13
- PanicBoardData::Table.new
14
- end
15
-
16
13
  before do
17
14
  @result = table.to_html
18
15
  end
@@ -23,6 +20,25 @@ describe PanicBoardData::Table do
23
20
 
24
21
  end
25
22
 
23
+ [:array, :result].to_objects { [
24
+ [ [0], "<td>0</td>"],
25
+ [ [1], "<td>1</td>"],
26
+ [ [1, 2], "<td>1</td><td>2</td>"],
27
+ ] }.each do |test|
28
+
29
+ describe "one row" do
30
+
31
+ before do
32
+ table.data = [test.array]
33
+ @result = table.to_html
34
+ end
35
+
36
+ it "should return a result" do
37
+ @result.must_equal "<table><tr>#{test.result}</tr></table>"
38
+ end
39
+ end
40
+ end
41
+
26
42
  end
27
43
 
28
44
  describe "to_csv" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panic_board_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: -4148033820212453287
146
+ hash: 1900610976032698658
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  none: false
149
149
  requirements:
@@ -152,10 +152,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  segments:
154
154
  - 0
155
- hash: -4148033820212453287
155
+ hash: 1900610976032698658
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 1.8.25
158
+ rubygems_version: 1.8.24
159
159
  signing_key:
160
160
  specification_version: 3
161
161
  summary: Export data for Panic Board