Class: KubeDSL::Ref
- Inherits:
-
Object
- Object
- KubeDSL::Ref
- Includes:
- StringHelpers
- Defined in:
- lib/kube-dsl/ref.rb
Direct Known Subclasses
Constant Summary
Constants included from StringHelpers
Instance Attribute Summary collapse
-
#autoload_prefix ⇒ Object
readonly
Returns the value of attribute autoload_prefix.
-
#inflector ⇒ Object
readonly
Returns the value of attribute inflector.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#ruby_namespace_prefix ⇒ Object
readonly
Returns the value of attribute ruby_namespace_prefix.
-
#schema_dir ⇒ Object
readonly
Returns the value of attribute schema_dir.
-
#serialize_handlers ⇒ Object
readonly
Returns the value of attribute serialize_handlers.
-
#str ⇒ Object
readonly
Returns the value of attribute str.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #document ⇒ Object
-
#initialize(str, ruby_namespace_prefix, inflector, schema_dir, autoload_prefix, serialize_handlers) ⇒ Ref
constructor
A new instance of Ref.
- #inline? ⇒ Boolean
- #meta ⇒ Object
- #object? ⇒ Boolean
- #ruby_autoload_path ⇒ Object
- #ruby_namespace ⇒ Object
Methods included from StringHelpers
#capitalize, #underscore, #unkeywordify
Constructor Details
#initialize(str, ruby_namespace_prefix, inflector, schema_dir, autoload_prefix, serialize_handlers) ⇒ Ref
Returns a new instance of Ref.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/kube-dsl/ref.rb', line 9 def initialize(str, ruby_namespace_prefix, inflector, schema_dir, autoload_prefix, serialize_handlers) @str = str @ruby_namespace_prefix = ruby_namespace_prefix @inflector = inflector @schema_dir = schema_dir @autoload_prefix = autoload_prefix @serialize_handlers = serialize_handlers ns, v, k = str.split('.').last(3) if ns == 'api' && v == 'resource' @kind = k elsif ns == 'core' @kind = k @version = v else @kind = k @namespace = ns @version = v end end |
Instance Attribute Details
#autoload_prefix ⇒ Object (readonly)
Returns the value of attribute autoload_prefix.
7 8 9 |
# File 'lib/kube-dsl/ref.rb', line 7 def autoload_prefix @autoload_prefix end |
#inflector ⇒ Object (readonly)
Returns the value of attribute inflector.
6 7 8 |
# File 'lib/kube-dsl/ref.rb', line 6 def inflector @inflector end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
6 7 8 |
# File 'lib/kube-dsl/ref.rb', line 6 def kind @kind end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/kube-dsl/ref.rb', line 6 def namespace @namespace end |
#ruby_namespace_prefix ⇒ Object (readonly)
Returns the value of attribute ruby_namespace_prefix.
7 8 9 |
# File 'lib/kube-dsl/ref.rb', line 7 def ruby_namespace_prefix @ruby_namespace_prefix end |
#schema_dir ⇒ Object (readonly)
Returns the value of attribute schema_dir.
6 7 8 |
# File 'lib/kube-dsl/ref.rb', line 6 def schema_dir @schema_dir end |
#serialize_handlers ⇒ Object (readonly)
Returns the value of attribute serialize_handlers.
7 8 9 |
# File 'lib/kube-dsl/ref.rb', line 7 def serialize_handlers @serialize_handlers end |
#str ⇒ Object (readonly)
Returns the value of attribute str.
6 7 8 |
# File 'lib/kube-dsl/ref.rb', line 6 def str @str end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/kube-dsl/ref.rb', line 6 def version @version end |
Instance Method Details
#document ⇒ Object
39 40 41 |
# File 'lib/kube-dsl/ref.rb', line 39 def document JSON.parse(File.read(filename)) end |
#inline? ⇒ Boolean
31 32 33 |
# File 'lib/kube-dsl/ref.rb', line 31 def inline? false end |
#meta ⇒ Object
35 36 37 |
# File 'lib/kube-dsl/ref.rb', line 35 def @meta ||= ResourceMeta.new(self, inflector, serialize_handlers) end |
#object? ⇒ Boolean
43 44 45 |
# File 'lib/kube-dsl/ref.rb', line 43 def object? document.include?('properties') end |
#ruby_autoload_path ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/kube-dsl/ref.rb', line 59 def ruby_autoload_path @ruby_autoload_path ||= File.join( [autoload_prefix].tap do |path| path << underscore(namespace) if namespace path << underscore(version) if version path << "#{underscore(kind)}.rb" end ) end |
#ruby_namespace ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kube-dsl/ref.rb', line 47 def ruby_namespace @ruby_namespace ||= begin [*ruby_namespace_prefix].tap do |mods| mods << namespace if namespace mods << version if version mods.map! do |m| inflector.camelize(underscore(m)) end end end end |