SimpleOutput 1.1.3 → 1.2.1

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: f811fbd06a4da856b597e44dcbffd32b4a75091b
4
- data.tar.gz: ecf8b08452983132ee44ba1ce9c90af5fd782e81
3
+ metadata.gz: b43102aa451e1122cb1729d25015153221fd980e
4
+ data.tar.gz: 6a478021615867f3befbe113bff398608fdd4729
5
5
  SHA512:
6
- metadata.gz: 4fde526633c956c4b90dd33059d1e4d1e43144afc1e28bbabf0aa62d40a0ed6769f8227b91b14fa6b7aa4ba0d3799e6860bab1ebd2b5a6ba4b9938f0d046698e
7
- data.tar.gz: c7c4e90392fbc4f6f93057457c79b07a202bb4b369e1c1a1c1b21540b66397074e3cadd1bfc0b93d60c7418d001f8460d018ad4fea97d10b503311bd4b79d2bc
6
+ metadata.gz: 25ff50585f15751ace4dcaf700bb815bd3705f3aa4abac0a031dd2784af615ba311d1260de751c7294eeaad3e6d0a940e6a442cf6dc05241f48741d2b1b5adb5
7
+ data.tar.gz: b8f667f40aca309a04aecdda8e33259b62dce092bc8805ab46d6ea936de88454db1c4213caae166fa0749a01c2cc978a8168fb4552d410cf50ccabebf190d31d
@@ -28,7 +28,6 @@ class SimpleChartkick < SimpleOutput::SimpleOutputPlugin
28
28
  @html = "<html>\n<title>\n#{title}\n</title>\n<script src='http://www.google.com/jsapi'></script>\n
29
29
  <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'></script>
30
30
  <script src='#{chartkick_path}'></script>\n<body>\n"
31
-
32
31
  end
33
32
 
34
33
  def check_title(name, options)
@@ -132,32 +131,30 @@ class SimpleChartkick < SimpleOutput::SimpleOutputPlugin
132
131
  self.chart_div("AreaChart", data)
133
132
  end
134
133
 
135
- def getMultiSeriesHashes
136
- data_hash = {}
137
-
138
- @x.each_pair do |(key, x_series)|
139
- data_hash[key] = []
140
- y_series = @y[key]
141
- x_series.each_with_index do |x_data, index|
142
-
143
- y_data = y_series[index]
144
- series_key = @series_names[key][index]
145
- data_hash[key] << {'name' => series_key}
146
- data_hash[key].last['data'] = {}
147
- x_data.each_with_index do |x_point, index|
148
- y_point = y_data[index]
149
- data_hash[key].last['data'][x_point] = y_point
150
- end
151
- end
152
- end
153
- return data_hash
134
+ def get_multiseries_hashes
135
+ data_hash = {}
136
+ @x.each_pair do |(key, x_series)|
137
+ data_hash[key] = []
138
+ y_series = @y[key]
139
+ x_series.each_with_index do |x_data, index|
140
+ y_data = y_series[index]
141
+ series_key = @series_names[key][index]
142
+ data_hash[key] << {'name' => series_key}
143
+ data_hash[key].last['data'] = {}
144
+ x_data.each_with_index do |x_point, index|
145
+ y_point = y_data[index]
146
+ data_hash[key].last['data'][x_point] = y_point
147
+ end
148
+ end
154
149
  end
150
+ return data_hash
151
+ end
155
152
 
156
153
  def save
157
154
  @chart_id = 0
158
155
  @js_block = ""
159
156
 
160
- self.getMultiSeriesHashes.each_pair do |(chart_name, chart_series)|
157
+ self.get_multiseries_hashes.each_pair do |(chart_name, chart_series)|
161
158
  if !@metadata.has_key?(chart_name)
162
159
  @metadata[chart_name] = {'chart_type' => 'LineChart', 'bincount' => 10}
163
160
  end
@@ -207,4 +204,4 @@ class SimpleChartkick < SimpleOutput::SimpleOutputPlugin
207
204
  end
208
205
  end
209
206
 
210
- end
207
+ end
data/lib/simplecsv.rb CHANGED
@@ -58,7 +58,7 @@ class SimpleCSV < SimpleOutput::SimpleOutputPlugin
58
58
  end
59
59
 
60
60
  def save()
61
- data = self.getDataAsXY()
61
+ data = self.get_data_as_xy()
62
62
  data.each do |set_name, series|
63
63
  CSV.open("#{@filename}_#{set_name}.csv", "wb") do |csv|
64
64
  xlabel = @metadata[set_name]['xlabel']
data/lib/simplelog.rb CHANGED
@@ -18,7 +18,7 @@ require 'time'
18
18
  class SimpleLog < SimpleOutput::SimpleOutputPlugin
19
19
  #Only supports annotation
20
20
  def initialize(name = "log", format="txt")
21
- filename = name + self.getTimestamp() + "." + format
21
+ filename = name + self.get_timestamp() + "." + format
22
22
  @file = File.new(filename, "w")
23
23
  @series_names = {}
24
24
  @data_id = 0
@@ -36,54 +36,54 @@ class SimpleLog < SimpleOutput::SimpleOutputPlugin
36
36
  end
37
37
 
38
38
 
39
- def setXData(data, name, options={})
39
+ def set_x_Data(data, name, options={})
40
40
 
41
41
  end
42
42
 
43
- def setYData(data, name, options={})
43
+ def set_y_data(data, name, options={})
44
44
 
45
45
  end
46
46
 
47
- def newData( x=[], y=[],name=nil, options={})
47
+ def new_data( x=[], y=[],name=nil, options={})
48
48
 
49
49
  end
50
50
 
51
51
  #Interface Functions ===================================
52
- def appendXY( x=[], y=[],name=nil, options={})
52
+ def append_xy( x=[], y=[],name=nil, options={})
53
53
  log_name(name)
54
54
  log_var(x, "Appending X Data")
55
55
  log_var(y, "Appending Y Data")
56
56
  end
57
57
 
58
- def setXY(x=[], y=[], name=nil, options={})
58
+ def set_xy(x=[], y=[], name=nil, options={})
59
59
  log_name(name)
60
60
  log_var(x, "Setting X Data")
61
61
  log_var(y, "Setting Y Data")
62
62
  end
63
63
 
64
- def appendPoints(points =[], name=nil, options={})
64
+ def append_points(points =[], name=nil, options={})
65
65
  log_name(name)
66
66
  log_var(points, "Appending (points)")
67
67
  end
68
68
 
69
- def setPoints(points = [], name=nil, options={})
69
+ def set_points(points = [], name=nil, options={})
70
70
  log_name(name)
71
71
  log_var(points, "Setting (points)")
72
72
  end
73
73
 
74
- def appendHash(hash = {}, name=nil, options={})
74
+ def append_hash(hash = {}, name=nil, options={})
75
75
  log_name(name)
76
76
  log_var(hash, "Appending (hash)")
77
77
  end
78
78
 
79
- def setHash(hash ={}, name=nil, options={})
79
+ def set_hash(hash ={}, name=nil, options={})
80
80
  log_name(name)
81
81
  log_var(hash, "Setting (hash)")
82
82
  end
83
83
 
84
84
 
85
85
 
86
- def setOptions(name=nil, options = {})
86
+ def set_options(name=nil, options = {})
87
87
  log_var(option, "Options")
88
88
  end
89
89
 
@@ -95,9 +95,9 @@ class SimpleLog < SimpleOutput::SimpleOutputPlugin
95
95
 
96
96
  def log(content, name = nil)
97
97
  if name != nil
98
- logtext = self.getTimestamp() + " #{name}: #{content}"
98
+ logtext = self.get_timestamp() + " #{name}: #{content}"
99
99
  else
100
- logtext = self.getTimestamp() + " #{content}"
100
+ logtext = self.get_timestamp() + " #{content}"
101
101
  end
102
102
  puts logtext
103
103
  @file.syswrite("#{logtext}\n")
@@ -147,19 +147,19 @@ class SimpleLog < SimpleOutput::SimpleOutputPlugin
147
147
 
148
148
 
149
149
 
150
- def getTimestamp()
150
+ def get_timestamp()
151
151
  Time.now.strftime("%Y-%m-%d-%H%M%S")
152
152
  end
153
153
 
154
- def getDataAsPoints
154
+ def get_data_as_points
155
155
  [[0,0]]
156
156
  end
157
157
 
158
- def getDataAsXY
158
+ def get_data_as_xy
159
159
  [[0],[0]]
160
160
  end
161
161
 
162
- def getSeriesHashes
162
+ def get_series_hashes
163
163
  {0 => 0}
164
164
  end
165
165
 
data/lib/simpleoutput.rb CHANGED
@@ -14,9 +14,6 @@ SimpleOutput
14
14
  See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  =end
17
-
18
-
19
-
20
17
 
21
18
  module SimpleOutput
22
19
  class SimpleOutputPlugin
@@ -83,28 +80,28 @@ module SimpleOutput
83
80
  (!@x.has_key?(name)) || (!@y.has_key?(name))
84
81
  end
85
82
 
86
- def setXData(data, name, options={})
83
+ def set_x_data(data, name, options={})
87
84
  @x[name] = []
88
85
  @x[name] << data
89
86
  self.set_x_callback(data, name, options)
90
87
  end
91
88
 
92
- def setYData(data, name, options={})
89
+ def set_y_data(data, name, options={})
93
90
  @y[name] = []
94
91
  @y[name] << data
95
92
  self.set_y_callback(data, name, options)
96
93
  end
97
94
 
98
- def newData( x=[], y=[],name=nil, options={})
95
+ def new_data( x=[], y=[],name=nil, options={})
99
96
  name = self.advance_series(name)
100
- self.setXData(x, name, options)
101
- self.setYData(y, name, options)
97
+ self.set_x_data(x, name, options)
98
+ self.set_y_data(y, name, options)
102
99
  self.append_series_name(name,options)
103
100
  self.options_callback(options)
104
101
  end
105
102
 
106
103
  #Interface Functions ===================================
107
- def appendXY( x=[], y=[],name=nil, options={})
104
+ def append_xy( x=[], y=[],name=nil, options={})
108
105
  name = translate_name(name)
109
106
  if !self.new_data_check(name)
110
107
  @x[name] << x
@@ -113,69 +110,43 @@ module SimpleOutput
113
110
  self.options_callback(options)
114
111
  self.append_callback(x,y,name,options)
115
112
  else
116
- self.newData(x,y,name,options)
113
+ self.new_data(x,y,name,options)
117
114
  end
118
115
  end
119
116
 
120
- def setXY(x=[], y=[], name=nil, options={})
121
- self.newData(x,y,name,options)
117
+ def set_xy(x=[], y=[], name=nil, options={})
118
+ self.new_data(x,y,name,options)
122
119
  end
123
120
 
124
- def appendPoints(points =[], name=nil, options={})
121
+ def append_points(points =[], name=nil, options={})
125
122
  x = []
126
123
  y = []
127
124
  points.each do |point|
128
125
  x << point[0]
129
126
  y << point[1]
130
127
  end
131
- self.appendXY(x,y,name,options)
128
+ self.append_xy(x,y,name,options)
132
129
  end
133
130
 
134
- def setPoints(points = [], name=nil, options={})
131
+ def set_points(points = [], name=nil, options={})
135
132
  x = []
136
133
  y = []
137
134
  points.each do |point|
138
135
  x << point[0]
139
136
  y << point[1]
140
137
  end
141
- self.setXY(x,y,name, options)
138
+ self.set_xy(x,y,name, options)
142
139
  end
143
140
 
144
- def appendHash(hash = {}, name=nil, options={})
141
+ def append_hash(hash = {}, name=nil, options={})
145
142
  name = translate_name(name)
146
- x = []
147
- y = []
148
- hash.each_with_index do |(key, value), index|
149
- if key.is_a? Numeric
150
- x << key
151
- else
152
- x << index
153
- end
154
- if value.is_a? Numeric
155
- y << value
156
- else
157
- y << 0
158
- end
159
- end
160
- self.appendXY(x,y,name,options)
143
+ x, y = self.hash_to_xy(hash)
144
+ self.append_xy(x,y,name,options)
161
145
  end
162
146
 
163
- def setHash(hash ={}, name=nil, options={})
164
- x = []
165
- y = []
166
- hash.each_with_index do |(key, value), index|
167
- if key.is_a? Numeric
168
- x << key
169
- else
170
- x << index
171
- end
172
- if value.is_a? Numeric
173
- y << value
174
- else
175
- y << 0
176
- end
177
- end
178
- self.setXY(x,y,name,options)
147
+ def set_hash(hash ={}, name=nil, options={})
148
+ x, y = self.hash_to_xy(hash)
149
+ self.set_xy(x,y,name,options)
179
150
  end
180
151
 
181
152
  def annotate(annotation, name=nil, options = {})
@@ -184,12 +155,12 @@ module SimpleOutput
184
155
  self.options_callback(options)
185
156
  end
186
157
 
187
- def setOptions(name=nil, options = {})
158
+ def set_options(name=nil, options = {})
188
159
  self.options_callback(options)
189
160
  end
190
161
 
191
162
  #Internal Helpers
192
- def getDataAsPoints
163
+ def get_data_as_points
193
164
  series_data = {}
194
165
  @x.each_pair do |(key, x_series)|
195
166
  #For each series of data
@@ -209,7 +180,7 @@ module SimpleOutput
209
180
  return series_data
210
181
  end
211
182
 
212
- def getDataAsXY
183
+ def get_data_as_xy
213
184
  series_data = {}
214
185
  @x.each_pair do |(key, x_series)|
215
186
  y_series = @y[key]
@@ -222,7 +193,7 @@ module SimpleOutput
222
193
  return series_data
223
194
  end
224
195
 
225
- def getSeriesHashes
196
+ def get_series_hashes
226
197
  data_hash = {}
227
198
 
228
199
  @x.each_pair do |(key, x_series)|
@@ -248,6 +219,25 @@ module SimpleOutput
248
219
 
249
220
  end
250
221
 
222
+ protected
223
+ def hash_to_xy(hash)
224
+ x = []
225
+ y = []
226
+ hash.each_with_index do |(key, value), index|
227
+ if key.is_a? Numeric
228
+ x << key
229
+ else
230
+ x << index
231
+ end
232
+ if value.is_a? Numeric
233
+ y << value
234
+ else
235
+ y << 0
236
+ end
237
+ end
238
+ return x, y
239
+ end
240
+
251
241
  end
252
242
 
253
243
  class SimpleOutputEngine
@@ -257,7 +247,7 @@ module SimpleOutput
257
247
  @data_id = 0
258
248
  end
259
249
 
260
- def addPlugin(plugin)
250
+ def add_plugin(plugin)
261
251
  @plugins << plugin
262
252
  end
263
253
 
@@ -265,50 +255,50 @@ module SimpleOutput
265
255
  #Hash [name] = y
266
256
  # array [x,y ]
267
257
  #Interface Functions
268
- def appendXY( x=[], y=[],name=nil, options={})
269
- @plugins.each {|plugin| plugin.appendXY(x.clone,y.clone,name, options)}
258
+ def append_xy( x=[], y=[],name=nil, options={})
259
+ @plugins.each {|plugin| plugin.append_xy(x.clone,y.clone,name, options)}
270
260
  end
271
261
 
272
- def appendXYarray(data=[], name=nil, options={})
273
- @plugins.each {|plugin| plugin.appendXY(data[0].clone,data[1].clone,name, options)}
262
+ def append_xy_array(data=[], name=nil, options={})
263
+ @plugins.each {|plugin| plugin.append_xy(data[0].clone,data[1].clone,name, options)}
274
264
  end
275
265
 
276
- def setXYarray(data = [], name=nil, options={})
277
- @plugins.each {|plugin| plugin.setXY(data[0].clone,data[1].clone, name, options)}
266
+ def set_xy_array(data = [], name=nil, options={})
267
+ @plugins.each {|plugin| plugin.set_xy(data[0].clone,data[1].clone, name, options)}
278
268
  end
279
269
 
280
- def setXY(x=[], y=[], name=nil, options={})
281
- @plugins.each {|plugin| plugin.setXY(x.clone,y.clone,name, options)}
270
+ def set_xy(x=[], y=[], name=nil, options={})
271
+ @plugins.each {|plugin| plugin.set_xy(x.clone,y.clone,name, options)}
282
272
  end
283
273
 
284
- def appendPoints(points =[], name=nil, options={})
285
- @plugins.each {|plugin| plugin.appendPoints(points.clone,name, options)}
274
+ def append_points(points =[], name=nil, options={})
275
+ @plugins.each {|plugin| plugin.append_points(points.clone,name, options)}
286
276
  end
287
277
 
288
- def setPoints(points = [], name=nil, options={})
289
- @plugins.each {|plugin| plugin.setPoints(points.clone,name, options)}
278
+ def set_points(points = [], name=nil, options={})
279
+ @plugins.each {|plugin| plugin.set_points(points.clone,name, options)}
290
280
  end
291
281
 
292
- def appendHash(hash = {}, name=nil, options={})
293
- @plugins.each {|plugin| plugin.appendHash(hash.clone,name, options)}
282
+ def append_hash(hash = {}, name=nil, options={})
283
+ @plugins.each {|plugin| plugin.append_hash(hash.clone,name, options)}
294
284
  end
295
285
 
296
- def setHash(hash ={}, name=nil, options={})
297
- @plugins.each {|plugin| plugin.setHash(hash.clone,name, options)}
286
+ def set_hash(hash ={}, name=nil, options={})
287
+ @plugins.each {|plugin| plugin.set_hash(hash.clone,name, options)}
298
288
  end
299
289
 
300
- def setArray(data = [], name=nil, options={})
290
+ def set_array(data = [], name=nil, options={})
301
291
  x = []
302
292
  data.count.times {|i| x << i}
303
293
  y = data
304
- self.setXY(x,y,name,options)
294
+ self.set_xy(x,y,name,options)
305
295
  end
306
296
 
307
- def appendArray(data = [], name=nil, options={})
297
+ def append_array(data = [], name=nil, options={})
308
298
  x = []
309
299
  data.count.times {|i| x << i}
310
300
  y = data.clone
311
- self.appendXY(x,y,name,options)
301
+ self.append_xy(x,y,name,options)
312
302
  end
313
303
 
314
304
  def annotate(annotation, name=nil, options={})
@@ -321,5 +311,4 @@ module SimpleOutput
321
311
 
322
312
  end
323
313
 
324
-
325
314
  end
data/lib/simpleplot.rb CHANGED
@@ -14,6 +14,7 @@ SimplePlot
14
14
  See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  =end
17
+
17
18
  class SimplePlot < SimpleOutput::SimpleOutputPlugin
18
19
  require 'gnuplot'
19
20
 
@@ -25,39 +26,7 @@ class SimplePlot < SimpleOutput::SimpleOutputPlugin
25
26
  end
26
27
 
27
28
  def options_callback(options)
28
- if options.has_key?('xsize')
29
- @metadata[@current_name]['xsize'] = options['xsize']
30
- end
31
- if options.has_key?('ysize')
32
- @metadata[@current_name]['ysize'] = options['ysize']
33
- end
34
- if options.has_key?('xlabel')
35
- @metadata[@current_name]['xlabel'] = options['xlabel']
36
- end
37
- if options.has_key?('ylabel')
38
- @metadata[@current_name]['ylabel'] = options['ylabel']
39
- end
40
- if options.has_key?('histogram')
41
- @metadata[@current_name]['histogram'] = options['histogram']
42
- end
43
- if options.has_key?('xmin')
44
- @metadata[@current_name]['xmin'] = options['xmin']
45
- end
46
- if options.has_key?('xmax')
47
- @metadata[@current_name]['xmax'] = options['xmax']
48
- end
49
- if options.has_key?('ymin')
50
- @metadata[@current_name]['ymin'] = options['ymin']
51
- end
52
- if options.has_key?('ymax')
53
- @metadata[@current_name]['ymax'] = options['ymax']
54
- end
55
- if options.has_key?('bincount')
56
- @metadata[@current_name]['bincount'] = options['bincount']
57
- end
58
- if options.has_key?('normalized')
59
- @metadata[@current_name]['normalized'] = options['normalized']
60
- end
29
+ @metadata[@current_name].merge! options
61
30
  end
62
31
 
63
32
  def check_title(name, options)
@@ -104,7 +73,7 @@ class SimplePlot < SimpleOutput::SimpleOutputPlugin
104
73
  end
105
74
 
106
75
  def save()
107
- data = self.getDataAsXY()
76
+ data = self.get_data_as_xy()
108
77
  data.each do |set_name, series|
109
78
  Gnuplot.open do |gp|
110
79
  Gnuplot::Plot.new(gp) do |plot|
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SimpleOutput
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austen Higgins-Cassidy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-27 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gnuplot
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.6'
20
- - - '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 2.6.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '2.6'
30
- - - '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.6.2
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: json
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1.7'
40
- - - '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: 1.7.7
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: '1.7'
50
- - - '>='
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: 1.7.7
53
- description: A pluging based graphing and report rendering system with multiple simultanous
54
- output systems supported
53
+ description: Takes data and outputs it to multiple formats and media using a simple
54
+ plugin system
55
55
  email: plasmarobo@gmail.com
56
56
  executables: []
57
57
  extensions: []
@@ -74,12 +74,12 @@ require_paths:
74
74
  - lib
75
75
  required_ruby_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - '>='
77
+ - - ">="
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - '>='
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
@@ -87,5 +87,5 @@ rubyforge_project:
87
87
  rubygems_version: 2.2.2
88
88
  signing_key:
89
89
  specification_version: 4
90
- summary: A Simple Engine to output data
90
+ summary: A Simple Engine to collect and then output data
91
91
  test_files: []