rubocop-stylecheck 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4437a4c241babe988942663869d2170d3e6f062f
4
- data.tar.gz: 66fe62aacc4033881906e2715c8869a13ff83eb2
3
+ metadata.gz: a660893931884643cf4ae2aebb2e377dd559131b
4
+ data.tar.gz: 7b5e3aaf96fe5b3d5c581fb9f723a8da0a80d75e
5
5
  SHA512:
6
- metadata.gz: 88e02b388440d9a1a4de25207cb00d0b2a0bc90ec6f9e5068340effb07b24a5c18cfd8298a50d1720cf02868cd156d9849c3c8d1ca9bafa2be64c0f032a6fd7d
7
- data.tar.gz: 861917fd1abd339b965d17448a0258ccaab79eb8c68ed7aa45e499cdc2d607f6ad429c544ba65b729d1c85ba965f7395188307690c174534247aafdb3ca4f1fe
6
+ metadata.gz: c8f70943ffdead8492f6f2df8b92f2be3aa9ea3ff3f70f0ff6fa28c7d51f1a9bbfca2defa6fb1ecbb1951a83ee07c2523f1d598e616e7196d48da1cbae6ae13b
7
+ data.tar.gz: fdd19e53cef94df422cc179258da8f2af822b6afaf39b52aab2d1d3a546a790d18934f6135ebf383ee0df7f158d58b4166f4a2b69a8ad40555cf4269fd49f6c3
@@ -2,6 +2,35 @@ module Rubocop
2
2
  module Stylecheck
3
3
  module Cli
4
4
  class << self
5
+ def run(options)
6
+ if Rubocop::Stylecheck.direct
7
+ direct_run(options)
8
+ else
9
+ run_via_sh(options)
10
+ end
11
+ end
12
+
13
+ def direct_run(options)
14
+ require "rubocop"
15
+ require "benchmark"
16
+
17
+ cli = RuboCop::CLI.new
18
+ result = 0
19
+
20
+ time = Benchmark.realtime do
21
+ result = cli.run(options)
22
+ end
23
+
24
+ puts "Finished in #{time} seconds" if cli.options[:debug]
25
+ exit result
26
+ end
27
+
28
+ def run_via_sh(options)
29
+ system "bundle exec rubocop #{options.join(' ')}" do |ok, _res|
30
+ abort "Fix code style errors" unless ok
31
+ end
32
+ end
33
+
5
34
  def options
6
35
  options = ["--fail-level", "refactor"]
7
36
  options += ["--rails"] if defined?(Rails)
@@ -1,22 +1,20 @@
1
1
  require "rubocop/stylecheck"
2
2
  require "fileutils"
3
3
 
4
- def run(options)
5
- sh "bundle exec rubocop #{options.join(' ')}" do |ok, _res|
6
- abort "Fix code style errors" unless ok
7
- end
8
- end
9
-
10
4
  namespace :style do
11
5
  namespace :rubocop do
12
6
  desc "Run RuboCop with auto_correct"
13
7
  task :with_auto_correct do
14
- run(Rubocop::Stylecheck::Cli.options_with_auto_correct)
8
+ Rubocop::Stylecheck::Cli.run(
9
+ Rubocop::Stylecheck::Cli.options_with_auto_correct
10
+ )
15
11
  end
16
12
 
17
13
  desc "Run RuboCop without auto_correct"
18
14
  task :without_auto_correct do
19
- run(Rubocop::Stylecheck::Cli.options_with_cop)
15
+ Rubocop::Stylecheck::Cli.run(
16
+ Rubocop::Stylecheck::Cli.options_with_cop
17
+ )
20
18
  end
21
19
 
22
20
  desc "Generate local RuboCop config"
@@ -27,7 +25,8 @@ namespace :style do
27
25
  if template_config_path && File.exist?(template_config_path)
28
26
  FileUtils.cp(template_config_path, project_config_path)
29
27
  else
30
- abort "Config file doesn't exist, please use Robocop::Stylecheck.config_path = ..."
28
+ abort "Config file doesn't exist, please use" \
29
+ "Robocop::Stylecheck.config_path = ..."
31
30
  end
32
31
  end
33
32
  end
@@ -1,5 +1,5 @@
1
1
  module Rubocop
2
2
  module Stylecheck
3
- VERSION = "0.1.1".freeze
3
+ VERSION = "0.1.2".freeze
4
4
  end
5
5
  end
@@ -3,7 +3,7 @@ require "rubocop/stylecheck/version"
3
3
  module Rubocop
4
4
  module Stylecheck
5
5
  class << self
6
- attr_accessor :config_path
6
+ attr_accessor :config_path, :direct
7
7
 
8
8
  def project_config_path
9
9
  File.join(Dir.pwd, ".rubocop.yml")
@@ -1 +1 @@
1
- require "rubocop/stylecheck"
1
+ require "rubocop/stylecheck"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-stylecheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Wawer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-05 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler