Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.1] - 2021-03-02

### Fixed

- Fixed a `NameError` that was thrown when `Patch::Sdg` was called. Specs have been added to ensure this does not happen again.

## [1.5.0] - 2021-03-01

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
patch_ruby (1.4.0)
patch_ruby (1.5.1)
json (~> 2.1, >= 2.1.0)
typhoeus (~> 1.0, >= 1.0.1)

Expand Down
1 change: 1 addition & 0 deletions lib/patch_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
require 'patch_ruby/models/project'
require 'patch_ruby/models/project_list_response'
require 'patch_ruby/models/project_response'
require 'patch_ruby/models/sdg'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model wasn't required, which caused the error.

require 'patch_ruby/models/standard'

# APIs
Expand Down
2 changes: 1 addition & 1 deletion lib/patch_ruby/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
=end

module Patch
VERSION = '1.5.0'
VERSION = '1.5.1'
end
18 changes: 18 additions & 0 deletions spec/patch_ruby_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe Patch do
context 'Models' do
it 'defines all models' do
constants.each do |constant|
expect { Patch.const_get(constant) }.not_to raise_error
end
end
end

def constants
# Given a file path return the constant of that path, for example:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All recommendations on how to achieve this in a smoother way is welcome. I'm sure there's a more straightforward approach to this that I can't think of right now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks pretty OK for now! Let's do a survey of other SDKs a bit later for best practices?

# 'lib/patch_ruby/models/project_response.rb' -> ProjectResponse
Dir.glob("lib/patch_ruby/models/*.rb").map do |file|
parsed_filename = file.split('/').last.split('.').first
constant = parsed_filename.split('_').map(&:capitalize).join('')
end
end
end