commit-comment-tools 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,111 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 Haruka Yoshihara <yoshihara@clear-code.com>
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ require "stringio"
19
+ require "commit-comment-tools/report-parser"
20
+
21
+ class ReportParserTest < Test::Unit::TestCase
22
+ def setup
23
+ @parser = CommitCommentTools::ReportParser.new
24
+ end
25
+
26
+ def test_oneline
27
+ report_io = StringIO.new(<<-REPORT)
28
+ 2013-1-30:40%:特になし
29
+ 2013-2-1:80%:typoが多かった
30
+ REPORT
31
+
32
+ actual_entries = @parser.parse_stream(report_io)
33
+ expected_entries = [
34
+ {:date => "2013-1-30", :read_ratio => "40", :comment => "特になし"},
35
+ {:date => "2013-2-1", :read_ratio => "80", :comment => "typoが多かった"},
36
+ ]
37
+ assert_equal(expected_entries, actual_entries)
38
+ end
39
+
40
+ def test_continues_lines
41
+ report_io = StringIO.new(<<-REPORT)
42
+ 2013-2-1:80%:typoが多かった
43
+ 2013-2-2:50%:
44
+ PHPのコードを久しぶりに書いた
45
+ データ駆動を使ってテストがどんどん書き直されていた
46
+ REPORT
47
+
48
+ actual_entries = @parser.parse_stream(report_io)
49
+ continues_comment = "PHPのコードを久しぶりに書いた\n" +
50
+ "データ駆動を使ってテストがどんどん書き直されていた"
51
+ expected_entries = [
52
+ {:date => "2013-2-1", :read_ratio => "80", :comment => "typoが多かった"},
53
+ {:date => "2013-2-2", :read_ratio => "50", :comment => continues_comment},
54
+ ]
55
+ assert_equal(expected_entries, actual_entries)
56
+ end
57
+
58
+ def test_zero_padding_date
59
+ report_io = StringIO.new("2013-01-30:40%:特になし")
60
+
61
+ actual_entries = @parser.parse_stream(report_io)
62
+ expected_entries = [
63
+ {:date => "2013-01-30", :read_ratio => "40", :comment => "特になし"},
64
+ ]
65
+ assert_equal(expected_entries, actual_entries)
66
+ end
67
+
68
+ def test_generate_daily_report
69
+ entries = [
70
+ {:date => "2013-1-30", :read_ratio => "40", :comment => "特になし"},
71
+ {:date => "2013-2-1", :read_ratio => "80", :comment => "typoが多かった"},
72
+ ]
73
+
74
+ actual_daily_report = @parser.generate_daily_report(entries)
75
+ expected_daily_report = {
76
+ "2013-1-30" => {
77
+ :read_ratio => "40",
78
+ :comment => "特になし"
79
+ },
80
+ "2013-2-1" => {
81
+ :read_ratio => "80",
82
+ :comment => "typoが多かった"
83
+ }
84
+ }
85
+
86
+ assert_equal(expected_daily_report, actual_daily_report)
87
+ end
88
+
89
+ def test_missing_colon
90
+ report_io = StringIO.new(<<-REPORT)
91
+ 2013-1-30:40%
92
+ 2013-2-1:80%
93
+ 2013-2-2:50%
94
+ PHPのコードを久しぶりに書いた
95
+ データ駆動を使ってテストがどんどん書き直されていた
96
+ REPORT
97
+
98
+ actual_entries = @parser.parse_stream(report_io)
99
+ continues_comment = <<-COMMENT
100
+ PHPのコードを久しぶりに書いた
101
+ データ駆動を使ってテストがどんどん書き直されていた
102
+ COMMENT
103
+ expected_entries = [
104
+ {:date => "2013-1-30", :read_ratio => "40", :comment => ""},
105
+ {:date => "2013-2-1", :read_ratio => "80", :comment => ""},
106
+ {:date => "2013-2-2", :read_ratio => "50", :comment => continues_comment.chomp},
107
+ ]
108
+
109
+ assert_equal(expected_entries, actual_entries)
110
+ end
111
+ end
metadata ADDED
@@ -0,0 +1,230 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commit-comment-tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kenji Okimoto
9
+ - Kouhei Sutou
10
+ - Haruka Yoshihara
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2013-04-11 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activerecord
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: grit
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: test-unit
50
+ requirement: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: test-unit-notify
66
+ requirement: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ - !ruby/object:Gem::Dependency
81
+ name: bundler
82
+ requirement: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rake
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: yard
114
+ requirement: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ - !ruby/object:Gem::Dependency
129
+ name: packnga
130
+ requirement: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ type: :development
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ - !ruby/object:Gem::Dependency
145
+ name: redcarpet
146
+ requirement: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ description:
161
+ email:
162
+ - okimoto@clear-code.com
163
+ - kou@clear-code.com
164
+ - yoshihara@clear-code.com
165
+ executables:
166
+ - git-stats
167
+ - report-analyzer
168
+ extensions: []
169
+ extra_rdoc_files: []
170
+ files:
171
+ - README.md
172
+ - Rakefile
173
+ - Gemfile
174
+ - commit-comment-tools.gemspec
175
+ - .yardopts
176
+ - lib/commit-comment-tools/report-normalizer.rb
177
+ - lib/commit-comment-tools/repository-loader.rb
178
+ - lib/commit-comment-tools/generator/csv.rb
179
+ - lib/commit-comment-tools/generator/graph.rb
180
+ - lib/commit-comment-tools/repository-stats.rb
181
+ - lib/commit-comment-tools/entry.rb
182
+ - lib/commit-comment-tools/version.rb
183
+ - lib/commit-comment-tools/generator.rb
184
+ - lib/commit-comment-tools/report-parser.rb
185
+ - doc/text/news.md
186
+ - doc/text/gpl-3.0.txt
187
+ - doc/text/scenario.txt
188
+ - test/run-test.rb
189
+ - test/test-report-normalizer.rb
190
+ - test/test-report-parser.rb
191
+ - test/test-entry.rb
192
+ - bin/git-stats
193
+ - bin/report-analyzer
194
+ homepage:
195
+ licenses:
196
+ - GPLv3 or later
197
+ post_install_message:
198
+ rdoc_options: []
199
+ require_paths:
200
+ - lib
201
+ required_ruby_version: !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ! '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ segments:
208
+ - 0
209
+ hash: -699049771115081577
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
211
+ none: false
212
+ requirements:
213
+ - - ! '>='
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ segments:
217
+ - 0
218
+ hash: -699049771115081577
219
+ requirements: []
220
+ rubyforge_project:
221
+ rubygems_version: 1.8.25
222
+ signing_key:
223
+ specification_version: 3
224
+ summary: Commit-comment-tools is the tools for [commit-comment-service](http://www.clear-code.com/services/commit-comment.html).
225
+ test_files:
226
+ - test/run-test.rb
227
+ - test/test-report-normalizer.rb
228
+ - test/test-report-parser.rb
229
+ - test/test-entry.rb
230
+ has_rdoc: