panic_board_data 0.0.11 → 0.0.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d46bf21799bb39b94841bb52e40858a17bef28f1
4
- data.tar.gz: 6ee2a85894c6e02e3233eb119d0ea2086baa502e
3
+ metadata.gz: 350c071a10efa215974a4300d171338d18301de9
4
+ data.tar.gz: 07596eb9a3eec08357d2f6735d9b5f89973bb0f4
5
5
  SHA512:
6
- metadata.gz: e9f3b8c307eb035b0275473e83582ee4fa97e855ed7dbdd56f467c8aa19fb523bd7ede2392d04e2430a8efa80acef5d442146e8b4252b331f0a6a36ea23f5de9
7
- data.tar.gz: 026a9e90005555b32788ea0c2bb9bf16e1d5a1d4b48f39c42d57a7de10ac5721ccdac4665e3d94a9da5a68695c6723c13d58cd7f85f823c652f81a923bfdbe92
6
+ metadata.gz: 0a796e8dd7e60d47873eda067df2d7e4e71212bc2a1c5f72ad1a0d7aa1e8ac809c3a51dc7a05d35390d30b612d2c0a4dec5fb4c5fe71d6dcd8bbab5c873a52d1
7
+ data.tar.gz: 880fb51cca44e7d049cad9f7cc97f66ae847b499376fd629e47740ede9f21aa1d1b1cba33ad69e071a42d72cdde757af92cb9d861a61abd53abc098759158f51
@@ -4,4 +4,8 @@ module Kernel
4
4
  progress_bar.value = int
5
5
  progress_bar
6
6
  end
7
+
8
+ def build_image value
9
+ "<img src=\"#{value}\" />"
10
+ end
7
11
  end
@@ -0,0 +1,80 @@
1
+ module PanicBoardData
2
+
3
+ class SingleValue
4
+
5
+ def initialize heading, value
6
+ @heading, @value = heading, value
7
+ end
8
+
9
+ def to_html
10
+ <<EOF
11
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=utf8" />
15
+ <meta http-equiv="Cache-control" content="no-cache" />
16
+ <style type="text/css">
17
+ @font-face
18
+ {
19
+ font-family: "Roadgeek2005SeriesD";
20
+ src: url("http://panic.com/fonts/Roadgeek 2005 Series D/Roadgeek 2005 Series D.otf");
21
+ }
22
+
23
+ body, *
24
+ {}
25
+
26
+ body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td
27
+ { margin: 0; padding: 0; }
28
+
29
+ fieldset,img
30
+ { border: 0; }
31
+
32
+ html, body, #main
33
+ { overflow: hidden; }
34
+
35
+ body
36
+ { color: white; font-family: 'Roadgeek2005SeriesD', sans-serif; font-size: 20px; line-height: 24px; }
37
+
38
+ body, html, #main
39
+ { background: transparent !important; }
40
+
41
+ #Container
42
+ { text-align: center; }
43
+
44
+ #Container *
45
+ { font-weight: normal; }
46
+
47
+ h1
48
+ { font-size: 120px; line-height: 120px; margin-top: 15px;
49
+ margin-bottom: 0px; color: white;
50
+ text-shadow:0px -2px 0px black; text-transform: uppercase; }
51
+
52
+ h2
53
+ { margin: 0px auto; padding-top: 20px; font-size: 16px;
54
+ line-height: 18px; color: #7e7e7e; text-transform: uppercase; }
55
+ </style>
56
+
57
+ <script type="text/javascript">
58
+ function init()
59
+ {
60
+ if (document.location.href.indexOf('desktop') > -1)
61
+ document.getElementById('Container').style.backgroundColor = 'black';
62
+ }
63
+ </script>
64
+ </head>
65
+
66
+ <body onload="init()">
67
+ <div id="main">
68
+ <div id="Container">
69
+ <h2>#{@heading}</h2>
70
+ <h1 id="howmany">#{@value}</h1>
71
+ </div>
72
+ </div>
73
+ </body>
74
+ </html>
75
+ EOF
76
+ end
77
+
78
+ end
79
+
80
+ end
@@ -5,16 +5,12 @@ module PanicBoardData
5
5
 
6
6
  class Table
7
7
 
8
- attr_accessor :data, :widths, :base_image_url
8
+ attr_accessor :data, :widths
9
9
 
10
10
  def initialize(data = [])
11
11
  @data = data
12
12
  end
13
13
 
14
- def build_image value
15
- "<img src=\"#{url_for(value)}\" />"
16
- end
17
-
18
14
  def to_html
19
15
  "<table>#{data_to_table_rows}</table>"
20
16
  end
@@ -31,16 +27,6 @@ module PanicBoardData
31
27
 
32
28
  private
33
29
 
34
- def url_for value
35
- [self.base_image_url, value]
36
- .select { |x| x.to_s != '' }
37
- .map { |x| x.to_s.strip }
38
- .map { |x| x.gsub('/', '') }
39
- .join('/')
40
- .gsub('http:', 'http://')
41
- .gsub('https:', 'https://')
42
- end
43
-
44
30
  def data_to_table_rows
45
31
  return '' unless data
46
32
  data.map { |r| build_row_for r }.join
@@ -52,7 +38,7 @@ module PanicBoardData
52
38
  end
53
39
 
54
40
  def build_cell_for value, index
55
- value = flatten_a_value_array_to_a_single_value value
41
+ value = flatten_a_value_array_to_a_single_value(value).to_s
56
42
  width = get_width_for index
57
43
  render_cell value, width
58
44
  end
@@ -66,11 +52,15 @@ module PanicBoardData
66
52
  end
67
53
 
68
54
  def render_cell value, width
69
- return value.to_s if value.is_a? PanicBoardData::ProgressBar
55
+ return value if this_value_defines_a_td value
70
56
  width ? "<td style=\"width: #{width}px\">#{value}</td>"
71
57
  : "<td>#{value}</td>"
72
58
  end
73
59
 
60
+ def this_value_defines_a_td value
61
+ value[0..2] == '<td'
62
+ end
63
+
74
64
  end
75
65
 
76
66
  end
@@ -1,3 +1,3 @@
1
1
  module PanicBoardData
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -1,25 +1,41 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe "progress_bar_to" do
4
- [:value, :result].to_objects {[
5
- [1],
6
- [2],
7
- [8]
8
- ]}.each do |test|
4
+
5
+ [1, 2, 3, 4, 5, 6, 7, 8].each do |value|
9
6
 
10
7
  describe "progress bars" do
11
8
 
12
9
  before do
13
- @result = progress_bar_to(test.value)
10
+ @result = progress_bar_to(value)
14
11
  end
15
12
 
16
13
  it "should create a progress bar with the right value" do
17
14
  @result.is_a?(PanicBoardData::ProgressBar).must_equal true
18
- @result.value.must_equal test.value
15
+ @result.value.must_equal value
19
16
  end
20
17
 
21
18
  end
22
19
 
23
20
  end
24
21
 
22
+ [:value, :result].to_objects { [
23
+ [ 0, "<img src=\"0\" />"],
24
+ [ 1, "<img src=\"1\" />"],
25
+ [ 'apple.jpg', "<img src=\"apple.jpg\" />"],
26
+ ] }.each do |test|
27
+
28
+ describe "basic image use" do
29
+
30
+ before do
31
+ @result = build_image test.value
32
+ end
33
+
34
+ it "should return a result" do
35
+ @result.must_equal test.result
36
+ end
37
+
38
+ end
39
+
40
+ end
25
41
  end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe PanicBoardData::SingleValue do
4
+
5
+ let(:single_value) { PanicBoardData::SingleValue.new heading, value }
6
+
7
+ [:heading, :value, :length].to_objects {[
8
+ ['the heading', 'the value', 1727],
9
+ ['one', 'two', 1713]
10
+ ]}.each do |test|
11
+
12
+ describe "to_html" do
13
+ let(:heading) { test.heading }
14
+ let(:value) { test.value }
15
+
16
+ it "should return a bunch of html" do
17
+ result = single_value.to_html
18
+ result.length.must_equal test.length
19
+ result.include?(test.heading).must_equal true
20
+ result.include?(test.value).must_equal true
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -55,39 +55,35 @@ describe PanicBoardData::Table do
55
55
 
56
56
  end
57
57
 
58
- [:array, :first_width, :second_width, :result].to_objects { [
59
- [ [0], 125, nil, "<td style=\"width: 125px\">0</td>"],
60
- [ [1], 200, nil, "<td style=\"width: 200px\">1</td>"],
61
- [ [1, 2], 102, nil, "<td style=\"width: 102px\">1</td><td>2</td>"],
62
- [ [1, 2], 401, 500, "<td style=\"width: 401px\">1</td><td style=\"width: 500px\">2</td>"],
58
+ [:array, :result].to_objects { [
59
+ [ ["<td>X</td>"], "<td>X</td>"],
60
+ [ ["<td width=''>Y</td>"], "<td width=''>Y</td>"],
63
61
  ] }.each do |test|
64
62
 
65
- describe "one row, adjusted width" do
66
-
63
+ describe "a cell value that starts with a TD" do
67
64
  before do
68
- table.data = [test.array]
69
- table.widths = [test.first_width, test.second_width]
65
+ table.data = [test.array]
70
66
  @result = table.to_html
71
67
  end
72
68
 
73
69
  it "should return a result" do
74
70
  @result.must_equal "<table><tr>#{test.result}</tr></table>"
75
71
  end
76
-
77
72
  end
78
-
79
73
  end
80
74
 
81
- [:array, :result].to_objects { [
82
- [ [0], "<td><img src=\"0\" /></td>"],
83
- [ [1], "<td><img src=\"1\" /></td>"],
84
- [ ['apple.jpg'], "<td><img src=\"apple.jpg\" /></td>"],
75
+ [:array, :first_width, :second_width, :result].to_objects { [
76
+ [ [0], 125, nil, "<td style=\"width: 125px\">0</td>"],
77
+ [ [1], 200, nil, "<td style=\"width: 200px\">1</td>"],
78
+ [ [1, 2], 102, nil, "<td style=\"width: 102px\">1</td><td>2</td>"],
79
+ [ [1, 2], 401, 500, "<td style=\"width: 401px\">1</td><td style=\"width: 500px\">2</td>"],
85
80
  ] }.each do |test|
86
81
 
87
- describe "basic image use" do
82
+ describe "one row, adjusted width" do
88
83
 
89
84
  before do
90
- table.data = [test.array.map { |x| table.build_image x }]
85
+ table.data = [test.array]
86
+ table.widths = [test.first_width, test.second_width]
91
87
  @result = table.to_html
92
88
  end
93
89
 
@@ -107,7 +103,7 @@ describe PanicBoardData::Table do
107
103
  describe "stacking multiple images into a single cell" do
108
104
 
109
105
  before do
110
- table.data = [[[table.build_image(test.first_image), table.build_image(test.second_image)]]]
106
+ table.data = [[[build_image(test.first_image), build_image(test.second_image)]]]
111
107
  @result = table.to_html
112
108
  end
113
109
 
@@ -119,54 +115,6 @@ describe PanicBoardData::Table do
119
115
 
120
116
  end
121
117
 
122
- [:array, :base_image_url, :result].to_objects { [
123
- [ [0], "http://www.google.com", "<td><img src=\"http://www.google.com/0\" /></td>"],
124
- [ [1], "http://www.bing.com/", "<td><img src=\"http://www.bing.com/1\" /></td>"],
125
- [ ['apple.jpg'], nil, "<td><img src=\"apple.jpg\" /></td>"],
126
- [ ['apple.jpg'], '', "<td><img src=\"apple.jpg\" /></td>"],
127
- [ ['/apple.jpg'], 'http://www.bing.com/', "<td><img src=\"http://www.bing.com/apple.jpg\" /></td>"],
128
- [ ['/apple.jpg'], 'https://www.bing.com/', "<td><img src=\"https://www.bing.com/apple.jpg\" /></td>"],
129
- ] }.each do |test|
130
-
131
- describe "basic image use" do
132
-
133
- before do
134
- table.base_image_url = test.base_image_url
135
- table.data = [test.array.map { |x| table.build_image x }]
136
-
137
- @result = table.to_html
138
- end
139
-
140
- it "should return a result" do
141
- @result.must_equal "<table><tr>#{test.result}</tr></table>"
142
- end
143
-
144
- end
145
-
146
- end
147
-
148
- [:value, :result].to_objects {[
149
- [1, '<td class="projectsBars"><div class="barSegment value1"></div></td>'],
150
- [2, '<td class="projectsBars"><div class="barSegment value1"></div><div class="barSegment value2"></div></td>'],
151
- [8, '<td class="projectsBars"><div class="barSegment value1"></div><div class="barSegment value2"></div><div class="barSegment value3"></div><div class="barSegment value4"></div><div class="barSegment value5"></div><div class="barSegment value6"></div><div class="barSegment value7"></div><div class="barSegment value8"></div></td>']
152
- ]}.each do |test|
153
-
154
- describe "progress bars" do
155
-
156
- before do
157
- table.data = [['a', table.progress_bar_to(test.value)]]
158
-
159
- @result = table.to_html
160
- end
161
-
162
- it "should create a cell with the proper progress bar" do
163
- @result.must_equal "<table><tr><td>a</td>#{test.result}</tr></table>"
164
- end
165
-
166
- end
167
-
168
- end
169
-
170
118
  end
171
119
 
172
120
  [->(d) { PanicBoardData::Table.to_csv(d) },
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panic_board_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cauthon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-10 00:00:00.000000000 Z
11
+ date: 2013-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -111,11 +111,13 @@ files:
111
111
  - lib/panic_board_data/graph.rb
112
112
  - lib/panic_board_data/kernel.rb
113
113
  - lib/panic_board_data/progress_bar.rb
114
+ - lib/panic_board_data/single_value.rb
114
115
  - lib/panic_board_data/table.rb
115
116
  - lib/panic_board_data/version.rb
116
117
  - panic_board_data.gemspec
117
118
  - spec/panic_board_data/graph_spec.rb
118
119
  - spec/panic_board_data/kernel_spec.rb
120
+ - spec/panic_board_data/single_value_spec.rb
119
121
  - spec/panic_board_data/table_spec.rb
120
122
  - spec/spec_helper.rb
121
123
  homepage: ''
@@ -145,5 +147,6 @@ summary: Export data for Panic Board
145
147
  test_files:
146
148
  - spec/panic_board_data/graph_spec.rb
147
149
  - spec/panic_board_data/kernel_spec.rb
150
+ - spec/panic_board_data/single_value_spec.rb
148
151
  - spec/panic_board_data/table_spec.rb
149
152
  - spec/spec_helper.rb