lurker 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -1
- data/lib/lurker/json/concerns/validatable.rb +4 -10
- data/lib/lurker/json/parser/expertise.rb +4 -11
- data/lib/lurker/json/parser/typed_strategy.rb +9 -18
- data/lib/lurker/json/schema/attribute.rb +16 -19
- data/lib/lurker/json/schema/list.rb +10 -14
- data/lib/lurker/json/schema/object.rb +12 -19
- data/lib/lurker/json/schema/reference.rb +1 -3
- data/lib/lurker/json/schema/response_codes.rb +1 -2
- data/lib/lurker/json/schema/tuple/all_of.rb +1 -3
- data/lib/lurker/json/schema/tuple/any_of.rb +1 -3
- data/lib/lurker/json/schema/tuple/one_of.rb +1 -3
- data/lib/lurker/json.rb +27 -0
- data/lib/lurker/version.rb +1 -1
- data/lib/lurker.rb +1 -0
- data/spec/lurker/json/object_spec.rb +43 -0
- data.tar.gz.sig +3 -2
- metadata +5 -3
- metadata.gz.sig +5 -1
- data/lib/lurker/json_schema_hash.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f19d765a42825a49246ece3cfe310a71ef07026
|
4
|
+
data.tar.gz: 04db573bb51da7ac28f3f55c5a85990e6bb6768b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d203a0847bda1f56a2b8b39eda067d0d40f1ddde7bd27c5e800ae61f3000c7cae600c076d619bfc634c087c9f9e4480e6982c745c1f267c3689ec46d77671e7
|
7
|
+
data.tar.gz: 98af7ab781606392252390b6f7f74a844b56d1d61910acd2b6b2c180fbb06dc03ed43b03b6b2d34f59dec7c5cdcc681a0bc188d6235d662335d54f1aa75638d9
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
|
1
|
+
aR)�&���L�PS���!D����E�'���H��\�]_�km��n zԎ�"����B���j����w
|
2
|
+
r2��;#��D�d#KO�H����eqr���Q����SV[6��y�\ھ� .���$�^��0��_ D�`)�0b�>)lp��o6�&��-�
|
3
|
+
-r�sb����X���\:�6���W�v=��N�Li���l��?��c/�3|Ff
|
@@ -2,12 +2,6 @@ module Lurker
|
|
2
2
|
module Json
|
3
3
|
module Concerns
|
4
4
|
module Validatable
|
5
|
-
ID = 'id'.freeze
|
6
|
-
TYPE = 'type'.freeze
|
7
|
-
OBJECT = 'object'.freeze
|
8
|
-
PROPERTIES = 'properties'.freeze
|
9
|
-
ADDITIONAL_PROPERTIES = 'additionalProperties'.freeze
|
10
|
-
|
11
5
|
def validate(data)
|
12
6
|
Lurker::Validator.new(to_validation_schema, data,
|
13
7
|
record_errors: true).validate.map { |error| "- #{error}" }
|
@@ -15,7 +9,7 @@ module Lurker
|
|
15
9
|
|
16
10
|
def to_validation_schema
|
17
11
|
set_additional_properties_false_on(to_hash).tap do |schema|
|
18
|
-
schema[ID] = "file://#{uri}"
|
12
|
+
schema[Json::ID] = "file://#{uri}"
|
19
13
|
end
|
20
14
|
end
|
21
15
|
|
@@ -26,12 +20,12 @@ module Lurker
|
|
26
20
|
when Hash
|
27
21
|
copy = object.dup
|
28
22
|
|
29
|
-
if object[TYPE] == OBJECT || object.key?(PROPERTIES)
|
30
|
-
copy[ADDITIONAL_PROPERTIES] ||= false
|
23
|
+
if object[Json::TYPE] == Json::OBJECT || object.key?(Json::PROPERTIES)
|
24
|
+
copy[Json::ADDITIONAL_PROPERTIES] ||= false
|
31
25
|
end
|
32
26
|
|
33
27
|
object.each do |key, value|
|
34
|
-
next if key == ADDITIONAL_PROPERTIES
|
28
|
+
next if key == Json::ADDITIONAL_PROPERTIES
|
35
29
|
copy[key] = set_additional_properties_false_on(value)
|
36
30
|
end
|
37
31
|
|
@@ -2,27 +2,20 @@ module Lurker
|
|
2
2
|
module Json
|
3
3
|
class Parser
|
4
4
|
module Expertise
|
5
|
-
REF = '$ref'.freeze
|
6
|
-
TYPE = 'type'.freeze
|
7
|
-
ANYOF = 'anyOf'.freeze
|
8
|
-
ALLOF = 'allOf'.freeze
|
9
|
-
ONEOF = 'oneOf'.freeze
|
10
|
-
ITEMS = 'items'.freeze
|
11
|
-
PROPERTIES = 'properties'.freeze
|
12
|
-
|
13
5
|
module_function
|
14
6
|
|
15
7
|
def type_defined?(hash)
|
16
8
|
return false unless hash.is_a?(Hash)
|
17
9
|
|
18
|
-
hash.key? TYPE
|
10
|
+
hash.key?(Json::TYPE) && Json::PRIMITIVES.include?(hash[Json::TYPE])
|
19
11
|
end
|
20
12
|
|
21
13
|
def type_supposed?(hash)
|
22
14
|
return false unless hash.is_a?(Hash)
|
23
15
|
|
24
|
-
hash.key?(ANYOF) || hash.key?(ALLOF) || hash.key?(ONEOF) ||
|
25
|
-
hash.key?(ITEMS) || hash.key?(PROPERTIES) ||
|
16
|
+
hash.key?(Json::ANYOF) || hash.key?(Json::ALLOF) || hash.key?(Json::ONEOF) ||
|
17
|
+
hash.key?(Json::ITEMS) || hash.key?(Json::PROPERTIES) ||
|
18
|
+
hash.key?(Json::REF)
|
26
19
|
end
|
27
20
|
end
|
28
21
|
end
|
@@ -4,15 +4,6 @@ module Lurker
|
|
4
4
|
class TypedStrategy
|
5
5
|
include Lurker::Json::Parser::Expertise
|
6
6
|
|
7
|
-
ANYOF = 'anyOf'.freeze
|
8
|
-
ALLOF = 'allOf'.freeze
|
9
|
-
ONEOF = 'oneOf'.freeze
|
10
|
-
ITEMS = 'items'.freeze
|
11
|
-
TYPE = 'type'.freeze
|
12
|
-
ARRAY = 'array'.freeze
|
13
|
-
OBJECT = 'object'.freeze
|
14
|
-
PROPERTIES = 'properties'.freeze
|
15
|
-
|
16
7
|
attr_reader :schema_options
|
17
8
|
|
18
9
|
def initialize(options)
|
@@ -38,17 +29,17 @@ module Lurker
|
|
38
29
|
private
|
39
30
|
|
40
31
|
def create_by_supposition(payload)
|
41
|
-
if payload.key?(ITEMS)
|
32
|
+
if payload.key?(Json::ITEMS)
|
42
33
|
Lurker::Json::List.new(payload, schema_options)
|
43
|
-
elsif payload.key?(PROPERTIES)
|
34
|
+
elsif payload.key?(Json::PROPERTIES)
|
44
35
|
Lurker::Json::Object.new(payload, schema_options)
|
45
|
-
elsif payload.key?(ANYOF)
|
36
|
+
elsif payload.key?(Json::ANYOF)
|
46
37
|
Lurker::Json::Tuple::AnyOf.new(payload, schema_options)
|
47
|
-
elsif payload.key?(ALLOF)
|
38
|
+
elsif payload.key?(Json::ALLOF)
|
48
39
|
Lurker::Json::Tuple::AllOf.new(payload, schema_options)
|
49
|
-
elsif payload.key?(ONEOF)
|
40
|
+
elsif payload.key?(Json::ONEOF)
|
50
41
|
Lurker::Json::Tuple::OneOf.new(payload, schema_options)
|
51
|
-
elsif payload.key?(REF)
|
42
|
+
elsif payload.key?(Json::REF)
|
52
43
|
Lurker::Json::Reference.new(payload, schema_options)
|
53
44
|
else
|
54
45
|
raise "Unknown type supposition for #{payload}"
|
@@ -56,10 +47,10 @@ module Lurker
|
|
56
47
|
end
|
57
48
|
|
58
49
|
def create_by_type(payload)
|
59
|
-
case payload[TYPE]
|
60
|
-
when OBJECT
|
50
|
+
case payload[Json::TYPE]
|
51
|
+
when Json::OBJECT
|
61
52
|
Lurker::Json::Object.new(payload, schema_options)
|
62
|
-
when ARRAY
|
53
|
+
when Json::ARRAY
|
63
54
|
Lurker::Json::List.new(payload, schema_options)
|
64
55
|
else
|
65
56
|
Lurker::Json::Attribute.new(payload, schema_options)
|
@@ -4,26 +4,23 @@ module Lurker
|
|
4
4
|
module Json
|
5
5
|
class Attribute < Schema
|
6
6
|
URI = 'uri'.freeze
|
7
|
-
TYPE = 'type'.freeze
|
8
7
|
COLOR = 'color'.freeze
|
9
8
|
FORMAT = 'format'.freeze
|
10
|
-
EXAMPLE = 'example'.freeze
|
11
9
|
DATE_TIME = 'date-time'.freeze
|
12
|
-
DESCRIPTION = 'description'.freeze
|
13
10
|
|
14
11
|
TYPE_MAP = {
|
15
|
-
'Time' =>
|
16
|
-
'Hash' =>
|
17
|
-
'Float' =>
|
18
|
-
'Fixnum' =>
|
19
|
-
'NilClass' =>
|
20
|
-
'TrueClass' =>
|
21
|
-
'FalseClass' =>
|
22
|
-
'ActionDispatch::Http::UploadedFile' =>
|
12
|
+
'Time' => Json::STRING,
|
13
|
+
'Hash' => Json::OBJECT,
|
14
|
+
'Float' => Json::NUMBER,
|
15
|
+
'Fixnum' => Json::INTEGER,
|
16
|
+
'NilClass' => Json::NULL,
|
17
|
+
'TrueClass' => Json::BOOLEAN,
|
18
|
+
'FalseClass' => Json::BOOLEAN,
|
19
|
+
'ActionDispatch::Http::UploadedFile' => Json::STRING
|
23
20
|
}.freeze
|
24
21
|
|
25
22
|
def merge!(schema)
|
26
|
-
return replace!(schema) if @schema[TYPE].blank?
|
23
|
+
return replace!(schema) if @schema[Json::TYPE].blank?
|
27
24
|
|
28
25
|
schema = attributify(schema)
|
29
26
|
return if eql?(schema)
|
@@ -42,7 +39,7 @@ module Lurker
|
|
42
39
|
end
|
43
40
|
|
44
41
|
def eql?(schema)
|
45
|
-
@schema[TYPE] == attributify(schema)[TYPE]
|
42
|
+
@schema[Json::TYPE] == attributify(schema)[Json::TYPE]
|
46
43
|
end
|
47
44
|
|
48
45
|
private
|
@@ -62,9 +59,9 @@ module Lurker
|
|
62
59
|
return schema if schema.is_a?(Hash) || schema.is_a?(Lurker::Json::Schema)
|
63
60
|
|
64
61
|
attribute = {
|
65
|
-
DESCRIPTION => '',
|
66
|
-
TYPE => guess_type(schema),
|
67
|
-
EXAMPLE => serialize_example(schema)
|
62
|
+
Json::DESCRIPTION => '',
|
63
|
+
Json::TYPE => guess_type(schema),
|
64
|
+
Json::EXAMPLE => serialize_example(schema)
|
68
65
|
}
|
69
66
|
|
70
67
|
if format = guess_format(schema)
|
@@ -75,9 +72,9 @@ module Lurker
|
|
75
72
|
end
|
76
73
|
|
77
74
|
def initialize_properties
|
78
|
-
@schema[DESCRIPTION] ||= ''
|
79
|
-
@schema[TYPE] ||= ''
|
80
|
-
@schema[EXAMPLE] ||= ''
|
75
|
+
@schema[Json::DESCRIPTION] ||= ''
|
76
|
+
@schema[Json::TYPE] ||= ''
|
77
|
+
@schema[Json::EXAMPLE] ||= ''
|
81
78
|
end
|
82
79
|
|
83
80
|
def serialize_example(data)
|
@@ -1,23 +1,19 @@
|
|
1
1
|
module Lurker
|
2
2
|
module Json
|
3
3
|
class List < Schema
|
4
|
-
TYPE = 'type'.freeze
|
5
|
-
ARRAY = 'array'.freeze
|
6
|
-
ITEMS = 'items'.freeze
|
7
|
-
|
8
4
|
def merge!(schema)
|
9
5
|
if schema.is_a?(Array)
|
10
|
-
schema.each { |payload| @schema[ITEMS].merge!(payload) }
|
6
|
+
schema.each { |payload| @schema[Json::ITEMS].merge!(payload) }
|
11
7
|
else
|
12
|
-
@schema[ITEMS].merge!(schema)
|
8
|
+
@schema[Json::ITEMS].merge!(schema)
|
13
9
|
end
|
14
10
|
end
|
15
11
|
|
16
12
|
def replace!(property, schema)
|
17
|
-
if @schema[ITEMS].is_a?(Lurker::Json::Attribute)
|
18
|
-
@schema[ITEMS] = schema
|
13
|
+
if @schema[Json::ITEMS].is_a?(Lurker::Json::Attribute)
|
14
|
+
@schema[Json::ITEMS] = schema
|
19
15
|
else
|
20
|
-
@schema[ITEMS].replace!(property, schema)
|
16
|
+
@schema[Json::ITEMS].replace!(property, schema)
|
21
17
|
end
|
22
18
|
end
|
23
19
|
|
@@ -31,11 +27,11 @@ module Lurker
|
|
31
27
|
|
32
28
|
schema = schema.dup
|
33
29
|
if schema.is_a?(Array)
|
34
|
-
@schema[ITEMS] = @parser.typed.parse(schema.shift)
|
30
|
+
@schema[Json::ITEMS] = @parser.typed.parse(schema.shift)
|
35
31
|
|
36
|
-
schema.each { |payload| @schema[ITEMS].merge!(payload) }
|
32
|
+
schema.each { |payload| @schema[Json::ITEMS].merge!(payload) }
|
37
33
|
else
|
38
|
-
@schema[ITEMS] = @parser.typed.parse(schema.delete ITEMS) if schema.key?(ITEMS)
|
34
|
+
@schema[Json::ITEMS] = @parser.typed.parse(schema.delete Json::ITEMS) if schema.key?(Json::ITEMS)
|
39
35
|
@schema.merge!(schema)
|
40
36
|
end
|
41
37
|
|
@@ -43,8 +39,8 @@ module Lurker
|
|
43
39
|
end
|
44
40
|
|
45
41
|
def initialize_properties
|
46
|
-
@schema[TYPE] ||= ARRAY
|
47
|
-
@schema[ITEMS] ||= []
|
42
|
+
@schema[Json::TYPE] ||= Json::ARRAY
|
43
|
+
@schema[Json::ITEMS] ||= []
|
48
44
|
end
|
49
45
|
end
|
50
46
|
end
|
@@ -1,23 +1,16 @@
|
|
1
1
|
module Lurker
|
2
2
|
module Json
|
3
3
|
class Object < Schema
|
4
|
-
TYPE = 'type'.freeze
|
5
|
-
OBJECT = 'object'.freeze
|
6
|
-
REQUIRED = 'required'.freeze
|
7
|
-
PROPERTIES = 'properties'.freeze
|
8
|
-
DESCRIPTION = 'description'.freeze
|
9
|
-
ADDITIONAL_PROPERTIES = 'additionalProperties'.freeze
|
10
|
-
|
11
4
|
def merge!(schema)
|
12
5
|
unless schema.is_a?(Hash)
|
13
|
-
return replace_with_new_type(schema) if @schema[PROPERTIES].blank?
|
6
|
+
return replace_with_new_type(schema) if @schema[Json::PROPERTIES].blank?
|
14
7
|
|
15
8
|
raise TypeError, "Unable to merge #{schema.class} into JSON object"
|
16
9
|
end
|
17
10
|
|
18
11
|
schema.each do |property, property_schema|
|
19
|
-
if @schema[PROPERTIES].key?(property)
|
20
|
-
@schema[PROPERTIES][property].merge!(property_schema)
|
12
|
+
if @schema[Json::PROPERTIES].key?(property)
|
13
|
+
@schema[Json::PROPERTIES][property].merge!(property_schema)
|
21
14
|
next
|
22
15
|
end
|
23
16
|
|
@@ -26,7 +19,7 @@ module Lurker
|
|
26
19
|
end
|
27
20
|
|
28
21
|
def replace!(property, property_schema)
|
29
|
-
@schema[PROPERTIES][property] = Lurker::Json::Parser.typed(subschema_options)
|
22
|
+
@schema[Json::PROPERTIES][property] = Lurker::Json::Parser.typed(subschema_options)
|
30
23
|
.parse_property(property, property_schema)
|
31
24
|
end
|
32
25
|
|
@@ -37,10 +30,10 @@ module Lurker
|
|
37
30
|
initialize_properties
|
38
31
|
|
39
32
|
schema = schema.dup
|
40
|
-
merge_required = schema.key?(PROPERTIES)
|
33
|
+
merge_required = schema.key?(Json::PROPERTIES)
|
41
34
|
|
42
|
-
(schema.delete(PROPERTIES) || schema).each do |property, property_schema|
|
43
|
-
@schema[PROPERTIES][property] = @parser.typed.parse_property(
|
35
|
+
(schema.delete(Json::PROPERTIES) || schema).each do |property, property_schema|
|
36
|
+
@schema[Json::PROPERTIES][property] = @parser.typed.parse_property(
|
44
37
|
property, property_schema)
|
45
38
|
end
|
46
39
|
|
@@ -56,11 +49,11 @@ module Lurker
|
|
56
49
|
end
|
57
50
|
|
58
51
|
def initialize_properties
|
59
|
-
@schema[DESCRIPTION] ||= ''
|
60
|
-
@schema[TYPE] ||= OBJECT
|
61
|
-
@schema[ADDITIONAL_PROPERTIES] = !!@schema[ADDITIONAL_PROPERTIES]
|
62
|
-
@schema[REQUIRED] ||= []
|
63
|
-
@schema[PROPERTIES] ||= {}
|
52
|
+
@schema[Json::DESCRIPTION] ||= ''
|
53
|
+
@schema[Json::TYPE] ||= Json::OBJECT
|
54
|
+
@schema[Json::ADDITIONAL_PROPERTIES] = !!@schema[Json::ADDITIONAL_PROPERTIES]
|
55
|
+
@schema[Json::REQUIRED] ||= []
|
56
|
+
@schema[Json::PROPERTIES] ||= {}
|
64
57
|
end
|
65
58
|
end
|
66
59
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Lurker
|
2
2
|
module Json
|
3
3
|
class Reference < Schema
|
4
|
-
REF = '$ref'.freeze
|
5
|
-
|
6
4
|
attr_reader :original_uri
|
7
5
|
|
8
6
|
delegate :merge!, :replace!, :reorder!, to: :@schema
|
@@ -18,7 +16,7 @@ module Lurker
|
|
18
16
|
|
19
17
|
# NOTE : We decide that reference is relative, so we are using merge
|
20
18
|
# We use first read for correct relative path resolving
|
21
|
-
reader = Lurker::Json::Reader.new(@uri.merge(schema[REF]).path)
|
19
|
+
reader = Lurker::Json::Reader.new(@uri.merge(schema[Json::REF]).path)
|
22
20
|
payload = reader.payload
|
23
21
|
|
24
22
|
@original_uri = parse_uri(reader.path)
|
@@ -3,7 +3,6 @@ module Lurker
|
|
3
3
|
class ResponseCodes < Schema
|
4
4
|
STATUS = 'status'.freeze
|
5
5
|
SUCCESSFUL = 'successful'.freeze
|
6
|
-
DESCRIPTION = 'description'.freeze
|
7
6
|
|
8
7
|
def initialize(schema, options = {})
|
9
8
|
@parent_property = 'responseCodes'
|
@@ -14,7 +13,7 @@ module Lurker
|
|
14
13
|
def merge!(status_code, successful)
|
15
14
|
return if exists?(status_code, successful)
|
16
15
|
|
17
|
-
payload = {STATUS => status_code, SUCCESSFUL => successful, DESCRIPTION => ''}
|
16
|
+
payload = {STATUS => status_code, SUCCESSFUL => successful, Json::DESCRIPTION => ''}
|
18
17
|
@schema << Lurker::Json::Parser.plain(root_schema: root_schema).parse(payload)
|
19
18
|
end
|
20
19
|
|
data/lib/lurker/json.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Lurker
|
2
|
+
module Json
|
3
|
+
NULL = 'null'.freeze
|
4
|
+
ARRAY = 'array'.freeze
|
5
|
+
STRING = 'string'.freeze
|
6
|
+
OBJECT = 'object'.freeze
|
7
|
+
NUMBER = 'number'.freeze
|
8
|
+
BOOLEAN = 'boolean'.freeze
|
9
|
+
INTEGER = 'integer'.freeze
|
10
|
+
|
11
|
+
PRIMITIVES = [NULL, BOOLEAN, INTEGER, NUMBER, STRING, ARRAY, OBJECT].freeze
|
12
|
+
|
13
|
+
ID = 'id'.freeze
|
14
|
+
REF = '$ref'.freeze
|
15
|
+
TYPE = 'type'.freeze
|
16
|
+
ITEMS = 'items'.freeze
|
17
|
+
EXAMPLE = 'example'.freeze
|
18
|
+
REQUIRED = 'required'.freeze
|
19
|
+
PROPERTIES = 'properties'.freeze
|
20
|
+
DESCRIPTION = 'description'.freeze
|
21
|
+
ADDITIONAL_PROPERTIES = 'additionalProperties'.freeze
|
22
|
+
|
23
|
+
ANYOF = 'anyOf'.freeze
|
24
|
+
ALLOF = 'allOf'.freeze
|
25
|
+
ONEOF = 'oneOf'.freeze
|
26
|
+
end
|
27
|
+
end
|
data/lib/lurker/version.rb
CHANGED
data/lib/lurker.rb
CHANGED
@@ -63,6 +63,7 @@ require 'lurker/presenters/service_presenter'
|
|
63
63
|
require 'lurker/presenters/endpoint_presenter'
|
64
64
|
require 'lurker/presenters/schema_presenter'
|
65
65
|
require 'lurker/presenters/response_code_presenter'
|
66
|
+
require 'lurker/json'
|
66
67
|
require 'lurker/json/reader'
|
67
68
|
require 'lurker/json/writter'
|
68
69
|
require 'lurker/json/orderer'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lurker::Json::Object do
|
4
|
+
let(:klass) { described_class }
|
5
|
+
|
6
|
+
describe '#merge!' do
|
7
|
+
context 'when merge a hash with keywords' do
|
8
|
+
let(:object) { klass.new('name' => 'razum2um') }
|
9
|
+
let(:expected) do
|
10
|
+
{
|
11
|
+
'description' => '',
|
12
|
+
'type' => 'object',
|
13
|
+
'additionalProperties' => false,
|
14
|
+
'required' => [],
|
15
|
+
'properties' => {
|
16
|
+
'name' => {
|
17
|
+
'description' => '',
|
18
|
+
'type' => 'string',
|
19
|
+
'example' => 'razum2um'
|
20
|
+
},
|
21
|
+
'achievement' => {
|
22
|
+
'description' => '',
|
23
|
+
'type' => 'object',
|
24
|
+
'additionalProperties' => false,
|
25
|
+
'required' => [],
|
26
|
+
'properties' => {
|
27
|
+
'type' => {
|
28
|
+
'description' => '',
|
29
|
+
'type' => 'string',
|
30
|
+
'example' => 'unlocked'
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
before { object.merge!('achievement' => {'type' => 'unlocked'}) }
|
39
|
+
|
40
|
+
it { expect(object.to_hash).to eq expected }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
';��,��6�G�m2�n=����� Cmu�p���R¶���f
|
2
|
+
M|3�:��}6�k�W��J��N1����a���yV/DK���#���6 y�~9�+��z�w:7�;�t����6[�����[����X��'N�l۪x=/Eoe�����J��%�/�Q�m�CI~1`c����q|��G��!���Qȵu���j�pl����&^I��
|
3
|
+
ٌ.8`h
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lurker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Bokov
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
vzKbYclpJ7gENr/xiTjGqA/Md3zJMzmsFrzUXt4RVmo5SaCyZjC6gFfhSr+PODc7
|
31
31
|
ZaSbckvH/+m4boAsg0JkGGFcS3j5fgNmdwgA1A==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-08-
|
33
|
+
date: 2014-08-18 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: json
|
@@ -487,6 +487,7 @@ files:
|
|
487
487
|
- lib/lurker/erb_schema_context.rb
|
488
488
|
- lib/lurker/form_builder.rb
|
489
489
|
- lib/lurker/jaml_descriptor.rb
|
490
|
+
- lib/lurker/json.rb
|
490
491
|
- lib/lurker/json/concerns/validatable.rb
|
491
492
|
- lib/lurker/json/orderer.rb
|
492
493
|
- lib/lurker/json/parser.rb
|
@@ -506,7 +507,6 @@ files:
|
|
506
507
|
- lib/lurker/json/schema/tuple/any_of.rb
|
507
508
|
- lib/lurker/json/schema/tuple/one_of.rb
|
508
509
|
- lib/lurker/json/writter.rb
|
509
|
-
- lib/lurker/json_schema_hash.rb
|
510
510
|
- lib/lurker/presenters/base_presenter.rb
|
511
511
|
- lib/lurker/presenters/endpoint_presenter.rb
|
512
512
|
- lib/lurker/presenters/json_presenter.rb
|
@@ -575,6 +575,7 @@ files:
|
|
575
575
|
- lurker.gemspec
|
576
576
|
- spec/lurker/endpoint_spec.rb
|
577
577
|
- spec/lurker/json/list_spec.rb
|
578
|
+
- spec/lurker/json/object_spec.rb
|
578
579
|
- spec/lurker/json/schema_spec.rb
|
579
580
|
- spec/lurker/yaml_spec.rb
|
580
581
|
- spec/spec_helper.rb
|
@@ -631,6 +632,7 @@ test_files:
|
|
631
632
|
- features/test_endpoint.feature
|
632
633
|
- spec/lurker/endpoint_spec.rb
|
633
634
|
- spec/lurker/json/list_spec.rb
|
635
|
+
- spec/lurker/json/object_spec.rb
|
634
636
|
- spec/lurker/json/schema_spec.rb
|
635
637
|
- spec/lurker/yaml_spec.rb
|
636
638
|
- spec/spec_helper.rb
|
metadata.gz.sig
CHANGED
@@ -1,48 +0,0 @@
|
|
1
|
-
module Lurker
|
2
|
-
class JsonSchemaHash
|
3
|
-
attr_accessor :schema_hash
|
4
|
-
include JamlDescriptor::Rescue
|
5
|
-
|
6
|
-
def initialize(schema_hash, uri)
|
7
|
-
@to_s = uri
|
8
|
-
@uri = URI.parse(uri)
|
9
|
-
@uri = URI.parse("file://#{uri}") if @uri.relative?
|
10
|
-
|
11
|
-
@schema_hash = Hash[schema_hash.map do |k, v|
|
12
|
-
if k == '$ref' && v.is_a?(String)
|
13
|
-
uri = @uri.merge(v)
|
14
|
-
schema_hash = JSON.parse(open(uri.to_s).read)
|
15
|
-
[k, JsonSchemaHash.new(schema_hash, uri.to_s)]
|
16
|
-
elsif v.is_a?(Hash)
|
17
|
-
[k, JsonSchemaHash.new(v, @to_s)]
|
18
|
-
else
|
19
|
-
[k, v]
|
20
|
-
end
|
21
|
-
end]
|
22
|
-
end
|
23
|
-
|
24
|
-
def respond_to_missing?(method, include_private = false)
|
25
|
-
@schema_hash.send(:respond_to_missing?, method, include_private)
|
26
|
-
end
|
27
|
-
|
28
|
-
def method_missing(method, *args, &block)
|
29
|
-
@schema_hash.send method, *args, &block
|
30
|
-
end
|
31
|
-
|
32
|
-
def is_a?(*args)
|
33
|
-
@schema_hash.is_a?(*args)
|
34
|
-
end
|
35
|
-
|
36
|
-
def to_h
|
37
|
-
Hash[@schema_hash.map do |k, v|
|
38
|
-
if JsonSchemaHash === v
|
39
|
-
[k, v.to_h]
|
40
|
-
elsif v.is_a?(Array)
|
41
|
-
[k, v.map { |i| JsonSchemaHash === i ? i.to_h : i }]
|
42
|
-
else
|
43
|
-
[k, v]
|
44
|
-
end
|
45
|
-
end]
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|