devtools 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/Gemfile +0 -2
  4. data/README.md +2 -2
  5. data/circle.yml +1 -1
  6. data/config/devtools.yml +2 -0
  7. data/config/flay.yml +2 -2
  8. data/config/flog.yml +1 -1
  9. data/config/mutant.yml +2 -0
  10. data/config/reek.yml +7 -12
  11. data/devtools.gemspec +20 -18
  12. data/lib/devtools.rb +34 -83
  13. data/lib/devtools/config.rb +76 -55
  14. data/lib/devtools/flay.rb +94 -0
  15. data/lib/devtools/project.rb +28 -105
  16. data/lib/devtools/project/initializer.rb +2 -12
  17. data/lib/devtools/project/initializer/rake.rb +9 -7
  18. data/lib/devtools/project/initializer/rspec.rb +28 -55
  19. data/lib/devtools/rake/flay.rb +126 -0
  20. data/lib/devtools/spec_helper.rb +1 -3
  21. data/shared/spec/shared/abstract_type_behavior.rb +0 -2
  22. data/shared/spec/shared/command_method_behavior.rb +0 -2
  23. data/shared/spec/shared/each_method_behaviour.rb +0 -2
  24. data/shared/spec/shared/hash_method_behavior.rb +0 -2
  25. data/shared/spec/shared/idempotent_method_behavior.rb +0 -2
  26. data/shared/spec/support/ice_nine_config.rb +0 -2
  27. data/spec/integration/devtools/rake/flay/verify_spec.rb +164 -0
  28. data/spec/spec_helper.rb +2 -8
  29. data/spec/unit/devtools/config/yardstick_spec.rb +17 -0
  30. data/spec/unit/devtools/config_spec.rb +78 -0
  31. data/spec/unit/devtools/flay/file_list/call_spec.rb +19 -0
  32. data/spec/unit/devtools/flay/scale/flay_report_spec.rb +17 -0
  33. data/spec/unit/devtools/flay/scale/measure_spec.rb +43 -0
  34. data/spec/unit/devtools/project/initializer/rake_spec.rb +21 -0
  35. data/spec/unit/devtools/project/initializer/rspec_spec.rb +52 -0
  36. data/spec/unit/devtools/project_spec.rb +34 -0
  37. data/spec/unit/devtools_spec.rb +14 -0
  38. data/tasks/metrics/ci.rake +1 -3
  39. data/tasks/metrics/coverage.rake +0 -2
  40. data/tasks/metrics/flay.rake +6 -33
  41. data/tasks/metrics/flog.rake +0 -2
  42. data/tasks/metrics/mutant.rake +31 -39
  43. data/tasks/metrics/reek.rake +0 -2
  44. data/tasks/metrics/rubocop.rake +0 -2
  45. data/tasks/metrics/yardstick.rake +0 -14
  46. data/tasks/spec.rake +0 -2
  47. data/tasks/yard.rake +0 -2
  48. metadata +96 -31
  49. data/.travis.yml +0 -15
  50. data/TODO +0 -0
  51. data/bin/devtools +0 -18
  52. data/default/config/devtools.yml +0 -2
  53. data/default/config/flay.yml +0 -3
  54. data/default/config/flog.yml +0 -2
  55. data/default/config/mutant.yml +0 -3
  56. data/default/config/reek.yml +0 -103
  57. data/default/config/rubocop.yml +0 -91
  58. data/default/config/yardstick.yml +0 -2
  59. data/lib/devtools/platform.rb +0 -118
  60. data/lib/devtools/site.rb +0 -41
  61. data/lib/devtools/site/initializer.rb +0 -57
@@ -0,0 +1,52 @@
1
+ describe Devtools::Project::Initializer::Rspec do
2
+ let(:spec_root) { Devtools.root.join('spec') }
3
+ let(:unit_test_timeout) { instance_double(Float) }
4
+
5
+ let(:project) do
6
+ instance_double(
7
+ Devtools::Project,
8
+ spec_root: spec_root,
9
+ devtools: instance_double(
10
+ Devtools::Config::Devtools,
11
+ unit_test_timeout: unit_test_timeout
12
+ )
13
+ )
14
+ end
15
+
16
+ describe '.call' do
17
+ subject do
18
+ described_class.call(project)
19
+ end
20
+
21
+ it 'performs expected rspec initialization' do
22
+ called = false
23
+ example = -> { called = true }
24
+
25
+ expect(Dir).to receive(:glob)
26
+ .with(Devtools.root.join('shared/spec/{shared,support}/**/*.rb'))
27
+ .and_return(%w[shared-a shared-b])
28
+
29
+ expect(Kernel).to receive(:require).with('shared-a')
30
+ expect(Kernel).to receive(:require).with('shared-b')
31
+
32
+ expect(Dir).to receive(:glob)
33
+ .with(Devtools.root.join('spec/{shared,support}/**/*.rb'))
34
+ .and_return(%w[support-a support-b])
35
+
36
+ expect(Kernel).to receive(:require).with('support-a')
37
+ expect(Kernel).to receive(:require).with('support-b')
38
+
39
+ expect(Timeout).to receive(:timeout).with(unit_test_timeout) do |&block|
40
+ block.call
41
+ end
42
+
43
+ expect(RSpec.configuration).to receive(:around)
44
+ .with(file_path: %r{\bspec/unit/})
45
+ .and_yield(example)
46
+
47
+ expect(subject).to be(described_class)
48
+
49
+ expect(called).to be(true)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,34 @@
1
+ RSpec.describe Devtools::Project do
2
+ let(:object) { described_class.new(Devtools.root) }
3
+
4
+ describe '#init_rspec' do
5
+ subject { object.init_rspec }
6
+
7
+ it 'calls the rspec initializer' do
8
+ expect(Devtools::Project::Initializer::Rspec).to receive(:call).with(Devtools.project)
9
+ expect(subject).to be(object)
10
+ end
11
+ end
12
+
13
+ {
14
+ devtools: Devtools::Config::Devtools,
15
+ flay: Devtools::Config::Flay,
16
+ flog: Devtools::Config::Flog,
17
+ reek: Devtools::Config::Reek,
18
+ mutant: Devtools::Config::Mutant,
19
+ rubocop: Devtools::Config::Rubocop,
20
+ yardstick: Devtools::Config::Yardstick
21
+ }.each do |name, klass|
22
+ describe "##{name}" do
23
+ subject { object.send(name) }
24
+
25
+ specify { should eql(klass.new(Devtools.root.join('config'))) }
26
+ end
27
+ end
28
+
29
+ describe '#spec_root' do
30
+ subject { object.spec_root }
31
+
32
+ specify { should eql(Devtools.root.join('spec')) }
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ describe Devtools do
2
+ describe '.project' do
3
+ specify do
4
+ expect(Devtools.project).to equal(Devtools::PROJECT)
5
+ end
6
+ end
7
+
8
+ describe '.init_rake_tasks' do
9
+ specify do
10
+ expect(Devtools::Project::Initializer::Rake).to receive(:call)
11
+ expect(Devtools.init_rake_tasks).to be(Devtools)
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,5 @@
1
- # encoding: utf-8
2
-
3
1
  desc 'Run all specs, metrics and mutant'
4
- task ci: %w[spec ci:metrics metrics:mutant]
2
+ task ci: %w[ci:metrics metrics:mutant]
5
3
 
6
4
  namespace :ci do
7
5
  tasks = %w[
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  namespace :metrics do
4
2
  desc 'Measure code coverage'
5
3
  task :coverage do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  namespace :metrics do
4
2
  require 'flay'
5
3
 
@@ -12,37 +10,12 @@ namespace :metrics do
12
10
  task :flay do
13
11
  threshold = config.threshold
14
12
  total_score = config.total_score
15
- files = Flay.expand_dirs_to_files(config.lib_dirs).sort
16
-
17
- # Run flay first to ensure the max mass matches the threshold
18
- flay = Flay.new(fuzzy: false, verbose: false, mass: 0)
19
- flay.process(*files)
20
- flay.analyze
21
-
22
- masses = flay.masses.map do |hash, mass|
23
- Rational(mass, flay.hashes[hash].size)
24
- end
25
-
26
- max = (masses.max || 0).to_i
27
- unless max >= threshold
28
- Devtools.notify_metric_violation "Adjust flay threshold down to #{max}"
29
- end
30
-
31
- total = masses.inject(:+).to_i
32
- unless total == total_score
33
- Devtools.notify_metric_violation "Flay total is now #{total}, but expected #{total_score}"
34
- end
35
-
36
- # Run flay a second time with the threshold set
37
- flay = Flay.new(fuzzy: false, verbose: false, mass: threshold.succ)
38
- flay.process(*files)
39
- flay.analyze
40
-
41
- mass_size = flay.masses.size
42
13
 
43
- if mass_size.nonzero?
44
- flay.report
45
- Devtools.notify_metric_violation "#{mass_size} chunks have a duplicate mass > #{threshold}"
46
- end
14
+ Devtools::Rake::Flay.call(
15
+ threshold: threshold,
16
+ total_score: total_score,
17
+ lib_dirs: config.lib_dirs,
18
+ excludes: config.excludes
19
+ )
47
20
  end
48
21
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  namespace :metrics do
4
2
  require 'flog'
5
3
  require 'flog_cli'
@@ -1,50 +1,42 @@
1
- # encoding: utf-8
2
-
3
1
  namespace :metrics do
4
2
  config = Devtools.project.mutant
5
3
 
6
- if !ENV['DEVTOOLS_SELF']
7
- desc 'Measure mutation coverage'
8
- task mutant: :coverage do
9
- require 'mutant'
4
+ desc 'Measure mutation coverage'
5
+ task mutant: :coverage do
6
+ require 'mutant'
10
7
 
11
- namespace =
12
- if config.zombify
13
- Mutant.zombify
14
- Zombie::Mutant
15
- else
16
- Mutant
17
- end
8
+ namespace =
9
+ if config.zombify
10
+ Mutant.zombify
11
+ Zombie::Mutant
12
+ else
13
+ Mutant
14
+ end
18
15
 
19
- namespaces = Array(config.namespace).map { |n| "#{n}*" }
16
+ namespaces = Array(config.namespace).map { |n| "#{n}*" }
20
17
 
21
- ignore_subjects = config.ignore_subjects.flat_map do |matcher|
22
- %W[--ignore #{matcher}]
23
- end
18
+ ignore_subjects = config.ignore_subjects.flat_map do |matcher|
19
+ %W[--ignore #{matcher}]
20
+ end
24
21
 
25
- since =
26
- if config.since
27
- %W[--since #{config.since}]
28
- else
29
- []
30
- end
31
-
32
- arguments = %W[
33
- --include lib
34
- --require #{config.name}
35
- --expect-coverage #{config.expect_coverage}
36
- --use #{config.strategy}
37
- ].concat(ignore_subjects).concat(namespaces).concat(since)
38
-
39
- status = namespace::CLI.run(arguments)
40
- if status.nonzero?
41
- Devtools.notify_metric_violation 'Mutant task is not successful'
22
+ jobs = ENV.key?('CIRCLECI') ? %w[--jobs 4] : []
23
+
24
+ since =
25
+ if config.since
26
+ %W[--since #{config.since}]
27
+ else
28
+ []
42
29
  end
43
- end
44
- else
45
- desc 'Measure mutation coverage'
46
- task mutant: :coverage do
47
- $stderr.puts 'Mutant is disabled'
30
+
31
+ arguments = %W[
32
+ --include lib
33
+ --require #{config.name}
34
+ --expect-coverage #{config.expect_coverage}
35
+ --use #{config.strategy}
36
+ ].concat(ignore_subjects).concat(namespaces).concat(since).concat(jobs)
37
+
38
+ unless namespace::CLI.run(arguments)
39
+ Devtools.notify_metric_violation('Mutant task is not successful')
48
40
  end
49
41
  end
50
42
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  namespace :metrics do
4
2
  require 'reek/rake/task'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  namespace :metrics do
4
2
  desc 'Check with code style guide'
5
3
  task :rubocop do
@@ -1,22 +1,8 @@
1
- # encoding: utf-8
2
-
3
1
  namespace :metrics do
4
2
  namespace :yardstick do
5
3
  require 'yardstick/rake/measurement'
6
4
  require 'yardstick/rake/verify'
7
5
 
8
- # Enable the legacy parser for JRuby until ripper is fully supported
9
- if Devtools.jruby?
10
- # Remove when https://github.com/lsegal/yard/issues/681 is resolved
11
- # This code first requires ripper, then removes the constant so
12
- # that it does not trigger a bug in YARD where if it checks if Ripper
13
- # is available and assumes other constants are defined, when JRuby's
14
- # implementation does not yet.
15
- require 'ripper'
16
- Object.send(:remove_const, :Ripper)
17
- YARD::Parser::SourceParser.parser_type = :ruby18
18
- end
19
-
20
6
  options = Devtools.project.yardstick.options
21
7
 
22
8
  Yardstick::Rake::Measurement.new(:measure, options)
data/tasks/spec.rake CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  begin
4
2
  require 'rspec/core/rake_task'
5
3
 
data/tasks/yard.rake CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  begin
4
2
  require 'yard'
5
3
 
metadata CHANGED
@@ -1,43 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-06 00:00:00.000000000 Z
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: procto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.x
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.x
27
+ - !ruby/object:Gem::Dependency
28
+ name: anima
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.x
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.x
41
+ - !ruby/object:Gem::Dependency
42
+ name: concord
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.x
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.x
55
+ - !ruby/object:Gem::Dependency
56
+ name: adamantium
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.x
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.x
13
69
  - !ruby/object:Gem::Dependency
14
70
  name: rspec
15
71
  requirement: !ruby/object:Gem::Requirement
16
72
  requirements:
17
73
  - - "~>"
18
74
  - !ruby/object:Gem::Version
19
- version: 3.3.0
75
+ version: 3.4.0
20
76
  type: :runtime
21
77
  prerelease: false
22
78
  version_requirements: !ruby/object:Gem::Requirement
23
79
  requirements:
24
80
  - - "~>"
25
81
  - !ruby/object:Gem::Version
26
- version: 3.3.0
82
+ version: 3.4.0
27
83
  - !ruby/object:Gem::Dependency
28
84
  name: rspec-core
29
85
  requirement: !ruby/object:Gem::Requirement
30
86
  requirements:
31
87
  - - "~>"
32
88
  - !ruby/object:Gem::Version
33
- version: 3.3.0
89
+ version: 3.4.0
34
90
  type: :runtime
35
91
  prerelease: false
36
92
  version_requirements: !ruby/object:Gem::Requirement
37
93
  requirements:
38
94
  - - "~>"
39
95
  - !ruby/object:Gem::Version
40
- version: 3.3.0
96
+ version: 3.4.0
41
97
  - !ruby/object:Gem::Dependency
42
98
  name: rspec-its
43
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,28 +170,28 @@ dependencies:
114
170
  requirements:
115
171
  - - "~>"
116
172
  - !ruby/object:Gem::Version
117
- version: 3.5.0
173
+ version: 3.7.0
118
174
  type: :runtime
119
175
  prerelease: false
120
176
  version_requirements: !ruby/object:Gem::Requirement
121
177
  requirements:
122
178
  - - "~>"
123
179
  - !ruby/object:Gem::Version
124
- version: 3.5.0
180
+ version: 3.7.0
125
181
  - !ruby/object:Gem::Dependency
126
182
  name: rubocop
127
183
  requirement: !ruby/object:Gem::Requirement
128
184
  requirements:
129
185
  - - "~>"
130
186
  - !ruby/object:Gem::Version
131
- version: 0.34.0
187
+ version: 0.35.1
132
188
  type: :runtime
133
189
  prerelease: false
134
190
  version_requirements: !ruby/object:Gem::Requirement
135
191
  requirements:
136
192
  - - "~>"
137
193
  - !ruby/object:Gem::Version
138
- version: 0.34.0
194
+ version: 0.35.1
139
195
  - !ruby/object:Gem::Dependency
140
196
  name: simplecov
141
197
  requirement: !ruby/object:Gem::Requirement
@@ -170,73 +226,61 @@ dependencies:
170
226
  requirements:
171
227
  - - "~>"
172
228
  - !ruby/object:Gem::Version
173
- version: 0.8.3
229
+ version: 0.8.9
174
230
  type: :runtime
175
231
  prerelease: false
176
232
  version_requirements: !ruby/object:Gem::Requirement
177
233
  requirements:
178
234
  - - "~>"
179
235
  - !ruby/object:Gem::Version
180
- version: 0.8.3
236
+ version: 0.8.9
181
237
  - !ruby/object:Gem::Dependency
182
238
  name: mutant-rspec
183
239
  requirement: !ruby/object:Gem::Requirement
184
240
  requirements:
185
241
  - - "~>"
186
242
  - !ruby/object:Gem::Version
187
- version: 0.8.2
243
+ version: 0.8.8
188
244
  type: :runtime
189
245
  prerelease: false
190
246
  version_requirements: !ruby/object:Gem::Requirement
191
247
  requirements:
192
248
  - - "~>"
193
249
  - !ruby/object:Gem::Version
194
- version: 0.8.2
250
+ version: 0.8.8
195
251
  description: A metagem for ROM-style development
196
252
  email:
197
253
  - mbj@schirp-dso.com
198
- executables:
199
- - devtools
254
+ executables: []
200
255
  extensions: []
201
256
  extra_rdoc_files:
202
257
  - README.md
203
- - TODO
204
258
  files:
205
259
  - ".gitignore"
206
260
  - ".rspec"
207
261
  - ".rubocop.yml"
208
262
  - ".ruby-gemset"
209
- - ".travis.yml"
210
263
  - Gemfile
211
264
  - LICENSE
212
265
  - README.md
213
266
  - Rakefile
214
- - TODO
215
- - bin/devtools
216
267
  - circle.yml
268
+ - config/devtools.yml
217
269
  - config/flay.yml
218
270
  - config/flog.yml
219
271
  - config/mutant.yml
220
272
  - config/reek.yml
221
273
  - config/rubocop.yml
222
274
  - config/yardstick.yml
223
- - default/config/devtools.yml
224
- - default/config/flay.yml
225
- - default/config/flog.yml
226
- - default/config/mutant.yml
227
- - default/config/reek.yml
228
- - default/config/rubocop.yml
229
- - default/config/yardstick.yml
230
275
  - devtools.gemspec
231
276
  - lib/devtools.rb
232
277
  - lib/devtools/config.rb
233
- - lib/devtools/platform.rb
278
+ - lib/devtools/flay.rb
234
279
  - lib/devtools/project.rb
235
280
  - lib/devtools/project/initializer.rb
236
281
  - lib/devtools/project/initializer/rake.rb
237
282
  - lib/devtools/project/initializer/rspec.rb
238
- - lib/devtools/site.rb
239
- - lib/devtools/site/initializer.rb
283
+ - lib/devtools/rake/flay.rb
240
284
  - lib/devtools/spec_helper.rb
241
285
  - shared/spec/shared/abstract_type_behavior.rb
242
286
  - shared/spec/shared/command_method_behavior.rb
@@ -244,7 +288,17 @@ files:
244
288
  - shared/spec/shared/hash_method_behavior.rb
245
289
  - shared/spec/shared/idempotent_method_behavior.rb
246
290
  - shared/spec/support/ice_nine_config.rb
291
+ - spec/integration/devtools/rake/flay/verify_spec.rb
247
292
  - spec/spec_helper.rb
293
+ - spec/unit/devtools/config/yardstick_spec.rb
294
+ - spec/unit/devtools/config_spec.rb
295
+ - spec/unit/devtools/flay/file_list/call_spec.rb
296
+ - spec/unit/devtools/flay/scale/flay_report_spec.rb
297
+ - spec/unit/devtools/flay/scale/measure_spec.rb
298
+ - spec/unit/devtools/project/initializer/rake_spec.rb
299
+ - spec/unit/devtools/project/initializer/rspec_spec.rb
300
+ - spec/unit/devtools/project_spec.rb
301
+ - spec/unit/devtools_spec.rb
248
302
  - tasks/metrics/ci.rake
249
303
  - tasks/metrics/coverage.rake
250
304
  - tasks/metrics/flay.rake
@@ -275,9 +329,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
275
329
  version: '0'
276
330
  requirements: []
277
331
  rubyforge_project:
278
- rubygems_version: 2.4.5.1
332
+ rubygems_version: 2.5.1
279
333
  signing_key:
280
334
  specification_version: 4
281
335
  summary: A metagem for ROM-style development
282
336
  test_files:
337
+ - spec/integration/devtools/rake/flay/verify_spec.rb
283
338
  - spec/spec_helper.rb
339
+ - spec/unit/devtools/config/yardstick_spec.rb
340
+ - spec/unit/devtools/config_spec.rb
341
+ - spec/unit/devtools/flay/file_list/call_spec.rb
342
+ - spec/unit/devtools/flay/scale/flay_report_spec.rb
343
+ - spec/unit/devtools/flay/scale/measure_spec.rb
344
+ - spec/unit/devtools/project/initializer/rake_spec.rb
345
+ - spec/unit/devtools/project/initializer/rspec_spec.rb
346
+ - spec/unit/devtools/project_spec.rb
347
+ - spec/unit/devtools_spec.rb
348
+ has_rdoc: