occi-core 5.0.0.beta.5 → 5.0.0.beta.6

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: 10924a00e47bae93f04879bcfe242c3b4957dc7d
4
- data.tar.gz: 1f62fc249445349f361d1a909f9298ad619775a5
3
+ metadata.gz: aa9a61e70441d1bb4ab60fab3f894e2d3086c1f9
4
+ data.tar.gz: f8ecee4038e193c81a46dd410e474e8e82f4eaaa
5
5
  SHA512:
6
- metadata.gz: dbff54906247c5d0205fcbe28391f2fd1a5802ca8abc3f3c808681c4ebb024ac3edd151a9cb6090726d11f2782fb811ebef4604ac082eeb125a0757ae5b72d24
7
- data.tar.gz: 3068278a251a5c3cbe077726999ba2d06c610e15689c69e8d1d76149131ad37e10676b132be7ad0d0c6ff534d3197b684baa524ed550d938082c33a9e6b56a39
6
+ metadata.gz: fc42e510f55fb2f60baaeef56e223bc4d4a4e70f6e715a5e8dae91ed63bef410120a43ca56620eb53656c8aa65ed9fda11e4a06d6dcc48823c854482115de128
7
+ data.tar.gz: 56318eebcada2880af308767c224f362e03a514c743bd0ba1f3963467269a5f1aafd04b74f52d2acc935547a6e58fa9f0f6cebb51a95f66b0592765335e92896
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.2.2
5
- - 2.3.0
6
- - 2.4.0
4
+ - 2.2.7
5
+ - 2.3.4
6
+ - 2.4.1
7
7
  - ruby-head
8
8
 
9
9
  matrix:
@@ -14,13 +14,12 @@ matrix:
14
14
  branches:
15
15
  only:
16
16
  - master
17
- - 4.3.x
18
17
  - next
19
18
 
20
19
  env:
21
20
  - ON_TRAVIS_CI=yes
22
21
 
23
- install: 'gem install bundler -v ">= 1.12" && bundle install --retry=10'
22
+ install: 'gem install bundler -v ">= 1.15" && bundle install --retry=10'
24
23
 
25
24
  script: 'bundle exec rake acceptance'
26
25
 
data/Rakefile CHANGED
@@ -12,7 +12,10 @@ task spec: 'rcov:all'
12
12
 
13
13
  Gem::Tasks.new(build: { tar: true, zip: true }, sign: { checksum: true, pgp: false })
14
14
 
15
- RuboCop::RakeTask.new
15
+ desc 'Execute rubocop -D'
16
+ RuboCop::RakeTask.new(:rubocop) do |t|
17
+ t.options = ['-D'] # display cop name
18
+ end
16
19
 
17
20
  YARD::Rake::YardocTask.new do |t|
18
21
  t.stats_options = ['--list-undoc']
@@ -18,8 +18,8 @@ module Occi
18
18
  # Shortcuts to interesting object attributes, always prefixed with `object_`
19
19
  DELEGATED = %i[
20
20
  respond_to? send source target summary kind parent action
21
- attributes actions mixins depends applies links rel empty? resources
22
- links action_instances
21
+ attributes actions mixins depends applies rel empty?
22
+ categories entities resources links action_instances
23
23
  ].freeze
24
24
  delegate(*DELEGATED, to: :object, prefix: true)
25
25
 
@@ -14,12 +14,11 @@ module Occi
14
14
  class Collection < Model
15
15
  # :nodoc:
16
16
  def render_hash
17
- return {} if object_empty?
18
- return super if object.only_categories?
17
+ return {} if object_empty? || object.only_categories?
19
18
 
20
- if object.only_entities?
19
+ if ent_no_ai?
21
20
  render_entities_hash
22
- elsif object.only_action_instances?
21
+ elsif ai_no_ent?
23
22
  render_action_instances_hash
24
23
  else
25
24
  raise Occi::Core::Errors::RenderingError, 'Cannot render mixed collection to JSON'
@@ -29,10 +28,10 @@ module Occi
29
28
  # :nodoc:
30
29
  def render_entities_hash
31
30
  hsh = {}
32
- unless object_resources.blank?
31
+ if object_resources.any?
33
32
  hsh[:resources] = object_resources.collect { |r| Resource.new(r, options).render_hash }
34
33
  end
35
- unless object_links.blank?
34
+ if object_links.any?
36
35
  hsh[:links] = object_links.collect { |r| Link.new(r, options).render_hash }
37
36
  end
38
37
  hsh
@@ -45,6 +44,16 @@ module Occi
45
44
  end
46
45
  ActionInstance.new(object_action_instances.first, options).render_hash
47
46
  end
47
+
48
+ # :nodoc:
49
+ def ent_no_ai?
50
+ object_entities.any? && object_action_instances.empty?
51
+ end
52
+
53
+ # :nodoc:
54
+ def ai_no_ent?
55
+ object_action_instances.any? && object_entities.empty?
56
+ end
48
57
  end
49
58
  end
50
59
  end
@@ -18,6 +18,10 @@ module Occi
18
18
 
19
19
  attr_accessor :object, :options
20
20
 
21
+ # Shortcuts to interesting object attributes, always prefixed with `object_`
22
+ DELEGATED = %i[send empty? categories entities resources links action_instances].freeze
23
+ delegate(*DELEGATED, to: :object, prefix: true)
24
+
21
25
  # Constructs a renderer instance for the given
22
26
  # object.
23
27
  #
@@ -16,12 +16,11 @@ module Occi
16
16
  #
17
17
  # @return [String] textual representation of Object
18
18
  def render_plain
19
- return '' if object.empty?
20
- return super if object.only_categories?
19
+ return '' if object_empty? || object.only_categories?
21
20
 
22
- if object.only_entities?
21
+ if ent_no_ai?
23
22
  prepare_instances 'entities'
24
- elsif object.only_action_instances?
23
+ elsif ai_no_ent?
25
24
  prepare_instances 'action_instances'
26
25
  else
27
26
  raise Occi::Core::Errors::RenderingError,
@@ -34,12 +33,11 @@ module Occi
34
33
  #
35
34
  # @return [Hash] textual representation of Object for headers
36
35
  def render_headers
37
- return {} if object.empty?
38
- return super if object.only_categories?
36
+ return {} if object_empty? || object.only_categories?
39
37
 
40
- if object.only_entities?
38
+ if ent_no_ai?
41
39
  prepare_instances 'entities'
42
- elsif object.only_action_instances?
40
+ elsif ai_no_ent?
43
41
  prepare_instances 'action_instances'
44
42
  else
45
43
  raise Occi::Core::Errors::RenderingError,
@@ -51,12 +49,22 @@ module Occi
51
49
 
52
50
  # :nodoc:
53
51
  def prepare_instances(type)
54
- if object.send(type).count > 1
52
+ if object_send(type).count > 1
55
53
  raise Occi::Core::Errors::RenderingError,
56
54
  "Cannot render collection with multiple #{type.tr('_', ' ')} to text"
57
55
  end
58
56
 
59
- Occi::Core::Renderers::TextRenderer.render object.send(type).first, options
57
+ Occi::Core::Renderers::TextRenderer.render object_send(type).first, options
58
+ end
59
+
60
+ # :nodoc:
61
+ def ent_no_ai?
62
+ object_entities.any? && object_action_instances.empty?
63
+ end
64
+
65
+ # :nodoc:
66
+ def ai_no_ent?
67
+ object_action_instances.any? && object_entities.empty?
60
68
  end
61
69
  end
62
70
  end
@@ -3,7 +3,7 @@ module Occi
3
3
  MAJOR_VERSION = 5 # Major update constant
4
4
  MINOR_VERSION = 0 # Minor update constant
5
5
  PATCH_VERSION = 0 # Patch/Fix version constant
6
- STAGE_VERSION = 'beta.5'.freeze # use `nil` for production releases
6
+ STAGE_VERSION = 'beta.6'.freeze # use `nil` for production releases
7
7
 
8
8
  unless defined?(::Occi::Core::VERSION)
9
9
  VERSION = [
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.beta.5
4
+ version: 5.0.0.beta.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Parak
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-07-13 00:00:00.000000000 Z
13
+ date: 2017-07-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -571,7 +571,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
571
571
  version: 1.3.1
572
572
  requirements: []
573
573
  rubyforge_project:
574
- rubygems_version: 2.6.8
574
+ rubygems_version: 2.6.12
575
575
  signing_key:
576
576
  specification_version: 4
577
577
  summary: The rOCCI toolkit