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
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ gem 'yard'
2
+ gem 'redcarpet'
3
+ gem 'yard-redcarpet-ext'
4
+
5
+ require 'bundler/gem_tasks'
6
+
7
+ require 'yard'
8
+ require 'redcarpet'
9
+ require 'yard-redcarpet-ext'
10
+
11
+ YARD::Rake::YardocTask.new do |yardoc|
12
+ yardoc.files = ['lib/**/*.rb', '-', 'README.md']
13
+ yardoc.options << '--title' << 'Service Description Language Framework Documentation'
14
+ yardoc.options << '--plugin' << 'redcarpet-ext'
15
+ yardoc.options << '-M' << 'redcarpet'
16
+ end
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ gem 'sdl-ng'
4
+
5
+ require 'sdl'
6
+ require 'active_support'
7
+ require 'i18n'
8
+
9
+ # Make the translations for fact classes, instances, etc. known to the I18n framework
10
+ I18n.load_path << File.join(Dir.pwd, 'translations', 'en.yml')
11
+
12
+ # Create an empty service compendium
13
+ compendium = SDL::Base::ServiceCompendium.new
14
+
15
+ # Load SDL
16
+ Dir.glob(File.join(Dir.pwd, '**', '*.sdl.rb')) do |filename|
17
+ compendium.facts_definition do
18
+ eval(File.read(filename), binding, filename)
19
+ end
20
+ end
21
+
22
+ compendium.register_classes_globally
23
+
24
+ # Load Service Definitions
25
+ Dir.glob(File.join(Dir.pwd, '**', '*.service.rb')) do |filename|
26
+ service = compendium.service filename.match(%r[.+/(.+).service.rb])[1] do
27
+ eval(File.read(filename), binding, filename)
28
+ end
29
+ end
30
+
31
+ puts "Loaded Service Compendium with #{compendium.services.count} services. Generating output"
32
+
33
+ %w[xml rdf markdown].each do |directory| FileUtils.mkdir_p File.join(Dir.pwd, 'output', directory) end
34
+
35
+ schema_exporter = SDL::Exporters::XSDSchemaExporter.new(compendium)
36
+ service_exporter = SDL::Exporters::XMLServiceExporter.new(compendium)
37
+ markdown_exporter = SDL::Exporters::MarkdownServiceExporter.new(compendium)
38
+ rdf_exporter = SDL::Exporters::RDFExporter.new(compendium)
39
+
40
+ schema_dir = Dir.pwd + '/output/xml/schema.xsd'
41
+ File.open(schema_dir, 'w') {|f|
42
+ f.write(schema_exporter.export_schema)
43
+ puts "Written Service Compendium XSD schema into #{schema_dir}"
44
+ }
45
+
46
+ # Load XSD
47
+ xsd = Nokogiri::XML::Schema(File.read(Dir.pwd + '/output/xml/schema.xsd'))
48
+
49
+ compendium.services.each do |name, service|
50
+ xml_output_file = Dir.pwd + "/output/xml/#{name}.xml"
51
+ service_exporter.export_service_to_file service, xml_output_file
52
+ puts "Wrote XML export of service '#{name}' to #{xml_output_file}"
53
+
54
+ puts "Validating XML export against schema"
55
+ xsd.validate(Nokogiri::XML(File.read(Dir.pwd + "/output/xml/#{name}.xml"))).each do |error|
56
+ puts error.message
57
+ end
58
+
59
+ rdf_output_file = Dir.pwd + "/output/rdf/#{name}.rdf"
60
+ rdf_exporter.export_service_to_file service, rdf_output_file
61
+ puts "Wrote RDF export of service '#{name}' to #{rdf_output_file}"
62
+
63
+ markdown_output_file = Dir.pwd + "/output/markdown/#{name}.md"
64
+ markdown_exporter.export_service_to_file service, markdown_output_file
65
+ puts "Wrote Markdown export of service '#{name}' to #{markdown_output_file}"
66
+ end
67
+
68
+ all_needed_translations = {
69
+ 'en' => {
70
+ 'sdl' => I18n.backend.instance_eval{translations}[:en][:sdl]
71
+ }
72
+ }
73
+
74
+ def returning(value)
75
+ yield(value)
76
+ value
77
+ end
78
+
79
+ def convert_hash_to_ordered_hash_and_sort(object, deep = false)
80
+ # from http://seb.box.re/2010/1/15/deep-hash-ordering-with-ruby-1-8/
81
+ if object.is_a?(Hash)
82
+ # Hash is ordered in Ruby 1.9!
83
+ res = returning(RUBY_VERSION >= '1.9' ? Hash.new : ActiveSupport::OrderedHash.new) do |map|
84
+ object.each {|k, v| map[k] = deep ? convert_hash_to_ordered_hash_and_sort(v, deep) : v }
85
+ end
86
+ return res.class[res.sort {|a, b| a[0].to_s <=> b[0].to_s } ]
87
+ elsif deep && object.is_a?(Array)
88
+ array = Array.new
89
+ object.each_with_index {|v, i| array[i] = convert_hash_to_ordered_hash_and_sort(v, deep) }
90
+ return array
91
+ else
92
+ return object
93
+ end
94
+ end
95
+
96
+ translations_output_file = Dir.pwd + "/translations/en.out.yml"
97
+ File.open(translations_output_file, 'w') do |f|
98
+ f.write(convert_hash_to_ordered_hash_and_sort(all_needed_translations.deep_stringify_keys!, true).to_yaml)
99
+ puts "Wrote resulting translations file to #{translations_output_file}."
100
+ end
101
+
102
+ puts 'Finished'
@@ -0,0 +1,50 @@
1
+ name 'Google Drive for Business'
2
+
3
+ has_documentation 'http://www.google.com/enterprise/apps/business/products.html#drive'
4
+
5
+ has_add_on_repository 'https://www.google.com/enterprise/marketplace/home', 1000
6
+
7
+ has_cloud_service_model saas
8
+
9
+ has_communication_protection https
10
+
11
+ has_status_page 'http://www.google.com/appsstatus'
12
+
13
+ has_public_service_level_agreement 'http://www.google.com/apps/intl/en/terms/sla.html'
14
+
15
+ maintenance_free
16
+
17
+ has_past_release_notes 'https://plus.google.com/+GoogleDrive/posts'
18
+ has_feedback_page 'https://plus.google.com/+GoogleDrive/posts'
19
+
20
+ has_establishing_year 2006
21
+
22
+ has_rest_interface annotation: 'https://developers.google.com/drive/'
23
+
24
+ has_offline_capability annotation: 'https://support.google.com/drive/answer/2375012'
25
+
26
+ is_billed monthly, in_advance
27
+
28
+ has_payment_option credit_card
29
+
30
+ has_browser_interface do
31
+ compatible_browser firefox, 'recent'
32
+ compatible_browser chrome, 'recent'
33
+ compatible_browser safari, '5', annotation: 'on Mac'
34
+ compatible_browser internet_explorer, '9'
35
+ end
36
+
37
+ { "For documents" => [:html, :rtf, :word, :open_office, :pdf, :text],
38
+ "For spreadsheets" => [:csv, :html, :odf, :pdf, :xls, :text],
39
+ "For presentations" => [:pdf, :pptx, :text],
40
+ "For drawings" => [:png, :jpeg, :svg, :pdf]
41
+ }.each do |annotation, formats_list|
42
+ formats_list.each do |f|
43
+ has_data_capability export, f, annotation: annotation
44
+ end
45
+ end
46
+
47
+ headers = fetch_from_url 'http://www.google.com/enterprise/apps/business/products.html', 'div.apps-content-set:nth-child(3) div.maia-col-4 h3'
48
+ headers.each do |header|
49
+ has_feature header.content.strip, header.search('~p')[0]
50
+ end
@@ -0,0 +1,51 @@
1
+ name "Salesforce Sales Cloud"
2
+
3
+ has_documentation url: 'http://www.salesforce.com/sales-cloud/overview/'
4
+
5
+ has_add_on_repository 'https://appexchange.salesforce.com/' do
6
+ number_of_add_ons 2000
7
+ end
8
+
9
+ has_communication_protection https
10
+
11
+ has_status_page 'http://trust.salesforce.com/trust/status/'
12
+
13
+ has_public_service_level_agreement 'http://www.salesforce.com/assets/pdf/misc/salesforce_MSA.pdf'
14
+
15
+ has_establishing_year 1999
16
+
17
+ has_offline_capability annotation: 'http://help.salesforce.com/apex/HTViewHelpDoc?id=offline_def.htm'
18
+
19
+ maintenance_free
20
+
21
+ has_future_roadmap 'http://www.sfdcstatic.com/assets/pdf/misc/summer13_ReleasePreview.pdf'
22
+ has_past_release_notes 'http://www.salesforce.com/newfeatures/'
23
+
24
+ has_cloud_service_model saas
25
+
26
+ has_rest_interface
27
+ has_soap_interface
28
+ has_xmlrpc_interface
29
+
30
+ has_browser_interface do
31
+ compatible_browser internet_explorer, '7'
32
+ compatible_browser firefox, 'recent'
33
+ compatible_browser chrome, 'recent'
34
+ compatible_browser safari, '5', annotation: 'on Mac'
35
+ end
36
+
37
+ has_data_capability export, csv
38
+
39
+ is_billed annually, in_advance
40
+
41
+ has_payment_option credit_card
42
+ has_payment_option cheque
43
+ has_payment_option invoice
44
+
45
+ features = fetch_from_url 'http://www.salesforce.com/sales-cloud/overview/', '.slide h3 + p'
46
+
47
+ has_feature 'Mobile', features[0]
48
+ has_feature 'Contact Management', features[1]
49
+ has_feature 'Opportunity Management', features[2]
50
+ has_feature 'Chatter', features[3]
51
+ has_feature 'Email Integration', features[4]
@@ -0,0 +1,184 @@
1
+ ---
2
+ en:
3
+ sdl:
4
+ fact:
5
+ add_on_repository: The service has an add-on repository.
6
+ audit_option: The service has an audit option
7
+ bill: The service billing terms.
8
+ charge_unit: The unit of service charging, e.g. "per user".
9
+ cloud_service_model: The cloud service model
10
+ communication_protection: The communication with the service is protected
11
+ continuous_service_improvement: The service has continuous service improvement
12
+ means
13
+ continuous_service_improvement_feedback_page: The service has a feedback page
14
+ continuous_service_improvement_future_roadmap: The service has a future roadmap
15
+ continuous_service_improvement_past_release_notes: The service has past release
16
+ notes
17
+ data_capability: The service can carry out operations on a specific data format
18
+ data_deletion_policy: The service allows for complete deletion of user data
19
+ after termination of contract
20
+ data_encryption: The service applies encrpytion on user data
21
+ data_location: The service offers to locate service data at runtime
22
+ data_location_transparency: The provider makes the location of service data
23
+ transparent
24
+ documentation: Some service documentation
25
+ duration: Generic duration of something.
26
+ duration_provision_end_user_duration: The duration for provisioning an end user.
27
+ duration_set_up_consumption_duration: The duration for setting up the service.
28
+ establishing_year: The establishing year of the service is known
29
+ feature: A service feature
30
+ interface: An interface to service functionality
31
+ interface_browser_interface: A regular browser-based interface
32
+ interface_rest_interface: The service has a RESTful interface
33
+ interface_soap_interface: The service has a SOAP interface
34
+ interface_xmlrpc_interface: The service has an XMLRPC interface
35
+ maintenance: The service has maintenance information
36
+ maintenance_maintenance_free: The service is maintenance free
37
+ maintenance_maintenance_window: The service has a maintenance window
38
+ name: The service has a name.
39
+ offline_capability: Service functionality can be used offline
40
+ payment_option: The service can be payed by a payment option, e.g. credit card.
41
+ service_category: The service belongs to a category
42
+ service_level_agreement: The service has a kind of service level agreement
43
+ service_level_agreement_public_service_level_agreement: The service has a publicibly
44
+ accessible service level agreement
45
+ service_tag: The service is tagged
46
+ status_page: The service has a status page
47
+ instance:
48
+ type:
49
+ billing_term:
50
+ annually: Annually billing
51
+ monthly: Monthly billing
52
+ browser:
53
+ chrome: Google Chrome
54
+ firefox: Mozilla Firefox
55
+ internet_explorer: Internet Explorer
56
+ opera: Opera Browser
57
+ safari: Apple Safari
58
+ charge_unit:
59
+ floating_license: The number of floating licenses
60
+ user_account: The number of user accounts
61
+ cloud_service_model:
62
+ haas: Hardware as a Service (HaaS)
63
+ iaas: Infrastructure as a Service (IaaS)
64
+ paas: Platform as a Service (PaaS)
65
+ saas: Software as a Service (SaaS)
66
+ communication_protection:
67
+ https: HTTPS encryption
68
+ vpn: VPN connection
69
+ data_capability_operation:
70
+ export: Exporting data
71
+ import: Importing data
72
+ data_format:
73
+ csv: Comma-separated values (CSV)
74
+ html: HTML
75
+ jpeg: JPEG
76
+ odf: Open Document Format (ODF)
77
+ open_office: Open Office
78
+ pdf: Adobe PDF
79
+ png: Portable Network Graphics (PNG)
80
+ pptx: Microsoft PowerPoint
81
+ rtf: Rich text (RTF)
82
+ svg: Scalable Vector Graphics (SVG)
83
+ text: Plain text
84
+ word: Microsoft Word
85
+ xls: Microsoft Excel
86
+ key_control:
87
+ provider_only: Only the provider controls the encryption keys
88
+ shared: Both user and provider control the encryption keys
89
+ user_only: Only the service user controls the encryption keys
90
+ payment_option:
91
+ cheque: Cheque
92
+ credit_card: Credit card
93
+ invoice: Invoice
94
+ payment_term:
95
+ after_use: Payment is done after service consumption
96
+ in_advance: Payment is done in advance of service consumption
97
+ property:
98
+ fact:
99
+ add_on_repository:
100
+ number_of_add_ons: The number of available add-ons
101
+ url: The URL of the add-on repository
102
+ audit_option:
103
+ audit_option: The audit option
104
+ bill:
105
+ billing_term: The billing terms
106
+ payment_term: The payment terms
107
+ charge_unit:
108
+ charge_unit: The unit of charge
109
+ cloud_service_model:
110
+ cloud_service_model: The cloud service model
111
+ communication_protection:
112
+ communication_protection: The protection means
113
+ continuous_service_improvement:
114
+ url: A link to the continuous service improvement
115
+ data_capability:
116
+ format: The data format
117
+ operation: The operation, which can be carried out on the data format
118
+ data_encryption:
119
+ key_control: Who excercises control over the encryption keys
120
+ data_location:
121
+ location: The location of data
122
+ documentation:
123
+ url: The documentation URL
124
+ duration:
125
+ duration: The duration
126
+ establishing_year:
127
+ year: The year, the service was established
128
+ feature:
129
+ description: The feature description
130
+ feature: The feature name
131
+ interface_browser_interface:
132
+ compatible_browsers: The compatible browsers
133
+ required_plugins: The required browser plugins
134
+ maintenance_maintenance_window:
135
+ timespan: The timespan of the maintenance window
136
+ name:
137
+ name: The service name
138
+ payment_option:
139
+ payment_option: The payment option
140
+ service_category:
141
+ service_category: The category of the service
142
+ service_level_agreement_public_service_level_agreement:
143
+ url: The URL of the service level agreement
144
+ service_tag:
145
+ service_tag: The service tag
146
+ status_page:
147
+ url: The URL of the service status page
148
+ type:
149
+ browser:
150
+ browser_name: The name of the browser
151
+ url: The browser homepage URL
152
+ browser_plugin:
153
+ plugin_name: The name of the browser plugin
154
+ url: The browser plugin URL
155
+ compatible_browser:
156
+ compatible_browser: The compatible browser
157
+ min_version: The minimum version of the browser
158
+ data_format:
159
+ mime_type: The mime type of the data format
160
+ required_plugin:
161
+ min_version: The minimum version required of the browser plugin
162
+ required_plugin: The plugin
163
+ timespan:
164
+ end: The timespan end
165
+ start: The timespan start
166
+ type:
167
+ audit_option: An option to audit a service
168
+ billing_term: The billing term, e.g. "per month".
169
+ browser: A browser
170
+ browser_plugin: A browser plugin
171
+ charge_unit: The charge unit
172
+ cloud_service_model: A cloud service model
173
+ communication_protection: A communication protection means
174
+ compatible_browser: A compatible browser
175
+ data_capability_operation: The data capability operation
176
+ data_format: The data format
177
+ key_control: One possibility of key control
178
+ location: Location information
179
+ payment_option: The payment option
180
+ payment_term: The payment terms, i.e., in advance and after use.
181
+ required_plugin: The required plugins
182
+ service_category: The category of a service
183
+ service_tag: A Service tag
184
+ timespan: An arbitrary timespan
@@ -0,0 +1,8 @@
1
+ type :timespan do
2
+ datetime :start
3
+ datetime :end
4
+ end
5
+
6
+ fact :name do
7
+ string :name
8
+ end
@@ -0,0 +1,5 @@
1
+ type :location do
2
+ subtype :address
3
+ subtype :country
4
+ subtype :jurisdiction
5
+ end
@@ -0,0 +1,25 @@
1
+ type :cloud_service_model
2
+ type :service_category
3
+ type :service_tag
4
+
5
+ fact :cloud_service_model do
6
+ cloud_service_model
7
+ end
8
+
9
+ fact :service_category do
10
+ service_category
11
+ end
12
+
13
+ fact :service_tag do
14
+ service_tag
15
+ end
16
+
17
+ fact :add_on_repository do
18
+ url
19
+ integer :number_of_add_ons
20
+ end
21
+
22
+ cloud_service_model :saas
23
+ cloud_service_model :paas
24
+ cloud_service_model :iaas
25
+ cloud_service_model :haas