ghaki-report 2011.11.30.1 → 2011.12.06.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.
- data/VERSION +1 -1
- data/lib/ghaki/report/errors.rb +1 -2
- data/lib/ghaki/report/{base.rb → mixin/basic.rb} +17 -12
- data/lib/ghaki/report/mixin/output_file.rb +34 -0
- data/spec/ghaki/report/mixin/basic_spec.rb +145 -0
- data/spec/ghaki/report/mixin/linear_parser_spec.rb +5 -8
- data/spec/ghaki/report/mixin/output_file_spec.rb +51 -0
- metadata +24 -24
- data/lib/ghaki/report/output_file.rb +0 -41
- data/spec/ghaki/report/base_spec.rb +0 -70
- data/spec/ghaki/report/output_file_spec.rb +0 -32
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2011.
|
|
1
|
+
2011.12.06.1
|
data/lib/ghaki/report/errors.rb
CHANGED
|
@@ -3,17 +3,20 @@ require 'ghaki/stats/mixin'
|
|
|
3
3
|
|
|
4
4
|
module Ghaki #:nodoc:
|
|
5
5
|
module Report #:nodoc:
|
|
6
|
+
module Mixin #:nodoc:
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
module Basic
|
|
8
9
|
include Ghaki::Logger::Mixin
|
|
9
10
|
include Ghaki::Stats::Mixin
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
class << self
|
|
12
|
+
module ClassMethods
|
|
13
13
|
attr_accessor :report_name
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
def self.included klass #:nodoc:
|
|
17
|
+
klass.extend ClassMethods
|
|
18
|
+
end
|
|
19
|
+
|
|
17
20
|
def initialize opts={}
|
|
18
21
|
self.report_name = opts[:report_name] unless opts[:report_name].nil?
|
|
19
22
|
@stats = opts[:stats]
|
|
@@ -26,23 +29,26 @@ class Base
|
|
|
26
29
|
end
|
|
27
30
|
end
|
|
28
31
|
|
|
29
|
-
######################################################################
|
|
30
32
|
def report_name= title
|
|
31
|
-
|
|
33
|
+
if title.nil?
|
|
34
|
+
@report_name = self.class.report_name
|
|
35
|
+
elsif title[0,1] == '.'
|
|
36
|
+
@report_name = (@report_name || self.class.report_name) + title
|
|
37
|
+
else
|
|
38
|
+
@report_name = title
|
|
39
|
+
end
|
|
32
40
|
end
|
|
33
41
|
|
|
34
|
-
######################################################################
|
|
35
42
|
def report_name title=nil
|
|
36
43
|
if title.nil?
|
|
37
|
-
self.class.report_name
|
|
44
|
+
@report_name || self.class.report_name
|
|
38
45
|
elsif title[0,1] == '.'
|
|
39
|
-
self.class.report_name + title
|
|
46
|
+
(@report_name || self.class.report_name) + title
|
|
40
47
|
else
|
|
41
48
|
title
|
|
42
49
|
end
|
|
43
50
|
end
|
|
44
51
|
|
|
45
|
-
######################################################################
|
|
46
52
|
def minor_report_wrap title=nil, &block
|
|
47
53
|
logger.minor.wrap( report_name(title) ) do
|
|
48
54
|
begin
|
|
@@ -53,7 +59,6 @@ class Base
|
|
|
53
59
|
end
|
|
54
60
|
end
|
|
55
61
|
|
|
56
|
-
######################################################################
|
|
57
62
|
def major_report_wrap title=nil, &block
|
|
58
63
|
logger.major.wrap( report_name(title) ) do
|
|
59
64
|
begin
|
|
@@ -65,4 +70,4 @@ class Base
|
|
|
65
70
|
end
|
|
66
71
|
|
|
67
72
|
end
|
|
68
|
-
end end
|
|
73
|
+
end end end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'ghaki/core_ext/file/with_temp'
|
|
2
|
+
|
|
3
|
+
module Ghaki #:nodoc:
|
|
4
|
+
module Report #:nodoc:
|
|
5
|
+
module Mixin #:nodoc:
|
|
6
|
+
|
|
7
|
+
module OutputFile
|
|
8
|
+
|
|
9
|
+
attr_accessor :output_file
|
|
10
|
+
|
|
11
|
+
def initialize opts={} ; super opts
|
|
12
|
+
@output_file = opts[:output_file]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def output_report
|
|
16
|
+
output_prepare
|
|
17
|
+
File.with_opened_temp @output_file do |tmp_file|
|
|
18
|
+
output_to_format tmp_file
|
|
19
|
+
end
|
|
20
|
+
output_finish
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def output_finish
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def output_prepare
|
|
27
|
+
logger.info 'output file: ' + @output_file
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def output_to_format out_file
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end end end
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
require 'ghaki/report/mixin/basic'
|
|
2
|
+
require 'ghaki/logger/spec_helper'
|
|
3
|
+
require 'ghaki/stats/spec_helper'
|
|
4
|
+
|
|
5
|
+
module Ghaki module Report module Mixin module Basic_Testing
|
|
6
|
+
describe Basic do
|
|
7
|
+
include Ghaki::Logger::SpecHelper
|
|
8
|
+
include Ghaki::Stats::SpecHelper
|
|
9
|
+
|
|
10
|
+
SET_NAME = 'SET_NAME'
|
|
11
|
+
DEF_NAME = 'DEFAULT_NAME'
|
|
12
|
+
SUB_NAME = '.SUB_NAME'
|
|
13
|
+
SET_SUB_FULL = 'SET_NAME.SUB_NAME'
|
|
14
|
+
DEF_SUB_FULL = 'DEFAULT_NAME.SUB_NAME'
|
|
15
|
+
|
|
16
|
+
class MyReport
|
|
17
|
+
include Ghaki::Report::Mixin::Basic
|
|
18
|
+
self.report_name = DEF_NAME
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'meta class' do
|
|
22
|
+
subject { MyReport }
|
|
23
|
+
it { should respond_to :report_name }
|
|
24
|
+
it { should respond_to :report_name= }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context 'object instance' do
|
|
28
|
+
|
|
29
|
+
before(:each) do
|
|
30
|
+
setup_safe_stats
|
|
31
|
+
reset_safe_logger
|
|
32
|
+
@my_report = MyReport.new({
|
|
33
|
+
:logger => @logger,
|
|
34
|
+
:stats => @stats,
|
|
35
|
+
})
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
subject { @my_report }
|
|
39
|
+
|
|
40
|
+
it { should be_kind_of(Ghaki::Logger::Mixin) }
|
|
41
|
+
it { should be_kind_of(Ghaki::Stats::Mixin) }
|
|
42
|
+
|
|
43
|
+
it { should respond_to :logger }
|
|
44
|
+
it { should respond_to :logger= }
|
|
45
|
+
it { should respond_to :stats }
|
|
46
|
+
it { should respond_to :stats= }
|
|
47
|
+
|
|
48
|
+
describe '#initialize' do
|
|
49
|
+
context 'using option :report_name' do
|
|
50
|
+
it 'accepts full name' do
|
|
51
|
+
MyReport.new( :report_name => SET_NAME ).report_name == SET_NAME
|
|
52
|
+
end
|
|
53
|
+
it 'defaults to meta report name' do
|
|
54
|
+
MyReport.new.report_name.should == DEF_NAME
|
|
55
|
+
end
|
|
56
|
+
it 'accepts partial name using default' do
|
|
57
|
+
MyReport.new( :report_name => SUB_NAME ).report_name == DEF_SUB_FULL
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
context 'using option :stats' do
|
|
61
|
+
it 'defaults' do
|
|
62
|
+
Ghaki::Stats::Base.expects(:new).returns(@stats)
|
|
63
|
+
MyReport.new.
|
|
64
|
+
stats.should == @stats
|
|
65
|
+
end
|
|
66
|
+
it 'accepts' do
|
|
67
|
+
MyReport.new( :stats => @stats ).
|
|
68
|
+
stats.should == @stats
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
context 'using option :logger' do
|
|
72
|
+
it 'defaults' do
|
|
73
|
+
Ghaki::Logger::Base.expects(:new).returns(@logger)
|
|
74
|
+
MyReport.new.
|
|
75
|
+
logger.should == @logger
|
|
76
|
+
end
|
|
77
|
+
it 'accepts' do
|
|
78
|
+
MyReport.new( :logger => @logger).
|
|
79
|
+
logger.should == @logger
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe '#report_name' do
|
|
85
|
+
it 'defaults to meta report name' do
|
|
86
|
+
subject.report_name.should == DEF_NAME
|
|
87
|
+
end
|
|
88
|
+
it 'accepts full report name' do
|
|
89
|
+
subject.report_name(SET_NAME).should == SET_NAME
|
|
90
|
+
end
|
|
91
|
+
it 'accepts partial name with default' do
|
|
92
|
+
subject.report_name(SUB_NAME).should == DEF_SUB_FULL
|
|
93
|
+
end
|
|
94
|
+
it 'accepts partial name after override' do
|
|
95
|
+
subject.report_name = SET_NAME
|
|
96
|
+
subject.report_name(SUB_NAME).should == SET_SUB_FULL
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe '#report_name=' do
|
|
101
|
+
it 'assigns report name' do
|
|
102
|
+
subject.report_name = SET_NAME
|
|
103
|
+
subject.report_name.should == SET_NAME
|
|
104
|
+
end
|
|
105
|
+
it 'resets to default name on nil' do
|
|
106
|
+
subject.report_name = SET_NAME
|
|
107
|
+
subject.report_name = nil
|
|
108
|
+
subject.report_name.should == DEF_NAME
|
|
109
|
+
end
|
|
110
|
+
it 'accepts partial name with default' do
|
|
111
|
+
subject.report_name = SUB_NAME
|
|
112
|
+
subject.report_name.should == DEF_SUB_FULL
|
|
113
|
+
end
|
|
114
|
+
it 'accepts partial name after override' do
|
|
115
|
+
subject.report_name = SET_NAME
|
|
116
|
+
subject.report_name = SUB_NAME
|
|
117
|
+
subject.report_name.should == SET_SUB_FULL
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
describe '#minor_report_wrap' do
|
|
122
|
+
it 'calls logger minor mode with default report name' do
|
|
123
|
+
@logger.minor.expects(:wrap).with(DEF_NAME).once
|
|
124
|
+
subject.minor_report_wrap do end
|
|
125
|
+
end
|
|
126
|
+
it 'calls logger minor mode with given report name' do
|
|
127
|
+
@logger.minor.expects(:wrap).with(SET_NAME).once
|
|
128
|
+
subject.minor_report_wrap SET_NAME do end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
describe '#major_report_wrap' do
|
|
133
|
+
it 'calls logger major mode with default report name' do
|
|
134
|
+
@logger.major.expects(:wrap).with(DEF_NAME).once
|
|
135
|
+
subject.major_report_wrap do end
|
|
136
|
+
end
|
|
137
|
+
it 'calls logger major mode with given report name' do
|
|
138
|
+
@logger.major.expects(:wrap).with(SET_NAME).once
|
|
139
|
+
subject.major_report_wrap SET_NAME do end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end end end end
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
require 'ghaki/report/mixin/basic'
|
|
2
|
+
require 'ghaki/report/mixin/linear_parser'
|
|
1
3
|
require 'ghaki/logger/spec_helper'
|
|
2
4
|
require 'ghaki/stats/spec_helper'
|
|
3
|
-
require 'ghaki/report/base'
|
|
4
|
-
require 'ghaki/report/mixin/linear_parser'
|
|
5
5
|
|
|
6
6
|
module Ghaki module Report module Mixin module LinearParser_Testing
|
|
7
7
|
describe LinearParser do
|
|
8
8
|
include Ghaki::Logger::SpecHelper
|
|
9
9
|
include Ghaki::Stats::SpecHelper
|
|
10
10
|
|
|
11
|
-
class MyParser
|
|
12
|
-
include
|
|
11
|
+
class MyParser
|
|
12
|
+
include Ghaki::Report::Mixin::Basic
|
|
13
|
+
include Ghaki::Report::Mixin::LinearParser
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
before(:each) do
|
|
@@ -32,10 +33,6 @@ describe LinearParser do
|
|
|
32
33
|
it { should respond_to :parser_warn_max }
|
|
33
34
|
it { should respond_to :parser_warn_max= }
|
|
34
35
|
|
|
35
|
-
before(:each) do
|
|
36
|
-
@stats.clear
|
|
37
|
-
end
|
|
38
|
-
|
|
39
36
|
describe '#parser_startup' do
|
|
40
37
|
it 'defaults parser unknown max' do
|
|
41
38
|
subject.parser_unknown_max = nil
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'ghaki/report/mixin/basic'
|
|
2
|
+
require 'ghaki/report/mixin/output_file'
|
|
3
|
+
require 'ghaki/logger/spec_helper'
|
|
4
|
+
require 'ghaki/stats/spec_helper'
|
|
5
|
+
require 'ghaki/core_ext/file/spec_helper/fake_temp'
|
|
6
|
+
|
|
7
|
+
module Ghaki module Report module Mixin module OutputFileTesting
|
|
8
|
+
describe OutputFile do
|
|
9
|
+
include Ghaki::Logger::SpecHelper
|
|
10
|
+
include Ghaki::Stats::SpecHelper
|
|
11
|
+
include Ghaki::CoreExt::File::SpecHelper::FakeTemp
|
|
12
|
+
|
|
13
|
+
FAKE_OUT = '/tmp/myfile.txt'
|
|
14
|
+
|
|
15
|
+
class MyReport
|
|
16
|
+
include Ghaki::Report::Mixin::Basic
|
|
17
|
+
include Ghaki::Report::Mixin::OutputFile
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
before(:each) do
|
|
21
|
+
setup_safe_stats
|
|
22
|
+
reset_safe_logger
|
|
23
|
+
setup_fake_tempfile
|
|
24
|
+
@subj = MyReport.new({
|
|
25
|
+
:logger => @logger,
|
|
26
|
+
:stats => @stats,
|
|
27
|
+
:output_file => FAKE_OUT,
|
|
28
|
+
})
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
subject { @subj }
|
|
32
|
+
|
|
33
|
+
it { should respond_to :output_file }
|
|
34
|
+
it { should respond_to :output_file= }
|
|
35
|
+
it { should respond_to :output_report }
|
|
36
|
+
it { should respond_to :output_finish }
|
|
37
|
+
it { should respond_to :output_prepare }
|
|
38
|
+
it { should respond_to :output_to_format }
|
|
39
|
+
|
|
40
|
+
describe '#output_report' do
|
|
41
|
+
it 'should create file' do
|
|
42
|
+
abc = sequence('reporting')
|
|
43
|
+
subject.expects(:output_prepare).once.in_sequence(abc)
|
|
44
|
+
subject.expects(:output_to_format).with(@fake_tempfile).once.in_sequence(abc)
|
|
45
|
+
subject.expects(:output_finish).once.in_sequence(abc)
|
|
46
|
+
subject.output_report
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end end end end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ghaki-report
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2011.
|
|
4
|
+
version: 2011.12.06.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2011-
|
|
12
|
+
date: 2011-12-10 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: ghaki-app
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &80503420 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: 2011.11.29.1
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *80503420
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: ghaki-ext-file
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &80503200 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: 2011.11.29.1
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *80503200
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: ghaki-logger
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &80502980 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ! '>='
|
|
@@ -43,10 +43,10 @@ dependencies:
|
|
|
43
43
|
version: 2011.11.29.1
|
|
44
44
|
type: :runtime
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *80502980
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: ghaki-match
|
|
49
|
-
requirement: &
|
|
49
|
+
requirement: &80502760 !ruby/object:Gem::Requirement
|
|
50
50
|
none: false
|
|
51
51
|
requirements:
|
|
52
52
|
- - ! '>='
|
|
@@ -54,10 +54,10 @@ dependencies:
|
|
|
54
54
|
version: 2011.11.30.1
|
|
55
55
|
type: :runtime
|
|
56
56
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *80502760
|
|
58
58
|
- !ruby/object:Gem::Dependency
|
|
59
59
|
name: ghaki-stats
|
|
60
|
-
requirement: &
|
|
60
|
+
requirement: &80502540 !ruby/object:Gem::Requirement
|
|
61
61
|
none: false
|
|
62
62
|
requirements:
|
|
63
63
|
- - ! '>='
|
|
@@ -65,10 +65,10 @@ dependencies:
|
|
|
65
65
|
version: 2011.11.29.1
|
|
66
66
|
type: :runtime
|
|
67
67
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *80502540
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rspec
|
|
71
|
-
requirement: &
|
|
71
|
+
requirement: &80502320 !ruby/object:Gem::Requirement
|
|
72
72
|
none: false
|
|
73
73
|
requirements:
|
|
74
74
|
- - ! '>='
|
|
@@ -76,10 +76,10 @@ dependencies:
|
|
|
76
76
|
version: 2.4.0
|
|
77
77
|
type: :development
|
|
78
78
|
prerelease: false
|
|
79
|
-
version_requirements: *
|
|
79
|
+
version_requirements: *80502320
|
|
80
80
|
- !ruby/object:Gem::Dependency
|
|
81
81
|
name: mocha
|
|
82
|
-
requirement: &
|
|
82
|
+
requirement: &80502090 !ruby/object:Gem::Requirement
|
|
83
83
|
none: false
|
|
84
84
|
requirements:
|
|
85
85
|
- - ! '>='
|
|
@@ -87,10 +87,10 @@ dependencies:
|
|
|
87
87
|
version: 0.9.12
|
|
88
88
|
type: :development
|
|
89
89
|
prerelease: false
|
|
90
|
-
version_requirements: *
|
|
90
|
+
version_requirements: *80502090
|
|
91
91
|
- !ruby/object:Gem::Dependency
|
|
92
92
|
name: rdoc
|
|
93
|
-
requirement: &
|
|
93
|
+
requirement: &80501860 !ruby/object:Gem::Requirement
|
|
94
94
|
none: false
|
|
95
95
|
requirements:
|
|
96
96
|
- - ! '>='
|
|
@@ -98,7 +98,7 @@ dependencies:
|
|
|
98
98
|
version: 3.9.4
|
|
99
99
|
type: :development
|
|
100
100
|
prerelease: false
|
|
101
|
-
version_requirements: *
|
|
101
|
+
version_requirements: *80501860
|
|
102
102
|
description: Collection of extensions for basic reporting.
|
|
103
103
|
email: gerald@kalafut.org
|
|
104
104
|
executables: []
|
|
@@ -106,16 +106,16 @@ extensions: []
|
|
|
106
106
|
extra_rdoc_files:
|
|
107
107
|
- README
|
|
108
108
|
files:
|
|
109
|
+
- lib/ghaki/report/mixin/basic.rb
|
|
109
110
|
- lib/ghaki/report/mixin/linear_parser.rb
|
|
110
|
-
- lib/ghaki/report/output_file.rb
|
|
111
|
+
- lib/ghaki/report/mixin/output_file.rb
|
|
111
112
|
- lib/ghaki/report/errors.rb
|
|
112
|
-
- lib/ghaki/report/base.rb
|
|
113
113
|
- README
|
|
114
114
|
- LICENSE
|
|
115
115
|
- VERSION
|
|
116
|
-
- spec/ghaki/report/
|
|
116
|
+
- spec/ghaki/report/mixin/basic_spec.rb
|
|
117
117
|
- spec/ghaki/report/mixin/linear_parser_spec.rb
|
|
118
|
-
- spec/ghaki/report/output_file_spec.rb
|
|
118
|
+
- spec/ghaki/report/mixin/output_file_spec.rb
|
|
119
119
|
- spec/spec_helper.rb
|
|
120
120
|
homepage: http://github.com/ghaki
|
|
121
121
|
licenses: []
|
|
@@ -142,7 +142,7 @@ signing_key:
|
|
|
142
142
|
specification_version: 3
|
|
143
143
|
summary: Basic reporting helpers
|
|
144
144
|
test_files:
|
|
145
|
-
- spec/ghaki/report/
|
|
145
|
+
- spec/ghaki/report/mixin/basic_spec.rb
|
|
146
146
|
- spec/ghaki/report/mixin/linear_parser_spec.rb
|
|
147
|
-
- spec/ghaki/report/output_file_spec.rb
|
|
147
|
+
- spec/ghaki/report/mixin/output_file_spec.rb
|
|
148
148
|
- spec/spec_helper.rb
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require 'ghaki/core_ext/file/with_temp'
|
|
2
|
-
require 'ghaki/report/base'
|
|
3
|
-
|
|
4
|
-
module Ghaki #:nodoc:
|
|
5
|
-
module Report #:nodoc:
|
|
6
|
-
|
|
7
|
-
class OutputFile < Base
|
|
8
|
-
|
|
9
|
-
######################################################################
|
|
10
|
-
attr_accessor :output_file
|
|
11
|
-
|
|
12
|
-
######################################################################
|
|
13
|
-
def initialize opts={} ; super opts
|
|
14
|
-
self.class.report_name ||= 'WRITING REPORT'
|
|
15
|
-
@output_file = opts[:output_file]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
######################################################################
|
|
19
|
-
def output_report
|
|
20
|
-
output_prepare
|
|
21
|
-
logger.info 'output file: ' + @output_file
|
|
22
|
-
File.with_opened_temp @output_file do |tmp_file|
|
|
23
|
-
output_to_format tmp_file
|
|
24
|
-
end
|
|
25
|
-
output_finish
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
######################################################################
|
|
29
|
-
def output_finish
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
######################################################################
|
|
33
|
-
def output_prepare
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
######################################################################
|
|
37
|
-
def output_to_format out_file
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
end end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require 'ghaki/report/base'
|
|
2
|
-
|
|
3
|
-
module Ghaki module Report module BaseTesting
|
|
4
|
-
describe Base do
|
|
5
|
-
|
|
6
|
-
before(:all) do
|
|
7
|
-
@log = stub_everything()
|
|
8
|
-
@maj = stub_everything()
|
|
9
|
-
@min = stub_everything()
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
class MyReport < Base
|
|
13
|
-
self.report_name = 'my_report'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context 'eigen class' do
|
|
17
|
-
subject { MyReport }
|
|
18
|
-
it { should respond_to :report_name }
|
|
19
|
-
describe '#report_name' do
|
|
20
|
-
it 'specifies report name' do
|
|
21
|
-
MyReport.report_name.should == 'my_report'
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
subject do MyReport.new( :logger => @log ) end
|
|
27
|
-
|
|
28
|
-
context 'object instance' do
|
|
29
|
-
it { should respond_to :logger }
|
|
30
|
-
it { should respond_to :logger= }
|
|
31
|
-
it { should respond_to :stats }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
describe '#report_name' do
|
|
35
|
-
it 'defaults to eigen report name' do
|
|
36
|
-
subject.report_name == 'my_report'
|
|
37
|
-
end
|
|
38
|
-
it 'accepts normal report name' do
|
|
39
|
-
subject.report_name('quack').should == 'quack'
|
|
40
|
-
end
|
|
41
|
-
it 'accepts period leading report nmae' do
|
|
42
|
-
subject.report_name('.moo').should == 'my_report.moo'
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
describe '#report_name=' do
|
|
47
|
-
it 'assigns report name' do
|
|
48
|
-
subject.report_name = 'zap'
|
|
49
|
-
subject.report_name.should == 'zap'
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe '#minor_report_wrap' do
|
|
54
|
-
it 'calls logger minor mode' do
|
|
55
|
-
@log.expects(:minor).returns(@min).once
|
|
56
|
-
@min.expects(:wrap).with('my_report').once
|
|
57
|
-
subject.minor_report_wrap do end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe '#major_report_wrap' do
|
|
62
|
-
it 'calls logger major mode' do
|
|
63
|
-
@log.expects(:major).returns(@maj).once
|
|
64
|
-
@maj.expects(:wrap).with('my_report').once
|
|
65
|
-
subject.major_report_wrap do end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
end
|
|
70
|
-
end end end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
require 'ghaki/report/output_file'
|
|
2
|
-
|
|
3
|
-
module Ghaki module Report module OutputFileTesting
|
|
4
|
-
describe OutputFile do
|
|
5
|
-
|
|
6
|
-
before(:all) do
|
|
7
|
-
@log = stub_everything()
|
|
8
|
-
@out = '/tmp/myfile.txt'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
subject do OutputFile.new( :logger => @log, :output_file => @out ) end
|
|
12
|
-
|
|
13
|
-
it { should respond_to :output_file }
|
|
14
|
-
it { should respond_to :output_file= }
|
|
15
|
-
it { should respond_to :output_report }
|
|
16
|
-
it { should respond_to :output_finish }
|
|
17
|
-
it { should respond_to :output_prepare }
|
|
18
|
-
it { should respond_to :output_to_format }
|
|
19
|
-
|
|
20
|
-
describe '#output_report' do
|
|
21
|
-
it 'should create file' do
|
|
22
|
-
abc = sequence('reporting')
|
|
23
|
-
subject.expects(:output_prepare).once.in_sequence(abc)
|
|
24
|
-
::File.expects(:with_opened_temp).with(@out).yields(@out).once.in_sequence(abc)
|
|
25
|
-
subject.expects(:output_to_format).with(@out).once.in_sequence(abc)
|
|
26
|
-
subject.expects(:output_finish).once.in_sequence(abc)
|
|
27
|
-
subject.output_report
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
end end end
|