json_statham 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +153 -1
- data/README.md +24 -0
- data/lib/generators/json_statham/USAGE +8 -0
- data/lib/generators/json_statham/install_generator.rb +13 -0
- data/lib/generators/json_statham/templates/json_statham.rb.tt +7 -0
- data/lib/json_statham/logger.rb +58 -0
- data/lib/json_statham/railtie.rb +9 -0
- data/lib/json_statham/version.rb +1 -1
- data/lib/json_statham.rb +2 -0
- data/lib/tasks/json_statham_tasks.rake +9 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8086da405fa7309573448af4957f39283b821b40419269126c81e00d653aea0
|
4
|
+
data.tar.gz: 75e2b6b518a10367b81c28cc358e855aad94e603ca251a7dca3201df86e9a7ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aa2487a098ad2ad6dee3ab47a7257c866b41ebdc3d676f09a99f6c86c43ff82180208e63be708aeb471694c1e82d750e02dcd685a91e17121c3728693cf659b
|
7
|
+
data.tar.gz: b548f34e21f7963ce62c4f957740fc312129c08e74fd2f8e7b552a1430a7be782e63017e00e3bd783b2c4db37e9ec9ed4c3d79d460351fb3b90e14aee76657c1
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,23 +1,149 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
json_statham (0.1.
|
4
|
+
json_statham (0.1.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
actioncable (6.1.7.1)
|
10
|
+
actionpack (= 6.1.7.1)
|
11
|
+
activesupport (= 6.1.7.1)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailbox (6.1.7.1)
|
15
|
+
actionpack (= 6.1.7.1)
|
16
|
+
activejob (= 6.1.7.1)
|
17
|
+
activerecord (= 6.1.7.1)
|
18
|
+
activestorage (= 6.1.7.1)
|
19
|
+
activesupport (= 6.1.7.1)
|
20
|
+
mail (>= 2.7.1)
|
21
|
+
actionmailer (6.1.7.1)
|
22
|
+
actionpack (= 6.1.7.1)
|
23
|
+
actionview (= 6.1.7.1)
|
24
|
+
activejob (= 6.1.7.1)
|
25
|
+
activesupport (= 6.1.7.1)
|
26
|
+
mail (~> 2.5, >= 2.5.4)
|
27
|
+
rails-dom-testing (~> 2.0)
|
28
|
+
actionpack (6.1.7.1)
|
29
|
+
actionview (= 6.1.7.1)
|
30
|
+
activesupport (= 6.1.7.1)
|
31
|
+
rack (~> 2.0, >= 2.0.9)
|
32
|
+
rack-test (>= 0.6.3)
|
33
|
+
rails-dom-testing (~> 2.0)
|
34
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
+
actiontext (6.1.7.1)
|
36
|
+
actionpack (= 6.1.7.1)
|
37
|
+
activerecord (= 6.1.7.1)
|
38
|
+
activestorage (= 6.1.7.1)
|
39
|
+
activesupport (= 6.1.7.1)
|
40
|
+
nokogiri (>= 1.8.5)
|
41
|
+
actionview (6.1.7.1)
|
42
|
+
activesupport (= 6.1.7.1)
|
43
|
+
builder (~> 3.1)
|
44
|
+
erubi (~> 1.4)
|
45
|
+
rails-dom-testing (~> 2.0)
|
46
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
+
activejob (6.1.7.1)
|
48
|
+
activesupport (= 6.1.7.1)
|
49
|
+
globalid (>= 0.3.6)
|
50
|
+
activemodel (6.1.7.1)
|
51
|
+
activesupport (= 6.1.7.1)
|
52
|
+
activerecord (6.1.7.1)
|
53
|
+
activemodel (= 6.1.7.1)
|
54
|
+
activesupport (= 6.1.7.1)
|
55
|
+
activestorage (6.1.7.1)
|
56
|
+
actionpack (= 6.1.7.1)
|
57
|
+
activejob (= 6.1.7.1)
|
58
|
+
activerecord (= 6.1.7.1)
|
59
|
+
activesupport (= 6.1.7.1)
|
60
|
+
marcel (~> 1.0)
|
61
|
+
mini_mime (>= 1.1.0)
|
62
|
+
activesupport (6.1.7.1)
|
63
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
64
|
+
i18n (>= 1.6, < 2)
|
65
|
+
minitest (>= 5.1)
|
66
|
+
tzinfo (~> 2.0)
|
67
|
+
zeitwerk (~> 2.3)
|
9
68
|
ast (2.4.2)
|
69
|
+
builder (3.2.4)
|
10
70
|
coderay (1.1.3)
|
71
|
+
concurrent-ruby (1.2.0)
|
72
|
+
crass (1.0.6)
|
73
|
+
date (3.3.3)
|
11
74
|
diff-lcs (1.5.0)
|
12
75
|
docile (1.4.0)
|
76
|
+
erubi (1.12.0)
|
77
|
+
generator_spec (0.9.4)
|
78
|
+
activesupport (>= 3.0.0)
|
79
|
+
railties (>= 3.0.0)
|
80
|
+
globalid (1.1.0)
|
81
|
+
activesupport (>= 5.0)
|
82
|
+
i18n (1.12.0)
|
83
|
+
concurrent-ruby (~> 1.0)
|
13
84
|
json (2.6.3)
|
85
|
+
loofah (2.19.1)
|
86
|
+
crass (~> 1.0.2)
|
87
|
+
nokogiri (>= 1.5.9)
|
88
|
+
mail (2.8.1)
|
89
|
+
mini_mime (>= 0.1.1)
|
90
|
+
net-imap
|
91
|
+
net-pop
|
92
|
+
net-smtp
|
93
|
+
marcel (1.0.2)
|
14
94
|
method_source (1.0.0)
|
95
|
+
mini_mime (1.1.2)
|
96
|
+
minitest (5.17.0)
|
97
|
+
net-imap (0.3.4)
|
98
|
+
date
|
99
|
+
net-protocol
|
100
|
+
net-pop (0.1.2)
|
101
|
+
net-protocol
|
102
|
+
net-protocol (0.2.1)
|
103
|
+
timeout
|
104
|
+
net-smtp (0.3.3)
|
105
|
+
net-protocol
|
106
|
+
nio4r (2.5.8)
|
107
|
+
nokogiri (1.14.1-arm64-darwin)
|
108
|
+
racc (~> 1.4)
|
109
|
+
nokogiri (1.14.1-x86_64-linux)
|
110
|
+
racc (~> 1.4)
|
15
111
|
parallel (1.22.1)
|
16
112
|
parser (3.2.0.0)
|
17
113
|
ast (~> 2.4.1)
|
18
114
|
pry (0.14.2)
|
19
115
|
coderay (~> 1.1)
|
20
116
|
method_source (~> 1.0)
|
117
|
+
racc (1.6.2)
|
118
|
+
rack (2.2.6.2)
|
119
|
+
rack-test (2.0.2)
|
120
|
+
rack (>= 1.3)
|
121
|
+
rails (6.1.7.1)
|
122
|
+
actioncable (= 6.1.7.1)
|
123
|
+
actionmailbox (= 6.1.7.1)
|
124
|
+
actionmailer (= 6.1.7.1)
|
125
|
+
actionpack (= 6.1.7.1)
|
126
|
+
actiontext (= 6.1.7.1)
|
127
|
+
actionview (= 6.1.7.1)
|
128
|
+
activejob (= 6.1.7.1)
|
129
|
+
activemodel (= 6.1.7.1)
|
130
|
+
activerecord (= 6.1.7.1)
|
131
|
+
activestorage (= 6.1.7.1)
|
132
|
+
activesupport (= 6.1.7.1)
|
133
|
+
bundler (>= 1.15.0)
|
134
|
+
railties (= 6.1.7.1)
|
135
|
+
sprockets-rails (>= 2.0.0)
|
136
|
+
rails-dom-testing (2.0.3)
|
137
|
+
activesupport (>= 4.2.0)
|
138
|
+
nokogiri (>= 1.6)
|
139
|
+
rails-html-sanitizer (1.5.0)
|
140
|
+
loofah (~> 2.19, >= 2.19.1)
|
141
|
+
railties (6.1.7.1)
|
142
|
+
actionpack (= 6.1.7.1)
|
143
|
+
activesupport (= 6.1.7.1)
|
144
|
+
method_source
|
145
|
+
rake (>= 12.2)
|
146
|
+
thor (~> 1.0)
|
21
147
|
rainbow (3.1.1)
|
22
148
|
rake (13.0.6)
|
23
149
|
regexp_parser (2.6.2)
|
@@ -34,6 +160,14 @@ GEM
|
|
34
160
|
rspec-mocks (3.12.3)
|
35
161
|
diff-lcs (>= 1.2.0, < 2.0)
|
36
162
|
rspec-support (~> 3.12.0)
|
163
|
+
rspec-rails (6.0.1)
|
164
|
+
actionpack (>= 6.1)
|
165
|
+
activesupport (>= 6.1)
|
166
|
+
railties (>= 6.1)
|
167
|
+
rspec-core (~> 3.11)
|
168
|
+
rspec-expectations (~> 3.11)
|
169
|
+
rspec-mocks (~> 3.11)
|
170
|
+
rspec-support (~> 3.11)
|
37
171
|
rspec-support (3.12.0)
|
38
172
|
rubocop (1.44.1)
|
39
173
|
json (~> 2.3)
|
@@ -54,17 +188,35 @@ GEM
|
|
54
188
|
simplecov_json_formatter (~> 0.1)
|
55
189
|
simplecov-html (0.12.3)
|
56
190
|
simplecov_json_formatter (0.1.4)
|
191
|
+
sprockets (4.2.0)
|
192
|
+
concurrent-ruby (~> 1.0)
|
193
|
+
rack (>= 2.2.4, < 4)
|
194
|
+
sprockets-rails (3.4.2)
|
195
|
+
actionpack (>= 5.2)
|
196
|
+
activesupport (>= 5.2)
|
197
|
+
sprockets (>= 3.0.0)
|
198
|
+
thor (1.2.1)
|
199
|
+
timeout (0.3.1)
|
200
|
+
tzinfo (2.0.6)
|
201
|
+
concurrent-ruby (~> 1.0)
|
57
202
|
unicode-display_width (2.4.2)
|
203
|
+
websocket-driver (0.7.5)
|
204
|
+
websocket-extensions (>= 0.1.0)
|
205
|
+
websocket-extensions (0.1.5)
|
206
|
+
zeitwerk (2.6.6)
|
58
207
|
|
59
208
|
PLATFORMS
|
60
209
|
arm64-darwin-21
|
61
210
|
x86_64-linux
|
62
211
|
|
63
212
|
DEPENDENCIES
|
213
|
+
generator_spec
|
64
214
|
json_statham!
|
65
215
|
pry (~> 0.14.2)
|
216
|
+
rails (~> 6.1.7.1)
|
66
217
|
rake (~> 13.0)
|
67
218
|
rspec (~> 3.0)
|
219
|
+
rspec-rails
|
68
220
|
rubocop (~> 1.21)
|
69
221
|
simplecov (~> 0.22.0)
|
70
222
|
|
data/README.md
CHANGED
@@ -180,6 +180,30 @@ RSpec.describe FooSerializer do
|
|
180
180
|
end
|
181
181
|
```
|
182
182
|
|
183
|
+
## Rails
|
184
|
+
|
185
|
+
Run the generator:
|
186
|
+
|
187
|
+
$ rails g json_statham:install
|
188
|
+
|
189
|
+
This will create a new initializer at **config/initializers/json_statham.rb**.
|
190
|
+
After running your tests to generate the json files you can now run `rails json_statham`.
|
191
|
+
|
192
|
+
$ rails json_statham
|
193
|
+
|
194
|
+
This will show you a list of your json files ordered by duration.
|
195
|
+
|
196
|
+
```
|
197
|
+
+------------------------------------------------------------------------+-----------------------+
|
198
|
+
| File path | Duration |
|
199
|
+
+------------------------------------------------------------------------+-----------------------+
|
200
|
+
| schemas/user_serializer/valid_user.json | 0.5460864380002022 |
|
201
|
+
| schemas/user_serializer/invalid_user.json | 0.2532647902998724 |
|
202
|
+
| schemas/post_serializer/published.json | 0.2153625870094402 |
|
203
|
+
| schemas/post_serializer/draft.json | 0.1238838530000066 |
|
204
|
+
+------------------------------------------------------------------------+-----------------------+
|
205
|
+
```
|
206
|
+
|
183
207
|
## Development
|
184
208
|
|
185
209
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
|
5
|
+
module JsonStatham
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path("templates", __dir__)
|
8
|
+
|
9
|
+
def add_initializer
|
10
|
+
template "json_statham.rb", "config/initializers/json_statham.rb"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JsonStatham
|
4
|
+
class Logger
|
5
|
+
COL_LABELS = { file_path: "File path", duration: "Duration" }.freeze
|
6
|
+
|
7
|
+
def config
|
8
|
+
@_config = JsonStatham.config
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
log_header
|
13
|
+
log_values
|
14
|
+
log_divider
|
15
|
+
end
|
16
|
+
|
17
|
+
def columns
|
18
|
+
@_columns ||= COL_LABELS.each_with_object({}) do |(col, label), hash|
|
19
|
+
hash[col] = { label: label, width: [max_val(col), label.size].max }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def max_val(col)
|
24
|
+
values.map { |val| val[col].to_s.size }.max
|
25
|
+
end
|
26
|
+
|
27
|
+
def values
|
28
|
+
@_values ||= Dir["#{config.schemas_path}/**/*.json"].map do |file_path|
|
29
|
+
duration = JSON.parse(File.read(file_path))["duration"]
|
30
|
+
|
31
|
+
{ file_path: file_path, duration: duration }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def log_values
|
38
|
+
values
|
39
|
+
.sort_by { |hash| hash[:duration] }
|
40
|
+
.reverse
|
41
|
+
.each { |hash| log_schema(hash) }
|
42
|
+
end
|
43
|
+
|
44
|
+
def log_header
|
45
|
+
log_divider
|
46
|
+
puts "| #{columns.map { |_, col| col[:label].ljust(col[:width]) }.join(' | ')} |"
|
47
|
+
log_divider
|
48
|
+
end
|
49
|
+
|
50
|
+
def log_divider
|
51
|
+
puts "+-#{columns.map { |_, col| '-' * col[:width] }.join('-+-')}-+"
|
52
|
+
end
|
53
|
+
|
54
|
+
def log_schema(hash)
|
55
|
+
puts "| #{hash.keys.map { |key| hash[key].to_s.ljust(columns[key][:width]) }.join(' | ')} |"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/json_statham/version.rb
CHANGED
data/lib/json_statham.rb
CHANGED
@@ -4,12 +4,14 @@ require_relative "json_statham/helper"
|
|
4
4
|
require_relative "json_statham/version"
|
5
5
|
require_relative "json_statham/requests"
|
6
6
|
require_relative "json_statham/validation"
|
7
|
+
require_relative "json_statham/railtie" if defined?(Rails::Railtie)
|
7
8
|
|
8
9
|
module JsonStatham
|
9
10
|
autoload :Config, "json_statham/config"
|
10
11
|
autoload :Parser, "json_statham/parser"
|
11
12
|
autoload :Schema, "json_statham/schema"
|
12
13
|
autoload :Result, "json_statham/result"
|
14
|
+
autoload :Logger, "json_statham/logger"
|
13
15
|
|
14
16
|
class << self
|
15
17
|
def configure
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_statham
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: JsonStatham allows to check the structure changes in a json
|
14
14
|
email:
|
@@ -27,10 +27,15 @@ files:
|
|
27
27
|
- LICENSE.txt
|
28
28
|
- README.md
|
29
29
|
- Rakefile
|
30
|
+
- lib/generators/json_statham/USAGE
|
31
|
+
- lib/generators/json_statham/install_generator.rb
|
32
|
+
- lib/generators/json_statham/templates/json_statham.rb.tt
|
30
33
|
- lib/json_statham.rb
|
31
34
|
- lib/json_statham/config.rb
|
32
35
|
- lib/json_statham/helper.rb
|
36
|
+
- lib/json_statham/logger.rb
|
33
37
|
- lib/json_statham/parser.rb
|
38
|
+
- lib/json_statham/railtie.rb
|
34
39
|
- lib/json_statham/requests.rb
|
35
40
|
- lib/json_statham/requests/base.rb
|
36
41
|
- lib/json_statham/requests/observer.rb
|
@@ -40,6 +45,7 @@ files:
|
|
40
45
|
- lib/json_statham/schema.rb
|
41
46
|
- lib/json_statham/validation.rb
|
42
47
|
- lib/json_statham/version.rb
|
48
|
+
- lib/tasks/json_statham_tasks.rake
|
43
49
|
- sig/json_statham.rbs
|
44
50
|
homepage: https://github.com/victorauthiat/json_statham
|
45
51
|
licenses:
|
@@ -53,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
59
|
requirements:
|
54
60
|
- - ">="
|
55
61
|
- !ruby/object:Gem::Version
|
56
|
-
version: 2.
|
62
|
+
version: 2.7.0
|
57
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - ">="
|