Skip to content

Commit

Permalink
Updated to dry-schema 1.0 (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdubya authored and pkuczynski committed Jun 20, 2019
1 parent 3903f06 commit c7896dd
Show file tree
Hide file tree
Showing 108 changed files with 61 additions and 1,767 deletions.
44 changes: 0 additions & 44 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,15 @@ language: ruby
cache: bundler
sudo: false
rvm:
- 2.0.0
- 2.1.10
- 2.2.10
- 2.3.8
- 2.4.5
- 2.5.3
- 2.6.0
gemfile:
- gemfiles/rails_3.gemfile
- gemfiles/rails_4.gemfile
- gemfiles/rails_4.1.gemfile
- gemfiles/rails_4.2.gemfile
- gemfiles/rails_5.gemfile
- gemfiles/rails_5.1.gemfile
- gemfiles/rails_5.2.gemfile
- gemfiles/sinatra.gemfile
matrix:
exclude:
# Rails 3 requires Ruby 1.8.7 or newer
# Rails 4 prefers Ruby 2.0 and requires 1.9.3 or newer
# Rails 4.1 recommends Ruby 2.1 and requires 1.9.3 or newer
# Rails 4.2.1 recommends Ruby 2.2 and requires 1.9.3 or newer
# Rails 5 requires Ruby 2.2.2 or newer
# Sinatra 2 requires Ruby 2.2.2 or newer
- rvm: 2.0.0
gemfile: gemfiles/rails_5.gemfile
- rvm: 2.0.0
gemfile: gemfiles/rails_5.1.gemfile
- rvm: 2.0.0
gemfile: gemfiles/rails_5.2.gemfile
- rvm: 2.0.0
gemfile: gemfiles/sinatra.gemfile
- rvm: 2.1.10
gemfile: gemfiles/rails_5.gemfile
- rvm: 2.1.10
gemfile: gemfiles/rails_5.1.gemfile
- rvm: 2.1.10
gemfile: gemfiles/rails_5.2.gemfile
- rvm: 2.1.10
gemfile: gemfiles/sinatra.gemfile
# Rails 4 and 4.1 fails with Ruby newer then 2.3
- rvm: 2.4.5
gemfile: gemfiles/rails_4.gemfile
- rvm: 2.4.5
gemfile: gemfiles/rails_4.1.gemfile
- rvm: 2.5.3
gemfile: gemfiles/rails_4.gemfile
- rvm: 2.5.3
gemfile: gemfiles/rails_4.1.gemfile
- rvm: 2.6.0
gemfile: gemfiles/rails_4.gemfile
- rvm: 2.6.0
gemfile: gemfiles/rails_4.1.gemfile
before_install:
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
- gem install bundler -v '< 2'
Expand Down
16 changes: 0 additions & 16 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
appraise 'rails-3' do
gem 'sqlite3', '< 1.4.0'
gem 'rails', '3.2.22.5'
end

appraise 'rails-4' do
gem 'sqlite3', '< 1.4.0'
gem 'rails', '4.0.13'
end

appraise 'rails-4.1' do
gem 'sqlite3', '< 1.4.0'
gem 'rails', '4.1.16'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
end

appraise 'rails-4.2' do
gem 'sqlite3', '< 1.4.0'
gem 'rails', '4.2.11'
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

## Unreleased

## BREAKING CHANGES

* Dropped support for Rails `< 4.2`
* Dropped support for Ruby `< 2.4`

### Changes

* Upgraded dry-validation dependency to dry-schema 1.0 ([#224](https://github.com/railsconfig/config/pull/224))

## 1.7.2

### Bug fixes
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ Config helps you easily manage environment specific settings in an easy and usab

## Compatibility

* Ruby `2.x`
* Rails `>= 3.1`, `4` and `5`
* Ruby `>= 2.4`
* Rails `>= 4.2` and `5`
* Padrino
* Sinatra

For Ruby 2.0 to 2.3 or Rails 3 to 4.1 use version `1.x`.

For older versions of Rails or Ruby use [AppConfig](http://github.com/fredwu/app_config).

## Installing

### Installing on Rails 3, 4 or 5
### Installing on Rails

Add `gem 'config'` to your `Gemfile` and run `bundle install` to install it. Then run

Expand Down Expand Up @@ -316,7 +318,7 @@ If you define a schema it will automatically be used to validate your config. If
raise a `Config::Validation::Error` containing a nice message with information about all the mismatches
between the schema and your config.

Check [dry-validation](https://github.com/dry-rb/dry-validation) for more details.
Check [dry-schema](https://github.com/dry-rb/dry-schema) for more details.

### Missing keys

Expand Down
30 changes: 6 additions & 24 deletions config.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,18 @@ Gem::Specification.new do |s|
s.files += Dir.glob('doc/**/*')

s.require_paths = ['lib']
s.required_ruby_version = '>= 2.0.0'
s.required_ruby_version = '>= 2.4.0'

s.add_dependency 'activesupport', '>= 4.2'
s.add_dependency 'deep_merge', '~> 1.2', '>= 1.2.1'
s.add_dependency 'dry-schema', '~> 1.0'

if RUBY_VERSION >= '2.2'
s.add_dependency 'activesupport', '>= 3.0'
s.add_dependency 'dry-validation', '~> 0.12', '>= 0.12.2', '< 1.0.0'

s.add_development_dependency 'rails', '~> 5.2', '>= 5.2.2'
end

if RUBY_VERSION >= '2.1' && RUBY_VERSION < '2.2'
s.add_dependency 'activesupport', '>= 3.0', '< 5.0.0'
s.add_dependency 'dry-configurable', '~> 0.5.0'
s.add_dependency 'dry-logic', '~> 0.5.0'
s.add_dependency 'dry-validation', '~> 0.10', '>= 0.10.7', '< 1.0.0'
s.add_dependency 'i18n', '~> 0.9.0'

s.add_development_dependency 'rails', '< 5.0.0'
end

s.add_development_dependency 'bundler', '~> 1.13', '>= 1.13.6'
s.add_development_dependency 'bundler', '~> 1.17', '>= 1.17.3'
s.add_development_dependency 'rake', '~> 12.0', '>= 12.0.0'

# Testing
s.add_development_dependency 'appraisal', '~> 2.2', '>= 2.2.0'
s.add_development_dependency 'rails', '~> 5.2', '>= 5.2.2'
s.add_development_dependency 'rspec', '~> 3.7', '>= 3.7.0'
s.add_development_dependency 'rspec-rails', '~> 3.7', '>= 3.7.2'
s.add_development_dependency 'test-unit', '~> 3.2', '>= 3.2.7'
Expand All @@ -55,12 +41,8 @@ Gem::Specification.new do |s|
# Static code analysis
s.add_development_dependency 'mdl', '~> 0.5', '>= 0.5.0'

# Version 0.51 drops support for Ruby 2.0
s.add_development_dependency 'rubocop', '~> 0.50', '< 0.51' if RUBY_VERSION < '2.1'
# Version 0.58 drops support for Ruby 2.1
s.add_development_dependency 'rubocop', '~> 0.57', '< 0.58' if RUBY_VERSION >= '2.1' && RUBY_VERSION < '2.2'
# Version 0.62 requires Ruby 2.2
s.add_development_dependency 'rubocop', '~> 0.62' if RUBY_VERSION >= '2.2'
s.add_development_dependency 'rubocop', '~> 0.62'

if ENV['TRAVIS']
s.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.9'
Expand Down
8 changes: 0 additions & 8 deletions gemfiles/rails_3.gemfile

This file was deleted.

9 changes: 0 additions & 9 deletions gemfiles/rails_4.1.gemfile

This file was deleted.

8 changes: 0 additions & 8 deletions gemfiles/rails_4.gemfile

This file was deleted.

4 changes: 2 additions & 2 deletions lib/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
require 'config/integrations/rails/engine' if defined?(::Rails)
require 'config/sources/yaml_source'
require 'config/sources/hash_source'
require 'config/validation/schema' if RUBY_VERSION >= '2.1'
require 'config/validation/schema'
require 'deep_merge'

module Config
extend Config::Validation::Schema if RUBY_VERSION >= '2.1'
extend Config::Validation::Schema

# Ensures the setup only gets run once
@@_ran_once = false
Expand Down
6 changes: 3 additions & 3 deletions lib/config/options.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'ostruct'
require 'config/validation/validate' if RUBY_VERSION >= '2.1'
require 'config/validation/validate'

module Config
class Options < OpenStruct
include Enumerable
include Validation::Validate if RUBY_VERSION >= '2.1'
include Validation::Validate

def keys
marshal_dump.keys
Expand Down Expand Up @@ -91,7 +91,7 @@ def reload!
marshal_load(__convert(conf).marshal_dump)

reload_env! if Config.use_env
validate! if RUBY_VERSION >= '2.1'
validate!

self
end
Expand Down
15 changes: 2 additions & 13 deletions lib/config/validation/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,11 @@ module Validation
class Error < StandardError

def self.format(v_res)
flatten_hash(v_res.messages).map do |field, msgs|
"#{' ' * 2}#{field}: #{msgs.join('; ')}"
v_res.errors.group_by(&:path).map do |path, messages|
"#{' ' * 2}#{path.join('.')}: #{messages.map(&:text).join('; ')}"
end.join("\n")
end

def self.flatten_hash(h, acc={}, pref=[])
h.inject(acc) do |a, (k, v)|
if v.is_a?(Hash)
flatten_hash(v, acc, pref + [k])
else
acc[(pref + [k]).join('.')] = v
acc
end
end
end

end
end
end
4 changes: 2 additions & 2 deletions lib/config/validation/schema.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'dry-validation'
require 'dry-schema'
require 'config/validation/schema'

module Config
Expand All @@ -10,7 +10,7 @@ module Schema

def schema(&block)
if block_given?
@@schema = Dry::Validation.Schema(&block)
@@schema = Dry::Schema.define(&block)
else
@@schema
end
Expand Down
7 changes: 0 additions & 7 deletions spec/app/rails_3/Rakefile

This file was deleted.

13 changes: 0 additions & 13 deletions spec/app/rails_3/app/assets/javascripts/application.js

This file was deleted.

13 changes: 0 additions & 13 deletions spec/app/rails_3/app/assets/stylesheets/application.css

This file was deleted.

3 changes: 0 additions & 3 deletions spec/app/rails_3/app/controllers/application_controller.rb

This file was deleted.

2 changes: 0 additions & 2 deletions spec/app/rails_3/app/helpers/application_helper.rb

This file was deleted.

Empty file.
14 changes: 0 additions & 14 deletions spec/app/rails_3/app/views/layouts/application.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions spec/app/rails_3/bin/bundle

This file was deleted.

4 changes: 0 additions & 4 deletions spec/app/rails_3/bin/rails

This file was deleted.

4 changes: 0 additions & 4 deletions spec/app/rails_3/bin/rake

This file was deleted.

4 changes: 0 additions & 4 deletions spec/app/rails_3/config.ru

This file was deleted.

29 changes: 0 additions & 29 deletions spec/app/rails_3/config/application.rb

This file was deleted.

5 changes: 0 additions & 5 deletions spec/app/rails_3/config/boot.rb

This file was deleted.

Loading

0 comments on commit c7896dd

Please sign in to comment.