sdl-ng 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/translations/en.yml +32 -32
- data/lib/sdl/base/service.rb +4 -0
- data/lib/sdl/base/type.rb +14 -2
- data/lib/sdl/ng/version.rb +1 -1
- data/lib/sdl/receivers/type_instance_receiver.rb +5 -1
- data/lib/sdl/receivers/type_receiver.rb +10 -1
- data/lib/sdl/types.rb +1 -1
- data/lib/sdl/types/sdl_datetime.rb +1 -1
- data/lib/sdl/types/sdl_description.rb +5 -1
- data/lib/sdl/types/sdl_duration.rb +1 -1
- data/lib/sdl/types/sdl_number.rb +2 -2
- data/lib/sdl/types/sdl_simple_type.rb +57 -0
- data/lib/sdl/types/sdl_string.rb +1 -1
- data/lib/sdl/types/sdl_url.rb +9 -1
- data/spec/fact_type_instance_definition_spec.rb +14 -14
- data/spec/shared_test_compendium.rb +4 -0
- metadata +3 -3
- data/lib/sdl/types/sdl_default_type.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed2ffb4ec0dbbbcb9215c77af53ea65ff29697f4
|
4
|
+
data.tar.gz: 123f3cf6588274e6605708bc2fc27c71004702c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e13f8fb585f8339390a6f82d339ce0daf8b3057467aa67ead071905af9bc125802746b8a984b10198b918cecc57b90e45f07f11099606e2dfd175289a87c0246
|
7
|
+
data.tar.gz: acc087d16fbf6ceb3380e80b6f118d24270c31beb2a0d1a7f757f087e32e07e4c637d3c4da562926d57944fc8daa9f7ec65b7ee3e998503a248a8352e93e96bd
|
@@ -2,11 +2,11 @@
|
|
2
2
|
en:
|
3
3
|
sdl:
|
4
4
|
fact:
|
5
|
-
add_on_repository:
|
6
|
-
audit_option:
|
7
|
-
bill:
|
8
|
-
charge_unit:
|
9
|
-
cloud_service_model:
|
5
|
+
add_on_repository: Service add-on repo
|
6
|
+
audit_option: Audit option
|
7
|
+
bill: Billing terms
|
8
|
+
charge_unit: Charge unit
|
9
|
+
cloud_service_model: Cloud service model
|
10
10
|
communication_protection: The communication with the service is protected
|
11
11
|
continuous_service_improvement: The service has continuous service improvement
|
12
12
|
means
|
@@ -101,54 +101,54 @@ en:
|
|
101
101
|
property:
|
102
102
|
fact:
|
103
103
|
add_on_repository:
|
104
|
-
number_of_add_ons:
|
105
|
-
url:
|
104
|
+
number_of_add_ons: Number of add-ons
|
105
|
+
url: Repository URL
|
106
106
|
audit_option:
|
107
|
-
audit_option:
|
107
|
+
audit_option: Audit option
|
108
108
|
bill:
|
109
|
-
billing_term:
|
110
|
-
payment_term:
|
109
|
+
billing_term: Billing terms
|
110
|
+
payment_term: Payment terms
|
111
111
|
charge_unit:
|
112
|
-
charge_unit:
|
112
|
+
charge_unit: Charge unit
|
113
113
|
cloud_service_model:
|
114
|
-
cloud_service_model:
|
114
|
+
cloud_service_model: Cloud service model
|
115
115
|
communication_protection:
|
116
|
-
communication_protection:
|
116
|
+
communication_protection: Protection means
|
117
117
|
continuous_service_improvement:
|
118
|
-
url:
|
118
|
+
url: Link
|
119
119
|
data_capability:
|
120
|
-
format:
|
121
|
-
operation:
|
120
|
+
format: Format
|
121
|
+
operation: Operation
|
122
122
|
data_encryption:
|
123
|
-
key_control:
|
123
|
+
key_control: Controlling party
|
124
124
|
data_location:
|
125
|
-
location:
|
125
|
+
location: Data location
|
126
126
|
documentation:
|
127
|
-
url:
|
127
|
+
url: Documentation URL
|
128
128
|
duration:
|
129
|
-
duration:
|
129
|
+
duration: Duration
|
130
130
|
establishing_year:
|
131
|
-
year:
|
131
|
+
year: Established in
|
132
132
|
feature:
|
133
|
-
description:
|
134
|
-
feature:
|
133
|
+
description: Description
|
134
|
+
feature: Name
|
135
135
|
interface_browser_interface:
|
136
|
-
compatible_browsers:
|
137
|
-
required_plugins:
|
136
|
+
compatible_browsers: Compatible to
|
137
|
+
required_plugins: Required plugins
|
138
138
|
maintenance_maintenance_window:
|
139
|
-
timespan:
|
139
|
+
timespan: Maintenance Window
|
140
140
|
name:
|
141
|
-
name:
|
141
|
+
name: Service name
|
142
142
|
payment_option:
|
143
|
-
payment_option:
|
143
|
+
payment_option: Payment option
|
144
144
|
service_category:
|
145
|
-
service_category:
|
145
|
+
service_category: Service category
|
146
146
|
service_level_agreement_public_service_level_agreement:
|
147
|
-
url:
|
147
|
+
url: SLA URL
|
148
148
|
service_tag:
|
149
|
-
service_tag:
|
149
|
+
service_tag: Tag
|
150
150
|
status_page:
|
151
|
-
url:
|
151
|
+
url: Service status URL
|
152
152
|
type:
|
153
153
|
browser:
|
154
154
|
browser_name: The name of the browser
|
data/lib/sdl/base/service.rb
CHANGED
data/lib/sdl/base/type.rb
CHANGED
@@ -8,7 +8,7 @@ module SDL
|
|
8
8
|
attr_accessor :namespace
|
9
9
|
|
10
10
|
##
|
11
|
-
# The local name of the
|
11
|
+
# The local name of the type, e.g. "Name" or "ServiceInterface". Defaults to the name of the class.
|
12
12
|
#
|
13
13
|
# The ServiceCompendium#register_classes_globally method makes this class accessible by a constant of this name
|
14
14
|
@local_name
|
@@ -33,6 +33,18 @@ module SDL
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
def propertyless?(including_super = false)
|
37
|
+
properties(including_super).count == 0
|
38
|
+
end
|
39
|
+
|
40
|
+
def single_property?(including_super = false)
|
41
|
+
properties(including_super).count == 1
|
42
|
+
end
|
43
|
+
|
44
|
+
def multi_property?(including_super = true)
|
45
|
+
properties(including_super).count > 1
|
46
|
+
end
|
47
|
+
|
36
48
|
def is_sub?
|
37
49
|
not [SDL::Base::Type, SDL::Base::Fact].include? superclass
|
38
50
|
end
|
@@ -49,7 +61,7 @@ module SDL
|
|
49
61
|
naming_property = self.class.properties(true).find {|p| p.name.eql?(self.class.to_s.underscore) }
|
50
62
|
|
51
63
|
if(naming_property)
|
52
|
-
instance_variable_get
|
64
|
+
instance_variable_get("@#{naming_property.name.to_sym}").to_s
|
53
65
|
else
|
54
66
|
self.class.to_s
|
55
67
|
end
|
data/lib/sdl/ng/version.rb
CHANGED
@@ -24,7 +24,11 @@ module SDL
|
|
24
24
|
value = compendium.type_instances[property.type][value] || raise("Could not find instance :#{value.to_s} in predefined #{property.type.name} types")
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
begin
|
28
|
+
instance.send "#{property.name}=", value
|
29
|
+
rescue RuntimeError => e
|
30
|
+
raise RuntimeError, "Cannot set property '#{property.name}' of Type #{@instance.class.name}: #{e}", e.backtrace
|
31
|
+
end
|
28
32
|
end
|
29
33
|
else
|
30
34
|
# Multi-valued properties are added to by their singular name
|
@@ -69,7 +69,16 @@ module SDL
|
|
69
69
|
def add_property(sym, type, multi)
|
70
70
|
unless multi
|
71
71
|
@klass.class_eval do
|
72
|
-
|
72
|
+
attr_reader sym
|
73
|
+
|
74
|
+
# Setter
|
75
|
+
define_method "#{sym}=" do |value|
|
76
|
+
if type < SDL::Types::SDLSimpleType
|
77
|
+
instance_variable_set "@#{sym}".to_s, type.new(value)
|
78
|
+
else
|
79
|
+
instance_variable_set "@#{sym}".to_s, value
|
80
|
+
end
|
81
|
+
end
|
73
82
|
end
|
74
83
|
else
|
75
84
|
# Define accessor method for lists
|
data/lib/sdl/types.rb
CHANGED
data/lib/sdl/types/sdl_number.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
##
|
2
|
+
# Base SDL type.
|
3
|
+
#
|
4
|
+
# All types share a common constructor, which delegates part of its functionality.
|
5
|
+
class SDL::Types::SDLSimpleType
|
6
|
+
include SDL::Types::SDLType
|
7
|
+
|
8
|
+
# The SDL value type value, possibly converted to the wrapped ruby type, e.g., an URI object created from an
|
9
|
+
# "http://" String
|
10
|
+
attr_reader :value
|
11
|
+
|
12
|
+
# The raw value, with which this type was instatiated
|
13
|
+
attr_reader :raw_value
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new instance of an SDL type.
|
17
|
+
#
|
18
|
+
# Invokes +from_+ methods of subtypes, if +value+ is not subtype of the wrapped Ruby type.
|
19
|
+
#
|
20
|
+
# @param[Object] value
|
21
|
+
# The instance value. Unless the value class is a subclass of the wrapped Ruby class,
|
22
|
+
# perform conversion by invoking +from_#{classname}+, e.g. +from_string+ or +from_integer+.
|
23
|
+
#
|
24
|
+
# Subclasses are expected to implement this conversion function.
|
25
|
+
def initialize(value)
|
26
|
+
@raw_value = value
|
27
|
+
|
28
|
+
if value.class <= self.class.wrapped_type
|
29
|
+
@value = value
|
30
|
+
else
|
31
|
+
begin
|
32
|
+
send(conversion_method_name(value), value)
|
33
|
+
rescue NoMethodError
|
34
|
+
raise "Cannot create instance of #{self.class.name} with a #{value.class.name} value. Please implement #{self.class.name}##{conversion_method_name(value)}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def ==(value)
|
40
|
+
@value == value
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
@value.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Designates this SDLType to be a default type, i.e., to be loaded by all ServiceCompendiums automatically
|
49
|
+
def self.inherited(subclass)
|
50
|
+
SDL::Base::ServiceCompendium.default_sdltypes << subclass
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
def conversion_method_name(value)
|
55
|
+
value.class.name.demodulize.camelize.downcase
|
56
|
+
end
|
57
|
+
end
|
data/lib/sdl/types/sdl_string.rb
CHANGED
data/lib/sdl/types/sdl_url.rb
CHANGED
@@ -2,11 +2,19 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module SDL
|
4
4
|
module Types
|
5
|
-
class SDLUrl <
|
5
|
+
class SDLUrl < SDLSimpleType
|
6
6
|
include SDLType
|
7
7
|
|
8
8
|
wraps URI
|
9
9
|
codes :uri, :url
|
10
|
+
|
11
|
+
def from_string(string_value)
|
12
|
+
begin
|
13
|
+
URI.parse string_value
|
14
|
+
rescue URI::InvalidURIError
|
15
|
+
throw "Invalid URI: #{string_value}"
|
16
|
+
end
|
17
|
+
end
|
10
18
|
end
|
11
19
|
end
|
12
20
|
end
|
@@ -125,23 +125,23 @@ describe 'Doing type instance definition' do
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
expect(compendium.services[:multi_service].facts[0].a).to
|
129
|
-
expect(compendium.services[:multi_service].facts[0].b).to
|
130
|
-
expect(compendium.services[:multi_service].facts[0].c).to eq
|
131
|
-
expect(compendium.services[:multi_service].facts[0].d).to
|
128
|
+
expect(compendium.services[:multi_service].facts[0].a).to eq '1'
|
129
|
+
expect(compendium.services[:multi_service].facts[0].b).to eq '2'
|
130
|
+
expect(compendium.services[:multi_service].facts[0].c).to eq nil
|
131
|
+
expect(compendium.services[:multi_service].facts[0].d).to eq '3'
|
132
132
|
expect(compendium.services[:multi_service].facts[0].e).to eq(nil)
|
133
133
|
|
134
|
-
expect(compendium.services[:multi_service].facts[1].multis[0].b).to
|
135
|
-
expect(compendium.services[:multi_service].facts[1].multis[1].e).to
|
134
|
+
expect(compendium.services[:multi_service].facts[1].multis[0].b).to eq '2'
|
135
|
+
expect(compendium.services[:multi_service].facts[1].multis[1].e).to eq '5'
|
136
136
|
end
|
137
137
|
|
138
|
-
context 'the #to_s method of a
|
138
|
+
context 'the #to_s method of a fact' do
|
139
139
|
it 'gives out the #to_s output of a same-named property than the class' do
|
140
|
-
compendium.service :
|
141
|
-
|
140
|
+
compendium.service :named_service do
|
141
|
+
has_name 'My name'
|
142
142
|
end
|
143
143
|
|
144
|
-
expect(compendium.services[:
|
144
|
+
expect(compendium.services[:named_service].facts[0].to_s).to eq 'My name'
|
145
145
|
end
|
146
146
|
|
147
147
|
it 'gives out the Fact class local name when no same-named property than the class exists' do
|
@@ -149,7 +149,7 @@ describe 'Doing type instance definition' do
|
|
149
149
|
has_color :blue
|
150
150
|
end
|
151
151
|
|
152
|
-
expect(compendium.services[:blue_service].facts[0].to_s).to eq
|
152
|
+
expect(compendium.services[:blue_service].facts[0].to_s).to eq 'Color'
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
@@ -171,8 +171,8 @@ describe 'Doing type instance definition' do
|
|
171
171
|
|
172
172
|
expect(compendium.services[:favourite_service].facts[0].favourites[0].color).to eq(compendium.type_instances[Color][:red])
|
173
173
|
expect(compendium.services[:favourite_service].facts[0].favourites[1].color).to eq(compendium.type_instances[Color][:green])
|
174
|
-
expect(compendium.services[:favourite_service].facts[0].favourites[0].rating).to eq
|
175
|
-
expect(compendium.services[:favourite_service].facts[0].favourites[1].rating).to eq
|
174
|
+
expect(compendium.services[:favourite_service].facts[0].favourites[0].rating).to eq 5
|
175
|
+
expect(compendium.services[:favourite_service].facts[0].favourites[1].rating).to eq 10
|
176
176
|
end
|
177
177
|
|
178
178
|
it 'returns the values of all properties by calling #property_values on a type' do
|
@@ -183,6 +183,6 @@ describe 'Doing type instance definition' do
|
|
183
183
|
property_values = compendium.services[:imaginative_service].facts[0].property_values
|
184
184
|
|
185
185
|
expect(property_values[property_values.keys[0]]).to eq(compendium.type_instances[Color][:yellow])
|
186
|
-
expect(property_values[property_values.keys[1]]).to eq
|
186
|
+
expect(property_values[property_values.keys[1]]).to eq 'Yellow'
|
187
187
|
end
|
188
188
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdl-ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Slawik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -237,10 +237,10 @@ files:
|
|
237
237
|
- lib/sdl/translations/en.yml
|
238
238
|
- lib/sdl/types.rb
|
239
239
|
- lib/sdl/types/sdl_datetime.rb
|
240
|
-
- lib/sdl/types/sdl_default_type.rb
|
241
240
|
- lib/sdl/types/sdl_description.rb
|
242
241
|
- lib/sdl/types/sdl_duration.rb
|
243
242
|
- lib/sdl/types/sdl_number.rb
|
243
|
+
- lib/sdl/types/sdl_simple_type.rb
|
244
244
|
- lib/sdl/types/sdl_string.rb
|
245
245
|
- lib/sdl/types/sdl_type.rb
|
246
246
|
- lib/sdl/types/sdl_url.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module SDL
|
2
|
-
module Types
|
3
|
-
class SDLDefaultType
|
4
|
-
include SDLType
|
5
|
-
|
6
|
-
##
|
7
|
-
# Designates this SDLType to be a default type, i.e., to be loaded by all ServiceCompendiums automatically
|
8
|
-
def self.inherited(subclass)
|
9
|
-
SDL::Base::ServiceCompendium.default_sdltypes << subclass
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|