ruby_reportable 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b04f619cf3775ffacbf265722b9f168f43d88702
4
+ data.tar.gz: d3f891c8f6d3be584b5c1895b8bffb8181faf3fa
5
+ SHA512:
6
+ metadata.gz: 9ee540862f28daed7fa72d27ec7d7434041c58bf1d2f27e7e088f81d54db7232b0a5c1d98fe9007f111eb77c359362bd4ef48e63c093e203768c093980b78e7e
7
+ data.tar.gz: 1c981b6af75c60f80ec14e2753f132027ec222eb5c0ac7d920878d5e8e5ab383fa1a88590908099a5c0abe775614352167594836dc4db856cddf12854611cceb
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ vendor/bundle
2
+ .bundle
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p195
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_reportable (0.1.3)
4
+ ruby_reportable (0.3.0)
5
5
 
6
6
  GEM
7
- remote: http://rubygems.org/
7
+ remote: https://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.1.3)
10
10
  rr (1.0.4)
@@ -1,6 +1,8 @@
1
+ require 'benchmark'
2
+
1
3
  module RubyReportable
2
4
  module Report
3
- attr_accessor :data_source, :outputs, :filters
5
+ attr_accessor :data_source, :filters
4
6
 
5
7
  def clear
6
8
  @outputs = []
@@ -9,6 +11,17 @@ module RubyReportable
9
11
  @report = self.to_s
10
12
  @category = 'Reports'
11
13
  @meta = {}
14
+ @benchmarks = {}
15
+ end
16
+
17
+ # :sandbox, :filters, :finalize, :output, :group, :sort
18
+ def benchmarks
19
+ @benchmarks ||= {}
20
+ end
21
+
22
+ def benchmark(name)
23
+ benchmarks[name] ||= 0.0
24
+ benchmarks[name] += (Benchmark.realtime { yield if block_given? } * 1000)
12
25
  end
13
26
 
14
27
  def meta(key, value = nil, &block)
@@ -54,13 +67,21 @@ module RubyReportable
54
67
  end
55
68
 
56
69
  def output(name, options = {}, &block)
57
- @outputs << RubyReportable::Output.new(name, options, block) if options[:hidden].nil? || options[:hidden] == false
70
+ @outputs << RubyReportable::Output.new(name, options, block)
58
71
  end
59
72
 
60
73
 
61
74
  #
62
75
  # methods you shouldn't use inside the blocks
63
76
  #
77
+ def outputs(hidden = false)
78
+ if hidden
79
+ @outputs
80
+ else
81
+ @outputs.select {|output| output[:hidden] != true}
82
+ end
83
+ end
84
+
64
85
  def useable_filters(scope)
65
86
  @filters.values.select {|filter| !filter[:input].nil? && (filter[:use].nil? || filter[:use].call(scope))}.sort_by {|filter| filter[:priority].to_i}
66
87
  end
@@ -150,22 +171,34 @@ module RubyReportable
150
171
  options = {:input => {}}.merge(options)
151
172
 
152
173
  # initial sandbox
153
- sandbox = _source(options)
174
+ benchmark(:sandbox) do
175
+ sandbox = _source(options)
176
+ end
154
177
 
155
178
  # apply filters to source
156
- filtered_sandbox = _data(sandbox, options)
179
+ benchmark(:filters) do
180
+ filtered_sandbox = _data(sandbox, options)
181
+ end
157
182
 
158
183
  # finalize raw data from source
159
- source_data = _finalize(filtered_sandbox, options).source
184
+ benchmark(:finalize) do
185
+ source_data = _finalize(filtered_sandbox, options).source
186
+ end
160
187
 
161
188
  # {:default => [{outputs => values}]
162
- data = _output(source_data, options)
189
+ benchmark(:output) do
190
+ data = _output(source_data, options)
191
+ end
163
192
 
164
193
  # transform into {group => [outputs => values]}
165
- grouped = _group(options[:group], data, options)
194
+ benchmark(:group) do
195
+ grouped = _group(options[:group], data, options)
196
+ end
166
197
 
167
198
  # sort grouped data
168
- _sort(options[:sort], grouped, options)
199
+ benchmark(:sort) do
200
+ _sort(options[:sort], grouped, options)
201
+ end
169
202
  end # end def run
170
203
 
171
204
  def valid?(options = {})
@@ -1,3 +1,3 @@
1
1
  module RubyReportable
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_reportable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - John 'asceth' Long
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-30 00:00:00.000000000 Z
11
+ date: 2013-06-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rr
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Allows you to write reports that use existing ruby classes/methods to
@@ -52,7 +47,9 @@ extensions: []
52
47
  extra_rdoc_files: []
53
48
  files:
54
49
  - .gemtest
50
+ - .gitignore
55
51
  - .rspec
52
+ - .ruby-version
56
53
  - .rvmrc
57
54
  - Gemfile
58
55
  - Gemfile.lock
@@ -78,27 +75,26 @@ files:
78
75
  - spec/spec_helper.rb
79
76
  homepage: http://github.com/asceth/ruby_reportable
80
77
  licenses: []
78
+ metadata: {}
81
79
  post_install_message:
82
80
  rdoc_options: []
83
81
  require_paths:
84
82
  - lib
85
83
  required_ruby_version: !ruby/object:Gem::Requirement
86
- none: false
87
84
  requirements:
88
- - - ! '>='
85
+ - - '>='
89
86
  - !ruby/object:Gem::Version
90
87
  version: '0'
91
88
  required_rubygems_version: !ruby/object:Gem::Requirement
92
- none: false
93
89
  requirements:
94
- - - ! '>='
90
+ - - '>='
95
91
  - !ruby/object:Gem::Version
96
92
  version: '0'
97
93
  requirements: []
98
94
  rubyforge_project: ruby_reportable
99
- rubygems_version: 1.8.23
95
+ rubygems_version: 2.0.2
100
96
  signing_key:
101
- specification_version: 3
97
+ specification_version: 4
102
98
  summary: Ruby Reporting
103
99
  test_files:
104
100
  - spec/base_spec.rb