sdl-ng 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63c012a4a880107aa2abc578cd5d6e31586685f4
4
- data.tar.gz: 9f48ce28d5770a44db409a24e851ec417dea2566
3
+ metadata.gz: 7d1ec08b2a5a2c3e43249e9b10d3de36c4c3a98b
4
+ data.tar.gz: 1c0a4526564013c5a575a0067d0928222398d466
5
5
  SHA512:
6
- metadata.gz: ff01a182a62dd8a80e8f4c417382fe1b376e4938c8fd8ba7864fed886d549d1afb04099ac58d74794ac2ee03160e4171d5c024b63e6a7df881795101a8c14027
7
- data.tar.gz: 18875548fa81bf0b0e4b48a5c0313eb031aebc8e93194583624f92cb42848c7aac79cbf087796766596adb7f1f329fc6f11b965755d1d36d38c1f8ee9b838ee8
6
+ metadata.gz: 4a7d602e5a4aea0d43a67ea9ccf6af365d71f81e18b89425787be450bbc84b0260e708f375c2c0443d537b2403fe068dc8e4aedcc2f0df2e9248dc3883eda962
7
+ data.tar.gz: 43a04fd9d23ddd0e0a8ef6bb9de7091f5d681cfef670bec02ea802512863706ffff9ffae953f2048a215cc8def1652e787ddc64df7b19bfc27ad98cee66539a6
@@ -42,7 +42,7 @@ has_payment_option credit_card
42
42
  has_payment_option cheque
43
43
  has_payment_option invoice
44
44
 
45
- features = fetch_from_url 'http://www.salesforce.com/sales-cloud/overview/', '.slide h3 + p'
45
+ features = fetch_from_url 'http://www.salesforce.com/sales-cloud/overview/', '.slide h3 + *'
46
46
 
47
47
  has_feature 'Mobile', features[0]
48
48
  has_feature 'Contact Management', features[1]
@@ -10,10 +10,6 @@ en:
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
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
13
  data_capability: The service can carry out operations on a specific data format
18
14
  data_deletion_policy: The service allows for complete deletion of user data
19
15
  after termination of contract
@@ -116,6 +112,12 @@ en:
116
112
  communication_protection: Protection means
117
113
  continuous_service_improvement:
118
114
  url: Link
115
+ continuous_service_improvement_feedback_page:
116
+ url: Feedback page
117
+ continuous_service_improvement_future_roadmap:
118
+ url: Future roadmap
119
+ continuous_service_improvement_past_release_notes:
120
+ url: Past release notes
119
121
  data_capability:
120
122
  format: Format
121
123
  operation: Operation
data/lib/sdl.rb CHANGED
@@ -5,8 +5,7 @@ require 'active_support/dependencies'
5
5
  require 'active_support/inflector'
6
6
 
7
7
  require 'i18n'
8
-
9
- ActiveSupport::Dependencies.autoload_paths += ['sdl']
8
+ require 'verbs'
10
9
 
11
10
  ##
12
11
  #
@@ -18,11 +17,8 @@ module SDL
18
17
  autoload :Base
19
18
  autoload :Exporters
20
19
  autoload :Receivers
20
+ autoload :Types
21
21
 
22
- eager_autoload do
23
- autoload :Types
24
- end
25
-
26
- require_relative 'sdl/util'
27
- require_relative 'sdl/ng/version'
22
+ ActiveSupport::Dependencies::Loadable.require_dependency File.join(__dir__, 'sdl', 'util.rb')
23
+ ActiveSupport::Dependencies::Loadable.require_dependency File.join(__dir__, 'sdl', 'ng', 'version.rb')
28
24
  end
@@ -10,9 +10,12 @@ class SDL::Base::Property
10
10
  # Is this Property multi-valued
11
11
  attr :multi
12
12
 
13
- # The parent type, where this property belongs to
13
+ # The type, for which the property is defined
14
14
  attr :parent
15
15
 
16
+ # The type, which currently holds this property
17
+ attr_accessor :holder
18
+
16
19
  # Is this Property single-valued
17
20
  def single?
18
21
  !@multi
@@ -111,7 +111,7 @@ class SDL::Base::ServiceCompendium
111
111
  ##
112
112
  # Registers all default types
113
113
  def register_default_types
114
- SDL::Types::SDLSimpleType.sdl_types.each do |type|
114
+ SDL::Types::SDLSimpleType.descendants.each do |type|
115
115
  register_sdltype_codes type
116
116
  end
117
117
  end
@@ -23,9 +23,13 @@ class SDL::Base::Type
23
23
 
24
24
  def properties(including_super = false)
25
25
  if including_super && is_sub?
26
- self.properties + superclass.properties(true)
26
+ retrieved_properties = self.properties + superclass.properties(true)
27
27
  else
28
- @properties ||= []
28
+ retrieved_properties = @properties ||= []
29
+ end
30
+
31
+ retrieved_properties.each do |p|
32
+ p.holder = self
29
33
  end
30
34
  end
31
35
 
@@ -1,5 +1,5 @@
1
1
  module SDL
2
2
  module NG
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -2,22 +2,10 @@ module SDL
2
2
  module Receivers
3
3
  extend ActiveSupport::Autoload
4
4
 
5
+ autoload :Receiver
5
6
  autoload :FactReceiver
6
7
  autoload :ServiceReceiver
7
8
  autoload :TypeReceiver
8
9
  autoload :TypeInstanceReceiver
9
-
10
- #
11
- def self.set_value(type_class, type_instance, *property_values, compendium)
12
- property_values.zip(type_class.properties(true)).each do |value, property|
13
- if(value.is_a?(Hash))
14
- TypeInstanceReceiver.new(type_instance, compendium).send(value.keys.first.to_s, value.values.first)
15
- else
16
- raise "Specified value '#{value}' for non-existing property." unless property
17
-
18
- TypeInstanceReceiver.new(type_instance, compendium).send(property.name, value)
19
- end
20
- end
21
- end
22
10
  end
23
11
  end
@@ -1,14 +1,14 @@
1
1
  require 'verbs'
2
2
 
3
- class SDL::Receivers::ServiceReceiver
3
+ class SDL::Receivers::ServiceReceiver < SDL::Receivers::Receiver
4
4
  include ActiveSupport::Inflector
5
5
 
6
6
  attr :service
7
- attr :compendium
8
7
 
9
8
  def initialize(sym, compendium)
9
+ super(compendium)
10
+
10
11
  @service = SDL::Base::Service.new(sym.to_s)
11
- @compendium = compendium
12
12
 
13
13
  compendium.fact_classes.each do |fact_class|
14
14
  define_singleton_method("is_#{fact_class.local_name.underscore.verb.conjugate(:tense => :past, :person => :third, :plurality => :singular, :aspect => :perfective)}") do |*args, &block|
@@ -30,7 +30,7 @@ class SDL::Receivers::ServiceReceiver
30
30
  fact_instance = fact_class.new
31
31
  fact_instance.service = @service
32
32
 
33
- SDL::Receivers.set_value(fact_class, fact_instance, *property_values, @compendium)
33
+ set_value(fact_class, fact_instance, *property_values)
34
34
 
35
35
  if block_given?
36
36
  SDL::Receivers::TypeInstanceReceiver.new(fact_instance, @compendium).instance_eval &block
@@ -1,16 +1,15 @@
1
1
  ##
2
2
  # Receiver for setting the properties of Type instances
3
- class SDL::Receivers::TypeInstanceReceiver
3
+ class SDL::Receivers::TypeInstanceReceiver < SDL::Receivers::Receiver
4
4
  attr_accessor :instance
5
5
 
6
- attr_accessor :compendium
7
-
8
6
  ##
9
7
  # When initialized for a fact or type instance, the receiver creates singleton methods on itself for all
10
8
  # properties.
11
9
  def initialize(instance, compendium)
10
+ super(compendium)
11
+
12
12
  @instance = instance
13
- @compendium = compendium
14
13
 
15
14
  instance.class.properties(true).each do |property|
16
15
  if property.single?
@@ -48,7 +47,7 @@ class SDL::Receivers::TypeInstanceReceiver
48
47
  else
49
48
  new_list_item = property.type.new
50
49
 
51
- SDL::Receivers.set_value(property.type, new_list_item, *property_values, @compendium)
50
+ set_value(property.type, new_list_item, *property_values)
52
51
 
53
52
  self.class.new(new_list_item, @compendium).instance_exec(&block) unless block.nil?
54
53
 
@@ -1,12 +1,12 @@
1
- class SDL::Receivers::TypeReceiver
1
+ class SDL::Receivers::TypeReceiver < SDL::Receivers::Receiver
2
2
  include ActiveSupport::Inflector
3
3
 
4
4
  attr :klass
5
5
  attr :subclasses
6
- attr :compendium
7
6
 
8
7
  def initialize(sym, compendium, superklass = nil)
9
- @compendium = compendium
8
+ super(compendium)
9
+
10
10
  @klass = Class.new(superklass || base_class)
11
11
  @klass.local_name = sym.to_s.camelize
12
12
 
@@ -9,17 +9,16 @@ module SDL
9
9
  extend ActiveSupport::Autoload
10
10
 
11
11
  # Required, as these types register Receiver methods for their usage in property definitions.
12
- eager_autoload do
13
- autoload :SDLType
14
- autoload :SDLSimpleType
15
- autoload :SDLDatetime
16
- autoload :SDLDescription
17
- autoload :SDLDuration
18
- autoload :SDLNumber
19
- autoload :SDLString
20
- autoload :SDLUrl
12
+ autoload :SDLType
13
+ autoload :SDLSimpleType
14
+
15
+ %w[datetime description duration number string url].each do |typefile|
16
+ ActiveSupport::Dependencies::Loadable.require_dependency File.join(__dir__, 'types', "sdl_#{typefile}.rb")
21
17
  end
22
18
 
23
- eager_load!
19
+ autoload :SDLDescription
20
+ autoload :SDLDuration
21
+ autoload :SDLNumber
22
+ autoload :SDLUrl
24
23
  end
25
24
  end
@@ -1,10 +1,23 @@
1
+ ##
2
+ # Description values are extended string values with additional conversion functions.
1
3
  class SDL::Types::SDLDescription < SDL::Types::SDLSimpleType
2
4
  include SDL::Types::SDLType
3
5
 
4
6
  wraps String
5
7
  codes :description
6
8
 
7
- def from_nilclass(nilvalue)
9
+ def from_nil_class(nilvalue)
8
10
  @value = ""
9
11
  end
12
+
13
+ def from_nokogiri_xml_element(element)
14
+ @value = element.content.squish
15
+ end
16
+
17
+ def to_html
18
+ case @raw_value.class
19
+ when Nokogiri::XML::Element
20
+ @raw_value.to_s
21
+ end
22
+ end
10
23
  end
@@ -5,19 +5,6 @@
5
5
  class SDL::Types::SDLSimpleType
6
6
  include SDL::Types::SDLType
7
7
 
8
- ##
9
- # Array of all SDLSimpleTypes. Used by the ServiceCompendium.
10
- def self.sdl_types
11
- @@sdl_types ||= []
12
- end
13
-
14
- ##
15
- # Every descendant of SDLSimpleType registers it with this class, so that all ServiceCompendiums
16
- # recognize the codes of descendants.
17
- def self.inherited(subclass)
18
- sdl_types << subclass
19
- end
20
-
21
8
  # The SDL value type value, possibly converted to the wrapped ruby type, e.g., an URI object created from an
22
9
  # "http://" String
23
10
  attr_reader :value
@@ -59,6 +46,6 @@ class SDL::Types::SDLSimpleType
59
46
 
60
47
  private
61
48
  def conversion_method_name(value)
62
- value.class.name.demodulize.camelize.downcase
49
+ 'from_' + value.class.name.underscore.gsub('/', '_')
63
50
  end
64
51
  end
@@ -8,7 +8,7 @@ class SDL::Types::SDLUrl < SDL::Types::SDLSimpleType
8
8
 
9
9
  def from_string(string_value)
10
10
  begin
11
- URI.parse string_value
11
+ @value = URI.parse string_value
12
12
  rescue URI::InvalidURIError
13
13
  throw "Invalid URI: #{string_value}"
14
14
  end
@@ -1,5 +1,5 @@
1
- require_relative 'util/nokogiri'
2
- require_relative 'util/documentation'
3
- require_relative 'util/verbs'
1
+ ActiveSupport::Dependencies.load_file File.join(__dir__, 'util', 'nokogiri.rb')
2
+ ActiveSupport::Dependencies.load_file File.join(__dir__, 'util', 'documentation.rb')
3
+ ActiveSupport::Dependencies.load_file File.join(__dir__, 'util', 'verbs.rb')
4
4
 
5
5
  I18n.load_path << File.join(__dir__, 'translations', 'en.yml')
@@ -1,15 +1,15 @@
1
1
  require 'active_support/inflector'
2
2
 
3
+ I18n.config.enforce_available_locales = true
4
+
3
5
  module I18n
4
6
  class MissingTranslation
5
7
  module Base
6
- alias :old_message :message
8
+ alias :old_message :message unless method_defined?(:old_message)
7
9
 
8
10
  def message
9
11
  puts old_message
10
12
 
11
- puts @key
12
-
13
13
  I18n.backend.store_translations I18n.locale, to_deep_hash({@key => 'Translate'})
14
14
 
15
15
  old_message
@@ -59,28 +59,41 @@ module SDL
59
59
 
60
60
  klass_key
61
61
  end
62
-
63
- [SDL::Base::Type, SDL::Base::Fact, SDL::Base::Property].each do |m| m.class_eval do include SDL::Util::Documentation end end
64
62
  end
65
63
  end
66
- end
67
64
 
68
- module SDL
69
65
  module Base
70
- class Type
71
- def self.documentation_key
72
- "sdl.#{SDL::Util::Documentation.walk_the_class_name(self)}"
73
- end
66
+ [Type, Fact, Property].each do |m| m.class_eval do include SDL::Util::Documentation end end
67
+ end
68
+ end
74
69
 
75
- def documentation_key
76
- "sdl.instance.#{SDL::Util::Documentation.walk_the_class_name(self.class)}.#{@identifier}"
77
- end
70
+ module SDL::Base
71
+ class Type
72
+ def self.documentation_key
73
+ "sdl.#{SDL::Util::Documentation.walk_the_class_name(self)}"
74
+ end
75
+
76
+ def documentation_key
77
+ "sdl.instance.#{SDL::Util::Documentation.walk_the_class_name(self.class)}.#{@identifier}"
78
78
  end
79
+ end
79
80
 
80
- class Property
81
- def documentation_key
82
- "sdl.property.#{SDL::Util::Documentation.walk_the_class_name(@parent)}.#{@name}"
81
+ class Property
82
+ ##
83
+ # As properties are inherited, the documentation could either be defined by the current type, or any subtypes, which
84
+ # also define or inherit this key. This method finds the first defined key.
85
+ def documentation_key
86
+ # Search class and ancestors, if any defines a documentation key
87
+ @holder.ancestors.each do |ancestor|
88
+ break if ancestor.eql? SDL::Base::Type
89
+
90
+ key = "sdl.property.#{SDL::Util::Documentation.walk_the_class_name(ancestor)}.#{@name}"
91
+
92
+ return key if I18n.exists? key
83
93
  end
94
+
95
+ # Return default key
96
+ return "sdl.property.#{SDL::Util::Documentation.walk_the_class_name(@parent)}.#{@name}"
84
97
  end
85
98
  end
86
99
  end
@@ -17,12 +17,6 @@ module SDL
17
17
  end
18
18
  end
19
19
 
20
- module SDL
21
- module Receivers
22
- [FactReceiver, ServiceReceiver, TypeInstanceReceiver, TypeReceiver].each do |r|
23
- r.class_eval do
24
- include(SDL::Util::NokogiriUtils)
25
- end
26
- end
27
- end
20
+ SDL::Receivers::Receiver.class_eval do
21
+ include(SDL::Util::NokogiriUtils)
28
22
  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.5
4
+ version: 0.0.6
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-07 00:00:00.000000000 Z
11
+ date: 2014-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport