codeclimate 0.2.4 → 0.2.6

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: 3dbff022149c78ea083976a0acf56e1da6d5b1d8
4
- data.tar.gz: 2d6297f56bf20b11b0159cb661f4123841a600e9
3
+ metadata.gz: 5d22f3f348dc789674ada7a4873bcde294a7b278
4
+ data.tar.gz: 65f5b34f666a35b6fcf9e69968e7597c3ae0318a
5
5
  SHA512:
6
- metadata.gz: e3f1a4161715e07abde090de18b58b219d9a538440b5fc59482d225c8a221d6c4ac8204a1771407f7588d4e82cdc7d3a4cb13123369aabc39b1ee99a4db367d6
7
- data.tar.gz: ecd82f39eaabca068d9793158b6d060d7a364e382bf851e41bd3b2d8f4a1b2b3ce2f0c8d26791aad65d6bce2e9b429118af75fd84ff6f1c45ce3efe0ea7b14b7
6
+ metadata.gz: 6fbe2daeb6327989f76ef44b242633107fcad116433fdf21f58cdc0d338e8a77c5b4c4adbe8736cc53b0965d813f56edf11e5bc5391eec48e6d8e2a472bade75
7
+ data.tar.gz: 517de74c052b220eab45ebd736623da94d5523b223deebb0a8108c8320df0543960c74c75529f816f2ee9ce05c4cd5dd18588ee7850a3141f5e4f85a49a5f3e1
@@ -21,6 +21,11 @@ module CC
21
21
  @config
22
22
  end
23
23
 
24
+ def exists?(engine_name)
25
+ return true if dev_mode?
26
+ list.keys.include?(engine_name)
27
+ end
28
+
24
29
  private
25
30
 
26
31
  def dev_mode?
@@ -12,8 +12,10 @@ module CC
12
12
  def run
13
13
  require_codeclimate_yml
14
14
 
15
- runner = EnginesRunner.new(registry, formatter, source_dir, config)
16
- runner.run
15
+ Dir.chdir(ENV['FILESYSTEM_DIR']) do
16
+ runner = EnginesRunner.new(registry, formatter, source_dir, config)
17
+ runner.run
18
+ end
17
19
 
18
20
  rescue EnginesRunner::InvalidEngineName => ex
19
21
  fatal(ex.message)
@@ -60,6 +60,10 @@ module CC
60
60
  def terminal
61
61
  @terminal ||= HighLine.new($stdin, $stdout)
62
62
  end
63
+
64
+ def engine_registry
65
+ @engine_registry ||= CC::Analyzer::EngineRegistry.new
66
+ end
63
67
  end
64
68
  end
65
69
  end
@@ -1,12 +1,10 @@
1
1
  module CC
2
2
  module CLI
3
3
  class Console < Command
4
-
5
4
  def run
6
5
  require "pry"
7
6
  binding.pry(quiet: true, prompt: Pry::SIMPLE_PROMPT, output: $stdout)
8
7
  end
9
-
10
8
  end
11
9
  end
12
10
  end
@@ -33,11 +33,11 @@ module CC
33
33
  end
34
34
 
35
35
  def engine_exists?
36
- engines_registry_list.keys.include?(engine_name)
36
+ engine_registry.exists?(engine_name)
37
37
  end
38
38
 
39
- def engines_registry_list
40
- @engines_registry_list ||= CC::Analyzer::EngineRegistry.new.list
39
+ def engine_registry_list
40
+ engine_registry.list
41
41
  end
42
42
  end
43
43
  end
@@ -1,5 +1,3 @@
1
- require "cc/analyzer"
2
-
3
1
  module CC
4
2
  module CLI
5
3
  module Engines
@@ -17,7 +15,7 @@ module CC
17
15
 
18
16
  def pull_docker_images
19
17
  engine_names.each do |name|
20
- if engine_exists?(name)
18
+ if engine_registry.exists?(name)
21
19
  image = engine_image(name)
22
20
  pull_engine_image(image)
23
21
  else
@@ -30,12 +28,8 @@ module CC
30
28
  @engine_names ||= parsed_yaml.engine_names
31
29
  end
32
30
 
33
- def engine_exists?(engine_name)
34
- engines_registry_list.keys.include?(engine_name)
35
- end
36
-
37
31
  def engine_image(engine_name)
38
- engines_registry_list[engine_name]["image"]
32
+ engine_registry_list[engine_name]["image"]
39
33
  end
40
34
 
41
35
  def pull_engine_image(engine_image)
@@ -4,7 +4,7 @@ module CC
4
4
  class List < EngineCommand
5
5
  def run
6
6
  say "Available engines:"
7
- engines_registry_list.sort_by { |name, _| name }.each do |name, attributes|
7
+ engine_registry_list.sort_by { |name, _| name }.each do |name, attributes|
8
8
  say "- #{name}: #{attributes["description"]}"
9
9
  end
10
10
  end
data/lib/cc/cli/init.rb CHANGED
@@ -52,7 +52,7 @@ module CC
52
52
  end
53
53
 
54
54
  def eligible_engines
55
- CC::Analyzer::EngineRegistry.new.list.each_with_object({}) do |(engine_name, config), result|
55
+ engine_registry.list.each_with_object({}) do |(engine_name, config), result|
56
56
  if engine_eligible?(config)
57
57
  result[engine_name] = config
58
58
  end
@@ -6,6 +6,8 @@ module CC
6
6
  include CC::Analyzer
7
7
  include CC::Yaml
8
8
 
9
+ VALID_CONFIG_MESSAGE = "No errors or warnings found in .codeclimate.yml file.".freeze
10
+
9
11
  def run
10
12
  require_codeclimate_yml
11
13
  verify_yaml
@@ -17,12 +19,12 @@ module CC
17
19
  if any_issues?
18
20
  display_issues
19
21
  else
20
- puts colorize("No errors or warnings found in .codeclimate.yml file.", :green)
22
+ puts colorize(VALID_CONFIG_MESSAGE, :green)
21
23
  end
22
24
  end
23
25
 
24
26
  def any_issues?
25
- parsed_yaml.errors? || parsed_yaml.nested_warnings.any? || parsed_yaml.warnings?
27
+ parsed_yaml.errors? || parsed_yaml.nested_warnings.any? || parsed_yaml.warnings? || invalid_engines.any?
26
28
  end
27
29
 
28
30
  def yaml_content
@@ -48,28 +50,47 @@ module CC
48
50
  def display_issues
49
51
  display_errors
50
52
  display_warnings
53
+ display_invalid_engines
51
54
  display_nested_warnings
52
55
  end
53
56
 
54
57
  def display_errors
55
58
  errors.each do |error|
56
- puts colorize("ERROR: " + error, :red)
59
+ puts colorize("ERROR: #{error}", :red)
57
60
  end
58
61
  end
59
62
 
60
63
  def display_nested_warnings
61
64
  nested_warnings.each do |nested_warning|
62
65
  if nested_warning[0][0]
63
- puts colorize("WARNING in " + nested_warning[0][0] + ": " + nested_warning[1], :red)
66
+ puts colorize("WARNING in #{nested_warning[0][0]}: #{nested_warning[1]}", :red)
64
67
  end
65
68
  end
66
69
  end
67
70
 
68
71
  def display_warnings
69
72
  warnings.each do |warning|
70
- puts colorize("WARNING: " + warning, :red)
73
+ puts colorize("WARNING: #{warning}", :red)
71
74
  end
72
75
  end
76
+
77
+ def display_invalid_engines
78
+ invalid_engines.each do |engine_name|
79
+ puts colorize("WARNING: unknown engine <#{engine_name}>", :red)
80
+ end
81
+ end
82
+
83
+ def invalid_engines
84
+ @invalid_engines ||= engine_names.reject { |engine_name| engine_registry.exists? engine_name }
85
+ end
86
+
87
+ def engine_names
88
+ @engine_names ||= engines.keys
89
+ end
90
+
91
+ def engines
92
+ @engines ||= parsed_yaml.engines || {}
93
+ end
73
94
  end
74
95
  end
75
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code Climate
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-31 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport