Skip to content

Commit

Permalink
Merge pull request #12 from civisanalytics/maintenance-feb-2021
Browse files Browse the repository at this point in the history
Maintenance
  • Loading branch information
mikesaelim authored Feb 9, 2021
2 parents 4e4bcae + 4db1257 commit ef8b038
Show file tree
Hide file tree
Showing 75 changed files with 1,784 additions and 1,628 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--color
--warnings
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.5
NewCops: disable
SuggestExtensions: false

Style/Documentation:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.6
3.0.0
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: ruby
cache: bundler
rvm:
- 2.3.8
- 2.4.10
- 2.5.8
- 2.6.6
- 2.7.2
- 3.0.0
before_install:
- gem install bundler
branches:
Expand Down
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.0.0] - 2021-02-09

### Added
- Added Ruby 2.7 and 3.0 to the Travis build matrix

### Changed
- Bumped the Ruby version for development to 3.0.0
- Fixed deprecation warnings around positional and keyword arguments from ruby 2.7.0
- Updated rubocop to v1.9.1, and fixed rubocop violations
- Configured rspec to emit warnings, and fix them
- Re-recorded the spec cassettes
- Fixed broken links in the README

### Removed
- Removed Ruby 2.3 and 2.4 from the Travis build matrix

## [1.3.0] - 2020-04-20

### Changed
Expand Down Expand Up @@ -34,6 +50,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

* Initial Release

[Unreleased]: https://github.com/civisanalytics/mistral_client/compare/v1.2.0...HEAD
[Unreleased]: https://github.com/civisanalytics/mistral_client/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/civisanalytics/mistral_client/compare/v1.3.0...v2.0.0
[1.3.0]: https://github.com/civisanalytics/mistral_client/compare/v1.2.1...v1.3.0
[1.2.1]: https://github.com/civisanalytics/mistral_client/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/civisanalytics/mistral_client/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/civisanalytics/mistral_client/compare/v1.0.0...v1.1.0
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# MistralClient

[![Build Status](https://travis-ci.org/civisanalytics/mistral_client.svg?branch=master)](https://travis-ci.org/civisanalytics/mistral_client)
[![Build Status](https://travis-ci.com/civisanalytics/mistral_client.svg?branch=master)](https://travis-ci.com/civisanalytics/mistral_client)
[![Gem Version](https://badge.fury.io/rb/mistral_client.svg)](http://badge.fury.io/rb/mistral_client)
[![Dependency Status](https://gemnasium.com/civisanalytics/mistral_client.svg)](https://gemnasium.com/civisanalytics/mistral_client)

MistralClient provides a Ruby interface to a limited subset of
the [Mistral] [API].

[Mistral]: https://wiki.openstack.org/wiki/Mistral
[API]: https://docs.openstack.org/mistral/latest/api/v2.html
[Mistral]: https://docs.openstack.org/mistral/latest/
[API]: https://docs.openstack.org/mistral/latest/user/rest_api_v2.html

## Installation

Expand Down
1 change: 1 addition & 0 deletions lib/mistral_client/action_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ActionExecution < Base
include MistralClient::Mixins::MistralObject

def initialize(server, id: nil)
super()
@server = server
@path = 'action_executions'
@id = id
Expand Down
12 changes: 7 additions & 5 deletions lib/mistral_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ def self.resources
}
end

def method_missing(name, *args, &block)
def method_missing(name, *args, **kwargs, &block)
if self.class.resources.keys.include?(name)
self.class.resources[name].new(self, *args)
if kwargs.nil? || kwargs.empty?
self.class.resources[name].new(self, *args)
else
self.class.resources[name].new(self, *args, **kwargs)
end
else
super
end
Expand Down Expand Up @@ -68,9 +72,7 @@ def post_or_put(verb, path, body, json)

def check_for_error(resp)
return if resp.code >= 200 && resp.code < 300
if resp.code == 404
raise MissingObjectError, JSON.parse(resp.body)['faultstring']
end
raise MissingObjectError, JSON.parse(resp.body)['faultstring'] if resp.code == 404

raise MistralResponseError.new(resp),
"Could not perform the requested operation:\n#{resp.body}"
Expand Down
7 changes: 3 additions & 4 deletions lib/mistral_client/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class Environment < Base
include MistralClient::Mixins::Definable

def initialize(server, definition = nil, name: nil)
super()
@server = server
@definition = parse_definition(definition) if definition
@definition = definition ? parse_definition(definition) : nil
@name = name
if @name
reload
Expand Down Expand Up @@ -38,9 +39,7 @@ def create_environment
end

def massage_definition(definition)
if definition['variables'].is_a? Hash
definition['variables'] = definition['variables'].to_json
end
definition['variables'] = definition['variables'].to_json if definition['variables'].is_a? Hash
definition
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/mistral_client/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ module MistralClient
class MistralError < StandardError; end

class ConfigurationError < MistralError; end

class MissingObjectError < MistralError; end

class MistralResponseError < MistralError
attr_reader :response

Expand Down
1 change: 1 addition & 0 deletions lib/mistral_client/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Execution < Base
# rubocop:disable Metrics/ParameterLists
def initialize(server, workflow_id: nil, env: nil, task_name: nil,
id: nil, input: nil)
super()
set_attributes(server, workflow_id, env, task_name, id, input)
if @id
reload
Expand Down
1 change: 1 addition & 0 deletions lib/mistral_client/health.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Health < Base
PATH = ''.freeze

def initialize(server)
super()
@server = server
end

Expand Down
4 changes: 1 addition & 3 deletions lib/mistral_client/mixins/definable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module Mixins
module Definable
# rubocop:disable Metrics/MethodLength
def parse_definition(definition)
if definition.is_a?(Hash) || definition.is_a?(Array)
return YAML.dump(definition)
end
return YAML.dump(definition) if definition.is_a?(Hash) || definition.is_a?(Array)

definition = File.read(definition) if File.exist?(definition)
# Called outside the if/else to validate the YAML.
Expand Down
8 changes: 5 additions & 3 deletions lib/mistral_client/mixins/mistral_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def list(params = {})
end

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/PerceivedComplexity
def ivars_from_response(resp)
klass = self.class
@id = resp['id']
Expand All @@ -38,15 +40,15 @@ def ivars_from_response(resp)
instance_variable_set("@#{var}", resp[var]) if resp.key? var
end
klass::DATE_FIELDS.each do |var|
if resp[var]
instance_variable_set("@#{var}", DateTime.parse(resp[var]))
end
instance_variable_set("@#{var}", DateTime.parse(resp[var])) if resp[var]
end
klass::JSON_FIELDS.each do |var|
instance_variable_set("@#{var}", JSON.parse(resp[var])) if resp[var]
end
end
# rubocop:enable Metrics/PerceivedComplexity
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/AbcSize
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/mistral_client/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Task < Base
include MistralClient::Mixins::MistralObject

def initialize(server, id: nil)
super()
@server = server
@path = 'tasks'
@id = id
Expand Down
2 changes: 1 addition & 1 deletion lib/mistral_client/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module MistralClient
VERSION = '1.3.0'.freeze
VERSION = '2.0.0'.freeze
end
1 change: 1 addition & 0 deletions lib/mistral_client/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Workflow < Base
include MistralClient::Mixins::Deletable

def initialize(server, definition = nil, id: nil, name: nil)
super()
@server = server
if definition
@definition = parse_definition(definition)
Expand Down
8 changes: 4 additions & 4 deletions mistral_client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Gem::Specification.new do |spec|

spec.summary = 'Ruby client for Mistral.'
spec.description = "A Ruby client for OpenStack's Mistral " \
'<https://wiki.openstack.org/wiki/Mistral>.'
'<https://docs.openstack.org/mistral/latest/>.'
spec.homepage = 'https://github.com/civisanalytics/mistral_client'
spec.license = 'BSD 3-Clause'
spec.license = 'BSD-3-Clause'

spec.required_ruby_version = '~> 2.3'
spec.required_ruby_version = ['>= 2.5', '< 3.1']
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
Expand All @@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'pry', '~> 0.13.1'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.9'
spec.add_development_dependency 'rubocop', '~> 0.81.0'
spec.add_development_dependency 'rubocop', '~> 1.9.1'
spec.add_development_dependency 'vcr', '~> 5.1'
spec.add_development_dependency 'webmock', '~> 3.8'
end
Loading

0 comments on commit ef8b038

Please sign in to comment.