skunk 0.3.1 → 0.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31e5fabed605521119f56bd2d3391bf8f206562deeea374685ed9c2fa549e0f9
4
- data.tar.gz: e5a42b34af7d2162a25b4ab91abaa33dec4930c4c58ee44c9ecd1e74f05661e2
3
+ metadata.gz: 9d3c745cc66587d122f3765510fae8271ff4f9fe050a01b98de8691e247f2948
4
+ data.tar.gz: 8bc479b7593c3fdcfc2555649e2a3c08d77ef624eda2148d9ba5c6b56e62d1e8
5
5
  SHA512:
6
- metadata.gz: 6ec99d947845d5bb77f2efa446078e0fc20658c67b1bd75e618dbbe3d453403e080798124cf7d60e5799573e636ac6847fdecd1a4b37ad8404e766937530133b
7
- data.tar.gz: 51cdff8ee198c28b6281d5176e103b9af3f716656ef411716a945f9c21dbfe36894533849ac7b1090904073a10b0dc5131f7228fc16a23e4d0e7894abd77db81
6
+ metadata.gz: f2537c79bc13dcdc590d52076f46934ed522489cd2c4afe82aea8aca4064e274ece9391c9813188dffd79a23a080e46e36809afdd9c9731de528cfb84adbe3ac
7
+ data.tar.gz: a8b72fddcd6118858c4cf161c1aa99f3de087e22794cc3c6f68a8b1e1e6d94b2d9f1015a995aed65fd69305e254173b5f4ce615a8d5fe042893fe652274ca394
data/.reek.yml CHANGED
@@ -1,28 +1,33 @@
1
1
  # Auto generated by Reeks --todo flag
2
2
  ---
3
3
  detectors:
4
- UtilityFunction:
4
+ Attribute:
5
5
  exclude:
6
- - capture_output_streams
7
- - Skunk::Command::Compare#analyse_modified_files
8
- - Skunk::Command::Compare#build_details_path
6
+ - Skunk::Command::StatusReporter#analysed_modules
7
+ FeatureEnvy:
8
+ exclude:
9
+ - Skunk::Command::StatusReporter#table
9
10
  InstanceVariableAssumption:
10
11
  exclude:
11
- - Skunk::Cli::Application
12
12
  - Skunk::Cli::Command::Default
13
+ - Skunk::Cli::Options::Argv
13
14
  - RubyCritic::AnalysedModulesCollection
14
- TooManyStatements:
15
- exclude:
16
- - initialize
17
- - Skunk::Cli::Application#execute
18
15
  IrresponsibleModule:
19
16
  exclude:
20
17
  - Skunk::Cli::Command::Help
18
+ - Skunk::Cli::Options::Argv
21
19
  - Skunk::Cli::Options
22
20
  - RubyCritic::AnalysedModulesCollection
23
- Attribute:
21
+ NestedIterators:
24
22
  exclude:
25
- - Skunk::Command::StatusReporter#analysed_modules
26
- FeatureEnvy:
23
+ - Skunk::Cli::Options::Argv#parse
24
+ TooManyStatements:
27
25
  exclude:
28
- - Skunk::Command::StatusReporter#table
26
+ - initialize
27
+ - Skunk::Cli::Application#execute
28
+ - Skunk::Cli::Options::Argv#parse
29
+ UtilityFunction:
30
+ exclude:
31
+ - capture_output_streams
32
+ - Skunk::Command::Compare#analyse_modified_files
33
+ - Skunk::Command::Compare#build_details_path
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- skunk (0.3.1)
4
+ skunk (0.3.2)
5
5
  rubycritic (~> 4.2.1)
6
6
  terminal-table (~> 1.8.0)
7
7
 
@@ -1,16 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rubycritic/cli/options"
4
+ require "rubycritic/cli/application"
5
+
3
6
  require "skunk"
4
7
  require "skunk/rubycritic/analysed_module"
5
8
  require "skunk/cli/options"
6
9
  require "skunk/cli/command_factory"
7
10
 
8
- require "rubycritic/cli/application"
9
-
10
11
  module Skunk
11
12
  module Cli
12
13
  # Knows how to execute command line commands
13
14
  class Application < RubyCritic::Cli::Application
15
+ def initialize(argv)
16
+ @options = Skunk::Cli::Options.new(argv)
17
+ end
18
+
14
19
  def execute
15
20
  parsed_options = @options.parse.to_h
16
21
  reporter = Skunk::Cli::CommandFactory.create(parsed_options).execute
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "skunk/cli/commands/base"
4
+ require "rubycritic/commands/help"
4
5
 
5
6
  module Skunk
6
7
  module Cli
@@ -13,7 +13,7 @@ module Skunk
13
13
  HEADINGS = %w[file stink_score churn_times_cost churn cost coverage].freeze
14
14
 
15
15
  TEMPLATE = ERB.new(<<-TEMPL
16
- <%= ttable %>\n
16
+ <%= _ttable %>\n
17
17
  StinkScore Total: <%= total_stink_score %>
18
18
  Modules Analysed: <%= analysed_modules_count %>
19
19
  StinkScore Average: <%= stink_score_average %>
@@ -26,7 +26,7 @@ TEMPL
26
26
  def update_status_message
27
27
  opts = table_options.merge(headings: HEADINGS, rows: table)
28
28
 
29
- ttable = Terminal::Table.new(opts)
29
+ _ttable = Terminal::Table.new(opts)
30
30
 
31
31
  @status_message = TEMPLATE.result(binding)
32
32
  end
@@ -1,10 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubycritic/cli/options"
3
+ require "skunk/cli/options/argv"
4
+ require "rubycritic/cli/options/file"
4
5
 
5
6
  module Skunk
6
7
  module Cli
7
- class Options < RubyCritic::Cli::Options
8
+ # Knows how to parse options passed to the CLI application
9
+ class Options
10
+ attr_reader :argv_options, :file_options
11
+
12
+ def initialize(argv)
13
+ @argv_options = Argv.new(argv)
14
+ @file_options = RubyCritic::Cli::Options::File.new
15
+ end
16
+
17
+ def parse
18
+ argv_options.parse
19
+ file_options.parse
20
+ self
21
+ end
22
+
23
+ # :reek:NilCheck
24
+ def to_h
25
+ file_hash = file_options.to_h
26
+ argv_hash = argv_options.to_h
27
+
28
+ file_hash.merge(argv_hash) do |_, file_option, argv_option|
29
+ Array(argv_option).empty? ? file_option : argv_option
30
+ end
31
+ end
8
32
  end
9
33
  end
10
34
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubycritic/cli/options/argv"
4
+
5
+ module Skunk
6
+ module Cli
7
+ # :nodoc:
8
+ class Options
9
+ # Extends RubyCritic::Cli::Options::Argv to parse a subset of the
10
+ # parameters accepted by RubyCritic
11
+ class Argv < RubyCritic::Cli::Options::Argv
12
+ def parse # rubocop:disable Metrics/MethodLength
13
+ parser.new do |opts|
14
+ opts.banner = "Usage: skunk [options] [paths]\n"
15
+
16
+ opts.on(
17
+ "-p", "--path [PATH]",
18
+ "Set path where report will be saved (tmp/skunk by default)"
19
+ ) do |path|
20
+ @root = path
21
+ end
22
+
23
+ opts.on("-b", "--branch BRANCH", "Set branch to compare") do |branch|
24
+ self.base_branch = String(branch)
25
+ set_current_branch
26
+ self.mode = :compare_branches
27
+ end
28
+
29
+ opts.on_tail("-v", "--version", "Show gem's version") do
30
+ self.mode = :version
31
+ end
32
+
33
+ opts.on_tail("-h", "--help", "Show this message") do
34
+ self.mode = :help
35
+ end
36
+ end.parse!(@argv)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Skunk
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernesto Tagwerker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2019-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubycritic
@@ -196,6 +196,7 @@ files:
196
196
  - lib/skunk/cli/commands/help.rb
197
197
  - lib/skunk/cli/commands/status_reporter.rb
198
198
  - lib/skunk/cli/options.rb
199
+ - lib/skunk/cli/options/argv.rb
199
200
  - lib/skunk/rubycritic/analysed_module.rb
200
201
  - lib/skunk/rubycritic/analysed_modules_collection.rb
201
202
  - lib/skunk/version.rb