occi-core 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ee5d882ffc4b2bbd1303e37307911dc65cf1ecd
4
- data.tar.gz: b1d1b4fce539e518607ae2ffe5f74c92347b913c
3
+ metadata.gz: d523a58448adfcac4670df02b7666b1a9e48c7da
4
+ data.tar.gz: 2442b720cd5e338f33bfcf92f3da9ce1a3bff0c0
5
5
  SHA512:
6
- metadata.gz: 993fa9077687fc522635f593f37cc565686be0fed8c022ff7affe640cb31bfef8a7bd89df1c5e260246a828760d8b51fc0f0d65da5a0d5e4b227b92fcb6815b5
7
- data.tar.gz: 6962b980323f9d2f43f75901e07f8d3c353ca6e3f76829e4ea6a71ede49a813128a47820faa6812ae84533cd32c9be639ff18bb7a6b704b7cf48a4a0271501b5
6
+ metadata.gz: 02bf8369a2c0c5a084e670b2f106d43ba83312ba0e0bd2ae7b84421da32e2aa592f7f95b51a2c892f7ea5160cf7aa72a894245c1e91e194e13acb4859874f217
7
+ data.tar.gz: f8565410f77fd48b20aff72581fb2e477c00e3f8a5e42afc784988b01395360fdcdf3d5329d23b6c2a54b9e905ea26d98c8be2378e6257951a199f46c52032fb
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
 
3
4
  rvm:
4
5
  - 2.2.7
data/CHANGELOG.md CHANGED
@@ -0,0 +1,8 @@
1
+
2
+ 5.0.1 / 2017-09-05
3
+ ==================
4
+
5
+ * `occi.ipreservation.address` not required for `Occi::InfrastructureExt::IPReservation`
6
+ * Respecting `{source,target}_kind` for Link rendering to JSON
7
+ * Logging `debug` messages via blocks (perf.)
8
+ * Converting JSON keys to symbols by default
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  * Ruby 2.2.2+ or jRuby 9+ (with JDK7 a JDK8)
10
10
 
11
11
  ## Installation
12
- ### As a gem
12
+ ### Gem
13
13
  To install the most recent stable version
14
14
  ~~~
15
15
  gem install occi-core
@@ -19,17 +19,152 @@ To install the most recent beta version
19
19
  ~~~
20
20
  gem install occi-core --pre
21
21
  ~~~
22
-
23
- ### From source
24
- To build and install the bleeding edge version from master
22
+ ### Source
23
+ To build a bleeding edge version from master
25
24
  ~~~
26
25
  git clone git://github.com/the-rocci-project/rOCCI-core.git
27
26
  cd rOCCI-core
28
27
  gem build occi-core.gemspec
28
+ gem install occi-core-*.gem
29
29
  ~~~
30
30
 
31
31
  ## Usage
32
- `TODO`
32
+ ### Logging
33
+ ```ruby
34
+ require 'occi/infrastructure-ext'
35
+ logger = Yell.new STDOUT, name: Object # IO or String
36
+ logger.level = :debug # see https://github.com/rudionrails/yell
37
+ ```
38
+ ### Model
39
+ ```ruby
40
+ model = Occi::InfrastructureExt::Model.new
41
+ model.load_core!
42
+ model.load_infrastructure!
43
+ model.load_infrastructure_ext!
44
+
45
+ model.valid! # this should never raise an error when using stock model extensions
46
+ ```
47
+ ```ruby
48
+ model.kinds # => #<Set ...>
49
+ model.mixins # => #<Set ...>
50
+ model.actions # => #<Set ...>
51
+ ```
52
+ ```ruby
53
+ kind = model.find_by_identifier! 'http://schemas.ogf.org/occi/infrastructure#compute' # => #<Occi::Core::Kind ...>
54
+ mixin = model.find_by_identifier! 'http://schemas.ogf.org/occi/infrastructure#os_tpl' # => #<Occi::Core::Mixin ...>
55
+
56
+ model.find_dependent mixin # => #<Set ...> of mixins that depend on the given mixin
57
+ model.find_related kind # => #<Set ...> of kinds related to the given kind
58
+ ```
59
+ ### Instance Builder
60
+ ```ruby
61
+ # always access the IB instance associated with a model instance
62
+ ib = model.instance_builder
63
+ ib.get 'http://schemas.ogf.org/occi/infrastructure#compute' # => #<Occi::Infrastructure::Compute ...>
64
+ ```
65
+ ### Entity Instance
66
+ ```ruby
67
+ # using `mixin` selected from Model instance
68
+ # using `compute` created by InstanceBuilder instance
69
+ compute.identify! # to generate `occi.core.id`
70
+
71
+ compute['occi.core.id'] # => #<String ...>
72
+ compute['occi.core.title'] = 'Mine' # to assign instance attribute value
73
+
74
+ compute << mixin # add a mixin
75
+
76
+ compute.valid! # to validate
77
+ ```
78
+ ### Action Instance
79
+ ```ruby
80
+ # using `action` selected from Model instance
81
+ ai = Occi::Core::ActionInstance.new(action: action)
82
+
83
+ ai['method'] # => #<String ...>
84
+ ai['method'] = 'cold' # to assign action instance attribute value
85
+
86
+ ai.valid!
87
+ ```
88
+ ### Collection
89
+ ```ruby
90
+ # using `model`
91
+ # using `compute` created by InstanceBuilder instance
92
+ # using `compute1` created by InstanceBuilder instance
93
+ # using `compute2` created by InstanceBuilder instance
94
+ collection = Occi::Core::Collection.new
95
+ collection.categories = model.categories
96
+
97
+ collection << compute
98
+ collection << compute1
99
+ collection << compute2
100
+
101
+ collection.valid!
102
+ ```
103
+ ```ruby
104
+ # using `kind` selected from Model instance
105
+ collection.find_by_kind kind # => #<Set ...> of Occi::Core::Entity or its sub-type
106
+ collection.find_by_id! '12554' # => #<Occi::Core::Entity ...> or its sub-type
107
+ ```
108
+ ### Rendering
109
+ ```ruby
110
+ # using `compute` created by InstanceBuilder instance
111
+ compute.valid! # ALWAYS validate before rendering!
112
+
113
+ compute.to_text # => #<String ...>
114
+ compute.to_json # => #<String ...>
115
+ ```
116
+ ```ruby
117
+ # using `collection` with `collection.categories` set
118
+ collection.valid! # ALWAYS validate before rendering!
119
+
120
+ collection.to_text # => #<String ...> with at most one Occi::Core::Entity sub-type
121
+ collection.to_json # => #<String ...>
122
+ ```
123
+ ### Parsing
124
+ ```ruby
125
+ model = Occi::InfrastructureExt::Model.new # empty or partially loaded model instance can be used
126
+
127
+ mf = File.read File.join('examples', 'rendering', 'model.json')
128
+ Occi::Core::Parsers::JsonParser.model(mf, {}, 'application/occi+json', model)
129
+
130
+ model.valid! # ALWAYS validate before using the model!
131
+ ```
132
+ ```ruby
133
+ # using `model`
134
+ parser = Occi::Core::Parsers::JsonParser.new(model: model, media_type: 'application/occi+json')
135
+
136
+ cf = File.read File.join('examples', 'rendering', 'instance.json')
137
+ entities = parser.entities(cf, {}) # => #<Set ...>
138
+
139
+ entities.each(&:valid!) # ALWAYS validate before using parsed instances!
140
+ ```
141
+ ### Warehouse
142
+ ```ruby
143
+ module Custom
144
+ class Warehouse < Occi::Core::Warehouse
145
+ class << self
146
+ protected
147
+
148
+ def whereami
149
+ # the `warehouse` directory should be located in this directory
150
+ File.expand_path(File.dirname(__FILE__))
151
+ end
152
+ end
153
+ end
154
+ end
155
+ ```
156
+ See definitions in [`Occi::Infrastructure::Warehouse`](https://github.com/the-rocci-project/rOCCI-core/tree/master/lib/occi/infrastructure/warehouse) for inspiration.
157
+ ### Extending Model
158
+ If you need to extend the model, use a custom `Warehouse` class to do it. Actions, kinds, and mixins referenced
159
+ by identifier in `Custom::Warehouse` definition YAMLs have to be already present in the model instance being extended!
160
+ ```ruby
161
+ model = Occi::InfrastructureExt::Model.new
162
+ model.load_core!
163
+
164
+ Custom::Warehouse.bootstrap! model
165
+
166
+ model.valid!
167
+ ```
33
168
 
34
169
  ## Changelog
35
170
  See `CHANGELOG.md`.
@@ -37,9 +172,8 @@ See `CHANGELOG.md`.
37
172
  ## Code Documentation
38
173
  [Code Documentation for rOCCI](http://rubydoc.info/github/the-rocci-project/rOCCI-core/)
39
174
 
40
- ### Contribute
41
-
42
- 1. Fork it.
175
+ ## Contribute
176
+ 1. Fork it
43
177
  2. Create a branch (git checkout -b my_markup)
44
178
  3. Commit your changes (git commit -am "My changes")
45
179
  4. Push to the branch (git push origin my_markup)
@@ -154,7 +154,7 @@ module Occi
154
154
  begin
155
155
  valid! value
156
156
  rescue Occi::Core::Errors::AttributeValidationError => ex
157
- logger.debug "AttributeValidation: #{ex.message}"
157
+ logger.debug { "AttributeValidation: #{ex.message}" }
158
158
  return false
159
159
  end
160
160
 
@@ -8,7 +8,7 @@ module Occi
8
8
  module ArgumentValidator
9
9
  # :nodoc:
10
10
  def default_args!(args)
11
- logger.debug "Merging #{self.class} args #{args.inspect} with defaults #{defaults.inspect}"
11
+ logger.debug { "Merging #{self.class} args #{args.inspect} with defaults #{defaults.inspect}" }
12
12
  args.merge!(defaults) { |_, oldval, _| oldval }
13
13
  sufficient_args!(args)
14
14
  end
@@ -53,7 +53,7 @@ module Occi
53
53
  name_cache = attribute_names
54
54
  attributes.keep_if do |key, value|
55
55
  defined = name_cache.include?(key) && value && value.attribute_definition
56
- logger.debug "Removing undefined attribute #{key.inspect} on #{self.class}" unless defined
56
+ logger.debug { "Removing undefined attribute #{key.inspect} on #{self.class}" } unless defined
57
57
  defined
58
58
  end
59
59
  end
@@ -122,10 +122,10 @@ module Occi
122
122
  # @param force [TrueClass, FalseClass] forcibly change attribute value to default
123
123
  def reset_attribute(name, definition, force)
124
124
  if attributes[name]
125
- logger.debug "Setting attribute definition for existing #{name.inspect} on #{self.class}"
125
+ logger.debug { "Setting attribute definition for existing #{name.inspect} on #{self.class}" }
126
126
  attributes[name].attribute_definition = definition
127
127
  else
128
- logger.debug "Creating attribute definition for new #{name.inspect} on #{self.class}"
128
+ logger.debug { "Creating attribute definition for new #{name.inspect} on #{self.class}" }
129
129
  attributes[name] = Attribute.new(nil, definition)
130
130
  end
131
131
 
@@ -44,8 +44,8 @@ module Occi
44
44
  # @param derefd [Array] list of all available category instances
45
45
  # @param parsed_actions [Array] textual representation of needed actions
46
46
  def lookup_action_references!(cat, derefd, parsed_actions)
47
- logger.debug "Dereferencing actions #{parsed_actions.inspect} for #{cat.identifier.inspect}"
48
47
  return if parsed_actions.blank?
48
+ logger.debug { "Dereferencing actions #{parsed_actions.inspect} for #{cat.identifier.inspect}" }
49
49
  parsed_actions.each { |action| cat.actions << first_or_die(derefd, action) }
50
50
  end
51
51
 
@@ -54,7 +54,7 @@ module Occi
54
54
  # @param parsed_rel [Array] textual representation of needed parent(s)
55
55
  def lookup_parent_references!(kind, derefd, parsed_rel)
56
56
  return if parsed_rel.blank? || kind.parent.is_a?(Occi::Core::Kind)
57
- logger.debug "Dereferencing parent #{parsed_rel.inspect} for #{kind.identifier.inspect}"
57
+ logger.debug { "Dereferencing parent #{parsed_rel.inspect} for #{kind.identifier.inspect}" }
58
58
  if parsed_rel.is_a?(Enumerable)
59
59
  if parsed_rel.count > 1
60
60
  raise Occi::Core::Errors::ParsingError,
@@ -85,7 +85,7 @@ module Occi
85
85
  # @param what [String] identifier of the desired item
86
86
  # @return [Object] desired item from `where`
87
87
  def first_or_die(where, what)
88
- logger.debug "Looking for #{what.inspect} in #{where.class}"
88
+ logger.debug { "Looking for #{what.inspect} in #{where.class}" }
89
89
  found = where.detect { |elm| elm.identifier == what }
90
90
  unless found
91
91
  raise Occi::Core::Errors::ParsingError,
@@ -27,7 +27,7 @@ module Occi
27
27
  # @return [Object] output of the chosen renderer
28
28
  def render(format, options = {})
29
29
  options[:format] = format
30
- logger.debug "#{self.class} is being rendered to #{format} with #{options.inspect}" if respond_to?(:logger)
30
+ logger.debug { "#{self.class} is rendered to #{format} with #{options.inspect}" } if respond_to?(:logger)
31
31
  renderer_for(format).render(self, options)
32
32
  end
33
33
 
@@ -55,7 +55,7 @@ module Occi
55
55
  # @param base [Class] class receiving this module
56
56
  def self.included(base)
57
57
  renderer_factory.formats.each do |format|
58
- base.logger.debug "Adding support for format #{format} to #{base}" if base.respond_to?(:logger)
58
+ base.logger.debug { "Adding support for format #{format} to #{base}" } if base.respond_to?(:logger)
59
59
  base.send(:define_method, "to_#{format}", proc { render(format) })
60
60
  end
61
61
  end
@@ -25,7 +25,7 @@ module Occi
25
25
  raise 'This method cannot be invoked on instances' unless is_a? Class
26
26
  allowed_classes = respond_to?(:allowed_yaml_classes, true) ? allowed_yaml_classes : []
27
27
 
28
- logger.debug "Loading YAML definition for #{self} from #{path.inspect}"
28
+ logger.debug { "Loading YAML definition for #{self} from #{path.inspect}" }
29
29
  object_args = YAML.safe_load(File.read(path), allowed_classes)
30
30
  object_args.symbolize_keys!
31
31
  object_args.dereference_with!(self, model, attribute_definitions) if needs_dereferencing?
@@ -42,7 +42,7 @@ module Occi
42
42
  # @return [Object] constructed instance
43
43
  # @return [NilClass] if such an instance could not be constructed
44
44
  def build(identifier, args = {})
45
- logger.debug "Building instance of #{identifier.inspect} with #{args.inspect}"
45
+ logger.debug { "Building instance of #{identifier.inspect} with #{args.inspect}" }
46
46
  k_args = args_with_kind(identifier, args)
47
47
  klass(identifier, parent_klass(k_args[:kind])).new k_args
48
48
  end
@@ -93,7 +93,7 @@ module Occi
93
93
  "#{found_klass} is not a sub-type of #{known_ancestor}"
94
94
  end
95
95
 
96
- logger.debug "Found class #{found_klass} for #{identifier.inspect}"
96
+ logger.debug { "Found class #{found_klass} for #{identifier.inspect}" }
97
97
  found_klass
98
98
  end
99
99
 
@@ -119,10 +119,10 @@ module Occi
119
119
  # @return [Class] located known parent class
120
120
  def parent_klass(kind)
121
121
  if kind.related? kind_instance(Occi::Core::Constants::RESOURCE_KIND)
122
- logger.debug "Identified #{kind.identifier} as Resource"
122
+ logger.debug { "Identified #{kind.identifier} as Resource" }
123
123
  Occi::Core::Resource
124
124
  elsif kind.related? kind_instance(Occi::Core::Constants::LINK_KIND)
125
- logger.debug "Identified #{kind.identifier} as Link"
125
+ logger.debug { "Identified #{kind.identifier} as Link" }
126
126
  Occi::Core::Link
127
127
  else
128
128
  raise Occi::Core::Errors::ModelLookupError,
@@ -18,10 +18,6 @@ module Occi
18
18
 
19
19
  attr_accessor :model, :media_type
20
20
 
21
- # Shortcuts to interesting methods on logger
22
- DELEGATED = %i[debug? info? warn? error? fatal?].freeze
23
- delegate(*DELEGATED, to: :logger, prefix: true)
24
-
25
21
  # Constructs an instance of the parser that will use a particular model as the reference for every
26
22
  # parsed instance. Only instances allowed by the model will be successfuly parsed. In case of
27
23
  # `Occi::Core::Category` instances, only identifiers are parsed and existing instances from the model
@@ -36,7 +32,7 @@ module Occi
36
32
 
37
33
  @model = args.fetch(:model)
38
34
  @media_type = args.fetch(:media_type)
39
- logger.debug "Initializing parser for #{media_type.inspect}"
35
+ logger.debug { "Initializing parser for #{media_type.inspect}" }
40
36
 
41
37
  post_initialize(args)
42
38
  end
@@ -123,10 +119,6 @@ module Occi
123
119
  end
124
120
 
125
121
  class << self
126
- # Shortcuts to interesting methods on logger
127
- DELEGATED = %i[debug? info? warn? error? fatal?].freeze
128
- delegate(*DELEGATED, to: :logger, prefix: true)
129
-
130
122
  # Returns a list of supported media types for this parser.
131
123
  #
132
124
  # @return [Array] list of supported media types
@@ -12,10 +12,6 @@ module Occi
12
12
  extend Helpers::RawJsonParser
13
13
 
14
14
  class << self
15
- # Shortcuts to interesting methods on logger
16
- DELEGATED = %i[debug? info? warn? error? fatal?].freeze
17
- delegate(*DELEGATED, to: :logger, prefix: true)
18
-
19
15
  # Parses action instances. Internal references between objects are converted from strings
20
16
  # to actual objects. Actions have to be declared in the provided model.
21
17
  #
@@ -26,12 +22,12 @@ module Occi
26
22
  parsed = raw_hash(body)
27
23
  action = handle(Occi::Core::Errors::ParsingError) { model.find_by_identifier! parsed[:action] }
28
24
 
29
- logger.debug "Identified #{action.class}[#{action.identifier}]"
25
+ logger.debug { "Identified #{action.class}[#{action.identifier}]" }
30
26
  ai = Occi::Core::ActionInstance.new(action: action)
31
27
  ep = Entity.new(model: model)
32
28
  ep.set_attributes!(ai, parsed[:attributes]) if parsed[:attributes]
33
29
 
34
- logger.debug "Parsed into ActionInstance #{ai.inspect}" if logger_debug?
30
+ logger.debug { "Parsed into ActionInstance #{ai.inspect}" }
35
31
  ai
36
32
  end
37
33
  end
@@ -27,10 +27,6 @@ module Occi
27
27
  DEPENDS_KEY = :depends
28
28
 
29
29
  class << self
30
- # Shortcuts to interesting methods on logger
31
- DELEGATED = %i[debug? info? warn? error? fatal?].freeze
32
- delegate(*DELEGATED, to: :logger, prefix: true)
33
-
34
30
  # Parses categories into instances of subtypes of `Occi::Core::Category`. Internal references
35
31
  # between objects are converted from strings to actual objects. Categories provided in the model
36
32
  # will be reused but have to be declared in the parsed model as well.
@@ -41,12 +37,12 @@ module Occi
41
37
  def json(body, model)
42
38
  parsed = raw_hash(body)
43
39
  instantiate_hashes! parsed, model
44
- logger.debug "Parsed into raw hashes #{parsed.inspect}" if logger_debug?
40
+ logger.debug { "Parsed into raw hashes #{parsed.inspect}" }
45
41
 
46
42
  raw_categories = [parsed[:kinds], parsed[:mixins]].flatten.compact
47
43
  dereference_identifiers! model.categories, raw_categories
48
44
 
49
- logger.debug "Returning (updated) model #{model.inspect}" if logger_debug?
45
+ logger.debug { "Returning (updated) model #{model.inspect}" }
50
46
  model
51
47
  end
52
48
 
@@ -59,7 +55,7 @@ module Occi
59
55
 
60
56
  # :nodoc:
61
57
  def instatiate_hash(raw, klass)
62
- logger.debug "Creating #{klass} from #{raw.inspect}" if logger_debug?
58
+ logger.debug { "Creating #{klass} from #{raw.inspect}" }
63
59
 
64
60
  obj = klass.new(
65
61
  term: raw[:term], schema: raw[:scheme], title: raw[:title],
@@ -67,11 +63,11 @@ module Occi
67
63
  )
68
64
 
69
65
  if obj.respond_to?(:location)
70
- logger.debug "Setting location #{raw[:location].inspect}" if logger_debug?
66
+ logger.debug { "Setting location #{raw[:location].inspect}" }
71
67
  obj.location = handle(Occi::Core::Errors::ParsingError) { URI.parse(raw[:location]) }
72
68
  end
73
69
 
74
- logger.debug "Created category #{obj.inspect}" if logger_debug?
70
+ logger.debug { "Created category #{obj.inspect}" }
75
71
  obj
76
72
  end
77
73
 
@@ -81,7 +77,7 @@ module Occi
81
77
 
82
78
  attr_defs = {}
83
79
  raw.each_pair do |k, v|
84
- logger.debug "Creating AttributeDefinition for #{k.inspect} from #{v.inspect}" if logger_debug?
80
+ logger.debug { "Creating AttributeDefinition for #{k.inspect} from #{v.inspect}" }
85
81
  def_hsh = typecast(v)
86
82
  unless def_hsh[:type]
87
83
  raise Occi::Core::Errors::ParsingError, "Attribute #{k.to_s.inspect} has no type"
@@ -105,14 +101,14 @@ module Occi
105
101
 
106
102
  # :nodoc:
107
103
  def lookup_applies_references!(mixin, derefd, parsed_rel)
108
- logger.debug "Looking up applies from #{parsed_rel.inspect}" if logger_debug?
104
+ logger.debug { "Looking up applies from #{parsed_rel.inspect}" }
109
105
  return if parsed_rel.blank?
110
106
  parsed_rel.each { |kind| mixin.applies << first_or_die(derefd, kind) }
111
107
  end
112
108
 
113
109
  # :nodoc:
114
110
  def lookup_depends_references!(mixin, derefd, parsed_rel)
115
- logger.debug "Looking up depens from #{parsed_rel.inspect}" if logger_debug?
111
+ logger.debug { "Looking up depens from #{parsed_rel.inspect}" }
116
112
  return if parsed_rel.blank?
117
113
  parsed_rel.each { |mxn| mixin.depends << first_or_die(derefd, mxn) }
118
114
  end
@@ -14,10 +14,6 @@ module Occi
14
14
  include Helpers::ErrorHandler
15
15
  extend Helpers::RawJsonParser
16
16
 
17
- # Shortcuts to interesting methods on logger
18
- DELEGATED = %i[debug? info? warn? error? fatal?].freeze
19
- delegate(*DELEGATED, to: :logger, prefix: true)
20
-
21
17
  # Constants
22
18
  SINGLE_INSTANCE_TYPES = %i[resource link].freeze
23
19
  MULTI_INSTANCE_TYPES = %i[entity-collection].freeze
@@ -67,14 +63,14 @@ module Occi
67
63
  # @param hash [Hash] Hash body for parsing
68
64
  # @return [Array] constructed instances
69
65
  def json_single(hash)
70
- logger.debug "Converting #{hash.inspect} into a single instance" if logger_debug?
66
+ logger.debug { "Converting #{hash.inspect} into a single instance" }
71
67
  instance = @_ib.get hash[:kind], mixins: lookup(hash[:mixins]), actions: lookup(hash[:actions])
72
68
 
73
69
  set_attributes! instance, hash[:attributes]
74
70
  set_links! instance, hash[:links] if instance.respond_to?(:links)
75
71
  set_target! instance, hash[:target] if instance.respond_to?(:target)
76
72
 
77
- logger.debug "Created instance #{instance.inspect}" if logger_debug?
73
+ logger.debug { "Created instance #{instance.inspect}" }
78
74
  Set.new [instance]
79
75
  end
80
76
 
@@ -85,12 +81,12 @@ module Occi
85
81
  def json_collection(hash)
86
82
  all = []
87
83
 
88
- logger.debug "Converting #{hash.inspect} into multiple instances" if logger_debug?
84
+ logger.debug { "Converting #{hash.inspect} into multiple instances" }
89
85
  all.concat hash[:resources] if hash[:resources]
90
86
  all.concat hash[:links] if hash[:links]
91
87
  all.map! { |a| json_single(a) }
92
88
 
93
- logger.debug "Created instances #{all.inspect}" if logger_debug?
89
+ logger.debug { "Created instances #{all.inspect}" }
94
90
  Set.new(all).flatten
95
91
  end
96
92
 
@@ -107,7 +103,7 @@ module Occi
107
103
  def set_attributes!(instance, hash)
108
104
  return if hash.blank?
109
105
  hash.each_pair do |name, value|
110
- logger.debug "Setting attribute #{name} to #{value.inspect}" if logger_debug?
106
+ logger.debug { "Setting attribute #{name} to #{value.inspect}" }
111
107
  attribute = instance.attributes[name.to_s]
112
108
  unless attribute
113
109
  raise Occi::Core::Errors::ParsingError,
@@ -138,7 +134,7 @@ module Occi
138
134
  end
139
135
  return value unless TYPECASTER_HASH.key?(type)
140
136
 
141
- logger.debug "Typecasting value #{value.inspect} to #{type}" if logger_debug?
137
+ logger.debug { "Typecasting value #{value.inspect} to #{type}" }
142
138
  TYPECASTER_HASH[type].call(value)
143
139
  end
144
140
 
@@ -15,10 +15,6 @@ module Occi
15
15
  BASE_SCHEMAS = %i[occi-schema].freeze
16
16
 
17
17
  class << self
18
- # Shortcuts to interesting methods on logger
19
- DELEGATED = %i[debug? info? warn? error? fatal?].freeze
20
- delegate(*DELEGATED, to: :logger, prefix: true)
21
-
22
18
  # Validates given `json` text with the appropriate schema for `type`.
23
19
  # This method raises `Occi::Core::Errors::ParsingError` on failure.
24
20
  #
@@ -26,7 +22,7 @@ module Occi
26
22
  # @param type [Symbol] schema selector
27
23
  # @raise [Occi::Core::Errors::ParsingError] on validation failure
28
24
  def validate!(json, type)
29
- logger.debug "Validating #{json.inspect} as #{type}" if logger_debug?
25
+ logger.debug { "Validating #{json.inspect} as #{type}" }
30
26
 
31
27
  JSON::Validator.schema_reader = JSON::Schema::Reader.new(accept_uri: false, accept_file: true)
32
28
  JSON::Validator.validate!(schema_for(type), json, json: true)
@@ -75,7 +71,7 @@ module Occi
75
71
  raise Occi::Core::Errors::ParserError, "Schema type #{type.inspect} is not allowed"
76
72
  end
77
73
  schema_path = File.join(SCHEMA_REPO, "#{type}.json")
78
- logger.debug "Found JSON schema for #{type} in #{schema_path}" if logger_debug?
74
+ logger.debug { "Found JSON schema for #{type} in #{schema_path}" }
79
75
 
80
76
  schema_path
81
77
  end
@@ -34,7 +34,7 @@ module Occi
34
34
  # @return [Set] set of instances
35
35
  def entities(body, _headers = nil, expectation = nil)
36
36
  expectation ||= Occi::Core::Entity
37
- logger.debug "Parsing #{expectation}(s) from #{body.inspect}" if logger_debug?
37
+ logger.debug { "Parsing #{expectation}(s) from #{body.inspect}" }
38
38
  type = validate_entities! body
39
39
 
40
40
  entity_parser = Json::Entity.new(model: model)
@@ -55,7 +55,7 @@ module Occi
55
55
  # @param headers [Hash] raw headers as provided by the transport protocol
56
56
  # @return [Set] set of parsed instances
57
57
  def action_instances(body, _headers = nil)
58
- logger.debug "Parsing Occi::Core::ActionInstance(s) from #{body.inspect}" if logger_debug?
58
+ logger.debug { "Parsing Occi::Core::ActionInstance(s) from #{body.inspect}" }
59
59
  Json::Validator.validate_action_instance! body
60
60
  Set.new [Json::ActionInstance.json(body, model)]
61
61
  end
@@ -69,7 +69,7 @@ module Occi
69
69
  # @return [Set] set of instances
70
70
  def categories(body, _headers = nil, expectation = nil)
71
71
  expectation ||= Occi::Core::Category
72
- logger.debug "Parsing #{expectation}(s) from #{body.inspect}" if logger_debug?
72
+ logger.debug { "Parsing #{expectation}(s) from #{body.inspect}" }
73
73
  Json::Validator.validate_category_identifiers! body
74
74
 
75
75
  cats = Set.new
@@ -84,12 +84,12 @@ module Occi
84
84
  found = nil
85
85
 
86
86
  %i[link resource entity-collection].each do |type|
87
- logger.debug "Attempting to validate #{body.inspect} as #{type}" if logger_debug?
87
+ logger.debug { "Attempting to validate #{body.inspect} as #{type}" }
88
88
  begin
89
89
  Json::Validator.validate! body, type
90
90
  found = type
91
91
  rescue => ex
92
- logger.debug "Moving on, body does not contain valid #{type} - #{ex.message.inspect}"
92
+ logger.debug { "Moving on, body does not contain valid #{type} - #{ex.message.inspect}" }
93
93
  end
94
94
  end
95
95
  raise Occi::Core::Errors::ParsingError, 'No acceptable entity rendering found' unless found
@@ -111,7 +111,7 @@ module Occi
111
111
  raise Occi::Core::Errors::ParsingError,
112
112
  "Model cannot be parsed from #{media_type.inspect}"
113
113
  end
114
- logger.debug "Parsing model from #{media_type.inspect} in #{body.inspect}" if logger_debug?
114
+ logger.debug { "Parsing model from #{media_type.inspect} in #{body.inspect}" }
115
115
 
116
116
  Json::Validator.validate_model! body
117
117
  Json::Category.json body, model
@@ -129,7 +129,7 @@ module Occi
129
129
  unless media_types.include?(media_type)
130
130
  raise Occi::Core::Errors::ParsingError, "Locations cannot be parsed from #{media_type.inspect}"
131
131
  end
132
- logger.debug "Parsing locations from #{media_type.inspect} in #{body.inspect}" if logger_debug?
132
+ logger.debug { "Parsing locations from #{media_type.inspect} in #{body.inspect}" }
133
133
 
134
134
  Json::Validator.validate_locations! body
135
135
  handle(Occi::Core::Errors::ParsingError) { JSON.parse(body).map { |i| URI.parse(i) } }
@@ -20,10 +20,6 @@ module Occi
20
20
  DEPENDS_KEY = :rel
21
21
 
22
22
  class << self
23
- # Shortcuts to interesting methods on logger
24
- DELEGATED = %i[debug? info? warn? error? fatal?].freeze
25
- delegate(*DELEGATED, to: :logger, prefix: true)
26
-
27
23
  # Parses category lines into instances of subtypes of `Occi::Core::Category`. Internal references
28
24
  # between objects are converted from strings to actual objects. Categories provided in the model
29
25
  # will be reused but have to be declared in the parsed model as well. This mechanism can be used to
@@ -41,7 +37,7 @@ module Occi
41
37
  end
42
38
  dereference_identifiers! model.categories, raw_categories
43
39
 
44
- logger.debug "Returning (updated) model #{model.inspect}" if logger_debug?
40
+ logger.debug { "Returning (updated) model #{model.inspect}" }
45
41
  model
46
42
  end
47
43
 
@@ -52,7 +48,7 @@ module Occi
52
48
  # @param full [TrueClass, FalseClass] parse full definition, defaults to `true`
53
49
  # @return [Hash] raw category hash for further processing
54
50
  def plain_category(line, full = true)
55
- logger.debug "Parsing line #{line.inspect}" if logger_debug?
51
+ logger.debug { "Parsing line #{line.inspect}" }
56
52
  matched = line.match(CATEGORY_REGEXP)
57
53
  unless matched
58
54
  raise Occi::Core::Errors::ParsingError, "#{line.inspect} does not match expectations for Category"
@@ -96,7 +92,7 @@ module Occi
96
92
 
97
93
  attributes = {}
98
94
  line.split.each { |attribute| attributes.merge! plain_attribute(attribute) }
99
- logger.debug "Matched attributes as #{attributes.inspect}" if logger_debug?
95
+ logger.debug { "Matched attributes as #{attributes.inspect}" }
100
96
 
101
97
  attributes
102
98
  end
@@ -112,7 +108,7 @@ module Occi
112
108
  def plain_attribute(line)
113
109
  # TODO: find a better approach to fixing split
114
110
  line.gsub!(/\{(immutable|required)_(required|immutable)\}/, '{\1 \2}')
115
- logger.debug "Parsing attribute line #{line.inspect}" if logger_debug?
111
+ logger.debug { "Parsing attribute line #{line.inspect}" }
116
112
 
117
113
  matched = line.match(ATTRIBUTE_REGEXP)
118
114
  unless matched && matched[1]
@@ -13,10 +13,6 @@ module Occi
13
13
  include Helpers::ArgumentValidator
14
14
  include Helpers::ErrorHandler
15
15
 
16
- # Shortcuts to interesting methods on logger
17
- DELEGATED = %i[debug? info? warn? error? fatal?].freeze
18
- delegate(*DELEGATED, to: :logger, prefix: true)
19
-
20
16
  # Regexp constants
21
17
  ATTRIBUTE_REGEXP = /#{Constants::REGEXP_ATTRIBUTE}/
22
18
  LINK_REGEXP = /#{Constants::REGEXP_LINK}/
@@ -25,7 +21,7 @@ module Occi
25
21
  DEFAULT_LAMBDA = ->(val) { raise "#{self} -> Cannot typecast #{val.inspect} to an unknown type" }
26
22
 
27
23
  FLOAT_LAMBDA = ->(val) { Float(val) rescue raise(Occi::Core::Errors::ParsingError, "Wrong value #{val}") }
28
- JSON_LAMBDA = ->(val) { JSON.parse(val.gsub('\"', '"')) }
24
+ JSON_LAMBDA = ->(val) { JSON.parse(val.gsub('\"', '"'), symbolize_names: true) }
29
25
 
30
26
  TYPECASTER_HASH = {
31
27
  IPAddr => ->(val) { IPAddr.new val },
@@ -62,7 +58,7 @@ module Occi
62
58
  cats = plain_categories(lines)
63
59
  kind = cats.detect { |c| c.is_a?(Occi::Core::Kind) }
64
60
  raise Occi::Core::Errors::ParsingError, 'Entity does not specify its kind' unless kind
65
- logger.debug "Identified entity kind #{kind.inspect}" if logger_debug?
61
+ logger.debug { "Identified entity kind #{kind.inspect}" }
66
62
 
67
63
  entity = @_ib.build(kind.identifier)
68
64
  cats.each { |cat| cat.is_a?(Occi::Core::Mixin) && entity << cat }
@@ -70,7 +66,7 @@ module Occi
70
66
  plain_attributes! lines, entity.attributes
71
67
  plain_links! lines, entity
72
68
 
73
- logger.debug "Created instance #{entity.inspect}" if logger_debug?
69
+ logger.debug { "Created instance #{entity.inspect}" }
74
70
  entity
75
71
  end
76
72
 
@@ -116,7 +112,7 @@ module Occi
116
112
  # @param line [String] line containing a single entity attribute
117
113
  # @return [Array] two-element array with name and value of the attribute
118
114
  def raw_attribute(line)
119
- logger.debug "Parsing attribute line #{line.inspect}" if logger_debug?
115
+ logger.debug { "Parsing attribute line #{line.inspect}" }
120
116
  matched = line.match(ATTRIBUTE_REGEXP)
121
117
  unless matched
122
118
  raise Occi::Core::Errors::ParsingError, "#{line.inspect} does not match expectations for Attribute"
@@ -133,7 +129,7 @@ module Occi
133
129
  def plain_links!(lines, entity)
134
130
  lines.each do |line|
135
131
  next unless line.start_with?(TextParser::LINK_KEYS.first)
136
- logger.debug "Parsing link line #{line.inspect}" if logger_debug?
132
+ logger.debug { "Parsing link line #{line.inspect}" }
137
133
 
138
134
  matched = line.match(LINK_REGEXP)
139
135
  unless matched
@@ -196,11 +192,11 @@ module Occi
196
192
  target_kind = handle(Occi::Core::Errors::ParsingError) { model.find_by_identifier!(md[:rel]) }
197
193
  link = @_ib.build(categories.shift, target_kind: target_kind)
198
194
  categories.each do |mxn|
199
- logger.debug "Adding mixin #{mxn.inspect} to link instance" if logger_debug?
195
+ logger.debug { "Adding mixin #{mxn.inspect} to link instance" }
200
196
  link << handle(Occi::Core::Errors::ParsingError) { model.find_by_identifier!(mxn) }
201
197
  end
202
198
 
203
- logger.debug "Created link instance #{link.inspect} from #{md.inspect}" if logger_debug?
199
+ logger.debug { "Created link instance #{link.inspect} from #{md.inspect}" }
204
200
  link
205
201
  end
206
202
 
@@ -212,7 +208,7 @@ module Occi
212
208
  if md[:attributes].blank?
213
209
  raise Occi::Core::Errors::ParsingError, "Link #{link.id} is missing attribute information"
214
210
  end
215
- logger.debug "Parsing inline link attributes from line #{md[:attributes].inspect}" if logger_debug?
211
+ logger.debug { "Parsing inline link attributes from line #{md[:attributes].inspect}" }
216
212
 
217
213
  regexp = Regexp.new "(\\s*#{Constants::REGEXP_ATTRIBUTE_REPR})"
218
214
  line = md[:attributes].strip.gsub(/^;\s*/, '')
@@ -234,7 +230,7 @@ module Occi
234
230
  raise Occi::Core::Errors::ParsingError, 'Cannot typecast (un)set value to (un)set type'
235
231
  end
236
232
 
237
- logger.debug "Typecasting value #{value.inspect} to #{type}" if logger_debug?
233
+ logger.debug { "Typecasting value #{value.inspect} to #{type}" }
238
234
  self.class.typecaster[type].call(value)
239
235
  end
240
236
 
@@ -11,10 +11,6 @@ module Occi
11
11
  include Helpers::ErrorHandler
12
12
 
13
13
  class << self
14
- # Shortcuts to interesting methods on logger
15
- DELEGATED = %i[debug? info? warn? error? fatal?].freeze
16
- delegate(*DELEGATED, to: :logger, prefix: true)
17
-
18
14
  # Parses text/plain OCCI locations into `URI` instances suitable for futher processing.
19
15
  # Every location line is expected to begin with 'X-OCCI-Location'.
20
16
  #
@@ -25,7 +21,7 @@ module Occi
25
21
 
26
22
  locations = lines.map do |line|
27
23
  next if line.blank?
28
- logger.debug "Parsing location from line #{line.inspect}" if logger_debug?
24
+ logger.debug { "Parsing location from line #{line.inspect}" }
29
25
 
30
26
  matched = line.match(regexp)
31
27
  unless matched
@@ -45,7 +41,7 @@ module Occi
45
41
  def uri_list(lines)
46
42
  uris = lines.map do |line|
47
43
  next if line.blank? || line.start_with?('#')
48
- logger.debug "Parsing location from line #{line.inspect}" if logger_debug?
44
+ logger.debug { "Parsing location from line #{line.inspect}" }
49
45
 
50
46
  handle(Occi::Core::Errors::ParsingError) { URI.parse(line.strip) }
51
47
  end
@@ -50,7 +50,7 @@ module Occi
50
50
  # @return [Set] set of instances
51
51
  def entities(body, headers, expectation = nil)
52
52
  expectation ||= Occi::Core::Entity
53
- logger.debug "Parsing #{expectation} from #{body.inspect} and #{headers.inspect}" if logger_debug?
53
+ logger.debug { "Parsing #{expectation} from #{body.inspect} and #{headers.inspect}" }
54
54
 
55
55
  entity_parser = Text::Entity.new(model: model)
56
56
  entity = entity_parser.plain transform(body, headers)
@@ -68,7 +68,7 @@ module Occi
68
68
  # @param headers [Hash] raw headers as provided by the transport protocol
69
69
  # @return [Set] set of parsed instances
70
70
  def action_instances(body, headers)
71
- logger.debug "Parsing Occi::Core::ActionInstance from #{body.inspect} and #{headers.inspect}" if logger_debug?
71
+ logger.debug { "Parsing Occi::Core::ActionInstance from #{body.inspect} and #{headers.inspect}" }
72
72
  entity_parser = Text::Entity.new(model: model)
73
73
  tformed = transform(body, headers)
74
74
 
@@ -88,7 +88,7 @@ module Occi
88
88
  # @return [Set] set of instances
89
89
  def categories(body, headers, expectation = nil)
90
90
  expectation ||= Occi::Core::Category
91
- logger.debug "Parsing #{expectation} from #{body.inspect} and #{headers.inspect}" if logger_debug?
91
+ logger.debug { "Parsing #{expectation} from #{body.inspect} and #{headers.inspect}" }
92
92
 
93
93
  cats = transform(body, headers).map do |line|
94
94
  cat = Text::Category.plain_category(line, false)
@@ -119,9 +119,7 @@ module Occi
119
119
  # @param model [Occi::Core::Model] `Model`-like instance to be populated (may contain existing categories)
120
120
  # @return [Occi::Core::Model] model instance filled with parsed categories
121
121
  def model(body, headers, media_type, model)
122
- if logger_debug?
123
- logger.debug "Parsing model from #{media_type.inspect} in #{body.inspect} and #{headers.inspect}"
124
- end
122
+ logger.debug { "Parsing model from #{media_type.inspect} in #{body.inspect} and #{headers.inspect}" }
125
123
 
126
124
  if HEADERS_TEXT_TYPES.include? media_type
127
125
  Text::Category.plain transform_headers(headers), model
@@ -139,9 +137,7 @@ module Occi
139
137
  # @param media_type [String] media type string as provided by the transport protocol
140
138
  # @return [Array] list of extracted URIs
141
139
  def locations(body, headers, media_type)
142
- if logger_debug?
143
- logger.debug "Parsing locations from #{media_type.inspect} in #{body.inspect} and #{headers.inspect}"
144
- end
140
+ logger.debug { "Parsing locations from #{media_type.inspect} in #{body.inspect} and #{headers.inspect}" }
145
141
 
146
142
  if URI_LIST_TYPES.include? media_type
147
143
  Text::Location.uri_list transform_body(body)
@@ -170,7 +166,7 @@ module Occi
170
166
  # @param headers [Hash] hash with raw header key-value pairs
171
167
  # @return [Array] an array of body-like lines
172
168
  def transform_headers(headers)
173
- logger.debug "Transforming headers #{headers.inspect}" if logger_debug?
169
+ logger.debug { "Transforming headers #{headers.inspect}" }
174
170
  unify_headers(
175
171
  canonize_headers(
176
172
  normalize_headers(headers)
@@ -192,7 +188,7 @@ module Occi
192
188
  headers.delete_if { |_k, v| v.blank? } # remove pairs with empty values
193
189
  headers.keep_if { |k, _v| OCCI_KEYS.include?(k) } # drop non-OCCI pairs
194
190
 
195
- logger.debug "Normalized headers #{headers.inspect}" if logger_debug?
191
+ logger.debug { "Normalized headers #{headers.inspect}" }
196
192
  headers
197
193
  end
198
194
 
@@ -210,7 +206,7 @@ module Occi
210
206
  canonical[pref.first] = [canonize_header_value(value)].flatten
211
207
  end
212
208
 
213
- logger.debug "Canonized headers #{canonical.inspect}" if logger_debug?
209
+ logger.debug { "Canonized headers #{canonical.inspect}" }
214
210
  canonical
215
211
  end
216
212
 
@@ -237,7 +233,7 @@ module Occi
237
233
  lines << v.map { |val| "#{k}: #{val}" }
238
234
  end
239
235
 
240
- logger.debug "Unified headers #{lines.inspect}" if logger_debug?
236
+ logger.debug { "Unified headers #{lines.inspect}" }
241
237
  lines.flatten.sort
242
238
  end
243
239
 
@@ -31,7 +31,7 @@ module Occi
31
31
  def initialize(args = {})
32
32
  default_args! args
33
33
 
34
- logger.debug "Initializing RendererFactory with #{args.inspect}"
34
+ logger.debug { "Initializing RendererFactory with #{args.inspect}" }
35
35
  @required_methods = args.fetch(:required_methods)
36
36
  @namespace = args.fetch(:namespace)
37
37
 
@@ -40,7 +40,7 @@ module Occi
40
40
 
41
41
  #
42
42
  def reload!
43
- logger.debug 'Clearing RendererFactory cache for renderer reload'
43
+ logger.debug { 'Clearing RendererFactory cache for renderer reload' }
44
44
  @ravail_cache = nil
45
45
  end
46
46
 
@@ -65,7 +65,7 @@ module Occi
65
65
  @ravail_cache = {}
66
66
 
67
67
  renderer_classes.each do |rndr_klass|
68
- logger.debug "RendererFactory registering #{rndr_klass} for #{rndr_klass.formats}"
68
+ logger.debug { "RendererFactory registering #{rndr_klass} for #{rndr_klass.formats}" }
69
69
  rndr_klass.formats.each { |rndr_klass_f| @ravail_cache[rndr_klass_f] = rndr_klass }
70
70
  end
71
71
 
@@ -113,7 +113,7 @@ module Occi
113
113
  renderer_with_methods! candidate
114
114
  renderer_with_formats! candidate
115
115
  rescue Occi::Core::Errors::RendererError => ex
116
- logger.debug "Renderer validation failed with #{ex.message}"
116
+ logger.debug { "Renderer validation failed with #{ex.message}" }
117
117
  return false
118
118
  end
119
119
 
@@ -176,7 +176,7 @@ module Occi
176
176
  raise Occi::Core::Errors::RendererError, "#{namespace.inspect} " \
177
177
  'is not a Module'
178
178
  end
179
- logger.debug "RendererFactory looking for renderers in #{namespace}"
179
+ logger.debug { "RendererFactory looking for renderers in #{namespace}" }
180
180
  namespace.constants.collect { |const| namespace.const_get(const) }
181
181
  end
182
182
 
@@ -32,7 +32,7 @@ module Occi
32
32
  # @option options [String] :format (nil) rendering (sub)type
33
33
  # @return [String] object rendering
34
34
  def render(object, options)
35
- logger.debug "#{self} rendering #{object.inspect} with #{options.inspect}"
35
+ logger.debug { "#{self} rendering #{object.inspect} with #{options.inspect}" }
36
36
  candidate = rendering_candidate(object)
37
37
  unless candidate
38
38
  raise Occi::Core::Errors::RenderingError, "#{object.class} cannot be " \
@@ -12,7 +12,7 @@ module Occi
12
12
  class Link < Base
13
13
  include Instance
14
14
 
15
- # TODO: this is a hack for typing `source` on known Compute links
15
+ # Note: this is a hack for typing `source` on known Compute links
16
16
  COMPUTE_KIND = 'http://schemas.ogf.org/occi/infrastructure#compute'.freeze
17
17
  COMPUTY_LINKS = %w[
18
18
  http://schemas.ogf.org/occi/infrastructure#networkinterface
@@ -32,10 +32,11 @@ module Occi
32
32
  def typed_uri_hash(attribute, type)
33
33
  hsh = { location: attribute.to_s }
34
34
 
35
- if type == :target && object_respond_to?(:rel)
36
- hsh[:kind] = object_rel.to_s
37
- elsif type == :source && COMPUTY_LINKS.include?(object_kind.to_s)
38
- # TODO: fix this mess
35
+ known_kind = object_send("#{type}_kind")
36
+ hsh[:kind] = known_kind.identifier if known_kind
37
+
38
+ # Note: this is a hack for typing `source` on known Compute links
39
+ if hsh[:kind].blank? && type == :source && COMPUTY_LINKS.include?(object_kind.identifier)
39
40
  hsh[:kind] = COMPUTE_KIND
40
41
  end
41
42
 
@@ -2,7 +2,7 @@ module Occi
2
2
  module Core
3
3
  MAJOR_VERSION = 5 # Major update constant
4
4
  MINOR_VERSION = 0 # Minor update constant
5
- PATCH_VERSION = 0 # Patch/Fix version constant
5
+ PATCH_VERSION = 1 # Patch/Fix version constant
6
6
  STAGE_VERSION = nil # use `nil` for production releases
7
7
 
8
8
  unless defined?(::Occi::Core::VERSION)
@@ -29,7 +29,7 @@ module Occi
29
29
  #
30
30
  # @param model [Occi::Core::Model] model to be bootstrapped
31
31
  def bootstrap!(model)
32
- logger.debug "Bootstrapping#{model.empty? ? ' empty' : ''} model"
32
+ logger.debug { "Bootstrapping#{model.empty? ? ' empty' : ''} model" }
33
33
  actions! model
34
34
  kinds! model
35
35
  mixins! model
@@ -67,7 +67,7 @@ module Occi
67
67
  def kinds!(model)
68
68
  attribute_definitions = attribute_definitions_for(kinds_path)
69
69
  yamls_in(kinds_path).each do |file|
70
- logger.debug "Warehouse loading kind from #{file.inspect}"
70
+ logger.debug { "Warehouse loading kind from #{file.inspect}" }
71
71
  model << Occi::Core::Kind.from_yaml(file, model, attribute_definitions)
72
72
  end
73
73
  end
@@ -76,7 +76,7 @@ module Occi
76
76
  def mixins!(model)
77
77
  attribute_definitions = attribute_definitions_for(mixins_path)
78
78
  yamls_in(mixins_path).each do |file|
79
- logger.debug "Warehouse loading mixin from #{file.inspect}"
79
+ logger.debug { "Warehouse loading mixin from #{file.inspect}" }
80
80
  model << Occi::Core::Mixin.from_yaml(file, model, attribute_definitions)
81
81
  end
82
82
  end
@@ -86,7 +86,7 @@ module Occi
86
86
  # TODO: work with separate attribute definitions
87
87
  attribute_definitions = {}
88
88
  yamls_in(actions_path).each do |file|
89
- logger.debug "Warehouse loading action from #{file.inspect}"
89
+ logger.debug { "Warehouse loading action from #{file.inspect}" }
90
90
  model << Occi::Core::Action.from_yaml(file, model, attribute_definitions)
91
91
  end
92
92
  end
@@ -98,7 +98,7 @@ module Occi
98
98
  attr_defs_path = File.join(categories_path, ATTRIBS)
99
99
  yamls_in(attr_defs_path).each do |file|
100
100
  name = attribute_name_from(file)
101
- logger.debug "Warehouse loading attribute definition for #{name.inspect} from #{file.inspect}"
101
+ logger.debug { "Warehouse loading attribute definition for #{name.inspect} from #{file.inspect}" }
102
102
  attribute_definitions[name] = Occi::Core::AttributeDefinition.from_yaml(file)
103
103
  end
104
104
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  type: !ruby/class IPAddr
3
- required: true
3
+ required: false
4
4
  mutable: true
5
5
  default: ~
6
6
  description: IP address (v4 or v6) assigned to this reservation.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occi-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Parak
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-23 00:00:00.000000000 Z
12
+ date: 2017-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json