apipie-dsl 2.2.10 → 2.5.0

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: 990ebec629f1450a927333b32acec610e62378a52dd4d04247de392fa15376ad
4
- data.tar.gz: 15a19b903fa3a51096eda59a022ffcfaaaf1bbe82d9253a25b7696a6c04321bc
3
+ metadata.gz: a8d420cf5c758a736b1f45f9c12e81d7bb1340f64159a7e2b9dfe3929a6a8bfc
4
+ data.tar.gz: d14c1615c171f70f43715851c898f8e9b5244a7d646ab711a9f57bbc1343f028
5
5
  SHA512:
6
- metadata.gz: 8b0a2d9ea7df944cb6b1585db1bc18bc98220ffab60e612e832e9eddbd0e19668067da1b950b342b906a36e922c4f539d35ccf4a9d70977593a5931195d16e94
7
- data.tar.gz: ab9e8070fed5ce6cb24c5da93ec3c4b297cb792fa704b5e3fcc2f74c40927deaf608e0401de6dc5eef46fc784e9a89300b9317768398a44f78805c2ccb766333
6
+ metadata.gz: 302bbb70404e1c46c523f2e5c6ad089a1b4d91ac875ef51a93dda65a61f62e41517247a14e666d4df0ae49e4dd1ac12422812d0d00b7d04b64afe390f4bb94af
7
+ data.tar.gz: f2de5cd7638eb4cc34d494bd3056b4e1f8b298c17e43cd4b6d1040e2a501482c2aa74eddbf840ffbc37c660a48775fcdccb096909cbddea565c1b151aff8eff0
@@ -49,11 +49,11 @@ module ApipieDslHelper
49
49
  def apipie_erb_wrap(content, mode: :loud, open_trim: false, close_trim: false)
50
50
  case mode
51
51
  when :loud
52
- '<%= ' + content + " #{close_trim ? '-' : ''}%>"
52
+ "<%= #{content} #{close_trim ? '-' : ''}%>"
53
53
  when :comment
54
- '<%# ' + content + " #{close_trim ? '-' : ''}%>"
54
+ "<%# #{content} #{close_trim ? '-' : ''}%>"
55
55
  else
56
- "<%#{open_trim ? '- ' : ' '}" + content + " #{close_trim ? '-' : ''}%>"
56
+ "<%#{open_trim ? '-' : ''} #{content} #{close_trim ? '-' : ''}%>"
57
57
  end
58
58
  end
59
59
 
@@ -65,6 +65,8 @@ module ApipieDslHelper
65
65
  "\"\""
66
66
  when Symbol
67
67
  ":#{default}"
68
+ when String
69
+ "\"#{default}\""
68
70
  else
69
71
  default
70
72
  end
@@ -142,9 +144,10 @@ module ApipieDslHelper
142
144
  end
143
145
 
144
146
  def current_version(classes)
145
- if classes.is_a?(Array)
147
+ case classes
148
+ when Array
146
149
  classes.first[:version]
147
- elsif classes.is_a?(Hash)
150
+ when Hash
148
151
  classes.values.first[:version]
149
152
  else
150
153
  raise ApipieDSL::Error, "Cannot find current version for #{classes}"
@@ -9,7 +9,8 @@
9
9
  <td>
10
10
  <strong><%= param[:full_name] %> </strong><br>
11
11
  <small>
12
- <%= t("apipie_dsl.#{param[:type]}") %>
12
+ <%= t("apipie_dsl.#{param[:type]}") %><br>
13
+ <%= param[:type] == 'keyword' ? 'Optional' : '' %>
13
14
  </small>
14
15
  </td>
15
16
  <td>
@@ -14,7 +14,7 @@
14
14
 
15
15
  <h1 class='page-header'><%= t('apipie_dsl.classes') %></h1>
16
16
 
17
- <% @doc[:classes].each_value do |klass| %>
17
+ <% @doc[:classes].sort_by { |id, c| c[:name] }.each do |id, klass| %>
18
18
  <% next unless klass[:show] && in_section?(@section, klass[:id]) %>
19
19
  <h2>
20
20
  <a href='<%= klass[:doc_url] %><%= @doc[:link_extension] %>'>
@@ -1,4 +1,4 @@
1
- <% @doc[:classes].sort_by(&:first).each do |key, klass| %>
1
+ <% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
2
2
  <% next unless klass[:show] %>
3
3
  <h4><a href='#<%= key %>'><%= klass[:name] %></a></h4>
4
4
  <ul>
@@ -14,7 +14,7 @@
14
14
  </ul>
15
15
  <% end %>
16
16
 
17
- <% @doc[:classes].sort_by(&:first).each do |key, klass| %>
17
+ <% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
18
18
  <% next unless klass[:show] %>
19
19
  <hr/>
20
20
  <div>
@@ -1,4 +1,4 @@
1
- <% @doc[:classes].sort_by(&:first).each do |key, klass| %>
1
+ <% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
2
2
  <% next unless klass[:show] %>
3
3
  <h4><a href='#<%= key %>'><%= klass[:name] %></a></h4>
4
4
  <ul>
@@ -18,7 +18,7 @@
18
18
 
19
19
  <hr>
20
20
 
21
- <% @doc[:classes].sort_by(&:first).each do |key, klass| %>
21
+ <% @doc[:classes].sort_by { |id, c| c[:name] }.each do |key, klass| %>
22
22
  <% next unless klass[:show] %>
23
23
  <ul class='breadcrumb' id='<%= key %>'>
24
24
  <li><a href='#'><%= @doc[:name] %></a><span class='divider'>/</span></li>
@@ -6,7 +6,7 @@ module ApipieDSL
6
6
  require 'apipie_dsl/static_dispatcher'
7
7
 
8
8
  class Engine < Rails::Engine
9
- initializer 'static assets', :before => :build_middleware_stack do |app|
9
+ initializer 'static assets', before: :build_middleware_stack do |app|
10
10
  app.middleware.use ::ApipieDSL::StaticDispatcher, "#{root}/app/public"
11
11
  end
12
12
  end
@@ -23,7 +23,7 @@ module ApipieDSL
23
23
  @full_description = ApipieDSL.markup_to_html(dsl_data[:description]) if dsl_data[:description]
24
24
  @short_description = dsl_data[:short_description] || @short_description
25
25
  @tag_list = dsl_data[:tag_list]
26
- if dsl_data[:meta]&.is_a?(Hash)
26
+ if dsl_data[:meta].is_a?(Hash)
27
27
  @metadata&.merge!(dsl_data[:meta])
28
28
  elsif dsl_data[:meta]
29
29
  @metadata = dsl_data[:meta]
@@ -98,8 +98,8 @@ module ApipieDSL
98
98
  full_description: ApipieDSL.translate(@full_description, lang),
99
99
  version: version,
100
100
  metadata: @metadata,
101
- properties: @properties.map { |prop_desc| prop_desc.docs(section, lang) },
102
- methods: methods,
101
+ properties: @properties.map { |prop_desc| prop_desc.docs(section, lang) }.sort_by { |p| p[:name] },
102
+ methods: methods.sort_by { |m| m[:name] },
103
103
  deprecated: @deprecated,
104
104
  show: @show
105
105
  }
@@ -202,9 +202,10 @@ module ApipieDSL
202
202
  options[:desc] = desc_or_options
203
203
  end
204
204
 
205
- if retobj_or_options.is_a?(Hash)
205
+ case retobj_or_options
206
+ when Hash
206
207
  options.merge!(retobj_or_options)
207
- elsif retobj_or_options.is_a?(Symbol)
208
+ when Symbol
208
209
  options[:param_group] = retobj_or_options
209
210
  else
210
211
  options[:object_of] ||= retobj_or_options
@@ -388,7 +389,6 @@ module ApipieDSL
388
389
  @extension_data ||= { methods: [] }
389
390
  end
390
391
 
391
- # rubocop:disable Metrics/AbcSize
392
392
  def self.define_validators(class_scope, method_desc)
393
393
  return if method_desc.nil? || ![true, :implicitly, :explicitly].include?(ApipieDSL.configuration.validate)
394
394
  return unless [true, :implicitly].include?(ApipieDSL.configuration.validate)
@@ -415,7 +415,7 @@ module ApipieDSL
415
415
  def self.update_method_desc(method_desc, dsl_data)
416
416
  method_desc.full_description = dsl_data[:description] || method_desc.full_description
417
417
  method_desc.short_description = dsl_data[:short_description] || method_desc.short_description
418
- if dsl_data[:meta]&.is_a?(Hash)
418
+ if dsl_data[:meta].is_a?(Hash)
419
419
  method_desc.metadata&.merge!(dsl_data[:meta])
420
420
  else
421
421
  method_desc.metadata = dsl_data[:meta]
@@ -430,7 +430,6 @@ module ApipieDSL
430
430
  end
431
431
  ParameterDescription.merge(method_desc.plain_params, params)
432
432
  end
433
- # rubocop:enable Metrics/AbcSize
434
433
  end
435
434
  end
436
435
 
@@ -456,9 +455,10 @@ module ApipieDSL
456
455
  end
457
456
 
458
457
  def apipie(context = :method, desc_or_options = nil, options = {}, &block)
459
- if desc_or_options.is_a?(Hash)
458
+ case desc_or_options
459
+ when Hash
460
460
  options = options.merge(desc_or_options)
461
- elsif desc_or_options.is_a?(String)
461
+ when String
462
462
  options[:desc] = desc_or_options
463
463
  end
464
464
  options[:name] ||= context.to_s
@@ -509,9 +509,10 @@ module ApipieDSL
509
509
  private
510
510
 
511
511
  def prepare_delegatee(scope, desc_or_options, options, &block)
512
- if desc_or_options.is_a?(Hash)
512
+ case desc_or_options
513
+ when Hash
513
514
  options = options.merge(desc_or_options)
514
- elsif desc_or_options.is_a?(String)
515
+ when String
515
516
  options[:desc] = desc_or_options
516
517
  end
517
518
 
@@ -530,9 +531,10 @@ module ApipieDSL
530
531
  include ApipieDSL::Delegatable
531
532
 
532
533
  def apipie(context = :method, desc_or_options = nil, options = {}, &block)
533
- if desc_or_options.is_a?(Hash)
534
+ case desc_or_options
535
+ when Hash
534
536
  options = options.merge(desc_or_options)
535
- elsif desc_or_options.is_a?(String)
537
+ when String
536
538
  options[:desc] = desc_or_options
537
539
  end
538
540
  options[:name] ||= context.to_s
@@ -2,10 +2,12 @@
2
2
 
3
3
  module ApipieDSL
4
4
  class Error < StandardError; end
5
+
5
6
  class ParamError < Error
6
7
  attr_accessor :param
7
8
 
8
9
  def initialize(param)
10
+ super
9
11
  @param = param
10
12
  end
11
13
  end
@@ -46,6 +48,7 @@ module ApipieDSL
46
48
  attr_accessor :value
47
49
 
48
50
  def initialize(value)
51
+ super
49
52
  @value = value
50
53
  end
51
54
 
@@ -70,6 +73,7 @@ module ApipieDSL
70
73
  attr_reader :value
71
74
 
72
75
  def initialize(value)
76
+ super
73
77
  @value = value
74
78
  end
75
79
 
@@ -33,7 +33,6 @@ module ApipieDSL
33
33
  end
34
34
  end
35
35
 
36
- # rubocop:disable Metrics/ParameterLists
37
36
  def initialize(method_description, name, validator, desc_or_options = nil, options = {}, &block)
38
37
  if desc_or_options.is_a?(Hash)
39
38
  options = options.merge(desc_or_options)
@@ -64,7 +63,6 @@ module ApipieDSL
64
63
  end
65
64
  raise StandardError, "Validator for #{validator} not found." unless @validator
66
65
  end
67
- # rubocop:enable Metrics/ParameterLists
68
66
 
69
67
  def validator
70
68
  return @validator unless @validator.is_a?(ApipieDSL::Validator::Lazy)
@@ -12,8 +12,6 @@ module ApipieDSL
12
12
  @param_group = { scope: @scope }
13
13
  @options = options
14
14
  @return_type = (@options.keys & %i[array_of one_of object_of param_group]).first
15
-
16
- return unless @options[@return_type].is_a?(::Class)
17
15
  end
18
16
 
19
17
  # this routine overrides Param#default_param_group_scope
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApipieDSL
2
4
  module Routing
3
5
  module MapperExtensions
@@ -8,6 +8,9 @@ namespace :apipie_dsl do
8
8
  task :cache, [:include_json] => :environment do |_task, args|
9
9
  args.with_defaults(include_json: false)
10
10
  include_json = %w[1 true].include?(args[:include_json])
11
+ cache_part = ENV['cache_part']
12
+ generate_index = (cache_part == 'classes' ? false : true)
13
+ generate_classes = (cache_part == 'index' ? false : true)
11
14
  time_start = Time.now
12
15
  puts "#{time_start} | Started"
13
16
  ApipieDSL::TasksUtils.with_loaded_documentation do
@@ -24,12 +27,16 @@ namespace :apipie_dsl do
24
27
  ApipieDSL.url_prefix = "../../#{subdir}"
25
28
  doc = ApipieDSL.docs(version, nil, nil, lang, section)
26
29
  doc[:docs][:link_extension] = "#{ApipieDSL::TasksUtils.lang_ext(lang)}.html"
27
- ApipieDSL::TasksUtils.generate_index_page(file_base_version, doc, include_json, true, lang, section)
28
- ApipieDSL.url_prefix = "../../../#{subdir}"
29
- section_out = "#{file_base_version}/#{section}"
30
- ApipieDSL::TasksUtils.generate_class_pages(version, section_out, doc, include_json, lang, section)
31
- ApipieDSL.url_prefix = "../../../../#{subdir}"
32
- ApipieDSL::TasksUtils.generate_method_pages(version, section_out, doc, include_json, lang, section)
30
+ if generate_index
31
+ ApipieDSL::TasksUtils.generate_index_page(file_base_version, doc, include_json, true, lang, section)
32
+ end
33
+ if generate_classes
34
+ ApipieDSL.url_prefix = "../../../#{subdir}"
35
+ section_out = "#{file_base_version}/#{section}"
36
+ ApipieDSL::TasksUtils.generate_class_pages(version, section_out, doc, include_json, lang, section)
37
+ ApipieDSL.url_prefix = "../../../../#{subdir}"
38
+ ApipieDSL::TasksUtils.generate_method_pages(version, section_out, doc, include_json, lang, section)
39
+ end
33
40
  end
34
41
  ApipieDSL.url_prefix = "../../#{subdir}"
35
42
  doc = ApipieDSL.docs(version, nil, nil, lang)
@@ -61,12 +68,16 @@ namespace :apipie_dsl do
61
68
  ApipieDSL.url_prefix = "../../#{subdir}"
62
69
  doc = ApipieDSL.docs(version, nil, nil, lang, section)
63
70
  doc[:docs][:link_extension] = "#{ApipieDSL::TasksUtils.lang_ext(lang)}.html"
64
- ApipieDSL::TasksUtils.generate_index_page(file_base_version, doc, include_json, true, lang, section)
65
- ApipieDSL.url_prefix = "../../../#{subdir}"
66
- section_out = "#{file_base_version}/#{section}"
67
- ApipieDSL::TasksUtils.generate_class_pages(version, section_out, doc, include_json, lang, section)
68
- ApipieDSL.url_prefix = "../../../../#{subdir}"
69
- ApipieDSL::TasksUtils.generate_method_pages(version, section_out, doc, include_json, lang, section)
71
+ if generate_index
72
+ ApipieDSL::TasksUtils.generate_index_page(file_base_version, doc, include_json, true, lang, section)
73
+ end
74
+ if generate_classes
75
+ ApipieDSL.url_prefix = "../../../#{subdir}"
76
+ section_out = "#{file_base_version}/#{section}"
77
+ ApipieDSL::TasksUtils.generate_class_pages(version, section_out, doc, include_json, lang, section)
78
+ ApipieDSL.url_prefix = "../../../../#{subdir}"
79
+ ApipieDSL::TasksUtils.generate_method_pages(version, section_out, doc, include_json, lang, section)
80
+ end
70
81
  end
71
82
  ApipieDSL.url_prefix = "../../#{subdir}"
72
83
  doc = ApipieDSL.docs(version, nil, nil, lang)
@@ -21,11 +21,12 @@ module ApipieDSL
21
21
  base_paths.unshift("#{Rails.root}/app/views/apipie_dsl/apipie_dsls") if File.directory?("#{Rails.root}/app/views/apipie_dsl/apipie_dsls")
22
22
  end
23
23
  layouts_paths = [File.expand_path('../../app/views/layouts', __dir__)]
24
- if ApipieDSL.configuration.rails?
25
- layouts_paths.unshift("#{Rails.root}/app/views/layouts") if File.directory?("#{Rails.root}/app/views/layouts/apipie_dsl")
24
+ if ApipieDSL.configuration.rails? && File.directory?("#{Rails.root}/app/views/layouts/apipie_dsl")
25
+ layouts_paths.unshift("#{Rails.root}/app/views/layouts")
26
26
  end
27
27
  paths = ActionView::PathSet.new(base_paths + layouts_paths)
28
- @renderer = ActionView::Base.new(paths, {})
28
+ lookup_context = ActionView::LookupContext.new(paths)
29
+ @renderer = ActionView::Base.with_empty_template_cache.new(lookup_context, {}, nil)
29
30
  @renderer.singleton_class.send(:include, ::ApipieDslHelper)
30
31
  @renderer
31
32
  end
@@ -60,18 +60,7 @@ module ApipieDSL
60
60
  end
61
61
  end
62
62
  end
63
- if RUBY_VERSION < '2.5.0'
64
- class Hash
65
- def transform_keys
66
- result = {}
67
- each do |key, value|
68
- new_key = yield key
69
- result[new_key] = value
70
- end
71
- result
72
- end
73
- end
74
- end
63
+
75
64
  if defined? Rails
76
65
  class Module
77
66
  # https://github.com/rails/rails/pull/35035
@@ -17,6 +17,7 @@ module ApipieDSL
17
17
  BaseValidator.find(@param_description, @argument.constantize, @options, @block)
18
18
  end
19
19
  end
20
+
20
21
  # To create a new validator, inherit from ApipieDSL::Validator::BaseValidator
21
22
  # and implement class method 'build' and instance method 'validate'
22
23
  class BaseValidator
@@ -49,6 +50,7 @@ module ApipieDSL
49
50
  end
50
51
 
51
52
  def self.inherited(subclass)
53
+ super(subclass)
52
54
  @validators ||= []
53
55
  @validators.unshift(subclass)
54
56
  end
@@ -325,9 +327,7 @@ module ApipieDSL
325
327
  return false unless value.is_a?(Hash)
326
328
 
327
329
  @hash_params&.each do |name, param|
328
- if ApipieDSL.configuration.validate_value?
329
- param.validate(value[name]) if value.key?(name)
330
- end
330
+ param.validate(value[name]) if ApipieDSL.configuration.validate_value? && value.key?(name)
331
331
  end
332
332
  true
333
333
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ApipieDSL
4
- VERSION = '2.2.10'
4
+ VERSION = '2.5.0'
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.10
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleh Fedorenko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -198,7 +198,7 @@ homepage: https://github.com/ofedoren/apipie-dsl
198
198
  licenses:
199
199
  - MIT
200
200
  metadata: {}
201
- post_install_message:
201
+ post_install_message:
202
202
  rdoc_options: []
203
203
  require_paths:
204
204
  - lib
@@ -206,7 +206,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
206
  requirements:
207
207
  - - ">="
208
208
  - !ruby/object:Gem::Version
209
- version: 2.3.0
209
+ version: 2.5.0
210
210
  required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  requirements:
212
212
  - - ">="
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  version: '0'
215
215
  requirements: []
216
216
  rubygems_version: 3.1.2
217
- signing_key:
217
+ signing_key:
218
218
  specification_version: 4
219
219
  summary: Ruby DSL documentation tool
220
220
  test_files: