openapi-ruby 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fd91990e73c6bcd5fae00558bb63afd1c4999de976b16d542aa495ddf2ad6a4
4
- data.tar.gz: 19391cec8179b314284b51afa6adc977849f75aa431a7ec54df70f29b9877e45
3
+ metadata.gz: 420f08f5a6cc99f77fc5ecd23c7e280a52b1bc930996ca637c2f61828822cc54
4
+ data.tar.gz: 831c0a52dd27d6ed1c60986b82d0e71ca271290ea5c22b40653698fd969895ae
5
5
  SHA512:
6
- metadata.gz: e9384c41d176a5cdf12a8164a148e8ff0a853aa15c73b06efb4f32bc96d40aaa18d4667c93ab6db863bf12de8eac783308a232a99dad66f755b3e1141ad456e5
7
- data.tar.gz: c6d8b92d8473ac2f2582632c93d1f5d72fc41645b3c34a0b88192530d0bd1808aef836ac99b8864a92a88cb0587a89f1b0cf867811190e2758fdb86900e25552
6
+ metadata.gz: 5e0c13aaa9b0d389f067224265cb11a358679228fafd7e864cefb4cb4a037b3b80b823b4d30050e7b667eb7849c509611490403e042e4f072b78a3af88526e60
7
+ data.tar.gz: d075ef796755e29033fee117fff4cb6a4177b30749afbd6a57993e9a47273d111cce9f7c672fb87c841af3107e150120dac59655c32652da19108ca60e017821
@@ -46,12 +46,12 @@ module OpenapiRuby
46
46
  end
47
47
 
48
48
  def to_json(*_args)
49
- JSON.pretty_generate(@data)
49
+ JSON.pretty_generate(to_h)
50
50
  end
51
51
 
52
52
  def to_yaml
53
53
  require "yaml"
54
- @data.to_yaml
54
+ to_h.to_yaml
55
55
  end
56
56
 
57
57
  def valid?
@@ -67,14 +67,40 @@ module OpenapiRuby
67
67
  # so the two test frameworks don't both register Rails lazy
68
68
  # hooks in the same process — only the DSL needs to be live for
69
69
  # schema generation.
70
+ #
71
+ # Each glob runs with its own framework's directory at the head
72
+ # of $LOAD_PATH so the typical `require "openapi_helper"` /
73
+ # `require "rails_helper"` / `require "test_helper"` resolves
74
+ # to the right file. Without this, both spec/ and test/ getting
75
+ # unshifted in one block leads to whichever was unshifted last
76
+ # winning every lookup — and the wrong helper getting loaded
77
+ # for the other side's files.
70
78
  def hybrid_script(pattern)
79
+ globs = pattern.split(",").map(&:strip)
80
+ spec_globs = globs.grep(%r{\bspec/})
81
+ test_globs = globs.grep(%r{\btest/})
82
+ other_globs = globs - spec_globs - test_globs
83
+
71
84
  <<~RUBY
72
85
  require "rspec/core"
73
86
  require "openapi_ruby/rspec"
74
87
  require "openapi_ruby/minitest"
75
- $LOAD_PATH.unshift(File.expand_path("spec")) unless $LOAD_PATH.include?(File.expand_path("spec"))
76
- $LOAD_PATH.unshift(File.expand_path("test")) unless $LOAD_PATH.include?(File.expand_path("test"))
77
- #{glob_loads(pattern)}
88
+
89
+ load_with_path = lambda do |dir, glob|
90
+ path = File.expand_path(dir)
91
+ added = !$LOAD_PATH.include?(path)
92
+ $LOAD_PATH.unshift(path) if added
93
+ begin
94
+ Dir.glob(glob).sort.each { |f| require File.expand_path(f) }
95
+ ensure
96
+ $LOAD_PATH.delete(path) if added
97
+ end
98
+ end
99
+
100
+ #{spec_globs.map { |g| "load_with_path.call(\"spec\", #{g.inspect})" }.join("\n ")}
101
+ #{test_globs.map { |g| "load_with_path.call(\"test\", #{g.inspect})" }.join("\n ")}
102
+ #{other_globs.map { |g| %[Dir.glob(#{g.inspect}).sort.each { |f| require File.expand_path(f) }] }.join("\n ")}
103
+
78
104
  OpenapiRuby::Generator::SchemaWriter.generate_all!
79
105
  RUBY
80
106
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiRuby
4
- VERSION = "3.5.0"
4
+ VERSION = "3.5.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Hartvig