Skip to content

Commit cf8df19

Browse files
committed
Bump version to 1.7.0: Ruby & Rails version requirement declared
1 parent 9d35394 commit cf8df19

15 files changed

+29
-188
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
coverage
1313

1414
.idea/*
15+
Gemfile.lock

CHANGELOG.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@
22

33
## [Unreleased]
44

5+
## [1.7.0] - 2018/12/17 - [view diff](https://github.com/zhandao/zero-rails_openapi/compare/v1.6.1...v1.7.0)
6+
7+
### Added
8+
9+
1. Declare Ruby & Rails version requirement in Gemspec
10+
11+
### Fixed
12+
13+
1. `match?` => `'string'[matcher].present?`, for compatibility with ruby < 2.4
14+
515
### Changed
616

7-
1. `base_doc_class: ApiDoc` => `base_doc_classes: [ApiDoc]`
17+
1. Config option `base_doc_class: ApiDoc` changed to `base_doc_classes: [ApiDoc]`
818

919
## [1.6.1] - 2018/8/21 - [view diff](https://github.com/zhandao/zero-rails_openapi/compare/v1.6.0...v1.6.1)
1020

Gemfile.lock

-158
This file was deleted.

README.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -805,13 +805,7 @@
805805

806806
- **You wrote document of the current API, but not find in the generated json file?**
807807
Check your routing settings.
808-
- **Undefine method `match?`**
809-
Monkey patches for `String` and `Symbol`:
810-
```ruby
811-
class String # Symbol
812-
def match?(pattern); !match(pattern).nil? end
813-
end
814-
```
808+
815809
- **Report error when require `routes.rb`?***
816810
1. Run `rails routes`.
817811
2. Copy the output to a file, for example `config/routes.txt`.

README_zh.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -745,13 +745,7 @@
745745

746746
- **You wrote document of the current API, but not find in the generated json file?**
747747
Check your routing settings.
748-
- **Undefine method `match?`**
749-
Monkey patches for `String` and `Symbol`:
750-
```ruby
751-
class String # Symbol
752-
def match?(pattern); !match(pattern).nil? end
753-
end
754-
```
748+
755749
- **Report error when require `routes.rb`?***
756750
1. Run `rails routes`.
757751
2. Copy the output to a file, for example `config/routes.txt`.

documentation/examples/auto_gen_doc.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ module ClassMethods
1010
def inherited(subclass)
1111
super
1212
subclass.class_eval do
13-
break unless self.name.match?(/sController|sDoc/)
14-
route_base self.name.sub('Doc', '').downcase.gsub('::', '/') if self.name.match?(/sDoc/)
13+
break unless self.name[/sController|sDoc/]
14+
route_base self.name.sub('Doc', '').downcase.gsub('::', '/') if self.name[/sDoc/]
1515
open_api_dry
1616
end
1717
end

lib/oas_objs/param_obj.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def initialize(name, param_type, type, required, schema)
1212
self.processed = {
1313
name: name,
1414
in: param_type,
15-
required: required.to_s.match?(/req/)
15+
required: required.to_s[/req/].present?
1616
}
1717
self.schema = schema.is_a?(CombinedSchema) ? schema : SchemaObj.new(type, schema)
1818
merge! schema

lib/oas_objs/request_body_obj.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class RequestBodyObj < Hash
1111
attr_accessor :processed, :media_types
1212
def initialize(required, desc)
1313
self.media_types = [ ]
14-
self.processed = { required: required.match?('req'), description: desc }
14+
self.processed = { required: required['req'].present?, description: desc }
1515
end
1616

1717
def add_or_fusion(media_type, hash)

lib/oas_objs/schema_obj.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ def processed_type(type = self.type)
4040
elsif t.is_a? Symbol
4141
RefObj.new(:schema, t).process
4242
elsif t.in? %w[ float double int32 int64 ]
43-
{ type: t.match?('int') ? 'integer' : 'number', format: t }
43+
{ type: t['int'] ? 'integer' : 'number', format: t }
4444
elsif t.in? %w[ binary base64 uri ]
4545
{ type: 'string', format: t }
4646
elsif t == 'file' # TODO
4747
{ type: 'string', format: Config.file_format }
4848
elsif t == 'datetime'
4949
{ type: 'string', format: 'date-time' }
50-
elsif t.match?(/\{=>.*\}/)
50+
elsif t[/\{=>.*\}/]
5151
self[:values_type] = t[3..-2]
5252
{ type: 'object' }
5353
else # other string

lib/open_api/dsl.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def api action, summary = '', id: nil, tag: nil, http: http_method = nil, skip:
3838
doc_tag if @doc_info.nil?
3939
# select the routing info (corresponding to the current method) from routing list.
4040
action_path = "#{@route_base ||= controller_path}##{action}"
41-
routes = ctrl_routes_list&.select { |api| api[:action_path].match?(/^#{action_path}$/) }
41+
routes = ctrl_routes_list&.select { |api| api[:action_path][/^#{action_path}$/].present? }
4242
return puts ' ZRO'.red + " Route mapping failed: #{action_path}" if routes.blank?
4343

4444
api = Api.new(action_path, skip: Array(skip), use: Array(use))

lib/open_api/dsl/helpers.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _load_schema_based_on_show_attr(model)
3131
if columns.include?(attr)
3232
index = columns.index(attr)
3333
_type_mapping(model.columns[index])
34-
elsif attr.match?(/_info/)
34+
elsif attr[/_info/]
3535
# TODO: 如何获知关系是 many?因为不能只判断结尾是否 ‘s’
3636
assoc_model = Object.const_get(attr.to_s.split('_').first.singularize.camelize)
3737
{ attr => load_schema(assoc_model) }

lib/open_api/generator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def routes
8585

8686
def routes_list
8787
@routes_list ||= routes.split("\n").drop(1).map do |line|
88-
next unless line.match?('#')
88+
next unless line['#']
8989
infos = line.match(/[A-Z|].*/).to_s.split(' ') # => [GET, /api/v1/examples/:id, api/v1/examples#index]
9090

9191
{

lib/open_api/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module OpenApi
2-
VERSION = '1.6.0'
2+
VERSION = '1.7.0'
33
end

spec/support/api_doc.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def undo_dry
99
def inherited(subclass)
1010
super
1111
subclass.class_eval do
12-
break unless self.name.match?(/sController|sDoc/)
13-
route_base self.name.sub('Doc', '').downcase.gsub('::', '/') if self.name.match?(/sDoc/)
12+
break unless self.name[/sController|sDoc/]
13+
route_base self.name.sub('Doc', '').downcase.gsub('::', '/') if self.name[/sDoc/]
1414
end
1515
end
1616
end

zero-rails_openapi.gemspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
2121
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2222
spec.require_paths = ['lib']
2323

24-
# spec.required_ruby_version = ">= 2.2.2"
24+
spec.required_ruby_version = '>= 2.3.0'
2525

2626
spec.add_development_dependency 'bundler', '~> 1.16.a'
2727
spec.add_development_dependency 'rake', '~> 10.0'
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
3030
spec.add_development_dependency 'pry'
3131

3232
spec.add_runtime_dependency 'colorize'
33-
spec.add_runtime_dependency 'activesupport', '>= 3'
34-
spec.add_runtime_dependency 'rails', '>= 3'
33+
spec.add_runtime_dependency 'activesupport', '>= 4.1'
34+
spec.add_runtime_dependency 'rails', '>= 4.1'
3535

3636
# spec.post_install_message = ""
3737
end

0 commit comments

Comments
 (0)