rails_config_validator 2.0.0 → 3.0.0

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
  SHA1:
3
- metadata.gz: 67c8251b05c08262e174c1727c3d449539f8a3a8
4
- data.tar.gz: 9c1fb552a782ebc78e1ec9df099350a3cefc0bab
3
+ metadata.gz: f93583591e13258cc8ed95209de28ade1b585681
4
+ data.tar.gz: 6976741ebe7d7f9bfb00062ebec2326e9467867f
5
5
  SHA512:
6
- metadata.gz: fed8a30e0e0206c509ad005eb614ed27ffa0d10fc83759e0c73fe19c5653695672ba13c5d97394a6d6d16992df81ac6c7883bd9e7d8fd09cc6c1ac0786dd928b
7
- data.tar.gz: 71b0ecef171d30906b4ba23e972f2b56e17a3775489ec132e349a3c617d55568fa9f0512023910504fed708ae1f29cefa3d3f8bca90b85cfdd7d090504c44d0b
6
+ metadata.gz: 82f940f1a026542327ff42a55f0a12ce7cac4fc04c3d5924efabed4d5f276f11ec9dceeb4d8fbb46471f809114602c5b99a1d44814e343c2f0defb82949242ec
7
+ data.tar.gz: 1d789358c7c353b2a19e67fa22cae69514a38846e380ef011749f61ac2aea0610a7409f40863e76d0433c7a5d710524142d1d54aea1dc7de066fc0fde285b5d8
@@ -6,10 +6,8 @@ module RailsConfigValidator
6
6
  end
7
7
 
8
8
  initializer 'config_validator.configure' do
9
- config_paths = config.config_validator.configs.map { |c| File.join(Rails.root, 'config', "#{c}.yml") }
10
-
11
- validators = config_paths.map do |config|
12
- RailsConfigValidator::Validator.new(config, Rails.env)
9
+ validators = config.config_validator.configs.map do |config|
10
+ RailsConfigValidator::Validator.new(config, Rails.env, pwd: Rails.root)
13
11
  end
14
12
 
15
13
  validators.each(&:valid!)
@@ -19,22 +19,22 @@ module RailsConfigValidator
19
19
  desc "Copies database.schema.yml to Rails's config directory"
20
20
  task :init do
21
21
  rake_file_dir = File.expand_path(File.dirname(__FILE__))
22
+ destination = FileUtils.mkpath(File.join(Dir.pwd, 'config', 'schemas'))
22
23
  FileUtils.cp(
23
24
  File.join(rake_file_dir, 'templates', 'database.schema.yml'),
24
- File.join(Dir.pwd, 'config')
25
+ destination
25
26
  )
26
27
  end
27
28
  end
28
29
 
29
30
  def task_validate
30
31
  desc 'Validates Rails config file against YML schema'
31
- task :validate, [:config, :schema, :env] do |_, args|
32
+ task :validate, [:config, :env] do |_, args|
32
33
  config = args[:config]
33
- schema = args[:schema]
34
34
  env = args[:env] || Rails.env
35
35
  fail 'Missing parameter :config' if args[:config].nil?
36
36
 
37
- v = RailsConfigValidator::Validator.new(config, env, schema)
37
+ v = RailsConfigValidator::Validator.new(config, env, pwd: Rails.root)
38
38
  v.valid!
39
39
  end
40
40
  end
@@ -44,7 +44,7 @@ module RailsConfigValidator
44
44
  desc 'Validates all Rails config files against YML schema'
45
45
  task :all, [:env] do |_, args|
46
46
  Rails.application.config.config_validator.configs.each do |file_name|
47
- Rake::Task['config_validator:validate'].invoke("config/#{file_name}.yml", nil, args[:env])
47
+ Rake::Task['config_validator:validate'].invoke(file_name, args[:env])
48
48
  end
49
49
  end
50
50
  end
@@ -4,9 +4,10 @@ require 'rails_config_validator/errors'
4
4
 
5
5
  module RailsConfigValidator
6
6
  class Validator
7
- def initialize(config_path, env, schema_path = nil)
8
- @config_path = config_path
9
- @schema_path = schema_path || config_to_schema_path(config_path)
7
+ def initialize(config_name, env, options = {})
8
+ @pwd = options[:pwd] || '.'
9
+ @config_path = options[:config_path] || build_config_path(config_name)
10
+ @schema_path = options[:schema_path] || build_schema_path(config_name)
10
11
  @env = env
11
12
  end
12
13
 
@@ -76,8 +77,12 @@ module RailsConfigValidator
76
77
  document[@env]
77
78
  end
78
79
 
79
- def config_to_schema_path(yml)
80
- yml.sub(/\.yml$/, '.schema.yml')
80
+ def build_config_path(config_name)
81
+ File.join(@pwd, 'config', "#{config_name}.yml")
82
+ end
83
+
84
+ def build_schema_path(config_name)
85
+ File.join(@pwd, 'config', 'schemas', "#{config_name}.schema.yml")
81
86
  end
82
87
  end
83
88
  end
@@ -1,3 +1,3 @@
1
1
  module RailsConfigValidator
2
- VERSION = '2.0.0'
2
+ VERSION = '3.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_config_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michał Knapik
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-08 00:00:00.000000000 Z
11
+ date: 2015-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kwalify