opushon 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +103 -0
- data/.travis.yml +11 -5
- data/Gemfile +2 -0
- data/LICENSE.md +1 -1
- data/README.md +0 -1
- data/Rakefile +3 -2
- data/VERSION.semver +1 -1
- data/bin/console +1 -0
- data/bin/setup +1 -0
- data/lib/opushon/body.rb +2 -0
- data/lib/opushon/option.rb +2 -0
- data/lib/opushon/parameter.rb +14 -10
- data/lib/opushon/request.rb +2 -0
- data/lib/opushon/response.rb +2 -0
- data/lib/opushon/restricted_value.rb +4 -0
- data/lib/opushon.rb +28 -26
- data/opushon.gemspec +8 -7
- data/pkg_checksum +1 -0
- metadata +16 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 24fefd1822417befed8d3b8678ccda2e3f05eb7462617cdfd9bcf1d63302cded
|
4
|
+
data.tar.gz: 057236242425accea1ed1696b370b42cfbeedcf4cfce124734e3f6f0cac75552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 046e40f75c5a8bee027928d7b2af0da0fe00f6bd9d8d8a7732a959e643dbb93a373f7de43c479c4cb98e054eba7cd685a54796f1b55e628f6ab914c7f64f5d38
|
7
|
+
data.tar.gz: 1d95889786e06951548c92680e7a8795d97225839ba6a52aeb89723ac1bf0f8b6fb04fe82f022d1ac293783df6599483323f8b635c46032c20ab7d4503f07291
|
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-08-26 13:08:39 +0200 using RuboCop version 0.74.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, Include.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/OrderedDependencies:
|
14
|
+
Exclude:
|
15
|
+
- 'opushon.gemspec'
|
16
|
+
|
17
|
+
# Offense count: 24
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
20
|
+
# SupportedHashRocketStyles: key, separator, table
|
21
|
+
# SupportedColonStyles: key, separator, table
|
22
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
23
|
+
Layout/AlignHash:
|
24
|
+
Exclude:
|
25
|
+
- 'lib/opushon/body.rb'
|
26
|
+
- 'lib/opushon/option.rb'
|
27
|
+
- 'lib/opushon/parameter.rb'
|
28
|
+
- 'lib/opushon/request.rb'
|
29
|
+
- 'lib/opushon/response.rb'
|
30
|
+
- 'lib/opushon/restricted_value.rb'
|
31
|
+
|
32
|
+
# Offense count: 356
|
33
|
+
# Cop supports --auto-correct.
|
34
|
+
# Configuration parameters: AllowForAlignment.
|
35
|
+
Layout/SpaceAroundOperators:
|
36
|
+
Exclude:
|
37
|
+
- 'test/test_opushon.rb'
|
38
|
+
|
39
|
+
# Offense count: 140
|
40
|
+
# Cop supports --auto-correct.
|
41
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
42
|
+
# SupportedStyles: space, no_space, compact
|
43
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
44
|
+
Layout/SpaceInsideHashLiteralBraces:
|
45
|
+
Exclude:
|
46
|
+
- 'test/test_opushon.rb'
|
47
|
+
|
48
|
+
# Offense count: 1
|
49
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
50
|
+
Metrics/MethodLength:
|
51
|
+
Max: 22
|
52
|
+
|
53
|
+
# Offense count: 2
|
54
|
+
# Cop supports --auto-correct.
|
55
|
+
# Configuration parameters: EnforcedStyle.
|
56
|
+
# SupportedStyles: braces, no_braces, context_dependent
|
57
|
+
Style/BracesAroundHashParameters:
|
58
|
+
Exclude:
|
59
|
+
- 'test/test_opushon.rb'
|
60
|
+
|
61
|
+
# Offense count: 3
|
62
|
+
Style/Documentation:
|
63
|
+
Exclude:
|
64
|
+
- 'spec/**/*'
|
65
|
+
- 'test/**/*'
|
66
|
+
- 'lib/opushon/option.rb'
|
67
|
+
- 'lib/opushon/request.rb'
|
68
|
+
- 'lib/opushon/response.rb'
|
69
|
+
|
70
|
+
# Offense count: 356
|
71
|
+
# Cop supports --auto-correct.
|
72
|
+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
73
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
74
|
+
Style/HashSyntax:
|
75
|
+
Exclude:
|
76
|
+
- 'test/test_opushon.rb'
|
77
|
+
|
78
|
+
# Offense count: 1
|
79
|
+
Style/MixinUsage:
|
80
|
+
Exclude:
|
81
|
+
- 'test/test_opushon.rb'
|
82
|
+
|
83
|
+
# Offense count: 136
|
84
|
+
# Cop supports --auto-correct.
|
85
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
86
|
+
# SupportedStyles: single_quotes, double_quotes
|
87
|
+
Style/StringLiterals:
|
88
|
+
Exclude:
|
89
|
+
- 'test/test_opushon.rb'
|
90
|
+
|
91
|
+
# Offense count: 2
|
92
|
+
# Cop supports --auto-correct.
|
93
|
+
# Configuration parameters: MinSize, WordRegex.
|
94
|
+
# SupportedStyles: percent, brackets
|
95
|
+
Style/WordArray:
|
96
|
+
EnforcedStyle: brackets
|
97
|
+
|
98
|
+
# Offense count: 19
|
99
|
+
# Cop supports --auto-correct.
|
100
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
101
|
+
# URISchemes: http, https
|
102
|
+
Metrics/LineLength:
|
103
|
+
Max: 3537
|
data/.travis.yml
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
cache: bundler
|
4
|
-
script: 'bundle exec rake test:coverage --trace'
|
5
4
|
before_install:
|
6
5
|
- gem install bundler
|
6
|
+
script:
|
7
|
+
- bundle exec rubocop
|
8
|
+
- bundle exec rake test
|
7
9
|
rvm:
|
8
|
-
- 2.0
|
9
|
-
- 2.
|
10
|
-
- 2.2
|
10
|
+
- 2.5.0
|
11
|
+
- 2.6.2
|
11
12
|
- ruby-head
|
12
13
|
- jruby-head
|
13
|
-
- rbx-
|
14
|
+
- rbx-3
|
15
|
+
matrix:
|
16
|
+
allow_failures:
|
17
|
+
- rvm: ruby-head
|
18
|
+
- rvm: jruby-head
|
19
|
+
- rvm: rbx-3
|
data/Gemfile
CHANGED
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/cyril/opushon.rb.svg?branch=master)][travis]
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/opushon.svg)][gem]
|
5
5
|
[![Inline docs](http://inch-ci.org/github/cyril/opushon.rb.svg?branch=master)][inchpages]
|
6
|
-
[![Documentation](http://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
|
7
6
|
|
8
7
|
> An [Opushon's body](https://github.com/cyril/opushon) parser and emitter.
|
9
8
|
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rake/testtask'
|
3
5
|
require 'rubocop/rake_task'
|
@@ -16,5 +18,4 @@ namespace :test do
|
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
|
-
task
|
20
|
-
task default: [:test, :doc_stats, :rubocop]
|
21
|
+
task default: %i[test rubocop]
|
data/VERSION.semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/bin/console
CHANGED
data/bin/setup
CHANGED
data/lib/opushon/body.rb
CHANGED
data/lib/opushon/option.rb
CHANGED
data/lib/opushon/parameter.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'restricted_value'
|
2
4
|
|
3
5
|
module Opushon
|
6
|
+
# The content of headers, query string and body params MUST be described with
|
7
|
+
# the keys below. When a key is missing, its default value is assigned.
|
4
8
|
class Parameter
|
5
9
|
include Virtus.model(strict: true)
|
6
10
|
|
@@ -10,11 +14,11 @@ module Opushon
|
|
10
14
|
attribute :nullifiable, Boolean, default: true, required: true
|
11
15
|
attribute :restricted_values, Array[RestrictedValue], required: false
|
12
16
|
attribute :example, BasicObject, required: false
|
13
|
-
attribute :minlen,
|
14
|
-
attribute :maxlen,
|
17
|
+
attribute :minlen, Integer, required: false
|
18
|
+
attribute :maxlen, Integer, required: false
|
15
19
|
attribute :pattern, Regexp, required: false
|
16
|
-
attribute :min,
|
17
|
-
attribute :max,
|
20
|
+
attribute :min, Integer, required: false
|
21
|
+
attribute :max, Integer, required: false
|
18
22
|
|
19
23
|
def to_h
|
20
24
|
h = {
|
@@ -30,7 +34,7 @@ module Opushon
|
|
30
34
|
h.update(
|
31
35
|
minlen: @minlen,
|
32
36
|
maxlen: @maxlen,
|
33
|
-
pattern:
|
37
|
+
pattern: @pattern&.to_s
|
34
38
|
)
|
35
39
|
end
|
36
40
|
|
@@ -40,16 +44,16 @@ module Opushon
|
|
40
44
|
max: @max
|
41
45
|
)
|
42
46
|
end
|
47
|
+
|
48
|
+
h
|
43
49
|
end
|
44
50
|
|
45
51
|
private
|
46
52
|
|
47
53
|
def maybe_to_a(object)
|
48
|
-
if object.nil?
|
49
|
-
|
50
|
-
|
51
|
-
object.map(&:to_h)
|
52
|
-
end
|
54
|
+
return if object.nil?
|
55
|
+
|
56
|
+
object.map(&:to_h)
|
53
57
|
end
|
54
58
|
end
|
55
59
|
end
|
data/lib/opushon/request.rb
CHANGED
data/lib/opushon/response.rb
CHANGED
data/lib/opushon.rb
CHANGED
@@ -1,36 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'virtus'
|
2
4
|
require 'json'
|
3
|
-
require_relative File.join 'opushon', 'body'
|
4
5
|
|
5
6
|
# Namespace for the Opushon library.
|
7
|
+
# Representation of documentations for HTTP APIs.
|
6
8
|
#
|
7
9
|
# @api private
|
8
10
|
module Opushon
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
11
|
+
# Load opushon in to the Ruby data structure.
|
12
|
+
#
|
13
|
+
# @api public
|
14
|
+
#
|
15
|
+
# @example Load the option of a DELETE interface
|
16
|
+
# load('{"DELETE":{"title":"Delete issues","description":"Remove every issues.","request":{"headers":{},"query_string":{},"body":{}},"response":{"headers":{},"query_string":{},"body":{}}}}')
|
17
|
+
#
|
18
|
+
# @param [String] opushon_string
|
19
|
+
#
|
20
|
+
# @return [Body] the Ruby data structure
|
21
|
+
def self.load(opushon_string)
|
22
|
+
opushon_hash = JSON.parse(opushon_string)
|
23
|
+
Body.new(opushon_hash)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
26
|
+
# Dump Ruby object to a Opushon string.
|
27
|
+
#
|
28
|
+
# @api public
|
29
|
+
#
|
30
|
+
# @param [Body] opushon
|
31
|
+
#
|
32
|
+
# @return [String] the Opushon data representation
|
33
|
+
def self.dump(opushon)
|
34
|
+
opushon.to_h.to_json
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
require_relative File.join('opushon', 'body')
|
data/opushon.gemspec
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gem::Specification.new do |spec|
|
2
4
|
spec.name = 'opushon'
|
3
5
|
spec.version = File.read('VERSION.semver').chomp
|
4
|
-
spec.authors = ['Cyril
|
6
|
+
spec.authors = ['Cyril Kato']
|
5
7
|
spec.email = ['contact@cyril.email']
|
6
8
|
|
7
9
|
spec.summary = 'A HTTP Opushon parser and emitter'
|
@@ -16,10 +18,9 @@ Gem::Specification.new do |spec|
|
|
16
18
|
|
17
19
|
spec.add_dependency 'virtus', '~> 1.0.5'
|
18
20
|
|
19
|
-
spec.add_development_dependency 'bundler', '~>
|
20
|
-
spec.add_development_dependency 'rake', '~>
|
21
|
-
spec.add_development_dependency '
|
22
|
-
spec.add_development_dependency '
|
23
|
-
spec.add_development_dependency '
|
24
|
-
spec.add_development_dependency 'spectus', '~> 2.1'
|
21
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
22
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
23
|
+
spec.add_development_dependency 'simplecov', '~> 0.17'
|
24
|
+
spec.add_development_dependency 'rubocop', '~> 0.74'
|
25
|
+
spec.add_development_dependency 'spectus', '~> 3.0'
|
25
26
|
end
|
data/pkg_checksum
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opushon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Cyril
|
7
|
+
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -30,84 +30,70 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.0'
|
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
|
-
version: '
|
40
|
+
version: '2.0'
|
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
|
-
version: '
|
47
|
+
version: '12.3'
|
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
|
-
version: '
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: yard
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.8'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.8'
|
54
|
+
version: '12.3'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: simplecov
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
61
|
+
version: '0.17'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
68
|
+
version: '0.17'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rubocop
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
75
|
+
version: '0.74'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
82
|
+
version: '0.74'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: spectus
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
89
|
+
version: '3.0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
96
|
+
version: '3.0'
|
111
97
|
description: An Opushon's body parser and emitter.
|
112
98
|
email:
|
113
99
|
- contact@cyril.email
|
@@ -116,6 +102,8 @@ extensions: []
|
|
116
102
|
extra_rdoc_files: []
|
117
103
|
files:
|
118
104
|
- ".gitignore"
|
105
|
+
- ".rubocop.yml"
|
106
|
+
- ".rubocop_todo.yml"
|
119
107
|
- ".travis.yml"
|
120
108
|
- ".yardopts"
|
121
109
|
- CODE_OF_CONDUCT.md
|
@@ -156,10 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
144
|
- !ruby/object:Gem::Version
|
157
145
|
version: '0'
|
158
146
|
requirements: []
|
159
|
-
|
160
|
-
rubygems_version: 2.4.5.1
|
147
|
+
rubygems_version: 3.0.3
|
161
148
|
signing_key:
|
162
149
|
specification_version: 4
|
163
150
|
summary: A HTTP Opushon parser and emitter
|
164
151
|
test_files: []
|
165
|
-
has_rdoc:
|