schema-model 0.5.2 → 0.5.3
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 +4 -4
- data/.gitignore +51 -0
- data/.rubocop.yml +11 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +25 -0
- data/Gemfile.lock +75 -0
- data/LICENSE.txt +21 -0
- data/README.md +143 -0
- data/Rakefile +11 -0
- data/bin/schema-json2csv +77 -0
- data/gemfiles/ruby_1.9.3.gemfile +25 -0
- data/gemfiles/ruby_1.9.3.gemfile.lock +65 -0
- data/gemfiles/ruby_2.1.9.gemfile +25 -0
- data/gemfiles/ruby_2.1.9.gemfile.lock +73 -0
- data/gemfiles/ruby_2.6.3.gemfile +25 -0
- data/gemfiles/ruby_2.6.3.gemfile.lock +69 -0
- data/gemfiles/travis.gemfile +25 -0
- data/schema-model.gemspec +17 -0
- data/script/bundle_install_all_versions +8 -0
- data/script/console +7 -0
- data/script/rspec_all_versions +5 -0
- metadata +25 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 886e2c37370ab33f380d853295e6e8036e697af0a29c7e7be2a045a9a70b44ad
|
|
4
|
+
data.tar.gz: 95b80463a0a3f4b33126ed379750ae9aac7f0cc455a45f68ad0072579f0b7872
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b8ba2b50715578d71bf6452222935535876ce836e2d34583078e64cdc62fee980e7763d23c302290a5fb31547668fdb836e25a54f290e9c4530b7c8afed4db8
|
|
7
|
+
data.tar.gz: 8475c78e34497236bbb5ee719ad632422701affa68539bc6bfdd5f508254dda8f0b4919100d949f767c932006005b6dae29a62b2a89f449ae58a918c3796ecce
|
data/.gitignore
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# rcov generated
|
|
2
|
+
coverage
|
|
3
|
+
coverage.data
|
|
4
|
+
|
|
5
|
+
# rdoc generated
|
|
6
|
+
rdoc
|
|
7
|
+
|
|
8
|
+
# yard generated
|
|
9
|
+
doc
|
|
10
|
+
.yardoc
|
|
11
|
+
|
|
12
|
+
# bundler
|
|
13
|
+
.bundle
|
|
14
|
+
|
|
15
|
+
# jeweler generated
|
|
16
|
+
pkg
|
|
17
|
+
|
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
|
19
|
+
#
|
|
20
|
+
# * Create a file at ~/.gitignore
|
|
21
|
+
# * Include files you want ignored
|
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
|
23
|
+
#
|
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
|
26
|
+
#
|
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
|
28
|
+
#
|
|
29
|
+
# For MacOS:
|
|
30
|
+
#
|
|
31
|
+
.DS_Store
|
|
32
|
+
|
|
33
|
+
# For TextMate
|
|
34
|
+
#*.tmproj
|
|
35
|
+
#tmtags
|
|
36
|
+
|
|
37
|
+
# For emacs:
|
|
38
|
+
*~
|
|
39
|
+
\#*
|
|
40
|
+
.\#*
|
|
41
|
+
|
|
42
|
+
# For vim:
|
|
43
|
+
*.swp
|
|
44
|
+
|
|
45
|
+
# For redcar:
|
|
46
|
+
#.redcar
|
|
47
|
+
|
|
48
|
+
# For rubinius:
|
|
49
|
+
#*.rbc
|
|
50
|
+
|
|
51
|
+
*.gem
|
data/.rubocop.yml
ADDED
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
schema
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.6.3
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
env:
|
|
2
|
+
global:
|
|
3
|
+
- CC_TEST_REPORTER_ID=f06234974aa4c4c52d14cb9ef800df79de52013c38e1d149fd04f2284e722f57
|
|
4
|
+
rvm:
|
|
5
|
+
- 2.6.3
|
|
6
|
+
- 2.1.9
|
|
7
|
+
- 1.9.3
|
|
8
|
+
gemfile: gemfiles/travis.gemfile
|
|
9
|
+
language: ruby
|
|
10
|
+
before_script:
|
|
11
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
|
12
|
+
- chmod +x ./cc-test-reporter
|
|
13
|
+
- ./cc-test-reporter before-build
|
|
14
|
+
script:
|
|
15
|
+
- bundle exec rspec
|
|
16
|
+
after_script:
|
|
17
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/Gemfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source 'http://rubygems.org'
|
|
4
|
+
|
|
5
|
+
gem 'inheritance-helper'
|
|
6
|
+
|
|
7
|
+
group :development do
|
|
8
|
+
activemodel_version =
|
|
9
|
+
case ENV['RUBY_VERSION']
|
|
10
|
+
when /1\.9\.3/
|
|
11
|
+
3
|
|
12
|
+
when /2\.1\.9/
|
|
13
|
+
4
|
|
14
|
+
else
|
|
15
|
+
5
|
|
16
|
+
end
|
|
17
|
+
gem 'activemodel', "~> #{activemodel_version}"
|
|
18
|
+
gem 'rake'
|
|
19
|
+
gem 'rubocop'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
group :spec do
|
|
23
|
+
gem 'rspec'
|
|
24
|
+
gem 'simplecov'
|
|
25
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
activemodel (5.2.3)
|
|
5
|
+
activesupport (= 5.2.3)
|
|
6
|
+
activesupport (5.2.3)
|
|
7
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
8
|
+
i18n (>= 0.7, < 2)
|
|
9
|
+
minitest (~> 5.1)
|
|
10
|
+
tzinfo (~> 1.1)
|
|
11
|
+
appraisal (2.2.0)
|
|
12
|
+
bundler
|
|
13
|
+
rake
|
|
14
|
+
thor (>= 0.14.0)
|
|
15
|
+
ast (2.4.0)
|
|
16
|
+
concurrent-ruby (1.1.5)
|
|
17
|
+
diff-lcs (1.3)
|
|
18
|
+
docile (1.3.2)
|
|
19
|
+
i18n (1.6.0)
|
|
20
|
+
concurrent-ruby (~> 1.0)
|
|
21
|
+
inheritance-helper (0.1.0)
|
|
22
|
+
jaro_winkler (1.5.3)
|
|
23
|
+
json (2.2.0)
|
|
24
|
+
minitest (5.11.3)
|
|
25
|
+
parallel (1.17.0)
|
|
26
|
+
parser (2.6.3.0)
|
|
27
|
+
ast (~> 2.4.0)
|
|
28
|
+
rainbow (3.0.0)
|
|
29
|
+
rake (12.3.2)
|
|
30
|
+
rspec (3.8.0)
|
|
31
|
+
rspec-core (~> 3.8.0)
|
|
32
|
+
rspec-expectations (~> 3.8.0)
|
|
33
|
+
rspec-mocks (~> 3.8.0)
|
|
34
|
+
rspec-core (3.8.2)
|
|
35
|
+
rspec-support (~> 3.8.0)
|
|
36
|
+
rspec-expectations (3.8.4)
|
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
38
|
+
rspec-support (~> 3.8.0)
|
|
39
|
+
rspec-mocks (3.8.1)
|
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
41
|
+
rspec-support (~> 3.8.0)
|
|
42
|
+
rspec-support (3.8.2)
|
|
43
|
+
rubocop (0.73.0)
|
|
44
|
+
jaro_winkler (~> 1.5.1)
|
|
45
|
+
parallel (~> 1.10)
|
|
46
|
+
parser (>= 2.6)
|
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
48
|
+
ruby-progressbar (~> 1.7)
|
|
49
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
|
50
|
+
ruby-progressbar (1.10.1)
|
|
51
|
+
simplecov (0.17.0)
|
|
52
|
+
docile (~> 1.1)
|
|
53
|
+
json (>= 1.8, < 3)
|
|
54
|
+
simplecov-html (~> 0.10.0)
|
|
55
|
+
simplecov-html (0.10.2)
|
|
56
|
+
thor (0.20.3)
|
|
57
|
+
thread_safe (0.3.6)
|
|
58
|
+
tzinfo (1.2.5)
|
|
59
|
+
thread_safe (~> 0.1)
|
|
60
|
+
unicode-display_width (1.6.0)
|
|
61
|
+
|
|
62
|
+
PLATFORMS
|
|
63
|
+
ruby
|
|
64
|
+
|
|
65
|
+
DEPENDENCIES
|
|
66
|
+
activemodel (~> 5)
|
|
67
|
+
appraisal
|
|
68
|
+
inheritance-helper
|
|
69
|
+
rake
|
|
70
|
+
rspec
|
|
71
|
+
rubocop
|
|
72
|
+
simplecov
|
|
73
|
+
|
|
74
|
+
BUNDLED WITH
|
|
75
|
+
1.17.3
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Douglas Youch
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# schema
|
|
2
|
+
|
|
3
|
+
Fast and easy way to transform data into models for validation and type safety.
|
|
4
|
+
|
|
5
|
+
[](https://travis-ci.org/dougyouch/schema)
|
|
6
|
+
[](https://codeclimate.com/github/dougyouch/schema/maintainability)
|
|
7
|
+
[](https://codeclimate.com/github/dougyouch/schema/test_coverage)
|
|
8
|
+
|
|
9
|
+
Attributes of a model have a name and type. Any value passed in goes through a parser method. If the value can not be parsed successfully the error is added to parsing_errors.
|
|
10
|
+
|
|
11
|
+
Associations are nested schema models. Each association can have its own set of attributes.
|
|
12
|
+
|
|
13
|
+
Dynamic associations are useful when creating custom logic around schema validation.
|
|
14
|
+
|
|
15
|
+
#### Example that show cases multiple features
|
|
16
|
+
|
|
17
|
+
###### spec/examples/company_schema.rb
|
|
18
|
+
```ruby
|
|
19
|
+
# frozen_string_literal: true
|
|
20
|
+
|
|
21
|
+
# Example that show cases multiple features
|
|
22
|
+
class CompanySchema
|
|
23
|
+
# includes model, associations, parsers and active model validations
|
|
24
|
+
include Schema::All
|
|
25
|
+
|
|
26
|
+
# add common attributes
|
|
27
|
+
# attributes support additional names through the alias(es) option
|
|
28
|
+
attribute :name, :string, alias: 'CompanyName'
|
|
29
|
+
attribute :industry_type, :string, aliases: %w[IndustryType industry]
|
|
30
|
+
|
|
31
|
+
# will take a string split on the separator and use the parse_<data_type> method on every element
|
|
32
|
+
# basically take a list of comma separated numbers and create an array of integers
|
|
33
|
+
# code snippet: str.split(',').map { |v| parse_integer(field_name, parsing_errors, v) }
|
|
34
|
+
attribute :number_list, :array, separator: ',', data_type: :integer
|
|
35
|
+
|
|
36
|
+
# creates a nested dynamic schema based on the industry_type which is part of the main company data
|
|
37
|
+
industry_schema = has_one(:industry, external_type_field: :industry_type) do
|
|
38
|
+
attribute :name, :string
|
|
39
|
+
|
|
40
|
+
validates :name, presence: true
|
|
41
|
+
|
|
42
|
+
add_type('tech') do
|
|
43
|
+
attribute :custom_description, :string
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
add_type('qsr') do
|
|
47
|
+
attribute :number_of_locations, :integer
|
|
48
|
+
|
|
49
|
+
# custom validation
|
|
50
|
+
validates :number_of_locations, presence: true
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# create multiple dynamic location schemas based on the type field in the location data
|
|
55
|
+
has_many(:locations, type_field: :type) do
|
|
56
|
+
attribute :type, :string
|
|
57
|
+
attribute :address, :string
|
|
58
|
+
attribute :city, :string
|
|
59
|
+
attribute :state, :string
|
|
60
|
+
attribute :zip, :string
|
|
61
|
+
|
|
62
|
+
add_type('headquarters') do
|
|
63
|
+
attribute :main_floor, :integer
|
|
64
|
+
|
|
65
|
+
validates :city, presence: true
|
|
66
|
+
validates :main_floor, presence: true
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
add_type('store_front') do
|
|
70
|
+
attribute :main_entrance, :string
|
|
71
|
+
|
|
72
|
+
validates :address, presence: true
|
|
73
|
+
validates :main_entrance, presence: true
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# create multiple dynamic employee schemas based on the type field in the employee data
|
|
78
|
+
has_many(:employees, type_field: :type) do
|
|
79
|
+
attribute :type, :integer
|
|
80
|
+
attribute :name, :string
|
|
81
|
+
attribute :start_date, :date
|
|
82
|
+
add_type(1) do # worker
|
|
83
|
+
attribute :manager_name, :string
|
|
84
|
+
end
|
|
85
|
+
add_type(2) do # manager
|
|
86
|
+
attribute :rank, :float
|
|
87
|
+
end
|
|
88
|
+
# if no or an invalid type is specified, create a default employee schema object
|
|
89
|
+
# useful for communicating errors in an API
|
|
90
|
+
default_type
|
|
91
|
+
|
|
92
|
+
# dynamic_type_names returns all the types used, except for :default
|
|
93
|
+
validates :type, inclusion: { in: dynamic_type_names }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
validates :name, presence: true
|
|
97
|
+
validates :industry_type, inclusion: { in: industry_schema.dynamic_type_names }
|
|
98
|
+
|
|
99
|
+
# use the schema validator
|
|
100
|
+
validates :industry, presence: true, schema: true
|
|
101
|
+
validates :locations, presence: true, schema: true
|
|
102
|
+
validates :employees, presence: true, schema: true
|
|
103
|
+
end
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
###### spec/examples/company_schema.json
|
|
107
|
+
```javascript
|
|
108
|
+
{
|
|
109
|
+
"CompanyName": "Good Burger",
|
|
110
|
+
"IndustryType": "qsr",
|
|
111
|
+
"industry": {
|
|
112
|
+
"name": "Food & Beverage",
|
|
113
|
+
"number_of_locations": 2
|
|
114
|
+
},
|
|
115
|
+
"locations": [
|
|
116
|
+
{
|
|
117
|
+
"type": "headquarters",
|
|
118
|
+
"city": "Boston",
|
|
119
|
+
"main_floor": 5
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"type": "store_front",
|
|
123
|
+
"address": "1st Ave",
|
|
124
|
+
"zip": "02211",
|
|
125
|
+
"main_entrance": "side door"
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
"employees": [
|
|
129
|
+
{
|
|
130
|
+
"type": 2,
|
|
131
|
+
"name": "Queen Bee",
|
|
132
|
+
"start_date": "2016-01-09",
|
|
133
|
+
"rank": "0.9"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"type": 1,
|
|
137
|
+
"name": "Worker Bee",
|
|
138
|
+
"start_date": "2018-05-10",
|
|
139
|
+
"manager_name": "Queen Bee"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
```
|
data/Rakefile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'rake'
|
|
6
|
+
require 'rspec/core/rake_task'
|
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
8
|
+
t.pattern = Dir.glob('spec/**/*_spec.rb')
|
|
9
|
+
t.rspec_opts = '--format documentation'
|
|
10
|
+
end
|
|
11
|
+
task default: :spec
|
data/bin/schema-json2csv
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'schema-model'
|
|
4
|
+
require 'csv'
|
|
5
|
+
require 'json'
|
|
6
|
+
require 'optparse'
|
|
7
|
+
|
|
8
|
+
options = {
|
|
9
|
+
json_file: nil,
|
|
10
|
+
require_file: nil,
|
|
11
|
+
csv_file: nil,
|
|
12
|
+
schema_class_name: nil
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
OptionParser.new do |opts|
|
|
16
|
+
opts.banner = "Usage: " + File.basename(__FILE__)
|
|
17
|
+
|
|
18
|
+
opts.on('--json JSON_FILE', 'JSON data') do |v|
|
|
19
|
+
options[:json_file] = v
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
opts.on('-r', '--require FILE', 'File with schema model') do |v|
|
|
23
|
+
options[:require_file] = v
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
opts.on('--csv CSV_FILE', 'File to output csv data') do |v|
|
|
27
|
+
options[:csv_file] = v
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
opts.on('--schema SCHEMA_CLASS_NAME', 'Name of the schema to apply to the json data') do |v|
|
|
31
|
+
options[:schema_class_name] = v
|
|
32
|
+
end
|
|
33
|
+
end.parse!
|
|
34
|
+
|
|
35
|
+
raise('no filed required') unless options[:require_file]
|
|
36
|
+
raise('no schema specified') unless options[:schema_class_name]
|
|
37
|
+
|
|
38
|
+
$LOAD_PATH << '.'
|
|
39
|
+
raise("file #{options[:require_file]} not found") unless require(options[:require_file])
|
|
40
|
+
|
|
41
|
+
raise("schema #{options[:schema_class_name]} not found") unless Object.const_defined?(options[:schema_class_name])
|
|
42
|
+
|
|
43
|
+
schema_class = Object.const_get(options[:schema_class_name])
|
|
44
|
+
|
|
45
|
+
json_data =
|
|
46
|
+
if options[:json_file]
|
|
47
|
+
raise("json file #{options[:json_file]} not found") unless File.exist?(options[:json_file])
|
|
48
|
+
File.read(options[:json_file])
|
|
49
|
+
elsif ARGV.last == '-'
|
|
50
|
+
ARGF.read
|
|
51
|
+
else
|
|
52
|
+
raise('no json data specified')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
schema = schema_class.from_hash(JSON.parse(json_data))
|
|
56
|
+
|
|
57
|
+
io =
|
|
58
|
+
if file = options[:csv_file]
|
|
59
|
+
if File.exist?(file)
|
|
60
|
+
File.open(options[:csv_file], 'ab')
|
|
61
|
+
else
|
|
62
|
+
headers = CSV.generate do |csv|
|
|
63
|
+
csv << schema_class.to_headers
|
|
64
|
+
end
|
|
65
|
+
f = File.open(options[:csv_file], 'wb')
|
|
66
|
+
f.print headers
|
|
67
|
+
f
|
|
68
|
+
end
|
|
69
|
+
else
|
|
70
|
+
$stdout
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
str = CSV.generate do |csv|
|
|
74
|
+
csv << schema.to_a.flatten
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
io.print str
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source 'http://rubygems.org'
|
|
4
|
+
|
|
5
|
+
gem 'inheritance-helper'
|
|
6
|
+
|
|
7
|
+
group :development do
|
|
8
|
+
activemodel_version =
|
|
9
|
+
case ENV['RUBY_VERSION']
|
|
10
|
+
when /1\.9\.3/
|
|
11
|
+
3
|
|
12
|
+
when /2\.1\.9/
|
|
13
|
+
4
|
|
14
|
+
else
|
|
15
|
+
5
|
|
16
|
+
end
|
|
17
|
+
gem 'activemodel', "~> #{activemodel_version}"
|
|
18
|
+
gem 'rake'
|
|
19
|
+
gem 'rubocop'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
group :spec do
|
|
23
|
+
gem 'rspec'
|
|
24
|
+
gem 'simplecov'
|
|
25
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
activemodel (3.2.22.5)
|
|
5
|
+
activesupport (= 3.2.22.5)
|
|
6
|
+
builder (~> 3.0.0)
|
|
7
|
+
activesupport (3.2.22.5)
|
|
8
|
+
i18n (~> 0.6, >= 0.6.4)
|
|
9
|
+
multi_json (~> 1.0)
|
|
10
|
+
ast (2.4.0)
|
|
11
|
+
builder (3.0.4)
|
|
12
|
+
concurrent-ruby (1.1.5)
|
|
13
|
+
diff-lcs (1.3)
|
|
14
|
+
docile (1.3.2)
|
|
15
|
+
i18n (0.9.5)
|
|
16
|
+
concurrent-ruby (~> 1.0)
|
|
17
|
+
inheritance-helper (0.1.0)
|
|
18
|
+
json (2.2.0)
|
|
19
|
+
multi_json (1.13.1)
|
|
20
|
+
parser (2.4.0.2)
|
|
21
|
+
ast (~> 2.3)
|
|
22
|
+
powerpack (0.1.2)
|
|
23
|
+
rainbow (2.2.2)
|
|
24
|
+
rake
|
|
25
|
+
rake (12.2.1)
|
|
26
|
+
rspec (3.8.0)
|
|
27
|
+
rspec-core (~> 3.8.0)
|
|
28
|
+
rspec-expectations (~> 3.8.0)
|
|
29
|
+
rspec-mocks (~> 3.8.0)
|
|
30
|
+
rspec-core (3.8.2)
|
|
31
|
+
rspec-support (~> 3.8.0)
|
|
32
|
+
rspec-expectations (3.8.4)
|
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
34
|
+
rspec-support (~> 3.8.0)
|
|
35
|
+
rspec-mocks (3.8.1)
|
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
+
rspec-support (~> 3.8.0)
|
|
38
|
+
rspec-support (3.8.2)
|
|
39
|
+
rubocop (0.41.2)
|
|
40
|
+
parser (>= 2.3.1.1, < 3.0)
|
|
41
|
+
powerpack (~> 0.1)
|
|
42
|
+
rainbow (>= 1.99.1, < 3.0)
|
|
43
|
+
ruby-progressbar (~> 1.7)
|
|
44
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
45
|
+
ruby-progressbar (1.10.1)
|
|
46
|
+
simplecov (0.17.0)
|
|
47
|
+
docile (~> 1.1)
|
|
48
|
+
json (>= 1.8, < 3)
|
|
49
|
+
simplecov-html (~> 0.10.0)
|
|
50
|
+
simplecov-html (0.10.2)
|
|
51
|
+
unicode-display_width (1.6.0)
|
|
52
|
+
|
|
53
|
+
PLATFORMS
|
|
54
|
+
ruby
|
|
55
|
+
|
|
56
|
+
DEPENDENCIES
|
|
57
|
+
activemodel (~> 3)
|
|
58
|
+
inheritance-helper
|
|
59
|
+
rake
|
|
60
|
+
rspec
|
|
61
|
+
rubocop
|
|
62
|
+
simplecov
|
|
63
|
+
|
|
64
|
+
BUNDLED WITH
|
|
65
|
+
1.17.3
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source 'http://rubygems.org'
|
|
4
|
+
|
|
5
|
+
gem 'inheritance-helper'
|
|
6
|
+
|
|
7
|
+
group :development do
|
|
8
|
+
activemodel_version =
|
|
9
|
+
case ENV['RUBY_VERSION']
|
|
10
|
+
when /1\.9\.3/
|
|
11
|
+
3
|
|
12
|
+
when /2\.1\.9/
|
|
13
|
+
4
|
|
14
|
+
else
|
|
15
|
+
5
|
|
16
|
+
end
|
|
17
|
+
gem 'activemodel', "~> #{activemodel_version}"
|
|
18
|
+
gem 'rake'
|
|
19
|
+
gem 'rubocop'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
group :spec do
|
|
23
|
+
gem 'rspec'
|
|
24
|
+
gem 'simplecov'
|
|
25
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
activemodel (4.2.11.1)
|
|
5
|
+
activesupport (= 4.2.11.1)
|
|
6
|
+
builder (~> 3.1)
|
|
7
|
+
activesupport (4.2.11.1)
|
|
8
|
+
i18n (~> 0.7)
|
|
9
|
+
minitest (~> 5.1)
|
|
10
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
11
|
+
tzinfo (~> 1.1)
|
|
12
|
+
ast (2.4.0)
|
|
13
|
+
builder (3.2.3)
|
|
14
|
+
concurrent-ruby (1.1.5)
|
|
15
|
+
diff-lcs (1.3)
|
|
16
|
+
docile (1.3.2)
|
|
17
|
+
i18n (0.9.5)
|
|
18
|
+
concurrent-ruby (~> 1.0)
|
|
19
|
+
inheritance-helper (0.1.0)
|
|
20
|
+
jaro_winkler (1.5.3)
|
|
21
|
+
json (2.2.0)
|
|
22
|
+
minitest (5.11.3)
|
|
23
|
+
parallel (1.13.0)
|
|
24
|
+
parser (2.6.3.0)
|
|
25
|
+
ast (~> 2.4.0)
|
|
26
|
+
powerpack (0.1.2)
|
|
27
|
+
rainbow (3.0.0)
|
|
28
|
+
rake (12.3.3)
|
|
29
|
+
rspec (3.8.0)
|
|
30
|
+
rspec-core (~> 3.8.0)
|
|
31
|
+
rspec-expectations (~> 3.8.0)
|
|
32
|
+
rspec-mocks (~> 3.8.0)
|
|
33
|
+
rspec-core (3.8.2)
|
|
34
|
+
rspec-support (~> 3.8.0)
|
|
35
|
+
rspec-expectations (3.8.4)
|
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
+
rspec-support (~> 3.8.0)
|
|
38
|
+
rspec-mocks (3.8.1)
|
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
40
|
+
rspec-support (~> 3.8.0)
|
|
41
|
+
rspec-support (3.8.2)
|
|
42
|
+
rubocop (0.57.2)
|
|
43
|
+
jaro_winkler (~> 1.5.1)
|
|
44
|
+
parallel (~> 1.10)
|
|
45
|
+
parser (>= 2.5)
|
|
46
|
+
powerpack (~> 0.1)
|
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
48
|
+
ruby-progressbar (~> 1.7)
|
|
49
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
50
|
+
ruby-progressbar (1.10.1)
|
|
51
|
+
simplecov (0.17.0)
|
|
52
|
+
docile (~> 1.1)
|
|
53
|
+
json (>= 1.8, < 3)
|
|
54
|
+
simplecov-html (~> 0.10.0)
|
|
55
|
+
simplecov-html (0.10.2)
|
|
56
|
+
thread_safe (0.3.6)
|
|
57
|
+
tzinfo (1.2.5)
|
|
58
|
+
thread_safe (~> 0.1)
|
|
59
|
+
unicode-display_width (1.6.0)
|
|
60
|
+
|
|
61
|
+
PLATFORMS
|
|
62
|
+
ruby
|
|
63
|
+
|
|
64
|
+
DEPENDENCIES
|
|
65
|
+
activemodel (~> 4)
|
|
66
|
+
inheritance-helper
|
|
67
|
+
rake
|
|
68
|
+
rspec
|
|
69
|
+
rubocop
|
|
70
|
+
simplecov
|
|
71
|
+
|
|
72
|
+
BUNDLED WITH
|
|
73
|
+
1.17.3
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source 'http://rubygems.org'
|
|
4
|
+
|
|
5
|
+
gem 'inheritance-helper'
|
|
6
|
+
|
|
7
|
+
group :development do
|
|
8
|
+
activemodel_version =
|
|
9
|
+
case ENV['RUBY_VERSION']
|
|
10
|
+
when /1\.9\.3/
|
|
11
|
+
3
|
|
12
|
+
when /2\.1\.9/
|
|
13
|
+
4
|
|
14
|
+
else
|
|
15
|
+
5
|
|
16
|
+
end
|
|
17
|
+
gem 'activemodel', "~> #{activemodel_version}"
|
|
18
|
+
gem 'rake'
|
|
19
|
+
gem 'rubocop'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
group :spec do
|
|
23
|
+
gem 'rspec'
|
|
24
|
+
gem 'simplecov'
|
|
25
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
activemodel (5.2.3)
|
|
5
|
+
activesupport (= 5.2.3)
|
|
6
|
+
activesupport (5.2.3)
|
|
7
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
8
|
+
i18n (>= 0.7, < 2)
|
|
9
|
+
minitest (~> 5.1)
|
|
10
|
+
tzinfo (~> 1.1)
|
|
11
|
+
ast (2.4.0)
|
|
12
|
+
concurrent-ruby (1.1.5)
|
|
13
|
+
diff-lcs (1.3)
|
|
14
|
+
docile (1.3.2)
|
|
15
|
+
i18n (1.6.0)
|
|
16
|
+
concurrent-ruby (~> 1.0)
|
|
17
|
+
inheritance-helper (0.1.0)
|
|
18
|
+
jaro_winkler (1.5.3)
|
|
19
|
+
json (2.2.0)
|
|
20
|
+
minitest (5.11.3)
|
|
21
|
+
parallel (1.17.0)
|
|
22
|
+
parser (2.6.3.0)
|
|
23
|
+
ast (~> 2.4.0)
|
|
24
|
+
rainbow (3.0.0)
|
|
25
|
+
rake (12.3.3)
|
|
26
|
+
rspec (3.8.0)
|
|
27
|
+
rspec-core (~> 3.8.0)
|
|
28
|
+
rspec-expectations (~> 3.8.0)
|
|
29
|
+
rspec-mocks (~> 3.8.0)
|
|
30
|
+
rspec-core (3.8.2)
|
|
31
|
+
rspec-support (~> 3.8.0)
|
|
32
|
+
rspec-expectations (3.8.4)
|
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
34
|
+
rspec-support (~> 3.8.0)
|
|
35
|
+
rspec-mocks (3.8.1)
|
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
+
rspec-support (~> 3.8.0)
|
|
38
|
+
rspec-support (3.8.2)
|
|
39
|
+
rubocop (0.74.0)
|
|
40
|
+
jaro_winkler (~> 1.5.1)
|
|
41
|
+
parallel (~> 1.10)
|
|
42
|
+
parser (>= 2.6)
|
|
43
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
44
|
+
ruby-progressbar (~> 1.7)
|
|
45
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
|
46
|
+
ruby-progressbar (1.10.1)
|
|
47
|
+
simplecov (0.17.0)
|
|
48
|
+
docile (~> 1.1)
|
|
49
|
+
json (>= 1.8, < 3)
|
|
50
|
+
simplecov-html (~> 0.10.0)
|
|
51
|
+
simplecov-html (0.10.2)
|
|
52
|
+
thread_safe (0.3.6)
|
|
53
|
+
tzinfo (1.2.5)
|
|
54
|
+
thread_safe (~> 0.1)
|
|
55
|
+
unicode-display_width (1.6.0)
|
|
56
|
+
|
|
57
|
+
PLATFORMS
|
|
58
|
+
ruby
|
|
59
|
+
|
|
60
|
+
DEPENDENCIES
|
|
61
|
+
activemodel (~> 5)
|
|
62
|
+
inheritance-helper
|
|
63
|
+
rake
|
|
64
|
+
rspec
|
|
65
|
+
rubocop
|
|
66
|
+
simplecov
|
|
67
|
+
|
|
68
|
+
BUNDLED WITH
|
|
69
|
+
1.17.2
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source 'http://rubygems.org'
|
|
4
|
+
|
|
5
|
+
gem 'inheritance-helper'
|
|
6
|
+
|
|
7
|
+
group :development do
|
|
8
|
+
activemodel_version =
|
|
9
|
+
case ENV['RUBY_VERSION']
|
|
10
|
+
when /1\.9\.3/
|
|
11
|
+
3
|
|
12
|
+
when /2\.1\.9/
|
|
13
|
+
4
|
|
14
|
+
else
|
|
15
|
+
5
|
|
16
|
+
end
|
|
17
|
+
gem 'activemodel', "~> #{activemodel_version}"
|
|
18
|
+
gem 'rake'
|
|
19
|
+
gem 'rubocop'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
group :spec do
|
|
23
|
+
gem 'rspec'
|
|
24
|
+
gem 'simplecov'
|
|
25
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = 'schema-model'
|
|
5
|
+
s.version = '0.5.3'
|
|
6
|
+
s.licenses = ['MIT']
|
|
7
|
+
s.summary = 'Schema Model'
|
|
8
|
+
s.description = 'Easy way to create models from payloads'
|
|
9
|
+
s.authors = ['Doug Youch']
|
|
10
|
+
s.email = 'dougyouch@gmail.com'
|
|
11
|
+
s.homepage = 'https://github.com/dougyouch/schema'
|
|
12
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
13
|
+
s.bindir = 'bin'
|
|
14
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
15
|
+
|
|
16
|
+
s.add_runtime_dependency 'inheritance-helper'
|
|
17
|
+
end
|
data/script/console
ADDED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: schema-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Doug Youch
|
|
@@ -26,10 +26,29 @@ dependencies:
|
|
|
26
26
|
version: '0'
|
|
27
27
|
description: Easy way to create models from payloads
|
|
28
28
|
email: dougyouch@gmail.com
|
|
29
|
-
executables:
|
|
29
|
+
executables:
|
|
30
|
+
- schema-json2csv
|
|
30
31
|
extensions: []
|
|
31
32
|
extra_rdoc_files: []
|
|
32
33
|
files:
|
|
34
|
+
- ".gitignore"
|
|
35
|
+
- ".rubocop.yml"
|
|
36
|
+
- ".ruby-gemset"
|
|
37
|
+
- ".ruby-version"
|
|
38
|
+
- ".travis.yml"
|
|
39
|
+
- Gemfile
|
|
40
|
+
- Gemfile.lock
|
|
41
|
+
- LICENSE.txt
|
|
42
|
+
- README.md
|
|
43
|
+
- Rakefile
|
|
44
|
+
- bin/schema-json2csv
|
|
45
|
+
- gemfiles/ruby_1.9.3.gemfile
|
|
46
|
+
- gemfiles/ruby_1.9.3.gemfile.lock
|
|
47
|
+
- gemfiles/ruby_2.1.9.gemfile
|
|
48
|
+
- gemfiles/ruby_2.1.9.gemfile.lock
|
|
49
|
+
- gemfiles/ruby_2.6.3.gemfile
|
|
50
|
+
- gemfiles/ruby_2.6.3.gemfile.lock
|
|
51
|
+
- gemfiles/travis.gemfile
|
|
33
52
|
- lib/schema-model.rb
|
|
34
53
|
- lib/schema/active_model_validations.rb
|
|
35
54
|
- lib/schema/all.rb
|
|
@@ -51,6 +70,10 @@ files:
|
|
|
51
70
|
- lib/schema/parsing_errors.rb
|
|
52
71
|
- lib/schema/utils.rb
|
|
53
72
|
- lib/schema_validator.rb
|
|
73
|
+
- schema-model.gemspec
|
|
74
|
+
- script/bundle_install_all_versions
|
|
75
|
+
- script/console
|
|
76
|
+
- script/rspec_all_versions
|
|
54
77
|
homepage: https://github.com/dougyouch/schema
|
|
55
78
|
licenses:
|
|
56
79
|
- MIT
|