Skip to content

Commit 4109373

Browse files
committed
Refactor dependencies command to prepare
Reflecting the change in yaml key names, the command will also be called prepare now
1 parent f8fa2d0 commit 4109373

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

lib/cc/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module CLI
1111
autoload :Command, "cc/cli/command"
1212
autoload :Console, "cc/cli/console"
1313
autoload :Engines, "cc/cli/engines"
14-
autoload :Dependencies, "cc/cli/dependencies"
1514
autoload :Help, "cc/cli/help"
1615
autoload :Init, "cc/cli/init"
16+
autoload :Prepare, "cc/cli/prepare"
1717
autoload :Runner, "cc/cli/runner"
1818
autoload :Test, "cc/cli/test"
1919
autoload :ValidateConfig, "cc/cli/validate_config"

lib/cc/cli/help.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def commands
2121
"engines:install",
2222
"engines:list",
2323
"engines:remove #{underline("engine_name")}",
24-
"dependencies",
24+
"prepare",
2525
"help",
2626
"init",
2727
"validate-config",

lib/cc/cli/dependencies.rb renamed to lib/cc/cli/prepare.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
module CC
1111
module CLI
12-
class Dependencies < Command
12+
class Prepare < Command
1313
InternalHostError = Class.new(StandardError)
1414
FetchError = Class.new(StandardError)
1515

@@ -24,10 +24,10 @@ class Dependencies < Command
2424

2525
def run
2626
require_codeclimate_yml
27-
fatal("No file dependencies configured") unless files.present?
27+
fatal("No fetches configured") unless fetches.present?
2828

2929
::CC::Resolv.with_fixed_dns { fetch_all }
30-
success("All file dependencies fetched")
30+
success("All fetches fetched")
3131
rescue FetchError, InternalHostError => ex
3232
fatal(ex.message)
3333
end
@@ -38,16 +38,16 @@ def allow_internal_ips?
3838
@args.include?("--allow-internal-ips")
3939
end
4040

41-
def files
42-
@files ||= config.dependencies && config.dependencies.files
41+
def fetches
42+
@fetches ||= config[:prepare] && config[:prepare].fetch
4343
end
4444

4545
def config
4646
@config ||= CC::Yaml.parse(filesystem.read_path(CODECLIMATE_YAML))
4747
end
4848

4949
def fetch_all
50-
files.each do |entry|
50+
fetches.each do |entry|
5151
fetch(entry.url, entry.path)
5252
end
5353
end

spec/cc/cli/dependencies_spec.rb renamed to spec/cc/cli/prepare_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
require "spec_helper"
22

33
module CC::CLI
4-
describe Dependencies do
4+
describe Prepare do
55
include FileSystemHelpers
66
include ProcHelpers
77

88
FIXTURE_CONFIG = <<YAML
9-
dependencies:
10-
files:
9+
prepare:
10+
fetch:
1111
- url: "http://example.com/foo.json"
1212
path: bar.json
1313
YAML
@@ -23,7 +23,7 @@ module CC::CLI
2323

2424
stub_resp("example.com", "255.255.255.255", resp)
2525
stdout, stderr = capture_io do
26-
Dependencies.new.run
26+
Prepare.new.run
2727
end
2828
expect(stdout).to match("Wrote http://example.com/foo.json to bar.json")
2929

@@ -37,7 +37,7 @@ module CC::CLI
3737

3838
stub_resp("example.com", "127.0.0.1", resp)
3939
stdout, stderr, _ = capture_io_and_exit_code do
40-
Dependencies.new.run
40+
Prepare.new.run
4141
end
4242
expect(stderr).to match("maps to an internal address")
4343

@@ -50,7 +50,7 @@ module CC::CLI
5050

5151
stub_resp("example.com", "127.0.0.1", resp)
5252
stdout, stderr = capture_io do
53-
Dependencies.new(["--allow-internal-ips"]).run
53+
Prepare.new(["--allow-internal-ips"]).run
5454
end
5555
expect(stdout).to match("Wrote http://example.com/foo.json to bar.json")
5656

@@ -64,7 +64,7 @@ module CC::CLI
6464

6565
stub_resp("example.com", "255.255.255.255", resp)
6666
stdout, stderr, _ = capture_io_and_exit_code do
67-
Dependencies.new.run
67+
Prepare.new.run
6868
end
6969
expect(stderr).to match("Failed fetching")
7070

0 commit comments

Comments
 (0)