jimmy 0.5.0 → 0.5.1

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: a57c984eab30453b66049bd8720bfcb7a18ff973
4
- data.tar.gz: f157a9c9e255a546e79119a2cb1a5d0c9a353b17
3
+ metadata.gz: a62e54e6b0658797c8fb7c6ca16d2a59f68b53ef
4
+ data.tar.gz: bdb3b25cfb2ae06ad970e9f577c64bab1400ef4e
5
5
  SHA512:
6
- metadata.gz: 9db24fb7aacca4036027e564cdbe6a0dbbb8e65743958d4e7d41e0aecd85d4d8d5cabb13ecdf8f7e5e40b89ee8154567de3266a074aa1e2873be215b7b9cd124
7
- data.tar.gz: 0a863b9d1e2b3c1483f6b7ccf57c29518d89eb66e59da556fd566e92f7e0690af6fd3a0af33eee38beda3bcbbbe03c9316a944b94c7fc94d76aebd05dfd4a559
6
+ metadata.gz: 7dc6cf3628f02163eaaa2a946ef8daaecd20afedc422d1635499b32b2982563b89a07963a4325be5656c54c9183740c45aab39196f1d6370ab4dd18743af9de2
7
+ data.tar.gz: b6c6880288081fdc4a1739ff389739bd8d6e21853caeb3598a314cbd3bb1d0ebdf3383e23b9a30cd39d9df8c9189ad579e886da45a48893cf054c511b14be641
data/lib/jimmy/domain.rb CHANGED
@@ -11,7 +11,7 @@ module Jimmy
11
11
  transform_keys: nil
12
12
  }
13
13
 
14
- attr_reader :root, :types, :partials, :options
14
+ attr_reader :root, :types, :partials, :options, :schemas
15
15
 
16
16
  def initialize(root, **options)
17
17
  @root = URI(root)
@@ -1,10 +1,12 @@
1
+ require_relative './transform_keys'
2
+
1
3
  module Jimmy
2
4
  class Reference
3
5
  include SchemaCreation::MetadataMethods
4
6
  attr_reader :uri, :data
5
7
 
6
- def initialize(uri, nullable = false, *args, **opts, &block)
7
- @uri = uri
8
+ def initialize(uri, domain, nullable = false, *args, **opts, &block)
9
+ @uri = TransformKeys.transformer.transform_ref(uri, domain.options[:transform_keys])
8
10
  @nullable = nullable
9
11
  @data = {}
10
12
  args.each { |arg| __send__ arg }
@@ -48,7 +48,7 @@ module Jimmy
48
48
 
49
49
  def ref(*args, uri, &block)
50
50
  handler = SchemaCreation.handlers[self.class]
51
- instance_exec(Reference.new(uri, args.delete(:nullable), &block), *args, &handler) if handler
51
+ instance_exec(Reference.new(uri, domain, args.delete(:nullable), &block), *args, &handler) if handler
52
52
  end
53
53
  end
54
54
 
@@ -94,7 +94,7 @@ module Jimmy
94
94
  domain.autoload_type method
95
95
 
96
96
  if domain.types.key? method
97
- return instance_exec TypeReference.new(method, args.include?(:nullable)), *args, &SchemaCreation.handlers[self.class]
97
+ return instance_exec TypeReference.new(method, domain, args.include?(:nullable)), *args, &SchemaCreation.handlers[self.class]
98
98
  end
99
99
 
100
100
  if kind_of_array?(method)
@@ -22,10 +22,18 @@ module Jimmy
22
22
  sym
23
23
  end
24
24
  end
25
+
26
+ def transform_ref(str, method)
27
+ if method
28
+ str.sub(/#(.+)/) { '#' << $1.split('/').map { |part| __send__ method, part }.join('/') }
29
+ else
30
+ str
31
+ end
32
+ end
25
33
  end
26
34
 
27
35
  def self.transformer
28
36
  @transformer ||= Transformer.new
29
37
  end
30
38
  end
31
- end
39
+ end
data/lib/jimmy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jimmy
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jimmy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil E. Pearson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-07 00:00:00.000000000 Z
11
+ date: 2016-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema