hexx-suit 0.2.2 → 1.0.0

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.travis.yml +4 -9
  4. data/Gemfile +5 -6
  5. data/README.md +35 -26
  6. data/Rakefile +5 -6
  7. data/{lib/hexx/suit/install → config}/metrics/simplecov.yml +0 -0
  8. data/hexx-suit.gemspec +1 -6
  9. data/lib/hexx/suit/install/Guardfile +14 -5
  10. data/lib/hexx/suit/install/_rubocop.yml +1 -0
  11. data/lib/hexx/suit/install/_yardopts +1 -0
  12. data/lib/hexx/suit/install.rb +15 -46
  13. data/lib/hexx/suit/metrics/metric_fu/base.rb +15 -7
  14. data/lib/hexx/suit/metrics/metric_fu/cane.rb +1 -1
  15. data/lib/hexx/suit/metrics/metric_fu/churn.rb +1 -1
  16. data/lib/hexx/suit/metrics/metric_fu/flay.rb +1 -1
  17. data/lib/hexx/suit/metrics/metric_fu/reek.rb +1 -1
  18. data/lib/hexx/suit/metrics/metric_fu/roodi.rb +1 -1
  19. data/lib/hexx/suit/metrics/metric_fu/saikuro.rb +1 -1
  20. data/lib/hexx/suit/metrics/metric_fu.rb +1 -1
  21. data/lib/hexx/suit/metrics/rubocop.rb +1 -1
  22. data/lib/hexx/suit/metrics/yardstick.rb +1 -1
  23. data/lib/hexx/suit/metrics.rb +0 -3
  24. data/lib/hexx/suit/version.rb +7 -1
  25. data/lib/hexx/suit.rb +14 -67
  26. data/lib/hexx-suit.rb +10 -14
  27. data/lib/tasks/check/coverage.rake +2 -2
  28. data/lib/tasks/check/fu.rake +1 -1
  29. data/lib/tasks/check/inch.rake +1 -1
  30. data/lib/tasks/check/rubocop.rake +1 -1
  31. data/lib/tasks/check/yardstick.rake +1 -1
  32. data/lib/tasks/check.rake +9 -11
  33. data/lib/tasks/debug.rake +1 -1
  34. data/lib/tasks/test.rake +1 -1
  35. data/spec/spec_helper.rb +8 -6
  36. data/spec/support/config/tasks.rb +1 -1
  37. data/spec/tests/bin/install_spec.rb +22 -25
  38. data/spec/tests/lib/install_spec.rb +0 -4
  39. data/spec/tests/suit_spec.rb +7 -55
  40. data/spec/tests/tasks/check/coverage/display_spec.rb +2 -2
  41. data/spec/tests/tasks/check/coverage/run_spec.rb +2 -2
  42. data/spec/tests/tasks/check/display_spec.rb +0 -6
  43. data/spec/tests/tasks/check/fu/display_spec.rb +1 -1
  44. data/spec/tests/tasks/check/fu/run_spec.rb +1 -1
  45. data/spec/tests/tasks/check/inch_spec.rb +1 -1
  46. data/spec/tests/tasks/check/rubocop/display_spec.rb +1 -1
  47. data/spec/tests/tasks/check/rubocop/run_spec.rb +1 -1
  48. data/spec/tests/tasks/check/run_spec.rb +0 -6
  49. data/spec/tests/tasks/check/yardstick/display_spec.rb +1 -1
  50. data/spec/tests/tasks/check_spec.rb +0 -12
  51. data/spec/tests/tasks/debug_spec.rb +1 -1
  52. metadata +6 -103
  53. data/config/initializers/focus.rb +0 -5
  54. data/config/initializers/garbage_collection.rb +0 -11
  55. data/config/initializers/i18n.rb +0 -3
  56. data/config/initializers/random_order.rb +0 -4
  57. data/config/initializers/rspec.rb +0 -11
  58. data/lib/hexx/suit/install/Rakefile +0 -17
  59. data/lib/hexx/suit/install/_rspec +0 -2
  60. data/lib/hexx/suit/install/metrics/pippi.yml +0 -3
  61. data/lib/hexx/suit/metrics/base.rb +0 -88
  62. data/lib/hexx/suit/metrics/pippi.rb +0 -89
  63. data/lib/hexx/suit/metrics/simplecov.rb +0 -119
  64. data/lib/hexx/suit/utils/system.rb +0 -66
  65. data/lib/tasks/check/pippi.rake +0 -33
  66. data/spec/tests/lib/metrics/pippi_spec.rb +0 -104
  67. data/spec/tests/lib/metrics/simplecov_spec.rb +0 -102
  68. data/spec/tests/lib/utils/system_spec.rb +0 -85
  69. data/spec/tests/tasks/check/pippi/display_spec.rb +0 -48
  70. data/spec/tests/tasks/check/pippi/run_spec.rb +0 -26
  71. data/spec/tests/tasks/check/pippi_spec.rb +0 -27
  72. data/spec/tests/tasks/test_spec.rb +0 -21
@@ -1,11 +0,0 @@
1
- # Delays garbage collection until the end of testing.
2
- RSpec.configure do |config|
3
-
4
- config.before(:each) do
5
- GC.disable
6
- end
7
-
8
- config.after(:each) do
9
- GC.enable
10
- end
11
- end
@@ -1,3 +0,0 @@
1
- require "i18n"
2
-
3
- I18n.enforce_available_locales = false
@@ -1,4 +0,0 @@
1
- # Runs tests in a random order
2
- RSpec.configure do |config|
3
- config.order = "random"
4
- end
@@ -1,11 +0,0 @@
1
- # Configures RSpec default settings
2
- RSpec.configure do |config|
3
-
4
- config.mock_with :rspec do |mocks|
5
- mocks.yield_receiver_to_any_instance_implementation_blocks = false
6
- end
7
-
8
- config.expect_with :rspec do |c|
9
- c.syntax = :expect
10
- end
11
- end
@@ -1,17 +0,0 @@
1
- # encoding: utf-8
2
- begin
3
- require "bundler/setup"
4
- rescue LoadError
5
- puts "You must `gem install bundler` and `bundle install` to run rake tasks"
6
- exit
7
- end
8
-
9
- # Loads bundler tasks
10
- Bundler::GemHelper.install_tasks
11
-
12
- # Loads the Hexx::Suit and its tasks
13
- require "hexx-suit"
14
- Hexx::Suit.install_tasks
15
-
16
- # Sets the Hexx::Suit :test task to default
17
- task default: :test
@@ -1,2 +0,0 @@
1
- --require spec_helper
2
- --color
@@ -1,3 +0,0 @@
1
- ---
2
- checkset: basic
3
- output: "tmp/pippi/output.log"
@@ -1,88 +0,0 @@
1
- require "yaml"
2
-
3
- module Hexx
4
-
5
- module Suit
6
-
7
- module Metrics
8
-
9
- # Base class for metrics configurators
10
- #
11
- # @api private
12
- class Base
13
-
14
- # The utility class for sending commands to the system
15
- SYSTEM = Utils::System
16
-
17
- # Loads metric settings and configures the current metric
18
- #
19
- # @return [Hexx::Suit::Metrics]
20
- # the configured metric object
21
- def self.load
22
- send(:new).load
23
- end
24
-
25
- # Configures and runs the current metric
26
- #
27
- # @return (see #run)
28
- def self.run
29
- load.run
30
- end
31
-
32
- # Loads the configuration file and configures the metric
33
- #
34
- # @return [self]
35
- #
36
- # @api private
37
- def load
38
- self
39
- end
40
-
41
- # Runs the metric
42
- #
43
- # @abstract
44
- #
45
- # @return [undefined]
46
- #
47
- # @api private
48
- def run
49
- end
50
-
51
- # @note
52
- # The class has a private constructor.
53
- # Use methods {.load} or {.run}.
54
- private_class_method :new
55
-
56
- private
57
-
58
- # Extracts a hash of settings from the current file
59
- #
60
- # @return [Hash]
61
- #
62
- # @api private
63
- def settings
64
- @settings ||= file ? ::YAML.load_file(file) : {}
65
- end
66
-
67
- # Returns the name of the settings file
68
- #
69
- # @return [String]
70
- # when the file is present in the config/metrics folder
71
- # @return [nil]
72
- # when the file is absent in the config/metrics folder
73
- #
74
- # @api private
75
- def file
76
- @file ||= Dir["config/metrics/#{ name }.yml"].first
77
- end
78
-
79
- # The name of the current metric
80
- #
81
- # @abstract
82
- #
83
- # @return [Symbol]
84
- attr_reader :name
85
- end
86
- end
87
- end
88
- end
@@ -1,89 +0,0 @@
1
- module Hexx
2
- module Suit
3
- module Metrics
4
-
5
- # Prepares and runs pippi environment
6
- class Pippi < Base
7
-
8
- # Constructs the object and loads 'pippi' gem dependency
9
- #
10
- # Loads pippi settings, prepares the log file,
11
- # and sets ENV variables for the pippi rake tasks.
12
- #
13
- # @return [Hexx::Suit::Metrics::MetricFu]
14
- #
15
- # @api private
16
- def self.new
17
- require "pippi"
18
- super
19
- end
20
-
21
- # @!scope class
22
- # Prepares log file and sets ENV variables for pippi rake tasks
23
- #
24
- # @return [undefined]
25
- def load
26
- prepare_output
27
- set_environment
28
-
29
- super
30
- end
31
-
32
- # @!scope class
33
- # Starts pippi AutoRunner
34
- #
35
- # @return [undefined]
36
- def run
37
- ::Pippi::AutoRunner.new checkset: checkset, io: io
38
- end
39
-
40
- private
41
-
42
- # pippi metric definitions
43
-
44
- def name
45
- :pippi
46
- end
47
-
48
- def default_options
49
- {
50
- "checkset" => "basic",
51
- "output" => "tmp/pippi/output.log"
52
- }
53
- end
54
-
55
- # operations
56
-
57
- def prepare_output
58
- SYSTEM.call %(
59
- mkdir #{ File.dirname(output) } -p
60
- touch #{ output }
61
- )
62
- end
63
-
64
- def set_environment
65
- ENV["USE_PIPPI"] = "true"
66
- ENV["PIPPI_OUTPUT"] = output
67
- end
68
-
69
- # helpers
70
-
71
- def options
72
- @options ||= default_options.merge settings.to_hash
73
- end
74
-
75
- def output
76
- @output ||= options["output"]
77
- end
78
-
79
- def io
80
- ::File.open(output, "w")
81
- end
82
-
83
- def checkset
84
- options["checkset"]
85
- end
86
- end
87
- end
88
- end
89
- end
@@ -1,119 +0,0 @@
1
- module Hexx
2
- module Suit
3
- module Metrics
4
-
5
- # Prepares and runs pippi environment
6
- #
7
- # @api private
8
- class SimpleCov < Base
9
-
10
- # Loads the simplecov and coveralls gem
11
- #
12
- # @return [Hexx::Suit::Metrics::SimpleCov]
13
- #
14
- # @api private
15
- def self.new
16
- %w(simplecov coveralls).each { |gem| require gem }
17
- super
18
- end
19
-
20
- # @!scope class
21
- # Configures the SimpleCov metric
22
- #
23
- # @return [self]
24
- def load
25
- set_environment
26
- configure_metric
27
-
28
- super
29
- end
30
-
31
- # @!scope class
32
- # Configures simplecov from the simplecov.yml file and starts
33
- # the metric
34
- #
35
- # @return [undefined]
36
- def run
37
- metric.start
38
- end
39
-
40
- private
41
-
42
- # simplecov metric definitions
43
-
44
- def name
45
- "simplecov"
46
- end
47
-
48
- def metric
49
- ::SimpleCov
50
- end
51
-
52
- def default_options
53
- {
54
- "output" => "tmp/coverage",
55
- "filters" => ["spec/", "config/"],
56
- "groups" => {
57
- "Libraries" => "lib/",
58
- "Application" => "app/"
59
- }
60
- }
61
- end
62
-
63
- # operations
64
-
65
- def set_environment
66
- ENV["USE_SIMPLECOV"] = "true"
67
- ENV["SIMPLECOV_OUTPUT"] = "#{ output }/index.html"
68
- end
69
-
70
- def configure_metric
71
- add_filters
72
- add_groups
73
- set_formatters
74
- set_output
75
- end
76
-
77
- def add_filters
78
- filters.each(&metric.method(:add_filter))
79
- end
80
-
81
- def add_groups
82
- groups.each { |key, value| metric.add_group(key, value) }
83
- end
84
-
85
- def set_formatters
86
- metric.formatter = metric::Formatter::MultiFormatter[
87
- metric::Formatter::HTMLFormatter,
88
- ::Coveralls::SimpleCov::Formatter
89
- ]
90
- end
91
-
92
- def set_output
93
- metric.coverage_dir output
94
- end
95
-
96
- # helpers
97
-
98
- def options
99
- @options ||= default_options.merge settings.to_hash
100
- end
101
-
102
- def output
103
- @output = options["output"]
104
- end
105
-
106
- def filters
107
- @filters ||= Array(options["filters"]).flatten.map(&:to_s)
108
- end
109
-
110
- def groups
111
- @groups ||= begin
112
- list = options["groups"]
113
- list.is_a?(Hash) ? list : {}
114
- end
115
- end
116
- end
117
- end
118
- end
119
- end
@@ -1,66 +0,0 @@
1
- module Hexx
2
- module Suit
3
-
4
- # Contains utilitity classes
5
- module Utils
6
-
7
- # The utility sends multiline string to system
8
- #
9
- # Allows stubbing system calls in specifications.
10
- #
11
- # @example
12
- # System.call %(
13
- # inch --pedantic
14
- # rubocop
15
- # )
16
- #
17
- # @api private
18
- class System < String
19
-
20
- # Initializes multiline text to be sent to system
21
- #
22
- # Removes repetitive spaces from itself
23
- #
24
- # @param [#to_s] text
25
- # Multiline text to be sent to system
26
- #
27
- # @return [undefined]
28
- def initialize(text)
29
- super
30
- strip!
31
- gsub!(/ {2,}/, " ")
32
- end
33
-
34
- # Returns non-empty lines without trailing spaces
35
- #
36
- # @return [Array<String>]
37
- def lines
38
- Array(super).map(&:strip).reject(&:empty?)
39
- end
40
-
41
- # Sends itself to system line by line
42
- #
43
- # @return [self]
44
- def call
45
- lines.each(&method(:system))
46
-
47
- self
48
- end
49
-
50
- # Sends multiline string to system
51
- #
52
- # @example (see Hexx::Suit::Utils::System)
53
- #
54
- # @param (see #initialize)
55
- #
56
- # @return [Hexx::Suit::Utils::System]
57
- # utility object (allows chaining)
58
- def self.call(text)
59
- new(text).call
60
-
61
- self
62
- end
63
- end # class System
64
- end # module Utils
65
- end # module Suit
66
- end # module Hexx
@@ -1,33 +0,0 @@
1
- namespace :check do
2
-
3
- namespace :pippi do
4
-
5
- metric = Hexx::Suit::Metrics::Pippi
6
- caller = Hexx::Suit::Utils::System
7
- output = -> { ENV.fetch("PIPPI_OUTPUT") { "log/pippi.log" } }
8
-
9
- # Loads settings for pippi runtime metric from the '.hexx-suit.yml'
10
- task :configure do
11
- metric.load
12
- end
13
-
14
- desc "Runs tests with pippi runtime metric"
15
- task run: :configure do
16
- puts "******* STARTING METRIC pippi"
17
- caller.call "rake test"
18
- puts "see pippi results in #{ output.call }"
19
- puts "******* ENDING METRIC pippi"
20
- end
21
-
22
- desc "Displays results of pippi last run"
23
- task display: :configure do
24
- puts "******* DISPLAYING METRIC pippi"
25
- caller.call "cat #{ output.call }"
26
- puts "******* ENDING METRIC pippi"
27
- end
28
- end
29
-
30
- desc "Runs tests with pippi runtime metric and displays the results"
31
- task pippi: %w(pippi:run pippi:display)
32
-
33
- end if USE_PIPPI_METRIC
@@ -1,104 +0,0 @@
1
- # encoding: utf-8
2
- require "spec_helper"
3
-
4
- describe Hexx::Suit::Metrics::Pippi, :sandbox do
5
-
6
- require "pippi"
7
-
8
- shared_context "without pippi.yml" do
9
-
10
- let(:options) do
11
- { "checkset" => "basic", "output" => "tmp/pippi/output.log" }
12
- end
13
- end
14
-
15
- shared_context "with pippi.yml" do
16
-
17
- let(:options) do
18
- { "checkset" => "training", "output" => "custom/pippi.log" }
19
- end
20
-
21
- before { prepare_settings options, "config/metrics/pippi.yml" }
22
- end
23
-
24
- shared_examples "environments loader" do
25
-
26
- before { ENV["USE_PIPPI"] = nil }
27
- before { ENV["PIPPI_OUTPUT"] = nil }
28
-
29
- it "[sets USE_PIPPI]" do
30
- expect { subject }.to change { ENV["USE_PIPPI"] }.to "true"
31
- end
32
-
33
- it "[sets PIPPI_OUTPUT]" do
34
- expect { subject }.to change { ENV["PIPPI_OUTPUT"] }.to options["output"]
35
- end
36
- end
37
-
38
- shared_examples "file creator" do
39
-
40
- before { subject }
41
-
42
- it "[prepares the output file]" do
43
- expect(options["output"]).to be_present_in_sandbox
44
- end
45
- end
46
-
47
- shared_examples "metric runner" do
48
-
49
- after { subject }
50
-
51
- it "[runs the metric]" do
52
- expect(::Pippi::AutoRunner).to receive(:new) do |settings|
53
- expect(settings[:checkset]).to eq options["checkset"]
54
- expect(settings[:io]).to be_kind_of ::File
55
- expect(settings[:io].path).to eq options["output"]
56
- end
57
- end
58
- end
59
-
60
- describe ".load" do
61
-
62
- subject { try_in_sandbox { described_class.load } }
63
-
64
- context "when pippi.yml is absent" do
65
-
66
- include_context "without pippi.yml"
67
-
68
- it_behaves_like "environments loader"
69
- it_behaves_like "file creator"
70
- end
71
-
72
- context "when pippi.yml is present" do
73
-
74
- include_context "with pippi.yml"
75
-
76
- it_behaves_like "environments loader"
77
- it_behaves_like "file creator"
78
- end
79
- end
80
-
81
- describe ".run" do
82
-
83
- subject { try_in_sandbox { described_class.run } }
84
-
85
- context "when pippi.yml is absent" do
86
-
87
- include_context "with pippi.yml"
88
-
89
- it_behaves_like "environments loader"
90
- it_behaves_like "file creator"
91
- it_behaves_like "metric runner"
92
- end
93
-
94
- context "when pippi.yml is present" do
95
-
96
- include_context "without pippi.yml"
97
-
98
- it_behaves_like "environments loader"
99
- it_behaves_like "file creator"
100
- it_behaves_like "metric runner"
101
- end
102
- end
103
-
104
- end if USE_PIPPI_METRIC
@@ -1,102 +0,0 @@
1
- # encoding: utf-8
2
- require "spec_helper"
3
- require "simplecov"
4
-
5
- describe Hexx::Suit::Metrics::SimpleCov, :sandbox do
6
-
7
- shared_context "without simplecov.yml" do
8
-
9
- let(:options) do
10
- {
11
- "output" => "tmp/coverage",
12
- "filters" => ["spec/", "config/"],
13
- "groups" => {
14
- "Libraries" => "lib/",
15
- "Application" => "app/"
16
- }
17
- }
18
- end
19
- end
20
-
21
- shared_context "with simplecov.yml" do
22
-
23
- let(:options) do
24
- {
25
- "output" => "custom",
26
- "filters" => ["custom/"],
27
- "groups" => { "Custom" => "custom/" }
28
- }
29
- end
30
-
31
- before { prepare_settings options, "config/metrics/simplecov.yml" }
32
- end
33
-
34
- shared_examples "environmets setter" do
35
-
36
- before do
37
- ENV["USE_SIMPLECOV"] = nil
38
- ENV["SIMPLECOV_OUTPUT"] = nil
39
- end
40
-
41
- it "[sets USE_SIMPLECOV]" do
42
- expect { subject }
43
- .to change { ENV["USE_SIMPLECOV"] }
44
- .to "true"
45
- end
46
-
47
- it "[sets SIMPLECOV_OUTPUT]" do
48
- expect { subject }
49
- .to change { ENV["SIMPLECOV_OUTPUT"] }
50
- .to "#{ options['output'] }/index.html"
51
- end
52
- end
53
-
54
- shared_examples "metric loader" do
55
-
56
- after { subject }
57
-
58
- it "starts the metric" do
59
- expect(::SimpleCov).to receive(:start)
60
- end
61
- end
62
-
63
- describe ".load" do
64
-
65
- subject { try_in_sandbox { described_class.load } }
66
-
67
- context "without simplecov.yml" do
68
-
69
- include_context "without simplecov.yml"
70
-
71
- it_behaves_like "environmets setter"
72
- end
73
-
74
- context "with simplecov.yml" do
75
-
76
- include_context "with simplecov.yml"
77
-
78
- it_behaves_like "environmets setter"
79
- end
80
- end
81
-
82
- describe ".run" do
83
-
84
- subject { try_in_sandbox { described_class.run } }
85
-
86
- context "without simplecov.yml" do
87
-
88
- include_context "without simplecov.yml"
89
-
90
- it_behaves_like "environmets setter"
91
- it_behaves_like "metric loader"
92
- end
93
-
94
- context "with simplecov.yml" do
95
-
96
- include_context "without simplecov.yml"
97
-
98
- it_behaves_like "environmets setter"
99
- it_behaves_like "metric loader"
100
- end
101
- end
102
- end