Skip to content

Commit

Permalink
Merge branch 'master' into 5.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Parak committed Sep 27, 2017
2 parents 1ac69b7 + 72ad239 commit 825c810
Show file tree
Hide file tree
Showing 35 changed files with 59 additions and 52 deletions.
17 changes: 3 additions & 14 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require: rubocop-rspec
inherit_from: .rubocop_todo.yml

Metrics/ModuleLength:
Expand Down Expand Up @@ -44,24 +43,14 @@ Style/NilComparison:
Exclude:
- 'spec/occi/core/category_spec.rb'

Style/FileName:
Naming/FileName:
Exclude:
- 'lib/occi/infrastructure-ext.rb'

Style/YodaCondition:
Exclude:
- 'lib/occi/core/helpers/parser_dereferencer.rb'

RSpec/MultipleExpectations:
Max: 5

RSpec/MessageSpies:
EnforcedStyle: receive

RSpec/SubjectStub:
Exclude:
- 'spec/**/*'

RSpec/MessageExpectation:
Lint/Void:
Exclude:
- 'spec/**/*'
- '**/*'
5 changes: 5 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ Style/RescueModifier:
Exclude:
- 'lib/occi/core/parsers/json/entity.rb'
- 'lib/occi/core/parsers/text/entity.rb'

Lint/RescueWithoutErrorClass:
Exclude:
- 'lib/occi/core/parsers/json/entity.rb'
- 'lib/occi/core/parsers/text/entity.rb'
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

5.0.2 / 2017-09-27
==================

* Relaxing strict Regexp patterns on attrs
* DOI for releases from ZENODO

5.0.1 / 2017-09-05
==================

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Gemnasium](https://img.shields.io/gemnasium/the-rocci-project/rOCCI-core.svg?style=flat-square)](https://gemnasium.com/the-rocci-project/rOCCI-core)
[![Gem](https://img.shields.io/gem/v/occi-core.svg?style=flat-square)](https://rubygems.org/gems/occi-core)
[![Code Climate](https://img.shields.io/codeclimate/github/the-rocci-project/rOCCI-core.svg?style=flat-square)](https://codeclimate.com/github/the-rocci-project/rOCCI-core)
[![DOI](https://zenodo.org/badge/101084614.svg)](https://zenodo.org/badge/latestdoi/101084614)

## Requirements
### Ruby
Expand Down
5 changes: 3 additions & 2 deletions lib/occi/core/action_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class ActionInstance
include Helpers::ArgumentValidator
include Helpers::InstanceAttributeResetter

attr_accessor :action, :attributes
attr_reader :action
attr_accessor :attributes

ERRORS = [
Occi::Core::Errors::AttributeValidationError,
Expand Down Expand Up @@ -133,7 +134,7 @@ def defaults
# :nodoc:
def valid_attribute!(name, attribute)
attribute.valid!
rescue => ex
rescue StandardError => ex
raise ex, "Attribute #{name.inspect} invalid: #{ex}", ex.backtrace
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/occi/core/entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class Entity
include Helpers::InstanceAttributeResetter
include Helpers::MixinSelector

attr_accessor :kind, :actions, :attributes, :mixins
attr_reader :kind, :mixins
attr_writer :location
attr_accessor :actions, :attributes

ERRORS = [
Occi::Core::Errors::AttributeValidationError, Occi::Core::Errors::AttributeDefinitionError,
Expand Down Expand Up @@ -295,7 +296,7 @@ def valid?
#
# @return [NilClass] when entity instance is valid
def valid!
%i[kind location attributes mixins actions].each do |attr|
%i[kind attributes mixins actions].each do |attr|
unless send(attr)
raise Occi::Core::Errors::InstanceValidationError,
"Missing valid #{attr}"
Expand Down Expand Up @@ -334,7 +335,7 @@ def identify!
# :nodoc:
def valid_attribute!(name, attribute)
attribute.valid!
rescue => ex
rescue StandardError => ex
raise ex, "Attribute #{name.inspect} invalid: #{ex}", ex.backtrace
end

Expand Down Expand Up @@ -376,8 +377,7 @@ def post_initialize(args)
# @return [URI] generated location
def generate_location
if id.blank?
raise Occi::Core::Errors::MandatoryArgumentError,
'Cannot generate default location without an `id`'
raise Occi::Core::Errors::MandatoryArgumentError, 'Cannot generate default location without an `id`'
end
URI.parse "#{kind.location}#{id}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/occi/core/helpers/error_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def handle(klass)
raise 'You have to provide a block' unless block_given?
begin
yield # do whatever you need to do
rescue => ex
rescue StandardError => ex
raise klass, ex.message
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/occi/core/helpers/raw_json_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module RawJsonParser
# :nodoc:
def raw_hash(body)
JSON.parse body, symbolize_names: true
rescue => ex
rescue StandardError => ex
raise Occi::Core::Errors::ParsingError, "JSON parsing failed: #{ex.message}"
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/occi/core/locations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def scheme=(scheme)
def valid?
valid!
true
rescue => ex
rescue StandardError => ex
logger.warn "Location invalid: #{ex.message}"
false
end
Expand All @@ -73,7 +73,7 @@ def valid?
# @raise [Occi::Core::Errors::LocationValidationError] if some location is invalid
def valid!
map! { |uri| return_or_convert uri }
rescue => ex
rescue StandardError => ex
raise Occi::Core::Errors::LocationValidationError, ex.message
end
alias convert! valid!
Expand Down
2 changes: 1 addition & 1 deletion lib/occi/core/parsers/json/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Validator

# Repository constants
SCHEMA_DIR = 'validator'.freeze
SCHEMA_REPO = File.join(File.expand_path(File.dirname(__FILE__)), SCHEMA_DIR)
SCHEMA_REPO = File.join(__dir__, SCHEMA_DIR)
BASE_SCHEMAS = %i[occi-schema].freeze

class << self
Expand Down
2 changes: 1 addition & 1 deletion lib/occi/core/parsers/json_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def validate_entities!(body)
begin
Json::Validator.validate! body, type
found = type
rescue => ex
rescue StandardError => ex
logger.debug { "Moving on, body does not contain valid #{type} - #{ex.message.inspect}" }
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/occi/core/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Occi
module Core
MAJOR_VERSION = 5 # Major update constant
MINOR_VERSION = 0 # Minor update constant
PATCH_VERSION = 1 # Patch/Fix version constant
PATCH_VERSION = 2 # Patch/Fix version constant
STAGE_VERSION = nil # use `nil` for production releases

unless defined?(::Occi::Core::VERSION)
Expand Down
2 changes: 1 addition & 1 deletion lib/occi/core/warehouse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def bootstrap!(model)

# :nodoc:
def whereami
File.expand_path(File.dirname(__FILE__))
__dir__
end

# :nodoc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: true
default: ~
description: Title assigned to this entity sub-type instance.
pattern: !ruby/regexp '/^[[:word:]]([[:blank:]]|[[:word:]]|\-)*$/'
pattern: !ruby/regexp '/^.+$/'
2 changes: 1 addition & 1 deletion lib/occi/infrastructure/warehouse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class << self

# :nodoc:
def whereami
File.expand_path(File.dirname(__FILE__))
__dir__
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/occi/infrastructure/warehouse/actions/compute_save.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ attributes:
mutable: true
default: ~
description: Name of the copy
pattern: !ruby/regexp '/^[[:alnum:]]+$/'
pattern: !ruby/regexp '/^.+$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: true
default: ~
description: Compute FQDN.
pattern: ~
pattern: !ruby/regexp '/^.+$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Human-readable description of the current state.
pattern: ~
pattern: !ruby/regexp '/^.*$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: true
default: ~
description: Label of the network instance.
pattern: ~
pattern: !ruby/regexp '/^.+$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Human-readable description of the current state.
pattern: ~
pattern: !ruby/regexp '/^.*$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Network interface name.
pattern: !ruby/regexp '/^[[:alnum:]]+$/'
pattern: !ruby/regexp '/^.+$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Human-readable description of the current state.
pattern: ~
pattern: !ruby/regexp '/^.*$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Human-readable description of the current state.
pattern: ~
pattern: !ruby/regexp '/^.*$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Block device ID.
pattern: !ruby/regexp '/^([[:alnum:]]|-|_|\/)+$/'
pattern: !ruby/regexp '/^.+$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Block device mount point.
pattern: ~
pattern: !ruby/regexp '/^.+$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Human-readable description of the current state.
pattern: ~
pattern: !ruby/regexp '/^.*$/'
2 changes: 1 addition & 1 deletion lib/occi/infrastructure_ext/warehouse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class << self

# :nodoc:
def whereami
File.expand_path(File.dirname(__FILE__))
__dir__
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Human-readable description of the current state.
pattern: ~
pattern: !ruby/regexp '/^.*$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Human-readable description of the current state.
pattern: ~
pattern: !ruby/regexp '/^.*$/'
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ required: false
mutable: false
default: ~
description: Human-readable description of the current state.
pattern: ~
pattern: !ruby/regexp '/^.*$/'
1 change: 0 additions & 1 deletion occi-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'simplecov', '>= 0.11', '< 1'
gem.add_development_dependency 'pry', '>= 0.10', '< 1'
gem.add_development_dependency 'rubocop', '>= 0.32', '< 1'
gem.add_development_dependency 'rubocop-rspec', '>= 1.5', '< 2'
gem.add_development_dependency 'rubygems-tasks', '>= 0.2', '< 1'
gem.add_development_dependency 'yard', '>= 0.8', '< 1'
gem.add_development_dependency 'fasterer', '>= 0.3.2', '< 0.4'
Expand Down
8 changes: 7 additions & 1 deletion spec/occi/core/entity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,13 @@ module Core

describe '#valid!' do
context 'with missing required attributes' do
before { ent.id = nil }
before do
expect(attributes[attribute_title]).to receive(:valid!)
expect(attributes[attribute_id])
.to receive(:valid!)
.and_raise(Occi::Core::Errors::MandatoryArgumentError)
ent.id = nil
end

it 'raises error' do
expect { ent.valid! }.to raise_error(Occi::Core::Errors::MandatoryArgumentError)
Expand Down
2 changes: 1 addition & 1 deletion spec/occi/core/link_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module Core
before do
allow(kind).to receive(:attributes).and_return(attributes)
allow(kind).to receive(:location).and_return(URI.parse('/kind/'))
attributes.keys.each { |attrib| allow(attributes[attrib]).to receive(:default) }
attributes.each_key { |attrib| allow(attributes[attrib]).to receive(:default) }
end

LNK_ATTRS = %i[source target rel].freeze
Expand Down
2 changes: 1 addition & 1 deletion spec/occi/core/model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Core
let(:all) { Set.new([root_kind, kind, mixin, action]) }

before do
attributes.keys.each do |attrib|
attributes.each_key do |attrib|
allow(attributes[attrib]).to receive(:default)
allow(attributes[attrib]).to receive(:valid!)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/occi/core/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ module Core
before do
allow(link_kind).to receive(:attributes).and_return(link_attributes)
allow(link_kind).to receive(:location).and_return(URI.parse('/kind/'))
link_attributes.keys.each { |attrib| allow(link_attributes[attrib]).to receive(:default) }
link_attributes.each_key { |attrib| allow(link_attributes[attrib]).to receive(:default) }

allow(kind).to receive(:attributes).and_return(attributes)
allow(kind).to receive(:location).and_return(URI.parse('/kind/'))
attributes.keys.each { |attrib| allow(attributes[attrib]).to receive(:default) }
attributes.each_key { |attrib| allow(attributes[attrib]).to receive(:default) }
end

RES_ATTRS = [:summary].freeze
Expand Down

0 comments on commit 825c810

Please sign in to comment.