iglu-ruby-client 0.1.0.beta → 0.1.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e73421a2bfedada5669ee7482883196a824ffebc
4
- data.tar.gz: ea2ab1d53ecb6594a8bce2f299c2efcb366fdafa
3
+ metadata.gz: 3bf4ff6bce88c9734846c1f4ed5bd0d1a2c3846f
4
+ data.tar.gz: 035b84bf32c0b1d1aed5a6b404cc96f92403f2a8
5
5
  SHA512:
6
- metadata.gz: ea6bbef26f62f7e2ad2b85527a80f64ea9751bf555dbea95ddd20fcceec79d12e2d083ef3e53ec2764dee233b02e75c5287f3c9c9127f5c89791f272c54e40aa
7
- data.tar.gz: 4640a5303b0761eec70916f3763a9094d47c164801e4c15bddf223507a866eb8f1470c580bf147634a554d94cd6fed8007d0719958311072eaf710e11fa247c5
6
+ metadata.gz: 0fa0563292bd560ee0c4ee21bf39a02c6a1e8bf84ea0e06807f7d1f3593a778c3c131740d86e8394b70a133b1dc35bf8985640be899a0dccf1b9e8b61e3d8a9f
7
+ data.tar.gz: 483b95c1ea2e9d11be70b5682efc6a66da78871d4d93a8c6078204ca70bebb57d74503cf1e2f1e10cfe5e39a0c449ef57f2387585a932399b9fdc52c3e256e24
@@ -1,7 +1,10 @@
1
1
  module Iglu
2
2
  module Registries
3
3
  config = Iglu::Registries::RegistryRefConfig.new "Iglu Client Embedded", 0, []
4
- @@registry = Iglu::Registries::EmbeddedRegistryRef.new config, "iglu-client-embedded"
4
+ root = File.dirname(Iglu::Resolver.method(:parse).source_location[0])
5
+ path = File.join(root, '..', '..', 'assets', "iglu-client-embedded")
6
+
7
+ @@registry = Iglu::Registries::EmbeddedRegistryRef.new(config, path)
5
8
 
6
9
  # Registry embedded straight into iglu-client gem
7
10
  def self.bootstrap
@@ -65,12 +65,11 @@ module Iglu
65
65
  @class_priority = 1
66
66
  @descriptor = "embedded"
67
67
 
68
- @path = path
69
- @root = "assets"
68
+ @root = path
70
69
  end
71
70
 
72
71
  def lookup_schema(schema_key)
73
- schema_path = File.join(@root, @path, 'schemas', schema_key.as_path)
72
+ schema_path = File.join(@root, 'schemas', schema_key.as_path)
74
73
  content = File.read(schema_path)
75
74
  JSON::parse(content)
76
75
  rescue Errno::ENOENT => _
@@ -86,6 +85,10 @@ module Iglu
86
85
  def initialize(registry)
87
86
  @registry = registry
88
87
  end
88
+
89
+ def to_s
90
+ "Not found at #{@registry}"
91
+ end
89
92
  end
90
93
 
91
94
  class LookupFailure
@@ -95,13 +98,20 @@ module Iglu
95
98
  @reason = reason
96
99
  @registry = registry
97
100
  end
101
+
102
+ def to_s
103
+ "Lookup failure at #{@registry} because #{@reason}"
104
+ end
98
105
  end
99
106
 
100
107
  class ResolverError < StandardError
101
- attr_reader :lookups
108
+ attr_reader :lookups, :schema_key
102
109
 
103
110
  def initialize(lookups)
104
111
  @lookups = lookups
112
+ @schema_key = schema_key
113
+ message = "Schema [#{schema_key.as_uri}] was not found with in [#{lookups.length}] registries with following attempts: [#{lookups.map { |lookup| lookup.to_s }.join('; ')}]"
114
+ super(message)
105
115
  end
106
116
  end
107
117
 
@@ -48,7 +48,7 @@ module Iglu
48
48
  end
49
49
 
50
50
  if lookup_result.nil?
51
- raise Registries::ResolverError.new failures
51
+ raise Registries::ResolverError.new(failures, schema_key)
52
52
  else
53
53
  @cache[schema_key] = lookup_result
54
54
  lookup_result
@@ -112,16 +112,15 @@ module Iglu
112
112
  JSON::Validator.validate!(schema, data)
113
113
  end
114
114
 
115
-
116
- # Primary method. Validate self-describing JSON instance
117
- def self.validate(json)
118
- JSON::Validator.validate!(schema, data)
119
- end
120
-
121
115
  def prioritize_repos(schema_key, repository_refs)
122
116
  repository_refs.sort_by do |ref|
123
- [!ref.vendor_matched(schema_key), ref.class_priority, ref.config.priority]
117
+ [Resolver.btoi(!ref.vendor_matched(schema_key)), ref.class_priority, ref.config.priority]
124
118
  end
125
119
  end
120
+
121
+ # Convert boolean to int
122
+ def self.btoi(b)
123
+ if b then 1 else 0 end
124
+ end
126
125
  end
127
126
  end
@@ -33,7 +33,7 @@ module Iglu
33
33
 
34
34
  # Check if JSON is valid (throw exception otherwise)
35
35
  def validate(resolver)
36
- @valid = resolver.validate(to_json)
36
+ @valid = resolver.validate(self.to_json)
37
37
  @valid
38
38
  end
39
39
 
@@ -10,5 +10,5 @@
10
10
  # See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
11
11
 
12
12
  module Iglu
13
- CLIENT_VERSION = '0.1.0.beta'
13
+ CLIENT_VERSION = '0.1.0.beta.2'
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iglu-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta
4
+ version: 0.1.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Parkhomenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-25 00:00:00.000000000 Z
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -31,6 +31,9 @@ dependencies:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.7.0
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 2.7.0
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,11 +41,17 @@ dependencies:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
43
  version: 2.7.0
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.7.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rspec
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.14'
54
+ - - ">="
46
55
  - !ruby/object:Gem::Version
47
56
  version: 2.14.1
48
57
  type: :development
@@ -50,6 +59,9 @@ dependencies:
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
61
  - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '2.14'
64
+ - - ">="
53
65
  - !ruby/object:Gem::Version
54
66
  version: 2.14.1
55
67
  description: Iglu Client is used to resolve JSON Schemas and validate self-describing