sdl-ng 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.simplecov +7 -0
- data/bin/process_service_descriptions +35 -15
- data/lib/sdl/base/default_uri_mapper.rb +7 -3
- data/lib/sdl/base/fact.rb +4 -0
- data/lib/sdl/base/type.rb +6 -0
- data/lib/sdl/exporters.rb +0 -1
- data/lib/sdl/exporters/xml_mapping.rb +0 -4
- data/lib/sdl/exporters/xsd_schema_exporter.rb +16 -3
- data/lib/sdl/ng/version.rb +1 -1
- data/lib/sdl/receivers/service_receiver.rb +2 -0
- data/lib/sdl/receivers/type_instance_receiver.rb +31 -26
- data/lib/sdl/receivers/type_receiver.rb +4 -0
- data/lib/sdl/translations/en.yml +3 -1
- data/lib/sdl/types/sdl_description.rb +3 -1
- data/lib/sdl/util/documentation.rb +1 -1
- data/lib/sdl/util/nokogiri.rb +22 -17
- data/sdl-ng.gemspec +2 -1
- data/spec/bin_spec.rb +5 -6
- data/spec/documentation_spec.rb +13 -5
- data/spec/exporter_spec.rb +82 -0
- data/spec/fact_type_instance_definition_spec.rb +153 -3
- data/spec/nokogiri_spec.rb +54 -0
- data/spec/property_definitions_spec.rb +3 -1
- data/spec/service_compendium_spec.rb +1 -1
- data/spec/service_definition_spec.rb +33 -11
- data/spec/shared_test_compendium.rb +28 -0
- data/spec/shared_test_html.html +12 -0
- data/spec/shared_test_html.rb +11 -0
- data/spec/simple_types_spec.rb +55 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/uri_mapping_spec.rb +76 -61
- metadata +28 -4
- data/lib/sdl/exporters/markdown_service_exporter.rb +0 -27
@@ -72,6 +72,34 @@ shared_context 'the default compendium' do
|
|
72
72
|
has_color :red
|
73
73
|
end
|
74
74
|
|
75
|
+
compendium.service :complex_service do
|
76
|
+
name 'Complex Service'
|
77
|
+
|
78
|
+
has_multicolor do
|
79
|
+
color :red
|
80
|
+
color :green
|
81
|
+
color :blue
|
82
|
+
color :yellow
|
83
|
+
color :text
|
84
|
+
end
|
85
|
+
|
86
|
+
has_favourite_colors do
|
87
|
+
favourite do
|
88
|
+
color :blue
|
89
|
+
rating 5
|
90
|
+
|
91
|
+
annotation 'Mathias'
|
92
|
+
end
|
93
|
+
|
94
|
+
favourite do
|
95
|
+
color :green
|
96
|
+
rating 10
|
97
|
+
|
98
|
+
annotation 'Sabrina'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
75
103
|
compendium
|
76
104
|
end
|
77
105
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Example Page</title>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<h1>Test Page</h1>
|
8
|
+
<p>First test paragraph</p>
|
9
|
+
<p>Second test paragraph: <a href="/test">Testlink</a></p>
|
10
|
+
<p>Third test paragraph: <a href='::#::'>Invalid link</a></p>
|
11
|
+
</body>
|
12
|
+
</html>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
require_relative 'shared_test_html'
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
describe 'The simple types' do
|
7
|
+
include_context 'the example HTML'
|
8
|
+
|
9
|
+
context 'The SDLDescription type' do
|
10
|
+
it 'is empty if created from nil' do
|
11
|
+
type = SDL::Types::SDLDescription.new nil
|
12
|
+
|
13
|
+
expect(type).to eq ''
|
14
|
+
expect(type.to_html).to eq ''
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'contains squished content from Nokogiri XML Element' do
|
18
|
+
expect(SDL::Types::SDLDescription.new(example_nokogiri_doc.search('p')[0])).to eq 'First test paragraph'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'has a method #to_html, which returns HTML when created from Nokogiri XML Element' do
|
22
|
+
expect(SDL::Types::SDLDescription.new(example_nokogiri_doc.search('p')[0]).to_html).to eq '<p>First test paragraph</p>'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'contains a string and returns it by #to_html' do
|
26
|
+
expect(SDL::Types::SDLDescription.new('ABC').to_html).to eq 'ABC'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'raises an error, if #to_html is called with an unsupported object type' do
|
30
|
+
description = SDL::Types::SDLDescription.new ('ABC')
|
31
|
+
|
32
|
+
description.instance_eval do
|
33
|
+
@raw_value = Object.new
|
34
|
+
end
|
35
|
+
|
36
|
+
expect {
|
37
|
+
description.to_html
|
38
|
+
}.to raise_exception
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'The SDLUrl type' do
|
43
|
+
it 'parses correct URLs' do
|
44
|
+
type_instance = SDL::Types::SDLUrl.new('http://www.open-service-compendium.org')
|
45
|
+
|
46
|
+
expect(type_instance.value.host).to eq 'www.open-service-compendium.org'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'raises an error with invalid URLs' do
|
50
|
+
expect {
|
51
|
+
SDL::Types::SDLUrl.new('://')
|
52
|
+
}.to raise_exception
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/uri_mapping_spec.rb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
-
require_relative '../lib/sdl'
|
2
1
|
require_relative 'spec_helper'
|
3
2
|
require_relative 'shared_test_compendium'
|
4
3
|
|
5
4
|
require 'rspec'
|
6
5
|
|
7
6
|
shared_examples_for 'a group of URI mapped objects' do
|
7
|
+
module CustomURIMapper
|
8
|
+
def self.uri(object)
|
9
|
+
'www.example.org'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
let :custom_host do
|
14
|
+
'www.example.org'
|
15
|
+
end
|
16
|
+
|
8
17
|
it 'has valid URIs' do
|
9
18
|
expect do
|
10
19
|
subject.each do |object|
|
@@ -14,6 +23,64 @@ shared_examples_for 'a group of URI mapped objects' do
|
|
14
23
|
end
|
15
24
|
end.to_not raise_exception
|
16
25
|
end
|
26
|
+
|
27
|
+
context 'with an own URI mapper' do
|
28
|
+
it 'should use class#@uri_mapper if provided' do
|
29
|
+
subject.each do |resource|
|
30
|
+
resource.class.class_eval do
|
31
|
+
@uri_mapper = CustomURIMapper
|
32
|
+
end
|
33
|
+
|
34
|
+
expect(resource.uri).to eq custom_host
|
35
|
+
|
36
|
+
resource.class.class_eval do
|
37
|
+
@uri_mapper = nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should use #uri_mapper if provided' do
|
43
|
+
subject.each do |resource|
|
44
|
+
def resource.uri_mapper
|
45
|
+
CustomURIMapper
|
46
|
+
end
|
47
|
+
|
48
|
+
expect(resource.uri).to eq custom_host
|
49
|
+
|
50
|
+
resource.instance_eval do
|
51
|
+
undef uri_mapper
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should use class.uri_mapper if provided' do
|
57
|
+
subject.each do |resource|
|
58
|
+
resource.class.class_eval do
|
59
|
+
def self.uri_mapper
|
60
|
+
CustomURIMapper
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
expect(resource.uri).to eq custom_host
|
65
|
+
|
66
|
+
resource.class.class_eval do
|
67
|
+
class << self
|
68
|
+
undef uri_mapper
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should use @uri_mapper if provided' do
|
75
|
+
subject.each do |resource|
|
76
|
+
resource.instance_variable_set :@uri_mapper, CustomURIMapper
|
77
|
+
|
78
|
+
expect(resource.uri).to eq custom_host
|
79
|
+
|
80
|
+
resource.instance_variable_set :@uri_mapper, nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
17
84
|
end
|
18
85
|
|
19
86
|
describe 'The mapping of URIs' do
|
@@ -27,7 +94,7 @@ describe 'The mapping of URIs' do
|
|
27
94
|
'All services' => lambda { compendium.services.values },
|
28
95
|
'All fact instances' => lambda { compendium.services.values.map(&:facts).flatten },
|
29
96
|
'All fact classes' => lambda { compendium.fact_classes },
|
30
|
-
'All type instances' => lambda {
|
97
|
+
'All type instances' => lambda { ObjectSpace.each_object(SDL::Base::Type) },
|
31
98
|
'All type classes' => lambda { compendium.types }
|
32
99
|
}
|
33
100
|
|
@@ -39,67 +106,15 @@ describe 'The mapping of URIs' do
|
|
39
106
|
end
|
40
107
|
end
|
41
108
|
|
42
|
-
|
43
|
-
|
44
|
-
def self.uri(object)
|
45
|
-
'www.example.org'
|
46
|
-
end
|
47
|
-
end
|
109
|
+
it 'should raise error for any other object' do
|
110
|
+
resource = Object.new
|
48
111
|
|
49
|
-
|
50
|
-
|
112
|
+
resource.class_eval do
|
113
|
+
include SDL::Base::URIMappedResource
|
51
114
|
end
|
52
115
|
|
53
|
-
|
54
|
-
resource
|
55
|
-
|
56
|
-
resource.class_eval do
|
57
|
-
include SDL::Base::URIMappedResource
|
58
|
-
end
|
59
|
-
|
60
|
-
resource
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should use class#@uri_mapper if provided' do
|
64
|
-
resource = custom_mapped_resource
|
65
|
-
|
66
|
-
resource.class.class_eval do
|
67
|
-
@uri_mapper = CustomURIMapper
|
68
|
-
end
|
69
|
-
|
70
|
-
expect(resource.uri).to eq custom_host
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should use #uri_mapper if provided' do
|
74
|
-
resource = custom_mapped_resource
|
75
|
-
|
76
|
-
resource.class_eval do
|
77
|
-
def uri_mapper
|
78
|
-
CustomURIMapper
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
expect(resource.uri).to eq custom_host
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should use class.uri_mapper if provided' do
|
86
|
-
resource = custom_mapped_resource
|
87
|
-
|
88
|
-
resource.class.class_eval do
|
89
|
-
def self.uri_mapper
|
90
|
-
CustomURIMapper
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
expect(resource.uri).to eq custom_host
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'should use @uri_mapper if provided' do
|
98
|
-
resource = custom_mapped_resource
|
99
|
-
|
100
|
-
resource.instance_variable_set :@uri_mapper, CustomURIMapper
|
101
|
-
|
102
|
-
expect(resource.uri).to eq custom_host
|
103
|
-
end
|
116
|
+
expect {
|
117
|
+
resource.uri
|
118
|
+
}.to raise_exception
|
104
119
|
end
|
105
120
|
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Slawik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -53,7 +53,21 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rdf
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rdf-rdfxml
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ~>
|
@@ -188,6 +202,7 @@ extra_rdoc_files: []
|
|
188
202
|
files:
|
189
203
|
- .gitignore
|
190
204
|
- .rspec
|
205
|
+
- .simplecov
|
191
206
|
- .yard_redcarpet_ext
|
192
207
|
- Gemfile
|
193
208
|
- Gemfile.lock
|
@@ -222,7 +237,6 @@ files:
|
|
222
237
|
- lib/sdl/base/uri_mapped_resource.rb
|
223
238
|
- lib/sdl/exporters.rb
|
224
239
|
- lib/sdl/exporters/exporter.rb
|
225
|
-
- lib/sdl/exporters/markdown_service_exporter.rb
|
226
240
|
- lib/sdl/exporters/rdf_exporter.rb
|
227
241
|
- lib/sdl/exporters/rdf_mapping.rb
|
228
242
|
- lib/sdl/exporters/schema_exporter.rb
|
@@ -254,11 +268,16 @@ files:
|
|
254
268
|
- sdl-ng.gemspec
|
255
269
|
- spec/bin_spec.rb
|
256
270
|
- spec/documentation_spec.rb
|
271
|
+
- spec/exporter_spec.rb
|
257
272
|
- spec/fact_type_instance_definition_spec.rb
|
273
|
+
- spec/nokogiri_spec.rb
|
258
274
|
- spec/property_definitions_spec.rb
|
259
275
|
- spec/service_compendium_spec.rb
|
260
276
|
- spec/service_definition_spec.rb
|
261
277
|
- spec/shared_test_compendium.rb
|
278
|
+
- spec/shared_test_html.html
|
279
|
+
- spec/shared_test_html.rb
|
280
|
+
- spec/simple_types_spec.rb
|
262
281
|
- spec/spec_helper.rb
|
263
282
|
- spec/uri_mapping_spec.rb
|
264
283
|
homepage: https://github.com/TU-Berlin-SNET/sdl-ng
|
@@ -288,11 +307,16 @@ summary: Framework for building descriptions of business services.
|
|
288
307
|
test_files:
|
289
308
|
- spec/bin_spec.rb
|
290
309
|
- spec/documentation_spec.rb
|
310
|
+
- spec/exporter_spec.rb
|
291
311
|
- spec/fact_type_instance_definition_spec.rb
|
312
|
+
- spec/nokogiri_spec.rb
|
292
313
|
- spec/property_definitions_spec.rb
|
293
314
|
- spec/service_compendium_spec.rb
|
294
315
|
- spec/service_definition_spec.rb
|
295
316
|
- spec/shared_test_compendium.rb
|
317
|
+
- spec/shared_test_html.html
|
318
|
+
- spec/shared_test_html.rb
|
319
|
+
- spec/simple_types_spec.rb
|
296
320
|
- spec/spec_helper.rb
|
297
321
|
- spec/uri_mapping_spec.rb
|
298
322
|
has_rdoc:
|
@@ -1,27 +0,0 @@
|
|
1
|
-
class SDL::Exporters::MarkdownServiceExporter < SDL::Exporters::ServiceExporter
|
2
|
-
def export_service(service)
|
3
|
-
buf = StringIO.new
|
4
|
-
|
5
|
-
buf.puts I18n.t('sdl.markdown.header')
|
6
|
-
|
7
|
-
service.facts.each do |fact|
|
8
|
-
indent = 0
|
9
|
-
|
10
|
-
unless fact.class.documentation.empty?
|
11
|
-
buf.puts "* #{fact.class.documentation}"
|
12
|
-
|
13
|
-
indent = 2
|
14
|
-
end
|
15
|
-
|
16
|
-
buf.puts "#{' '* indent}* #{fact.documentation}#{fact.annotated? ? " (#{fact.annotations.join(', ')})" : ''}"
|
17
|
-
end
|
18
|
-
|
19
|
-
buf.string
|
20
|
-
end
|
21
|
-
|
22
|
-
def export_property_descriptions(property_holder, indentation = 0, buf)
|
23
|
-
property_holder.property_values.each do |property, value|
|
24
|
-
buf.puts("#{' '*indentation}* #{property.documentation}")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|