rails_config_validator 3.1.2 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 924b5eae765672ce30b8818688ef0bc21548f37c
4
- data.tar.gz: 1bfc42fdc79a01f93a2e51013635272c08415791
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWQ5NjU1NzU1MDdmOTRlM2U1YzQwMDg2NmFmODhlOTJmMDI3N2NjYw==
5
+ data.tar.gz: !binary |-
6
+ ZjVhNTM2OTU1YTI2NDRlOTMwZjc0YjQ0MTZmZDRiNjhiNmYyOWNlZQ==
5
7
  SHA512:
6
- metadata.gz: 28e23fa6df7b7324d2c597c71ca418c0871826e064dbfdec5f0ee6a75f3be7834e3c0ea025d912de2136d7e5e0d1c0762644171cee2a183ac2337d5158a09962
7
- data.tar.gz: c94db5ba87ce99be47b1108a94353670ba7fe853476cb1509724d33af685cb27c3701990da0e04a2e7bd0accdea879eda95efcb13a504637c55f0e43c2506a2b
8
+ metadata.gz: !binary |-
9
+ YTcwMGY0YjhhYmMyMDQ4YmYyMzQ4ZjBhN2IxOGVhOGU5NTFlYTU1N2NhNWY1
10
+ MDA1MWViOGZlNjdhYjlmMDVmOTk0NzcxNGNmMzVjYjY1ZDc3ZjQ1YjNmNmIy
11
+ YjEyYjlhYWYwMDEwYWU5MmJhNTQ1MTdhZWE1OGQ3MDI3MjdkOWU=
12
+ data.tar.gz: !binary |-
13
+ ZmExOTI4ZTljZTUxNmExODEwMWEwMWNhNzFhNzU3ZTFkODc3ZjllMTc3ODJi
14
+ N2VlZDcyODZiYTljNmRiNDE4ZmRlZDcyMzQzNTBlZjAyYmY2NzA1MWE1ZDNl
15
+ ODhhMzZlZWY1MzE1ZTg2YmM5M2Q5MmY5Njc3M2FhY2Y0YjFkMWU=
data/.rubocop.yml CHANGED
@@ -1 +1,8 @@
1
1
  inherit_from: .rubocop_u2i.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 1.9
5
+
6
+ Style/RescueModifier:
7
+ Exclude:
8
+ - spec/**/*_spec.rb
data/.rubocop_u2i.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  require: rubocop-rspec
2
2
 
3
3
  AllCops:
4
- RunRailsCops: true
5
4
  Include:
6
5
  - '**/Rakefile'
7
6
  - config.ru
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ env:
3
3
  language: ruby
4
4
  rvm:
5
5
  - 1.9.3
6
- - 2.1.5
7
- - 2.2.1
6
+ - 2.1
7
+ - 2.2
8
+ - 2.3.0
8
9
  - jruby-19mode
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [3.2.0] - 2016-05-12
8
+ ### Added
9
+ - Added `raise_errors` option to allow disabling exceptions and show warnings instead.
10
+
@@ -3,6 +3,7 @@ module RailsConfigValidator
3
3
  config.before_configuration do
4
4
  config.config_validator = ActiveSupport::OrderedOptions.new
5
5
  config.config_validator.configs %w(database)
6
+ config.config_validator.raise_errors true
6
7
  end
7
8
 
8
9
  rake_tasks do
@@ -12,8 +13,9 @@ module RailsConfigValidator
12
13
  end
13
14
 
14
15
  initializer 'config_validator.configure' do
16
+ raise_errors = config.config_validator.raise_errors
15
17
  validators = config.config_validator.configs.map do |config|
16
- RailsConfigValidator::Validator.new(config, Rails.env, pwd: Rails.root)
18
+ RailsConfigValidator::Validator.new(config, Rails.env, pwd: Rails.root, raise_errors: raise_errors)
17
19
  end
18
20
 
19
21
  validators.each(&:valid!)
@@ -32,7 +32,7 @@ module RailsConfigValidator
32
32
  task :validate, [:config, :env] do |_, args|
33
33
  config = args[:config]
34
34
  env = args[:env] || Rails.env
35
- fail 'Missing parameter :config' if args[:config].nil?
35
+ raise 'Missing parameter :config' if args[:config].nil?
36
36
 
37
37
  v = RailsConfigValidator::Validator.new(config, env, pwd: Rails.root)
38
38
  v.valid!
@@ -10,6 +10,7 @@ module RailsConfigValidator
10
10
  @config_path = options[:config_path] || build_config_path(config_name)
11
11
  @schema_path = options[:schema_path] || build_schema_path(config_name)
12
12
  @env = env
13
+ @raise_errors = options.fetch(:raise_errors, true)
13
14
  end
14
15
 
15
16
  def valid?
@@ -21,11 +22,17 @@ module RailsConfigValidator
21
22
 
22
23
  def valid!
23
24
  mv = meta_validate
24
- fail InvalidSchemaError,
25
- "Incorrect schema #{schema_path}; errors: #{mv}" unless mv.empty?
25
+ return error(
26
+ InvalidSchemaError,
27
+ "Incorrect schema #{schema_path}; errors: #{mv}"
28
+ ) unless mv.empty?
26
29
  v = validate
27
- fail InvalidConfigurationError,
28
- "Incorrect config #{config_path}; errors: #{v}" unless v.empty?
30
+ error(
31
+ InvalidConfigurationError,
32
+ "Incorrect config #{config_path}; errors: #{v}"
33
+ ) unless v.empty?
34
+ rescue InvalidConfigurationError, InvalidSchemaError => e
35
+ error(e.class, e)
29
36
  end
30
37
 
31
38
  def meta_validate
@@ -55,6 +62,11 @@ module RailsConfigValidator
55
62
 
56
63
  attr_reader :config_path, :schema_path
57
64
 
65
+ def error(*args)
66
+ raise(*args) if @raise_errors
67
+ warn(args.join("\n")) # Ruby 1.9 accepts only single argument
68
+ end
69
+
58
70
  def kwalify_validator
59
71
  Kwalify::Validator.new(schema)
60
72
  rescue Errno::ENOENT => e
@@ -66,15 +78,15 @@ module RailsConfigValidator
66
78
  end
67
79
 
68
80
  def config
69
- YAML.load(ERB.new((File.read(config_path))).result)
81
+ YAML.load(ERB.new(File.read(config_path)).result)
70
82
  end
71
83
 
72
84
  def env_config
73
85
  document = config
74
- fail InvalidConfigurationError,
75
- "config file #{config_path} is empty" unless document
76
- fail InvalidConfigurationError,
77
- "missing configuration for env #{@env} in #{config_path}" unless document.key?(@env)
86
+ raise InvalidConfigurationError,
87
+ "config file #{config_path} is empty" unless document
88
+ raise InvalidConfigurationError,
89
+ "missing configuration for env #{@env} in #{config_path}" unless document.key?(@env)
78
90
  document[@env]
79
91
  end
80
92
 
@@ -1,3 +1,3 @@
1
1
  module RailsConfigValidator
2
- VERSION = '3.1.2'
2
+ VERSION = '3.2.0'.freeze
3
3
  end
@@ -27,8 +27,9 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_development_dependency 'bundler', '~> 1.7'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'u2i-ci_utils', '~> 1.0.2'
30
+ spec.add_development_dependency 'u2i-ci_utils', '~> 3.0'
31
31
 
32
32
  spec.add_development_dependency 'guard-rubocop', '~> 1.2'
33
33
  spec.add_development_dependency 'guard-rspec', '~> 4.5'
34
+ spec.add_development_dependency 'listen', '~> 3.0.5'
34
35
  end
metadata CHANGED
@@ -1,99 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_config_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.2.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: 2016-01-07 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kwalify
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.7.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.7.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.7'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '10.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '10.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: u2i-ci_utils
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.2
61
+ version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.2
68
+ version: '3.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.2'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: guard-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '4.5'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '4.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: listen
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.5
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.5
97
111
  description: The gem uses Kwalify schema validator to check Rails configuration files
98
112
  syntax.
99
113
  email:
@@ -102,11 +116,12 @@ executables: []
102
116
  extensions: []
103
117
  extra_rdoc_files: []
104
118
  files:
105
- - ".gitignore"
106
- - ".rspec"
107
- - ".rubocop.yml"
108
- - ".rubocop_u2i.yml"
109
- - ".travis.yml"
119
+ - .gitignore
120
+ - .rspec
121
+ - .rubocop.yml
122
+ - .rubocop_u2i.yml
123
+ - .travis.yml
124
+ - CHANGELOG.md
110
125
  - Gemfile
111
126
  - Guardfile
112
127
  - README.md
@@ -132,12 +147,12 @@ require_paths:
132
147
  - lib
133
148
  required_ruby_version: !ruby/object:Gem::Requirement
134
149
  requirements:
135
- - - ">="
150
+ - - ! '>='
136
151
  - !ruby/object:Gem::Version
137
152
  version: '0'
138
153
  required_rubygems_version: !ruby/object:Gem::Requirement
139
154
  requirements:
140
- - - ">="
155
+ - - ! '>='
141
156
  - !ruby/object:Gem::Version
142
157
  version: '0'
143
158
  requirements: []