panic_board_data 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require 'csv'
3
3
  module PanicBoardData
4
4
  class Table
5
5
 
6
- attr_accessor :data
6
+ attr_accessor :data, :widths
7
7
 
8
8
  def to_html
9
9
  result = "<table>"
@@ -11,8 +11,12 @@ module PanicBoardData
11
11
  if data
12
12
  data.each do |record|
13
13
  result << "<tr>"
14
- record.each do |item|
15
- result << "<td>#{item}</td>"
14
+ record.each_with_index do |item, index|
15
+ if widths && widths[index]
16
+ result << "<td style=\"width: #{widths[index]}px\">#{item}</td>"
17
+ else
18
+ result << "<td>#{item}</td>"
19
+ end
16
20
  end
17
21
  result << "</tr>"
18
22
  end
@@ -1,3 +1,3 @@
1
1
  module PanicBoardData
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -39,6 +39,27 @@ describe PanicBoardData::Table do
39
39
  end
40
40
  end
41
41
 
42
+ [:array, :first_width, :second_width, :result].to_objects { [
43
+ [ [0], 125, nil, "<td style=\"width: 125px\">0</td>"],
44
+ [ [1], 200, nil, "<td style=\"width: 200px\">1</td>"],
45
+ [ [1, 2], 102, nil, "<td style=\"width: 102px\">1</td><td>2</td>"],
46
+ [ [1, 2], 401, 500, "<td style=\"width: 401px\">1</td><td style=\"width: 500px\">2</td>"],
47
+ ] }.each do |test|
48
+
49
+ describe "one row, adjusted width" do
50
+
51
+ before do
52
+ table.data = [test.array]
53
+ table.widths = [test.first_width, test.second_width]
54
+ @result = table.to_html
55
+ end
56
+
57
+ it "should return a result" do
58
+ @result.must_equal "<table><tr>#{test.result}</tr></table>"
59
+ end
60
+ end
61
+ end
62
+
42
63
  end
43
64
 
44
65
  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.6
4
+ version: 0.0.7
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: 1900610976032698658
146
+ hash: 3709807899752654922
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: 1900610976032698658
155
+ hash: 3709807899752654922
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 1.8.24
158
+ rubygems_version: 1.8.25
159
159
  signing_key:
160
160
  specification_version: 3
161
161
  summary: Export data for Panic Board