opushon 0.1.1 → 0.2
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 +0 -5
- data/.travis.yml +12 -3
- data/.yardopts +1 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +1 -0
- data/LICENSE.md +17 -18
- data/README.md +36 -3
- data/Rakefile +3 -2
- data/VERSION.semver +1 -1
- data/bin/console +7 -0
- data/bin/setup +5 -0
- data/lib/opushon/body.rb +35 -0
- data/lib/opushon/option.rb +22 -0
- data/lib/opushon/parameter.rb +52 -6
- data/lib/opushon/request.rb +19 -0
- data/lib/opushon/response.rb +17 -0
- data/lib/opushon/restricted_value.rb +4 -22
- data/lib/opushon.rb +23 -9
- data/opushon.gemspec +10 -6
- metadata +65 -68
- data/.coveralls.yml +0 -1
- data/.ruby-version +0 -1
- data/lib/opushon/error/base_error.rb +0 -6
- data/lib/opushon/error/min_is_greater_than_max_error.rb +0 -8
- data/lib/opushon/error/minlen_is_longer_than_maxlen_error.rb +0 -8
- data/lib/opushon/error/syntax_error.rb +0 -8
- data/lib/opushon/error/verb_error.rb +0 -8
- data/lib/opushon/error.rb +0 -3
- data/lib/opushon/instance.rb +0 -34
- data/lib/opushon/option_object.rb +0 -36
- data/lib/opushon/parameter/base.rb +0 -47
- data/lib/opushon/parameter/input.rb +0 -34
- data/lib/opushon/parameter/output.rb +0 -10
- data/lib/opushon/type/array.rb +0 -10
- data/lib/opushon/type/base.rb +0 -25
- data/lib/opushon/type/boolean.rb +0 -10
- data/lib/opushon/type/hash.rb +0 -10
- data/lib/opushon/type/number.rb +0 -29
- data/lib/opushon/type/string.rb +0 -32
- data/lib/opushon/type.rb +0 -10
- data/lib/opushon/verb/base.rb +0 -7
- data/lib/opushon/verb/delete.rb +0 -9
- data/lib/opushon/verb/get.rb +0 -9
- data/lib/opushon/verb/head.rb +0 -9
- data/lib/opushon/verb/patch.rb +0 -9
- data/lib/opushon/verb/post.rb +0 -9
- data/lib/opushon/verb/put.rb +0 -9
- data/lib/opushon/verb.rb +0 -9
- data/lib/opushon/version.rb +0 -9
- data/spec/opushon/parameter/input_spec.rb +0 -161
- data/spec/opushon/parameter/output_spec.rb +0 -108
- data/spec/opushon/parameter/spec_helper.rb +0 -1
- data/spec/opushon/restricted_value_spec.rb +0 -42
- data/spec/opushon/spec_helper.rb +0 -1
- data/spec/opushon/version_spec.rb +0 -9
- data/spec/opushon_spec.rb +0 -343
- data/spec/spec_helper.rb +0 -4
- data/spec/support/coverage.rb +0 -9
- data/spec/support/env.rb +0 -1
- data/spec/support/immutable.rb +0 -15
- data/spec/support.rb +0 -3
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opushon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Wack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: virtus
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: 1.0.4
|
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
|
-
version:
|
26
|
+
version: 1.0.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.8'
|
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: '1.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +53,61 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.8'
|
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: '0.
|
68
|
+
version: '0.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.9.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.9.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.29'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.29'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: expect
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.0.6
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.0.6
|
69
111
|
description: An Opushon's body parser and emitter.
|
70
112
|
email:
|
71
113
|
- contact@cyril.email
|
@@ -73,58 +115,25 @@ executables: []
|
|
73
115
|
extensions: []
|
74
116
|
extra_rdoc_files: []
|
75
117
|
files:
|
76
|
-
- ".coveralls.yml"
|
77
118
|
- ".gitignore"
|
78
|
-
- ".ruby-version"
|
79
119
|
- ".travis.yml"
|
120
|
+
- ".yardopts"
|
121
|
+
- CODE_OF_CONDUCT.md
|
80
122
|
- Gemfile
|
81
123
|
- LICENSE.md
|
82
124
|
- README.md
|
83
125
|
- Rakefile
|
84
126
|
- VERSION.semver
|
127
|
+
- bin/console
|
128
|
+
- bin/setup
|
85
129
|
- lib/opushon.rb
|
86
|
-
- lib/opushon/
|
87
|
-
- lib/opushon/
|
88
|
-
- lib/opushon/error/min_is_greater_than_max_error.rb
|
89
|
-
- lib/opushon/error/minlen_is_longer_than_maxlen_error.rb
|
90
|
-
- lib/opushon/error/syntax_error.rb
|
91
|
-
- lib/opushon/error/verb_error.rb
|
92
|
-
- lib/opushon/instance.rb
|
93
|
-
- lib/opushon/option_object.rb
|
130
|
+
- lib/opushon/body.rb
|
131
|
+
- lib/opushon/option.rb
|
94
132
|
- lib/opushon/parameter.rb
|
95
|
-
- lib/opushon/
|
96
|
-
- lib/opushon/
|
97
|
-
- lib/opushon/parameter/output.rb
|
133
|
+
- lib/opushon/request.rb
|
134
|
+
- lib/opushon/response.rb
|
98
135
|
- lib/opushon/restricted_value.rb
|
99
|
-
- lib/opushon/type.rb
|
100
|
-
- lib/opushon/type/array.rb
|
101
|
-
- lib/opushon/type/base.rb
|
102
|
-
- lib/opushon/type/boolean.rb
|
103
|
-
- lib/opushon/type/hash.rb
|
104
|
-
- lib/opushon/type/number.rb
|
105
|
-
- lib/opushon/type/string.rb
|
106
|
-
- lib/opushon/verb.rb
|
107
|
-
- lib/opushon/verb/base.rb
|
108
|
-
- lib/opushon/verb/delete.rb
|
109
|
-
- lib/opushon/verb/get.rb
|
110
|
-
- lib/opushon/verb/head.rb
|
111
|
-
- lib/opushon/verb/patch.rb
|
112
|
-
- lib/opushon/verb/post.rb
|
113
|
-
- lib/opushon/verb/put.rb
|
114
|
-
- lib/opushon/version.rb
|
115
136
|
- opushon.gemspec
|
116
|
-
- spec/opushon/parameter/input_spec.rb
|
117
|
-
- spec/opushon/parameter/output_spec.rb
|
118
|
-
- spec/opushon/parameter/spec_helper.rb
|
119
|
-
- spec/opushon/restricted_value_spec.rb
|
120
|
-
- spec/opushon/spec_helper.rb
|
121
|
-
- spec/opushon/version_spec.rb
|
122
|
-
- spec/opushon_spec.rb
|
123
|
-
- spec/spec_helper.rb
|
124
|
-
- spec/support.rb
|
125
|
-
- spec/support/coverage.rb
|
126
|
-
- spec/support/env.rb
|
127
|
-
- spec/support/immutable.rb
|
128
137
|
homepage: https://github.com/cyril/opushon.rb
|
129
138
|
licenses:
|
130
139
|
- MIT
|
@@ -137,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
146
|
requirements:
|
138
147
|
- - ">="
|
139
148
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
149
|
+
version: '0'
|
141
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
151
|
requirements:
|
143
152
|
- - ">="
|
@@ -145,21 +154,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
154
|
version: '0'
|
146
155
|
requirements: []
|
147
156
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.4.
|
157
|
+
rubygems_version: 2.4.5
|
149
158
|
signing_key:
|
150
159
|
specification_version: 4
|
151
160
|
summary: A HTTP Opushon parser and emitter
|
152
|
-
test_files:
|
153
|
-
- spec/opushon/parameter/input_spec.rb
|
154
|
-
- spec/opushon/parameter/output_spec.rb
|
155
|
-
- spec/opushon/parameter/spec_helper.rb
|
156
|
-
- spec/opushon/restricted_value_spec.rb
|
157
|
-
- spec/opushon/spec_helper.rb
|
158
|
-
- spec/opushon/version_spec.rb
|
159
|
-
- spec/opushon_spec.rb
|
160
|
-
- spec/spec_helper.rb
|
161
|
-
- spec/support.rb
|
162
|
-
- spec/support/coverage.rb
|
163
|
-
- spec/support/env.rb
|
164
|
-
- spec/support/immutable.rb
|
161
|
+
test_files: []
|
165
162
|
has_rdoc:
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.2.0-preview2
|
data/lib/opushon/error.rb
DELETED
data/lib/opushon/instance.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require_relative 'option_object'
|
2
|
-
require_relative 'verb'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
# Namespace for the Opushon library.
|
6
|
-
module Opushon
|
7
|
-
# Parse a Opushon string in opushon.
|
8
|
-
class Instance
|
9
|
-
def initialize(opushon)
|
10
|
-
o = JSON.parse(opushon, symbolize_names: true)
|
11
|
-
|
12
|
-
unless o.is_a?(Hash)
|
13
|
-
fail SyntaxError
|
14
|
-
end
|
15
|
-
|
16
|
-
unless o.keys.to_set.subset? VERBS
|
17
|
-
fail VerbError
|
18
|
-
end
|
19
|
-
|
20
|
-
@options = {}
|
21
|
-
o.each do |verb, option_object|
|
22
|
-
option_object_sym = JSON.parse(option_object.to_json, symbolize_names: true)
|
23
|
-
@options.update verb => OptionObject.new(option_object_sym)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Dump instance's opushon to a hash.
|
28
|
-
#
|
29
|
-
# @api public
|
30
|
-
def to_h
|
31
|
-
Hash[@options.each { |k,v| @options[k] = v.to_h }]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require_relative 'parameter'
|
2
|
-
|
3
|
-
# Namespace for the Opushon library.
|
4
|
-
module Opushon
|
5
|
-
# Parse a Opushon string in opushon.
|
6
|
-
class OptionObject
|
7
|
-
def initialize( title: '',
|
8
|
-
description: '',
|
9
|
-
parameters: {},
|
10
|
-
examples: {} )
|
11
|
-
|
12
|
-
@title = title.to_s
|
13
|
-
@description = description.to_s
|
14
|
-
|
15
|
-
@input_params = Parameter::Input.load parameters.fetch(:input) { nil }
|
16
|
-
@output_params = Parameter::Output.load parameters.fetch(:output) { nil }
|
17
|
-
|
18
|
-
@input_example = examples.fetch(:input) { nil }
|
19
|
-
@output_example = examples.fetch(:output) { nil }
|
20
|
-
|
21
|
-
freeze
|
22
|
-
end
|
23
|
-
|
24
|
-
# Dump option object's members to a hash.
|
25
|
-
def to_h
|
26
|
-
{
|
27
|
-
title: @title,
|
28
|
-
description: @description,
|
29
|
-
parameters: { input: @input_params,
|
30
|
-
output: @output_params },
|
31
|
-
examples: { input: @input_example,
|
32
|
-
output: @output_example }
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require_relative File.join '..', 'type'
|
2
|
-
|
3
|
-
# Namespace for the Opushon library.
|
4
|
-
module Opushon
|
5
|
-
module Parameter
|
6
|
-
# Abstract class.
|
7
|
-
class Base
|
8
|
-
def self.load(input_or_output_params)
|
9
|
-
if input_or_output_params.nil?
|
10
|
-
@input_or_output_params = nil
|
11
|
-
else
|
12
|
-
@input_or_output_params = {}
|
13
|
-
|
14
|
-
input_or_output_params.each do |key, properties|
|
15
|
-
properties_sym = JSON.parse(properties.to_json, symbolize_names: true)
|
16
|
-
@input_or_output_params.update key.to_sym => new(properties_sym).to_h
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
@input_or_output_params
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize( title: '',
|
24
|
-
description: '',
|
25
|
-
nullifiable: true,
|
26
|
-
type: 'string', **type_properties )
|
27
|
-
|
28
|
-
@title = title.to_s
|
29
|
-
@description = description.to_s
|
30
|
-
@nullifiable = nullifiable
|
31
|
-
@type = Type.const_get(type.capitalize).new(type_properties)
|
32
|
-
|
33
|
-
freeze
|
34
|
-
end
|
35
|
-
|
36
|
-
# Dump attribute's properties to a hash.
|
37
|
-
def to_h
|
38
|
-
{
|
39
|
-
title: @title,
|
40
|
-
description: @description,
|
41
|
-
nullifiable: @nullifiable,
|
42
|
-
type: @type.to_sym
|
43
|
-
}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require_relative 'base'
|
2
|
-
require_relative File.join '..', 'restricted_value'
|
3
|
-
|
4
|
-
# Namespace for the Opushon library.
|
5
|
-
module Opushon
|
6
|
-
module Parameter
|
7
|
-
# Parse a Opushon input.
|
8
|
-
class Input < Base
|
9
|
-
def initialize( query_string: true,
|
10
|
-
restricted_values: nil,
|
11
|
-
title: '',
|
12
|
-
description: '',
|
13
|
-
nullifiable: true,
|
14
|
-
type: 'string', **type_properties )
|
15
|
-
|
16
|
-
@query_string = query_string
|
17
|
-
@restricted_values = RestrictedValue.load_list(restricted_values)
|
18
|
-
|
19
|
-
@title = title.to_s
|
20
|
-
@description = description.to_s
|
21
|
-
@nullifiable = nullifiable
|
22
|
-
@type = Type.const_get(type.capitalize).new(type_properties)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Dump attribute's properties to a hash.
|
26
|
-
def to_h
|
27
|
-
{
|
28
|
-
query_string: @query_string,
|
29
|
-
restricted_values: @restricted_values
|
30
|
-
}.merge(super).merge(@type.constraints)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/opushon/type/array.rb
DELETED
data/lib/opushon/type/base.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# Namespace for the Opushon library.
|
2
|
-
module Opushon
|
3
|
-
module Type
|
4
|
-
# Abstract class.
|
5
|
-
class Base
|
6
|
-
def initialize(*)
|
7
|
-
freeze
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_h
|
11
|
-
{
|
12
|
-
type: to_sym
|
13
|
-
}.merge(constraints)
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_sym
|
17
|
-
self.class.name.split('::').last.downcase.to_sym
|
18
|
-
end
|
19
|
-
|
20
|
-
def constraints
|
21
|
-
{}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/opushon/type/boolean.rb
DELETED
data/lib/opushon/type/hash.rb
DELETED
data/lib/opushon/type/number.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative 'base'
|
2
|
-
|
3
|
-
# Namespace for the Opushon library.
|
4
|
-
module Opushon
|
5
|
-
module Type
|
6
|
-
# The type number.
|
7
|
-
class Number < Base
|
8
|
-
def initialize( min: nil,
|
9
|
-
max: nil )
|
10
|
-
|
11
|
-
if !min.nil? && !max.nil?
|
12
|
-
fail MinIsGreaterThanMaxError if min > max
|
13
|
-
end
|
14
|
-
|
15
|
-
@min = min
|
16
|
-
@max = max
|
17
|
-
|
18
|
-
freeze
|
19
|
-
end
|
20
|
-
|
21
|
-
def constraints
|
22
|
-
{
|
23
|
-
min: @min,
|
24
|
-
max: @max
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/opushon/type/string.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require_relative 'base'
|
2
|
-
|
3
|
-
# Namespace for the Opushon library.
|
4
|
-
module Opushon
|
5
|
-
module Type
|
6
|
-
# The type string.
|
7
|
-
class String < Base
|
8
|
-
def initialize( minlen: nil,
|
9
|
-
maxlen: nil,
|
10
|
-
pattern: nil )
|
11
|
-
|
12
|
-
if !minlen.nil? && !maxlen.nil?
|
13
|
-
fail MinlenIsLongerThanMaxlenError if minlen > maxlen
|
14
|
-
end
|
15
|
-
|
16
|
-
@minlen = minlen
|
17
|
-
@maxlen = maxlen
|
18
|
-
@pattern = pattern
|
19
|
-
|
20
|
-
freeze
|
21
|
-
end
|
22
|
-
|
23
|
-
def constraints
|
24
|
-
{
|
25
|
-
minlen: @minlen,
|
26
|
-
maxlen: @maxlen,
|
27
|
-
pattern: @pattern
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/lib/opushon/type.rb
DELETED
data/lib/opushon/verb/base.rb
DELETED
data/lib/opushon/verb/delete.rb
DELETED
data/lib/opushon/verb/get.rb
DELETED
data/lib/opushon/verb/head.rb
DELETED
data/lib/opushon/verb/patch.rb
DELETED
data/lib/opushon/verb/post.rb
DELETED
data/lib/opushon/verb/put.rb
DELETED
data/lib/opushon/verb.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
Dir[File.join File.dirname(__FILE__), 'verb', '*.rb'].each do |filename|
|
2
|
-
require_relative filename
|
3
|
-
end
|
4
|
-
|
5
|
-
# Namespace for the Opushon library.
|
6
|
-
module Opushon
|
7
|
-
# Allowed verbs
|
8
|
-
VERBS = Verb.constants.delete_if { |sym| sym.equal?(:Base) }.map(&:upcase).to_set
|
9
|
-
end
|