diff --git a/.gitignore b/.gitignore index c274f41..132bd16 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,4 @@ build-iPhoneSimulator/ .rvmrc /site/public /.byebug_history +/.idea diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 index 0000000..b5f802f --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1 @@ +copper \ No newline at end of file diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..6bf7c6f --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-2.5.1 diff --git a/Gemfile.lock b/Gemfile.lock index 5bb2c82..21ef7d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - c66-copper (0.0.3) + c66-copper (0.0.4) colorize (~> 0.8) ipaddress (~> 0.8) json (~> 1.4) @@ -17,8 +17,8 @@ GEM colorize (0.8.1) ffi (1.9.23) ipaddress (0.8.3) - json (1.8.3) - jsonpath (0.8.11) + json (1.8.6) + jsonpath (0.9.4) multi_json to_regexp (~> 0.2.1) listen (3.1.5) @@ -37,7 +37,7 @@ GEM semantic (1.6.1) thor (0.20.0) to_regexp (0.2.1) - treetop (1.6.9) + treetop (1.6.10) polyglot (~> 0.3) PLATFORMS @@ -51,4 +51,4 @@ DEPENDENCIES rerun (~> 0.13) BUNDLED WITH - 1.16.1 + 1.16.4 diff --git a/a.yaml b/a.yaml new file mode 100644 index 0000000..2d3b967 --- /dev/null +++ b/a.yaml @@ -0,0 +1,2 @@ +a: + b: "c" \ No newline at end of file diff --git a/b.rule b/b.rule new file mode 100644 index 0000000..bdfb8a3 --- /dev/null +++ b/b.rule @@ -0,0 +1,3 @@ +rule abc warn { + fetch("") -> console +} \ No newline at end of file diff --git a/bin/copper b/bin/copper index 28e7e5c..b149e21 100755 --- a/bin/copper +++ b/bin/copper @@ -36,23 +36,40 @@ module Copper require 'byebug' if $debug rule_file = options[:rules] + if !rule_file + puts "No rule file provided. Use --rule option".red + exit(1) + end + unless File.exists?(rule_file) puts "Rule file #{rule_file} not found".red exit(1) end content_file = options[:file] + if !content_file + puts "No config file provided. Use --file option".red + exit(1) + end + unless File.exists?(content_file) puts "Config file #{content_file} not found".red exit(1) end rules = File.read(rule_file) - file = "" + if rules.empty? + puts "Empty rules file".red + exit(2) + end raise ::NotImplementedError if options[:format] != 'yaml' # load the yaml file and split them into separate yamls failed = false content = File.read(content_file) + if content.empty? + puts "Empty config file".red + exit(2) + end content.split('---').each_with_index do |part, idx| puts "Validating part #{idx}" file = YAML::load(part) diff --git a/lib/copper/version.rb b/lib/copper/version.rb index c5e2302..2cb2b33 100644 --- a/lib/copper/version.rb +++ b/lib/copper/version.rb @@ -1,5 +1,5 @@ module Copper - VERSION = '0.0.4' + VERSION = '0.0.5' COPYRIGHT_MESSAGE = "(c) 2018 Cloud66 Inc." APP_NAME = 'Copper' end