sdl-ng 0.0.1

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.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.rspec +2 -0
  4. data/.yard_redcarpet_ext +1 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +13 -0
  7. data/README.md +454 -0
  8. data/Rakefile +16 -0
  9. data/bin/process_service_descriptions +102 -0
  10. data/examples/services/google_drive_for_business.service.rb +50 -0
  11. data/examples/services/salesforce_sales_cloud.service.rb +51 -0
  12. data/examples/translations/en.yml +184 -0
  13. data/examples/vocabulary/base/base.sdl.rb +8 -0
  14. data/examples/vocabulary/base/location.sdl.rb +5 -0
  15. data/examples/vocabulary/crf/characteristics.sdl.rb +25 -0
  16. data/examples/vocabulary/crf/charging.sdl.rb +8 -0
  17. data/examples/vocabulary/crf/compliance.sdl.rb +35 -0
  18. data/examples/vocabulary/crf/delivery.sdl.rb +22 -0
  19. data/examples/vocabulary/crf/dynamics.sdl.rb +6 -0
  20. data/examples/vocabulary/crf/interop.sdl.rb +54 -0
  21. data/examples/vocabulary/crf/optimizing.sdl.rb +15 -0
  22. data/examples/vocabulary/crf/portability.sdl.rb +25 -0
  23. data/examples/vocabulary/crf/protection.sdl.rb +8 -0
  24. data/examples/vocabulary/crf/reliability.sdl.rb +1 -0
  25. data/examples/vocabulary/crf/reputation.sdl.rb +3 -0
  26. data/lib/sdl.rb +17 -0
  27. data/lib/sdl/base.rb +20 -0
  28. data/lib/sdl/base/fact.rb +11 -0
  29. data/lib/sdl/base/property.rb +34 -0
  30. data/lib/sdl/base/service.rb +13 -0
  31. data/lib/sdl/base/service_compendium.rb +130 -0
  32. data/lib/sdl/base/type.rb +66 -0
  33. data/lib/sdl/exporters.rb +9 -0
  34. data/lib/sdl/exporters/exporter.rb +19 -0
  35. data/lib/sdl/exporters/markdown_service_exporter.rb +5 -0
  36. data/lib/sdl/exporters/rdf_exporter.rb +34 -0
  37. data/lib/sdl/exporters/rdf_mapping.rb +48 -0
  38. data/lib/sdl/exporters/schema_exporter.rb +9 -0
  39. data/lib/sdl/exporters/service_exporter.rb +9 -0
  40. data/lib/sdl/exporters/xml_mapping.rb +51 -0
  41. data/lib/sdl/exporters/xml_service_exporter.rb +37 -0
  42. data/lib/sdl/exporters/xsd_schema_exporter.rb +94 -0
  43. data/lib/sdl/receivers.rb +22 -0
  44. data/lib/sdl/receivers/fact_receiver.rb +15 -0
  45. data/lib/sdl/receivers/service_receiver.rb +63 -0
  46. data/lib/sdl/receivers/type_instance_receiver.rb +86 -0
  47. data/lib/sdl/receivers/type_receiver.rb +87 -0
  48. data/lib/sdl/translations/en.yml +9 -0
  49. data/lib/sdl/types.rb +19 -0
  50. data/lib/sdl/types/sdl_datetime.rb +10 -0
  51. data/lib/sdl/types/sdl_default_type.rb +13 -0
  52. data/lib/sdl/types/sdl_description.rb +10 -0
  53. data/lib/sdl/types/sdl_duration.rb +12 -0
  54. data/lib/sdl/types/sdl_number.rb +10 -0
  55. data/lib/sdl/types/sdl_string.rb +10 -0
  56. data/lib/sdl/types/sdl_type.rb +31 -0
  57. data/lib/sdl/types/sdl_url.rb +12 -0
  58. data/lib/sdl/util.rb +4 -0
  59. data/lib/sdl/util/documentation.rb +80 -0
  60. data/lib/sdl/util/nokogiri.rb +28 -0
  61. data/lib/sdl/util/verbs.rb +3 -0
  62. data/lib/sdl/version.rb +3 -0
  63. data/sdl-ng.gemspec +34 -0
  64. data/spec/documentation_spec.rb +64 -0
  65. data/spec/fact_type_instance_definition_spec.rb +188 -0
  66. data/spec/property_definitions_spec.rb +44 -0
  67. data/spec/service_compendium_spec.rb +90 -0
  68. data/spec/service_definition_spec.rb +81 -0
  69. data/spec/shared_test_compendium.rb +65 -0
  70. data/spec/spec_helper.rb +10 -0
  71. metadata +291 -0
@@ -0,0 +1,8 @@
1
+ type :charge_unit
2
+
3
+ fact :charge_unit do
4
+ charge_unit
5
+ end
6
+
7
+ charge_unit :user_account
8
+ charge_unit :floating_license
@@ -0,0 +1,35 @@
1
+ fact :data_location_transparency
2
+
3
+ fact :data_location do
4
+ location
5
+ end
6
+
7
+ fact :data_deletion_policy
8
+
9
+ type :key_control
10
+
11
+ fact :data_encryption do
12
+ key_control
13
+ end
14
+
15
+ key_control :user_only
16
+ key_control :provider_only
17
+ key_control :shared
18
+
19
+ type :audit_option
20
+
21
+ fact :audit_option do
22
+ audit_option
23
+ end
24
+
25
+ audit_option :audit_log
26
+
27
+ fact :status_page do
28
+ url
29
+ end
30
+
31
+ fact :service_level_agreement do
32
+ subfact :public_service_level_agreement do
33
+ url
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ type :billing_term
2
+ type :payment_term
3
+ type :payment_option
4
+
5
+ fact :bill do
6
+ billing_term
7
+ payment_term
8
+ end
9
+
10
+ fact :payment_option do
11
+ payment_option
12
+ end
13
+
14
+ billing_term :monthly
15
+ billing_term :annually
16
+
17
+ payment_term :in_advance
18
+ payment_term :after_use
19
+
20
+ payment_option :credit_card
21
+ payment_option :cheque
22
+ payment_option :invoice
@@ -0,0 +1,6 @@
1
+ fact :duration do
2
+ duration :duration
3
+
4
+ subfact :set_up_consumption_duration
5
+ subfact :provision_end_user_duration
6
+ end
@@ -0,0 +1,54 @@
1
+ type :browser do
2
+ url
3
+ end
4
+
5
+ type :browser_plugin do
6
+ url
7
+ end
8
+
9
+ fact :feature do
10
+ string :feature
11
+ description
12
+ end
13
+
14
+ fact :documentation do
15
+ url
16
+ end
17
+
18
+ fact :interface do
19
+ subfact :rest_interface
20
+ subfact :soap_interface
21
+ subfact :xmlrpc_interface
22
+
23
+ subfact :browser_interface do
24
+ list :compatible_browsers do
25
+ browser :compatible_browser
26
+ string :min_version
27
+ end
28
+
29
+ list :required_plugins do
30
+ browser_plugin :required_plugin
31
+ string :min_version
32
+ end
33
+ end
34
+ end
35
+
36
+ browser :firefox do
37
+ url 'http://www.mozilla.org/firefox/'
38
+ end
39
+
40
+ browser :opera do
41
+ url 'http://www.opera.com/'
42
+ end
43
+
44
+ browser :chrome do
45
+ url 'https://www.google.com/chrome'
46
+ end
47
+
48
+ browser :internet_explorer do
49
+ url 'http://windows.microsoft.com/en-US/internet-explorer/download-ie'
50
+ end
51
+
52
+ browser :safari do
53
+ url 'http://www.apple.com/safari'
54
+ end
@@ -0,0 +1,15 @@
1
+ fact :maintenance do
2
+ subfact :maintenance_window do
3
+ timespan
4
+ end
5
+
6
+ subfact :maintenance_free
7
+ end
8
+
9
+ fact :continuous_service_improvement do
10
+ url
11
+
12
+ subfact :future_roadmap
13
+ subfact :past_release_notes
14
+ subfact :feedback_page
15
+ end
@@ -0,0 +1,25 @@
1
+ type :data_capability_operation
2
+
3
+ type :data_format
4
+
5
+ fact :data_capability do
6
+ data_capability_operation :operation
7
+ data_format :format
8
+ end
9
+
10
+ data_format :csv
11
+ data_format :xls
12
+ data_format :html
13
+ data_format :rtf
14
+ data_format :word
15
+ data_format :open_office
16
+ data_format :pdf
17
+ data_format :text
18
+ data_format :odf
19
+ data_format :pptx
20
+ data_format :png
21
+ data_format :jpeg
22
+ data_format :svg
23
+
24
+ data_capability_operation :export
25
+ data_capability_operation :import
@@ -0,0 +1,8 @@
1
+ type :communication_protection
2
+
3
+ fact :communication_protection do
4
+ communication_protection
5
+ end
6
+
7
+ communication_protection :https
8
+ communication_protection :vpn
@@ -0,0 +1 @@
1
+ fact :offline_capability
@@ -0,0 +1,3 @@
1
+ fact :establishing_year do
2
+ number :year
3
+ end
data/lib/sdl.rb ADDED
@@ -0,0 +1,17 @@
1
+ #:include: ../README.md
2
+
3
+ require_relative 'sdl/base'
4
+ require_relative 'sdl/receivers'
5
+ require_relative 'sdl/types'
6
+ require_relative 'sdl/exporters'
7
+ require_relative 'sdl/util'
8
+ require_relative 'sdl/version'
9
+
10
+ ##
11
+ #
12
+ #
13
+ # Author:: Mathias Slawik (mailto:mathias.slawik@tu-berlin.de)
14
+ # License:: Apache License 2.0
15
+ module SDL
16
+
17
+ end
data/lib/sdl/base.rb ADDED
@@ -0,0 +1,20 @@
1
+ require_relative 'base/type'
2
+ require_relative 'base/fact'
3
+ require_relative 'base/property'
4
+ require_relative 'base/service'
5
+ require_relative 'base/service_compendium'
6
+
7
+ module SDL
8
+ ##
9
+ # This module contains the base classes of the \SDL Framework.
10
+ #
11
+ # These include:
12
+ # Fact:: A fact about a service
13
+ # Service:: A service, which is described through facts
14
+ # Type:: A type used in service descriptions
15
+ # Property:: A property of a fact or type
16
+ #
17
+ # The ServiceCompendium is used for easy definition of new facts, services, types and properties.
18
+ module Base
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ module SDL
2
+ module Base
3
+ ##
4
+ # A fact, which is known about a service.
5
+ #
6
+ # Facts are defined by using a ServiceCompendium.
7
+ class Fact < Type
8
+ attr_accessor :service
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,34 @@
1
+ module SDL
2
+ module Base
3
+ ##
4
+ # A property of a Fact or Type. It has a #name and an associated Type.
5
+ class Property
6
+ # The Property name
7
+ attr :name
8
+
9
+ # The Property Type
10
+ attr :type
11
+
12
+ # Is this Property multi-valued
13
+ attr :multi
14
+
15
+ # The parent type, where this property belongs to
16
+ attr :parent
17
+
18
+ # Is this Property single-valued
19
+ def single?
20
+ !@multi
21
+ end
22
+
23
+ # Is this Property multi-valued
24
+ def multi?
25
+ @multi
26
+ end
27
+
28
+ # Define a property by its name and type
29
+ def initialize(name, type, parent, multi = false)
30
+ @name, @type, @parent, @multi = name.to_s, type, parent, multi
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,13 @@
1
+ module SDL
2
+ module Base
3
+ class Service
4
+ attr_accessor :facts, :symbolic_name
5
+
6
+ def initialize(symbolic_name)
7
+ @symbolic_name = symbolic_name
8
+
9
+ @facts, @facades = [], []
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,130 @@
1
+ require 'active_support/inflector'
2
+
3
+ module SDL
4
+ module Base
5
+ ##
6
+ # A service compendium allows the definition of service facts, types and services.
7
+ class ServiceCompendium
8
+ class << self
9
+ def default_sdltypes
10
+ @default_sdltypes ||= []
11
+ end
12
+ end
13
+
14
+ attr :fact_classes
15
+ attr :types
16
+ attr :sdltype_codes
17
+ attr :type_instances
18
+ attr :services
19
+
20
+ def initialize
21
+ @fact_classes, @types, @services = [], [], {}
22
+ @type_instances, @sdltype_codes = {}, {}
23
+
24
+ register_default_types
25
+ end
26
+
27
+ def facts_definition(&facts_definitions)
28
+ self.instance_eval &facts_definitions
29
+ end
30
+
31
+ def type_instances_definition(&type_instances_definition)
32
+ self.instance_eval &type_instances_definition
33
+ end
34
+
35
+ # Defines a new class of service facts
36
+ def fact(sym, &fact_definition)
37
+ receiver = SDL::Receivers::FactReceiver.new(sym, self)
38
+ receiver.instance_eval &fact_definition if block_given?
39
+ receiver.subclasses.each do |fact_class|
40
+ @fact_classes << fact_class
41
+
42
+ # Refer to the symbolic name of the current class, which can be a subclass of
43
+ sym = fact_class.local_name.underscore.to_sym
44
+
45
+ ServiceMethods.class_eval do
46
+ unless Service.instance_methods.include? sym
47
+ define_method sym do
48
+ @facts.find {|fact| fact.is_a? fact_class}
49
+ end
50
+ end
51
+
52
+ unless Service.instance_methods.include? sym.to_s.pluralize.to_sym
53
+ define_method sym.to_s.pluralize do
54
+ @facts.find_all {|fact| fact.is_a? fact_class}
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ # Defines a new type and returns it
62
+ def type(sym, &type_definition)
63
+ receiver = SDL::Receivers::TypeReceiver.new(sym, self)
64
+ receiver.instance_eval &type_definition if block_given?
65
+ register_sdltype_codes(receiver.klass)
66
+ register_sdltype(receiver.klass)
67
+ @types << receiver.klass
68
+ @type_instances[receiver.klass] = {}
69
+ receiver.klass
70
+ end
71
+
72
+ # Defines a new service, adds all service methods, and returns it
73
+ def service(sym, &service_definition)
74
+ receiver = SDL::Receivers::ServiceReceiver.new(sym, self)
75
+ receiver.instance_eval &service_definition if block_given?
76
+ @services[sym] = receiver.service
77
+ receiver.service.symbolic_name = sym.to_s
78
+ receiver.service.extend ServiceMethods
79
+ receiver.service
80
+ end
81
+
82
+ ##
83
+ # Registers the type under its codes
84
+ def register_sdltype_codes(type)
85
+ type.instance_variable_get(:@codes).each do |code|
86
+ @sdltype_codes[code] = type
87
+ end
88
+ end
89
+
90
+ ##
91
+ # Allows this compendium to be used for adding new type instances
92
+ def register_sdltype(type)
93
+ # Define a method, which adds the type instance defined in the block to this compendium and adds it as a
94
+ # constant the the type class
95
+ self.class.send(:define_method, type.local_name.underscore) do |identifier, &block|
96
+ receiver = SDL::Receivers::TypeInstanceReceiver.new(type.new, self)
97
+
98
+ receiver.instance_eval &block if block != nil
99
+
100
+ receiver.instance.identifier = identifier
101
+ @type_instances[type][identifier] = receiver.instance
102
+ end
103
+ end
104
+
105
+ ##
106
+ # Registers all classes by their #local_name to be used in all scopes
107
+ def register_classes_globally
108
+ (@fact_classes + @types).each do |defined_class|
109
+ Object.send(:remove_const, defined_class.local_name) if Object.const_defined? defined_class.local_name.to_sym
110
+ Object.const_set defined_class.local_name, defined_class
111
+ end
112
+ end
113
+
114
+ # This module is included in every service defined by this compendium and contains methods to easily retreive
115
+ # certain fact instances by their name.
116
+ module ServiceMethods
117
+
118
+ end
119
+
120
+ private
121
+ ##
122
+ # Registers all default types
123
+ def register_default_types
124
+ self.class.default_sdltypes.each do |type|
125
+ register_sdltype_codes type
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,66 @@
1
+ require 'i18n'
2
+
3
+ module SDL
4
+ module Base
5
+ class Type
6
+ class << self
7
+ ## The namespace URL of this Fact class
8
+ attr_accessor :namespace
9
+
10
+ ##
11
+ # The local name of the fact, e.g. "Name" or "ServiceInterface". Defaults to the name of the class.
12
+ #
13
+ # The ServiceCompendium#register_classes_globally method makes this class accessible by a constant of this name
14
+ @local_name
15
+
16
+ def local_name
17
+ @local_name || name.demodulize
18
+ end
19
+
20
+ def local_name=(name)
21
+ @local_name = name
22
+ end
23
+
24
+ def to_s
25
+ @local_name || name
26
+ end
27
+
28
+ def properties(including_super = false)
29
+ if including_super && is_sub?
30
+ self.properties + superclass.properties(true)
31
+ else
32
+ @properties ||= []
33
+ end
34
+ end
35
+
36
+ def is_sub?
37
+ not [SDL::Base::Type, SDL::Base::Fact].include? superclass
38
+ end
39
+ end
40
+
41
+ ##
42
+ # Gets the values of all properties
43
+ def property_values
44
+ Hash[self.class.properties(true).map{|p| [p, send(p.name)]}]
45
+ end
46
+
47
+ def to_s
48
+ # If there is a property with the same name, than the type, return its to_s, return the name of the class
49
+ naming_property = self.class.properties(true).find {|p| p.name.eql?(self.class.to_s.underscore) }
50
+
51
+ if(naming_property)
52
+ instance_variable_get "@#{naming_property.name.to_sym}"
53
+ else
54
+ self.class.to_s
55
+ end
56
+ end
57
+
58
+ def annotations
59
+ @annotations ||= []
60
+ end
61
+
62
+ # An identifier for type instances
63
+ attr_accessor :identifier
64
+ end
65
+ end
66
+ end