occi-core 4.3.6 → 5.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.fasterer.yml +3 -0
- data/.gitignore +9 -16
- data/.rspec +1 -1
- data/.rubocop.yml +69 -0
- data/.travis.yml +27 -0
- data/AUTHORS +8 -6
- data/CHANGELOG.md +0 -0
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.md +25 -170
- data/Rakefile +25 -17
- data/examples/initialize_model.rb +10 -0
- data/examples/parse_action_instance_json.rb +15 -0
- data/examples/parse_action_instance_text.rb +15 -0
- data/examples/parse_categories_json.rb +15 -0
- data/examples/parse_categories_text.rb +15 -0
- data/examples/parse_instance_json.rb +15 -0
- data/examples/parse_instance_text.rb +15 -0
- data/examples/parse_model_json.rb +9 -0
- data/examples/parse_model_text.rb +9 -0
- data/examples/render_action_instance_json.rb +17 -0
- data/examples/render_action_instance_text.rb +17 -0
- data/examples/render_instance_json.rb +20 -0
- data/examples/render_instance_text.rb +20 -0
- data/examples/render_model_json.rb +12 -0
- data/examples/render_model_text.rb +12 -0
- data/examples/rendering/action_instance.json +6 -0
- data/examples/rendering/action_instance.txt +2 -0
- data/examples/rendering/categories.json +78 -0
- data/examples/rendering/categories.txt +4 -0
- data/examples/rendering/instance.json +70 -0
- data/examples/rendering/instance.txt +12 -0
- data/examples/rendering/model.alt.json +1716 -0
- data/examples/rendering/model.json +785 -0
- data/examples/rendering/model.txt +68 -0
- data/lib/occi/core/action.rb +12 -26
- data/lib/occi/core/action_instance.rb +109 -65
- data/lib/occi/core/attribute.rb +136 -0
- data/lib/occi/core/attribute_definition.rb +269 -0
- data/lib/occi/core/category.rb +110 -83
- data/lib/occi/core/collection.rb +255 -0
- data/lib/occi/core/constants.rb +14 -0
- data/lib/occi/core/entity.rb +301 -195
- data/lib/occi/core/errors/.gitkeep +0 -0
- data/lib/occi/core/errors/attribute_definition_error.rb +11 -0
- data/lib/occi/core/errors/attribute_validation_error.rb +13 -0
- data/lib/occi/core/errors/category_validation_error.rb +13 -0
- data/lib/occi/core/errors/collection_lookup_error.rb +11 -0
- data/lib/occi/core/errors/instance_validation_error.rb +13 -0
- data/lib/occi/core/errors/mandatory_argument_error.rb +11 -0
- data/lib/occi/core/errors/model_lookup_error.rb +11 -0
- data/lib/occi/core/errors/parser_error.rb +11 -0
- data/lib/occi/core/errors/parsing_error.rb +11 -0
- data/lib/occi/core/errors/renderer_error.rb +11 -0
- data/lib/occi/core/errors/rendering_error.rb +11 -0
- data/lib/occi/core/errors/validation_error.rb +11 -0
- data/lib/occi/core/errors.rb +9 -0
- data/lib/occi/core/helpers/.gitkeep +0 -0
- data/lib/occi/core/helpers/argument_validator.rb +27 -0
- data/lib/occi/core/helpers/attributes_accessor.rb +22 -0
- data/lib/occi/core/helpers/error_handler.rb +29 -0
- data/lib/occi/core/helpers/hash_dereferencer.rb +149 -0
- data/lib/occi/core/helpers/identifier_validator.rb +135 -0
- data/lib/occi/core/helpers/instance_attribute_resetter.rb +131 -0
- data/lib/occi/core/helpers/instance_attributes_accessor.rb +30 -0
- data/lib/occi/core/helpers/locatable.rb +40 -0
- data/lib/occi/core/helpers/parser_dereferencer.rb +96 -0
- data/lib/occi/core/helpers/raw_json_parser.rb +18 -0
- data/lib/occi/core/helpers/renderable.rb +93 -0
- data/lib/occi/core/helpers/yaml_summoner.rb +44 -0
- data/lib/occi/core/helpers.rb +13 -0
- data/lib/occi/core/instance_builder.rb +162 -0
- data/lib/occi/core/kind.rb +100 -132
- data/lib/occi/core/link.rb +47 -72
- data/lib/occi/core/mixin.rb +76 -61
- data/lib/occi/core/model.rb +341 -0
- data/lib/occi/core/parsers/.gitkeep +0 -0
- data/lib/occi/core/parsers/base_parser.rb +168 -0
- data/lib/occi/core/parsers/json/.gitkeep +0 -0
- data/lib/occi/core/parsers/json/action_instance.rb +36 -0
- data/lib/occi/core/parsers/json/category.rb +113 -0
- data/lib/occi/core/parsers/json/entity.rb +156 -0
- data/lib/occi/core/parsers/json/validator/.gitkeep +0 -0
- data/lib/occi/core/parsers/json/validator/action-instance.json +3 -0
- data/lib/occi/core/parsers/json/validator/entity-collection.json +3 -0
- data/lib/occi/core/parsers/json/validator/link-collection.json +3 -0
- data/lib/occi/core/parsers/json/validator/link.json +3 -0
- data/lib/occi/core/parsers/json/validator/locations.json +3 -0
- data/lib/occi/core/parsers/json/validator/mixin-collection.json +3 -0
- data/lib/occi/core/parsers/json/validator/model.json +3 -0
- data/lib/occi/core/parsers/json/validator/occi-schema.json +277 -0
- data/lib/occi/core/parsers/json/validator/resource-collection.json +3 -0
- data/lib/occi/core/parsers/json/validator/resource.json +3 -0
- data/lib/occi/core/parsers/json/validator.rb +87 -0
- data/lib/occi/core/parsers/json_parser.rb +128 -0
- data/lib/occi/core/parsers/text/.gitkeep +0 -0
- data/lib/occi/core/parsers/text/category.rb +183 -0
- data/lib/occi/core/parsers/text/constants.rb +89 -0
- data/lib/occi/core/parsers/text/entity.rb +257 -0
- data/lib/occi/core/parsers/text/location.rb +48 -0
- data/lib/occi/core/parsers/text_parser.rb +257 -0
- data/lib/occi/core/parsers.rb +18 -0
- data/lib/occi/core/renderer_factory.rb +213 -0
- data/lib/occi/core/renderers/.gitkeep +0 -0
- data/lib/occi/core/renderers/base_renderer.rb +81 -0
- data/lib/occi/core/renderers/json/.gitkeep +0 -0
- data/lib/occi/core/renderers/json/action_instance.rb +24 -0
- data/lib/occi/core/renderers/json/attributes.rb +50 -0
- data/lib/occi/core/renderers/json/base.rb +46 -0
- data/lib/occi/core/renderers/json/category.rb +85 -0
- data/lib/occi/core/renderers/json/collection.rb +52 -0
- data/lib/occi/core/renderers/json/instance.rb +39 -0
- data/lib/occi/core/renderers/json/link.rb +48 -0
- data/lib/occi/core/renderers/json/model.rb +26 -0
- data/lib/occi/core/renderers/json/resource.rb +27 -0
- data/lib/occi/core/renderers/json_renderer.rb +72 -0
- data/lib/occi/core/renderers/text/.gitkeep +0 -0
- data/lib/occi/core/renderers/text/action_instance.rb +36 -0
- data/lib/occi/core/renderers/text/attributes.rb +87 -0
- data/lib/occi/core/renderers/text/base.rb +82 -0
- data/lib/occi/core/renderers/text/category.rb +183 -0
- data/lib/occi/core/renderers/text/collection.rb +65 -0
- data/lib/occi/core/renderers/text/instance.rb +44 -0
- data/lib/occi/core/renderers/text/link.rb +40 -0
- data/lib/occi/core/renderers/text/model.rb +41 -0
- data/lib/occi/core/renderers/text/resource.rb +109 -0
- data/lib/occi/core/renderers/text_renderer.rb +72 -0
- data/lib/occi/core/renderers.rb +20 -0
- data/lib/occi/core/resource.rb +93 -57
- data/lib/occi/core/utils/.gitkeep +0 -0
- data/lib/occi/core/version.rb +17 -0
- data/lib/occi/core/warehouse/actions/.gitkeep +0 -0
- data/lib/occi/core/warehouse/actions/attributes/.gitkeep +0 -0
- data/lib/occi/core/warehouse/kinds/.gitkeep +0 -0
- data/lib/occi/core/warehouse/kinds/attributes/.gitkeep +0 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.id.yml +7 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.source.yml +7 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.summary.yml +7 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.target.yml +7 -0
- data/lib/occi/core/warehouse/kinds/attributes/occi.core.title.yml +7 -0
- data/lib/occi/core/warehouse/kinds/entity.yml +10 -0
- data/lib/occi/core/warehouse/kinds/link.yml +10 -0
- data/lib/occi/core/warehouse/kinds/resource.yml +9 -0
- data/lib/occi/core/warehouse/mixins/.gitkeep +0 -0
- data/lib/occi/core/warehouse/mixins/attributes/.gitkeep +0 -0
- data/lib/occi/core/warehouse.rb +115 -0
- data/lib/occi/core.rb +59 -23
- data/lib/occi/infrastructure/compute.rb +5 -122
- data/lib/occi/infrastructure/constants.rb +25 -0
- data/lib/occi/infrastructure/instance_builder.rb +24 -0
- data/lib/occi/infrastructure/mixins/.gitkeep +0 -0
- data/lib/occi/infrastructure/mixins/os_tpl.rb +19 -0
- data/lib/occi/infrastructure/mixins/resource_tpl.rb +19 -0
- data/lib/occi/infrastructure/mixins.rb +12 -0
- data/lib/occi/infrastructure/model.rb +27 -0
- data/lib/occi/infrastructure/network.rb +5 -104
- data/lib/occi/infrastructure/networkinterface.rb +5 -100
- data/lib/occi/infrastructure/storage.rb +5 -59
- data/lib/occi/infrastructure/storagelink.rb +5 -54
- data/lib/occi/infrastructure/version.rb +5 -0
- data/lib/occi/infrastructure/warehouse/actions/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/actions/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_restart.yml +12 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_save.yml +19 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_start.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_stop.yml +12 -0
- data/lib/occi/infrastructure/warehouse/actions/compute_suspend.yml +12 -0
- data/lib/occi/infrastructure/warehouse/actions/network_down.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/network_up.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/networkinterface_down.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/networkinterface_up.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_backup.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_offline.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_online.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_resize.yml +12 -0
- data/lib/occi/infrastructure/warehouse/actions/storage_snapshot.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storagelink_offline.yml +4 -0
- data/lib/occi/infrastructure/warehouse/actions/storagelink_online.yml +4 -0
- data/lib/occi/infrastructure/warehouse/kinds/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.architecture.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.cores.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.hostname.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.memory.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.speed.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.compute.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.network.label.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.network.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.network.vlan.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.networkinterface.interface.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.networkinterface.mac.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.networkinterface.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storage.size.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storage.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storagelink.deviceid.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storagelink.mountpoint.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/attributes/occi.storagelink.state.yml +7 -0
- data/lib/occi/infrastructure/warehouse/kinds/compute.yml +19 -0
- data/lib/occi/infrastructure/warehouse/kinds/network.yml +13 -0
- data/lib/occi/infrastructure/warehouse/kinds/networkinterface.yml +13 -0
- data/lib/occi/infrastructure/warehouse/kinds/storage.yml +15 -0
- data/lib/occi/infrastructure/warehouse/kinds/storagelink.yml +13 -0
- data/lib/occi/infrastructure/warehouse/mixins/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.network.address.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.network.allocation.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.network.gateway.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.networkinterface.address.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.networkinterface.allocation.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/attributes/occi.networkinterface.gateway.yml +7 -0
- data/lib/occi/infrastructure/warehouse/mixins/ipnetwork.yml +11 -0
- data/lib/occi/infrastructure/warehouse/mixins/ipnetworkinterface.yml +11 -0
- data/lib/occi/infrastructure/warehouse.rb +20 -0
- data/lib/occi/infrastructure-ext.rb +35 -0
- data/lib/occi/infrastructure.rb +34 -19
- data/lib/occi/infrastructure_ext/constants.rb +20 -0
- data/lib/occi/infrastructure_ext/instance_builder.rb +22 -0
- data/lib/occi/infrastructure_ext/ipreservation.rb +9 -0
- data/lib/occi/infrastructure_ext/mixins/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/mixins/availability_zone.rb +19 -0
- data/lib/occi/infrastructure_ext/mixins.rb +12 -0
- data/lib/occi/infrastructure_ext/model.rb +26 -0
- data/lib/occi/infrastructure_ext/securitygroup.rb +9 -0
- data/lib/occi/infrastructure_ext/securitygrouplink.rb +9 -0
- data/lib/occi/infrastructure_ext/version.rb +5 -0
- data/lib/occi/infrastructure_ext/warehouse/actions/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/actions/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/actions/ipreservation_down.yml +4 -0
- data/lib/occi/infrastructure_ext/warehouse/actions/ipreservation_up.yml +4 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.ipreservation.address.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.ipreservation.state.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.ipreservation.used.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.securitygroup.rules.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.securitygroup.state.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/attributes/occi.securitygrouplink.state.yml +7 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/ipreservation.yml +13 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/securitygroup.yml +9 -0
- data/lib/occi/infrastructure_ext/warehouse/kinds/securitygrouplink.yml +8 -0
- data/lib/occi/infrastructure_ext/warehouse/mixins/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse/mixins/attributes/.gitkeep +0 -0
- data/lib/occi/infrastructure_ext/warehouse.rb +20 -0
- data/lib/occi/monkey_island/boolean.rb +6 -0
- data/lib/occi/monkey_island/hash.rb +4 -0
- data/occi-core.gemspec +26 -26
- metadata +312 -243
- data/.yardopts +0 -1
- data/config/occi.yml +0 -4
- data/lib/occi/collection.rb +0 -265
- data/lib/occi/core/actions.rb +0 -21
- data/lib/occi/core/attributes.rb +0 -411
- data/lib/occi/core/categories.rb +0 -64
- data/lib/occi/core/dependencies.rb +0 -7
- data/lib/occi/core/entities.rb +0 -48
- data/lib/occi/core/kinds.rb +0 -22
- data/lib/occi/core/links.rb +0 -37
- data/lib/occi/core/mixins.rb +0 -37
- data/lib/occi/core/properties.rb +0 -108
- data/lib/occi/core/resources.rb +0 -14
- data/lib/occi/errors/attribute_definitions_converted_error.rb +0 -5
- data/lib/occi/errors/attribute_missing_error.rb +0 -5
- data/lib/occi/errors/attribute_name_invalid_error.rb +0 -5
- data/lib/occi/errors/attribute_not_defined_error.rb +0 -5
- data/lib/occi/errors/attribute_property_type_error.rb +0 -5
- data/lib/occi/errors/attribute_type_error.rb +0 -5
- data/lib/occi/errors/category_not_defined_error.rb +0 -5
- data/lib/occi/errors/kind_not_defined_error.rb +0 -5
- data/lib/occi/errors/parser_input_error.rb +0 -5
- data/lib/occi/errors/parser_type_error.rb +0 -5
- data/lib/occi/errors.rb +0 -1
- data/lib/occi/extensions/hashie.rb +0 -25
- data/lib/occi/helpers/comparators/action_instance.rb +0 -22
- data/lib/occi/helpers/comparators/attributes.rb +0 -22
- data/lib/occi/helpers/comparators/categories.rb +0 -22
- data/lib/occi/helpers/comparators/category.rb +0 -22
- data/lib/occi/helpers/comparators/collection.rb +0 -40
- data/lib/occi/helpers/comparators/entities.rb +0 -22
- data/lib/occi/helpers/comparators/entity.rb +0 -22
- data/lib/occi/helpers/comparators/properties.rb +0 -26
- data/lib/occi/helpers/comparators.rb +0 -1
- data/lib/occi/helpers/inspect.rb +0 -12
- data/lib/occi/infrastructure/network/ipnetwork.rb +0 -28
- data/lib/occi/infrastructure/networkinterface/ipnetworkinterface.rb +0 -28
- data/lib/occi/infrastructure/os_tpl.rb +0 -20
- data/lib/occi/infrastructure/resource_tpl.rb +0 -20
- data/lib/occi/log.rb +0 -71
- data/lib/occi/model.rb +0 -87
- data/lib/occi/parser/json.rb +0 -38
- data/lib/occi/parser/text/constants.rb +0 -89
- data/lib/occi/parser/text.rb +0 -280
- data/lib/occi/parser.rb +0 -144
- data/lib/occi/settings.rb +0 -10
- data/lib/occi/version.rb +0 -3
- data/lib/occi-core.rb +0 -53
- data/spec/helpers/to_plain.rb +0 -39
- data/spec/helpers/yaml_hash.rb +0 -32
- data/spec/occi/collection_samples/collection1.json +0 -1
- data/spec/occi/collection_samples/directory2/collection2.json +0 -1
- data/spec/occi/collection_spec.rb +0 -1003
- data/spec/occi/core/action_instance_spec.rb +0 -317
- data/spec/occi/core/action_spec.rb +0 -71
- data/spec/occi/core/attributes_spec.rb +0 -665
- data/spec/occi/core/categories_spec.rb +0 -28
- data/spec/occi/core/category_spec.rb +0 -216
- data/spec/occi/core/entities_spec.rb +0 -160
- data/spec/occi/core/entity_spec.rb +0 -374
- data/spec/occi/core/kind_spec.rb +0 -182
- data/spec/occi/core/link_spec.rb +0 -52
- data/spec/occi/core/links_spec.rb +0 -132
- data/spec/occi/core/mixin_spec.rb +0 -38
- data/spec/occi/core/mixins_spec.rb +0 -107
- data/spec/occi/core/properties_spec.rb +0 -171
- data/spec/occi/core/resource_spec.rb +0 -42
- data/spec/occi/core_spec.rb +0 -12
- data/spec/occi/infrastructure/compute_spec.rb +0 -229
- data/spec/occi/infrastructure/network_spec.rb +0 -96
- data/spec/occi/infrastructure/networkinterface_spec.rb +0 -96
- data/spec/occi/infrastructure/storage_spec.rb +0 -33
- data/spec/occi/infrastructure/storagelink_spec.rb +0 -45
- data/spec/occi/log_spec.rb +0 -117
- data/spec/occi/model_spec.rb +0 -256
- data/spec/occi/parser/json_samples/test.json +0 -49
- data/spec/occi/parser/text_samples/occi_categories.body_plain.expected +0 -2
- data/spec/occi/parser/text_samples/occi_categories.expected +0 -2
- data/spec/occi/parser/text_samples/occi_categories.parse_headers.expected +0 -2
- data/spec/occi/parser/text_samples/occi_categories.text +0 -2
- data/spec/occi/parser/text_samples/occi_compute_rocci_server.expected +0 -11
- data/spec/occi/parser/text_samples/occi_compute_rocci_server.text +0 -10
- data/spec/occi/parser/text_samples/occi_link_resource_instance.body_plain.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_resource_instance.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_resource_instance.parse.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_resource_instance.text +0 -7
- data/spec/occi/parser/text_samples/occi_link_simple.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_simple.text +0 -1
- data/spec/occi/parser/text_samples/occi_link_w_attributes.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_w_attributes.text +0 -7
- data/spec/occi/parser/text_samples/occi_link_w_category.expected +0 -7
- data/spec/occi/parser/text_samples/occi_link_w_category.text +0 -3
- data/spec/occi/parser/text_samples/occi_model_categories.expected +0 -3
- data/spec/occi/parser/text_samples/occi_model_rocci_server.text +0 -51
- data/spec/occi/parser/text_samples/occi_network_rocci_server.body_plain.expected +0 -11
- data/spec/occi/parser/text_samples/occi_network_rocci_server.expected +0 -11
- data/spec/occi/parser/text_samples/occi_network_rocci_server.resource.header.expected +0 -9
- data/spec/occi/parser/text_samples/occi_network_rocci_server.resource.rack.expected +0 -9
- data/spec/occi/parser/text_samples/occi_network_rocci_server.text +0 -11
- data/spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.parse.expected +0 -15
- data/spec/occi/parser/text_samples/occi_resource_custom_class_w_attributes.text +0 -15
- data/spec/occi/parser/text_samples/occi_resource_w_attributes.text +0 -11
- data/spec/occi/parser/text_samples/occi_resource_w_inline_links.expected +0 -1
- data/spec/occi/parser/text_samples/occi_resource_w_inline_links.text +0 -16
- data/spec/occi/parser/text_samples/occi_resource_w_inline_links_only.text +0 -13
- data/spec/occi/parser/text_samples/occi_storage_rocci_server.expected +0 -9
- data/spec/occi/parser/text_samples/occi_storage_rocci_server.text +0 -9
- data/spec/occi/parser/text_spec.rb +0 -320
- data/spec/occi/parser_spec.rb +0 -259
- data/spec/occi-core_spec.rb +0 -31
- data/spec/spec_helper.rb +0 -18
data/lib/occi/core/categories.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Core
|
3
|
-
class Categories < Set
|
4
|
-
|
5
|
-
include Occi::Helpers::Inspect
|
6
|
-
include Occi::Helpers::Comparators::Categories
|
7
|
-
|
8
|
-
attr_accessor :model
|
9
|
-
|
10
|
-
def initialize(categories=[])
|
11
|
-
categories.collect! { |category| convert category } if categories
|
12
|
-
super categories
|
13
|
-
end
|
14
|
-
|
15
|
-
def <<(category)
|
16
|
-
category = convert(category)
|
17
|
-
category.model = @model if @model && !category.kind_of?(String)
|
18
|
-
|
19
|
-
super(category)
|
20
|
-
end
|
21
|
-
|
22
|
-
def join(separator)
|
23
|
-
self.to_a.join(separator)
|
24
|
-
end
|
25
|
-
|
26
|
-
# Returns a Set with all categories related to the specified category
|
27
|
-
#
|
28
|
-
# @param [Occi::Core::Category] category
|
29
|
-
# @return [Occi::Core::Categories]
|
30
|
-
def get_related_to(category)
|
31
|
-
self.class.new select { |cat| cat.related_to? category }
|
32
|
-
end
|
33
|
-
|
34
|
-
# @param [Occi::Model] model
|
35
|
-
# @return [Occi::Model]
|
36
|
-
def model=(model)
|
37
|
-
@model = model
|
38
|
-
each { |category| category.model = model }
|
39
|
-
collect! { |category| model.get_by_id(category.to_s) || category }
|
40
|
-
end
|
41
|
-
|
42
|
-
# @param [Hash] options
|
43
|
-
# @return [Hashie::Mash] json representation
|
44
|
-
def as_json(options={})
|
45
|
-
self.to_a.as_json
|
46
|
-
end
|
47
|
-
|
48
|
-
def check
|
49
|
-
each { |category| category.check }
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def convert(category)
|
55
|
-
if category.kind_of?(String) && @model
|
56
|
-
@model.get_by_id(category) || category
|
57
|
-
else
|
58
|
-
category
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/lib/occi/core/entities.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Core
|
3
|
-
class Entities < Set
|
4
|
-
|
5
|
-
include Occi::Helpers::Inspect
|
6
|
-
include Occi::Helpers::Comparators::Entities
|
7
|
-
|
8
|
-
attr_accessor :model
|
9
|
-
|
10
|
-
def initialize(entities=[])
|
11
|
-
entities.to_a.each { |entity| entity.model = @model } if @model
|
12
|
-
super entities
|
13
|
-
end
|
14
|
-
|
15
|
-
def join(separator)
|
16
|
-
self.to_a.join(separator)
|
17
|
-
end
|
18
|
-
|
19
|
-
def model=(model)
|
20
|
-
@model = model
|
21
|
-
each { |entity| entity.model = model }
|
22
|
-
end
|
23
|
-
|
24
|
-
def check(set_defaults = false)
|
25
|
-
each { |entity| entity.check(set_defaults) }
|
26
|
-
end
|
27
|
-
|
28
|
-
def create(*args)
|
29
|
-
entity = Occi::Core::Entity.new(*args)
|
30
|
-
entity.model = @model if @model
|
31
|
-
self << entity
|
32
|
-
entity
|
33
|
-
end
|
34
|
-
|
35
|
-
def <<(entity)
|
36
|
-
entity.model = @model if @model
|
37
|
-
super entity
|
38
|
-
end
|
39
|
-
|
40
|
-
# @param [Hash] options
|
41
|
-
# @return [Hashie::Mash] json representation
|
42
|
-
def as_json(options={ })
|
43
|
-
self.to_a.as_json
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
data/lib/occi/core/kinds.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Core
|
3
|
-
class Kinds < Occi::Core::Categories
|
4
|
-
|
5
|
-
private
|
6
|
-
|
7
|
-
def convert(category)
|
8
|
-
category = super category
|
9
|
-
|
10
|
-
if category.kind_of? String
|
11
|
-
scheme, term = category.split '#'
|
12
|
-
scheme << '#'
|
13
|
-
|
14
|
-
klass = Occi::Core::Kind.get_class scheme, term, [Occi::Core::Kind.new]
|
15
|
-
category = klass.kind
|
16
|
-
end
|
17
|
-
category
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/occi/core/links.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Core
|
3
|
-
class Links < Occi::Core::Entities
|
4
|
-
|
5
|
-
def initialize(links=[])
|
6
|
-
links.collect! {|link| convert link} if links
|
7
|
-
super links
|
8
|
-
end
|
9
|
-
|
10
|
-
def <<(link)
|
11
|
-
super convert link
|
12
|
-
end
|
13
|
-
|
14
|
-
def create(*args)
|
15
|
-
link = Occi::Core::Link.new(*args)
|
16
|
-
link.model = @model if @model
|
17
|
-
self << link
|
18
|
-
|
19
|
-
link
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def convert(link)
|
25
|
-
if link.kind_of? String
|
26
|
-
link_location = link
|
27
|
-
link = Occi::Core::Link.new
|
28
|
-
link.id = link_location.split('/').last
|
29
|
-
link.location = link_location
|
30
|
-
end
|
31
|
-
|
32
|
-
link
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/lib/occi/core/mixins.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Core
|
3
|
-
class Mixins < Occi::Core::Categories
|
4
|
-
|
5
|
-
attr_accessor :entity
|
6
|
-
|
7
|
-
def entity=(entity)
|
8
|
-
self.each { |mixin| entity.attributes.merge! mixin.attributes.convert }
|
9
|
-
@entity = entity
|
10
|
-
end
|
11
|
-
|
12
|
-
def remove(mixin)
|
13
|
-
mixin = convert mixin
|
14
|
-
@entity.attributes.remove mixin.attributes if @entity
|
15
|
-
self.delete mixin
|
16
|
-
end
|
17
|
-
|
18
|
-
def <<(mixin)
|
19
|
-
mixin = convert mixin
|
20
|
-
@entity.attributes.merge! mixin.attributes.convert if @entity
|
21
|
-
super mixin
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
# TODO: fix mixin conversion
|
27
|
-
def convert(mixin)
|
28
|
-
mixin = super mixin
|
29
|
-
if mixin.kind_of? String
|
30
|
-
mixin = Occi::Core::Mixin.new *mixin.split('#')
|
31
|
-
end
|
32
|
-
mixin
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/lib/occi/core/properties.rb
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Core
|
3
|
-
class Properties
|
4
|
-
|
5
|
-
include Occi::Helpers::Inspect
|
6
|
-
include Occi::Helpers::Comparators::Properties
|
7
|
-
|
8
|
-
PROPERTY_KEYS = [:type, :required, :mutable, :default, :description, :pattern]
|
9
|
-
attr_accessor :required, :mutable, :default, :description, :pattern
|
10
|
-
attr_reader :type
|
11
|
-
alias_method :required?, :required
|
12
|
-
alias_method :mutable?, :mutable
|
13
|
-
|
14
|
-
# Types supported in properties, and their mapping to Ruby Classes
|
15
|
-
SUPPORTED_TYPES = {}
|
16
|
-
SUPPORTED_TYPES["string"] = [ String ]
|
17
|
-
SUPPORTED_TYPES["number"] = [ Numeric ]
|
18
|
-
SUPPORTED_TYPES["boolean"] = [ TrueClass, FalseClass ]
|
19
|
-
|
20
|
-
# @param source_hash [Hash]
|
21
|
-
def initialize(source_hash = {})
|
22
|
-
raise ArgumentError, 'Source_hash must be initialized from a hash-like structure!' unless source_hash.kind_of?(Hash)
|
23
|
-
raise ArgumentError, 'Source_hash must not be a Hashie::Mash instance!' if source_hash.kind_of?(Hashie::Mash)
|
24
|
-
source_hash = Occi::Core::Properties.normalize_props(source_hash)
|
25
|
-
|
26
|
-
self.type = source_hash[:type] || 'string'
|
27
|
-
self.required = source_hash[:required].nil? ? false : source_hash[:required]
|
28
|
-
self.mutable = source_hash[:mutable].nil? ? true : source_hash[:mutable]
|
29
|
-
self.pattern = source_hash[:pattern] || '.*'
|
30
|
-
self.description = source_hash[:description]
|
31
|
-
self.default = source_hash[:default]
|
32
|
-
end
|
33
|
-
|
34
|
-
# @param type [String] Requested attribute type
|
35
|
-
def type=(type)
|
36
|
-
raise Occi::Errors::AttributePropertyTypeError,
|
37
|
-
"Type \"#{type}\" unsupported in properties. Supported " \
|
38
|
-
"types are: #{Properties.supported_type_names}." unless SUPPORTED_TYPES.key?(type)
|
39
|
-
@type = type
|
40
|
-
end
|
41
|
-
|
42
|
-
# @param value [Object] Object whose class will be checked against definition
|
43
|
-
def check_value_for_type(value, key_name = nil)
|
44
|
-
raise Occi::Errors::AttributeTypeError,
|
45
|
-
"Attribute value #{value} for #{key_name.inspect} is class #{value.class.name}. " \
|
46
|
-
"It does not match attribute property type #{@type}" unless SUPPORTED_TYPES[@type].any? { |klasse| value.kind_of?(klasse) }
|
47
|
-
end
|
48
|
-
|
49
|
-
def to_hash
|
50
|
-
as_json
|
51
|
-
end
|
52
|
-
|
53
|
-
def to_json(*a)
|
54
|
-
as_json(*a).to_json(*a)
|
55
|
-
end
|
56
|
-
|
57
|
-
def as_json(options={})
|
58
|
-
hash = {}
|
59
|
-
|
60
|
-
hash["default"] = self.default if self.default
|
61
|
-
hash["type"] = self.type if self.type
|
62
|
-
hash["required"] = self.required unless self.required.nil?
|
63
|
-
hash["mutable"] = self.mutable unless self.mutable.nil?
|
64
|
-
hash["pattern"] = self.pattern if self.pattern
|
65
|
-
hash["description"] = self.description if self.description
|
66
|
-
|
67
|
-
hash
|
68
|
-
end
|
69
|
-
|
70
|
-
# @return [Bool] Indicating whether this set of properties is "empty", i.e. no attributes are set
|
71
|
-
def empty?
|
72
|
-
as_json.empty?
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.normalize_props(hash)
|
76
|
-
props = {}
|
77
|
-
|
78
|
-
PROPERTY_KEYS.each do |key|
|
79
|
-
found = hash.keys.select { |k| k.to_s.downcase.to_sym == key }.first
|
80
|
-
props[key] = hash[found] if found
|
81
|
-
end
|
82
|
-
|
83
|
-
props
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.contains_props?(hash)
|
87
|
-
# Not a hash == doesn't contain Properties
|
88
|
-
return false unless hash.kind_of? Hash
|
89
|
-
hash = normalize_props(hash)
|
90
|
-
|
91
|
-
# Are there any Property keys?
|
92
|
-
return false if hash.empty?
|
93
|
-
|
94
|
-
# Do all Property keys point to simple values?
|
95
|
-
complx_keys = hash.keys.select { |k| hash[k].kind_of?(Hash) }
|
96
|
-
return false unless complx_keys.empty?
|
97
|
-
|
98
|
-
true
|
99
|
-
end
|
100
|
-
|
101
|
-
private
|
102
|
-
|
103
|
-
def self.supported_type_names()
|
104
|
-
SUPPORTED_TYPES.keys.join(', ')
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
data/lib/occi/core/resources.rb
DELETED
data/lib/occi/errors.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Dir[File.join(File.dirname(__FILE__), 'errors', '*.rb')].each { |file| require file.gsub('.rb', '') }
|
@@ -1,25 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Monkeypatch for Hashie
|
3
|
-
module Hashie
|
4
|
-
class Hash
|
5
|
-
|
6
|
-
# Converts a mash back to a hash (with stringified keys)
|
7
|
-
def to_hash(options={})
|
8
|
-
out = {}
|
9
|
-
keys.each do |k|
|
10
|
-
if self[k].is_a?(Array)
|
11
|
-
k = options[:symbolize_keys] ? k.to_sym : k.to_s
|
12
|
-
out[k] ||= []
|
13
|
-
self[k].each do |array_object|
|
14
|
-
out[k] << (array_object.respond_to?(:to_hash) ? array_object.to_hash : array_object)
|
15
|
-
end
|
16
|
-
else
|
17
|
-
k = options[:symbolize_keys] ? k.to_sym : k.to_s
|
18
|
-
out[k] = self[k].respond_to?(:to_hash) ? self[k].to_hash : self[k]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
out
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Helpers
|
3
|
-
module Comparators
|
4
|
-
module ActionInstance
|
5
|
-
|
6
|
-
def ==(obj)
|
7
|
-
return false unless obj && obj.respond_to?(:action) && obj.respond_to?(:attributes)
|
8
|
-
(self.action == obj.action) && (self.attributes == obj.attributes)
|
9
|
-
end
|
10
|
-
|
11
|
-
def eql?(obj)
|
12
|
-
self == obj
|
13
|
-
end
|
14
|
-
|
15
|
-
def hash
|
16
|
-
[self.action, self.attributes].hash
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Helpers
|
3
|
-
module Comparators
|
4
|
-
module Attributes
|
5
|
-
|
6
|
-
def ==(obj)
|
7
|
-
return false unless obj && obj.respond_to?(:names)
|
8
|
-
self.names == obj.names
|
9
|
-
end
|
10
|
-
|
11
|
-
def eql?(obj)
|
12
|
-
self == obj
|
13
|
-
end
|
14
|
-
|
15
|
-
def hash
|
16
|
-
self.names.hash
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Helpers
|
3
|
-
module Comparators
|
4
|
-
module Categories
|
5
|
-
|
6
|
-
def ==(obj)
|
7
|
-
return false unless obj && obj.respond_to?(:to_a)
|
8
|
-
self.to_a == obj.to_a
|
9
|
-
end
|
10
|
-
|
11
|
-
def eql?(obj)
|
12
|
-
self == obj
|
13
|
-
end
|
14
|
-
|
15
|
-
def hash
|
16
|
-
self.to_a.hash
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Helpers
|
3
|
-
module Comparators
|
4
|
-
module Category
|
5
|
-
|
6
|
-
def ==(obj)
|
7
|
-
return false unless obj && obj.respond_to?(:type_identifier)
|
8
|
-
self.type_identifier == obj.type_identifier
|
9
|
-
end
|
10
|
-
|
11
|
-
def eql?(obj)
|
12
|
-
self == obj
|
13
|
-
end
|
14
|
-
|
15
|
-
def hash
|
16
|
-
self.type_identifier.hash
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Helpers
|
3
|
-
module Comparators
|
4
|
-
module Collection
|
5
|
-
|
6
|
-
REQUIRED_ACCESSORS = [:kinds, :mixins, :actions, :resources, :links, :action].freeze
|
7
|
-
|
8
|
-
def ==(obj)
|
9
|
-
return false unless obj && has_accessors?(obj)
|
10
|
-
contents_matches?(obj)
|
11
|
-
end
|
12
|
-
|
13
|
-
def eql?(obj)
|
14
|
-
self == obj
|
15
|
-
end
|
16
|
-
|
17
|
-
def hash
|
18
|
-
REQUIRED_ACCESSORS.collect { |accessor| self.send(accessor) }.hash
|
19
|
-
end
|
20
|
-
|
21
|
-
def has_accessors?(obj)
|
22
|
-
result = true
|
23
|
-
REQUIRED_ACCESSORS.each { |accessor| result = result && obj.respond_to?(accessor) }
|
24
|
-
|
25
|
-
result
|
26
|
-
end
|
27
|
-
private :has_accessors?
|
28
|
-
|
29
|
-
def contents_matches?(obj)
|
30
|
-
result = true
|
31
|
-
REQUIRED_ACCESSORS.each { |accessor| result = result && (self.send(accessor) == obj.send(accessor)) }
|
32
|
-
|
33
|
-
result
|
34
|
-
end
|
35
|
-
private :contents_matches?
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Helpers
|
3
|
-
module Comparators
|
4
|
-
module Entities
|
5
|
-
|
6
|
-
def ==(obj)
|
7
|
-
return false unless obj && obj.respond_to?(:to_a)
|
8
|
-
self.to_a == obj.to_a
|
9
|
-
end
|
10
|
-
|
11
|
-
def eql?(obj)
|
12
|
-
self == obj
|
13
|
-
end
|
14
|
-
|
15
|
-
def hash
|
16
|
-
self.to_a.hash
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Helpers
|
3
|
-
module Comparators
|
4
|
-
module Entity
|
5
|
-
|
6
|
-
def ==(obj)
|
7
|
-
return false unless obj && obj.respond_to?(:kind) && obj.respond_to?(:attributes)
|
8
|
-
(self.kind == obj.kind) && (self.attributes['occi.core.id'] == obj.attributes['occi.core.id'])
|
9
|
-
end
|
10
|
-
|
11
|
-
def eql?(obj)
|
12
|
-
self == obj
|
13
|
-
end
|
14
|
-
|
15
|
-
def hash
|
16
|
-
[self.kind, self.attributes['occi.core.id']].hash
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Helpers
|
3
|
-
module Comparators
|
4
|
-
module Properties
|
5
|
-
|
6
|
-
def ==(obj)
|
7
|
-
return false unless obj && obj.respond_to?(:instance_variables)
|
8
|
-
|
9
|
-
local_attrs = self.instance_variables.map { |ivar| self.instance_variable_get ivar }
|
10
|
-
remote_attrs = obj.instance_variables.map { |ivar| obj.instance_variable_get ivar }
|
11
|
-
|
12
|
-
local_attrs == remote_attrs
|
13
|
-
end
|
14
|
-
|
15
|
-
def eql?(obj)
|
16
|
-
self == obj
|
17
|
-
end
|
18
|
-
|
19
|
-
def hash
|
20
|
-
self.instance_variables.map { |ivar| self.instance_variable_get ivar }.hash
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
Dir[File.join(File.dirname(__FILE__), 'comparators', '*.rb')].each { |file| require file.gsub('.rb', '') }
|