apipie-dsl 2.2.7 → 2.2.8

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
  SHA256:
3
- metadata.gz: 751af0c065bd8a384dc9c710dc53da2275015666c7076c3a13eb4c89f47860d3
4
- data.tar.gz: fab345212215d732917c7c16375088d850933f147f4c49d757732dea8576ad0f
3
+ metadata.gz: 4621977ecc3d0783dc21032bb8790fd1d2a1c7cc81635f91932813d1ce2a9148
4
+ data.tar.gz: bb80ac4c8d298274fadf8edaf25d1ca77e98cb094d7d81f6e7fcb78db85318b5
5
5
  SHA512:
6
- metadata.gz: 490ad088339064f5495b3c1271ec549446444b17b4c0b7fc71b16ad1afc5b458b6d22525e2e2158a73f41aab346c4201333410f95c509bad971dcda5f17aa694
7
- data.tar.gz: 9e6285a8b353bdc8e87bf7485955bd6ce250734bd2140272329518080da2ebe316d9fc7c7f70b146d04263d601f8eb0b017b3cc8eda4e3f44dee730279c61954
6
+ metadata.gz: 1d4c14f184ca3595052c95dfab5f2df1cd52bebddfc466dbe47eb43a13eb1d19ba680db6455d61c0d3ba3e776a3b7ee3fb3a78d4f0eb296c56da5931277cc2ff
7
+ data.tar.gz: eb47d1566806421e25164d76ac6e3afb20d55733e4ae94bc358c5e24cf411b92f10829e9a960823a1f9a192d07aa83b23d675d3970be9ee5e20b98a6e3a1cef0
@@ -81,6 +81,9 @@ module ApipieDslHelper
81
81
  # Try to convert to a constant in case of LazyValidator usage
82
82
  # Will raise const missing exception in case of wrong usage of the method
83
83
  if obj.is_a?(String)
84
+ ref = ApipieDSL.refs[version][ApipieDSL.get_class_name(obj)]
85
+ return "<a href='#{ref.doc_url(ref.sections.first)}#{link_extension}'>#{obj}</a>" if ref
86
+
84
87
  obj = ApipieDSL.configuration.rails? ? obj.constantize : obj.split('::').reduce(::Module, :const_get)
85
88
  end
86
89
  return obj.to_s unless [::Module, ::Class, ::Array].include?(obj.class)
@@ -12,7 +12,7 @@ module ApipieDSL
12
12
  @properties = []
13
13
  @version = version || ApipieDSL.configuration.default_version
14
14
  @parent = ApipieDSL.get_class_description(ApipieDSL.superclass_for(klass), version)
15
- @refs = []
15
+ @refs = [@name]
16
16
  @sections = []
17
17
  @show = true
18
18
  update_from_dsl_data(dsl_data) if dsl_data
@@ -20,17 +20,22 @@ module ApipieDSL
20
20
 
21
21
  def update_from_dsl_data(dsl_data)
22
22
  @name = dsl_data[:class_name] if dsl_data[:class_name]
23
- @full_description = ApipieDSL.markup_to_html(dsl_data[:description])
24
- @short_description = dsl_data[:short_description]
23
+ @full_description = ApipieDSL.markup_to_html(dsl_data[:description]) if dsl_data[:description]
24
+ @short_description = dsl_data[:short_description] || @short_description
25
25
  @tag_list = dsl_data[:tag_list]
26
- @metadata = dsl_data[:meta]
26
+ if dsl_data[:meta]&.is_a?(Hash)
27
+ @metadata&.merge!(dsl_data[:meta])
28
+ elsif dsl_data[:meta]
29
+ @metadata = dsl_data[:meta]
30
+ end
27
31
  @deprecated = dsl_data[:deprecated] || false
28
32
  @show = dsl_data[:show] || @show
29
- @properties = (dsl_data[:properties] || []).map do |args|
30
- ApipieDSL::MethodDescription.from_dsl_data(self, args)
33
+ prop_names = @properties.map(&:name)
34
+ (dsl_data[:properties] || []).each do |args|
35
+ @properties << ApipieDSL::MethodDescription.from_dsl_data(self, args) unless prop_names.include?(args.first.to_s)
31
36
  end
32
- @refs = dsl_data[:refs] || [@name]
33
- @sections = dsl_data[:sections] || @sections
37
+ @refs = (@refs + dsl_data[:refs]).uniq if dsl_data[:refs]
38
+ @sections = (@sections + dsl_data[:sections]).uniq if dsl_data[:sections]
34
39
  return unless dsl_data[:app_info]
35
40
 
36
41
  ApipieDSL.configuration.app_info[version] = dsl_data[:app_info]
@@ -65,10 +70,6 @@ module ApipieDSL
65
70
  @methods.values
66
71
  end
67
72
 
68
- def property_descriptions
69
- @properties
70
- end
71
-
72
73
  def doc_url(section = nil)
73
74
  crumbs = []
74
75
  crumbs << version if ApipieDSL.configuration.version_in_url
@@ -347,7 +347,7 @@ module ApipieDSL
347
347
  include ApipieDSL::Klass
348
348
  include ApipieDSL::Method
349
349
 
350
- attr_reader :class_scope
350
+ attr_accessor :class_scope
351
351
 
352
352
  def initialize(class_scope)
353
353
  @class_scope = class_scope
@@ -385,7 +385,7 @@ module ApipieDSL
385
385
  end
386
386
 
387
387
  def self.extension_data
388
- @extension_data ||= []
388
+ @extension_data ||= { methods: [] }
389
389
  end
390
390
 
391
391
  # rubocop:disable Metrics/AbcSize
@@ -553,16 +553,19 @@ module ApipieDSL
553
553
 
554
554
  delegatee = Delegatee.instance_for(self).with(&block)
555
555
  delegatee.dsl_data[:update_only] = true
556
- # Don't eval the block, since it will be evaluated after method is defined
556
+
557
557
  return if context == :method
558
558
 
559
- # Currently method extensions are supported only
559
+ # Save instance to reuse when actual scope is set
560
+ Delegatee.extension_data[:class] = delegatee
560
561
  Delegatee.instance_reset
561
562
  end
562
563
 
563
564
  def prepended(klass)
564
565
  super
565
- Delegatee.extension_data.each do |method_name, dsl_data|
566
+ Delegatee.extension_data[:class]&.class_scope = klass
567
+ Delegatee.extension_data[:class]&.eval_dsl_for(:class)
568
+ Delegatee.extension_data[:methods].each do |method_name, dsl_data|
566
569
  class_scope = klass
567
570
  if dsl_data[:update_only]
568
571
  class_name = ApipieDSL.get_class_name(class_scope)
@@ -592,7 +595,7 @@ module ApipieDSL
592
595
  return if Delegatee.instance.nil?
593
596
 
594
597
  dsl_data = Delegatee.instance.eval_dsl_for(:method)
595
- Delegatee.extension_data << [method_name, dsl_data]
598
+ Delegatee.extension_data[:methods] << [method_name, dsl_data]
596
599
  ensure
597
600
  Delegatee.instance_reset
598
601
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ApipieDSL
4
- VERSION = '2.2.7'
4
+ VERSION = '2.2.8'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.7
4
+ version: 2.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleh Fedorenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-26 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler