Class: Omnijack::Endpoint::Metadata
- Inherits:
-
Omnijack::Endpoint
- Object
- Omnijack
- Omnijack::Endpoint
- Omnijack::Endpoint::Metadata
- Includes:
- Chef::Mixin::ParamsValidate, Config
- Defined in:
- lib/omnijack/endpoint/metadata.rb
Overview
A class for representing an Omnitruck metadata object
Constant Summary
Constants inherited from Omnijack
Instance Attribute Summary
Attributes inherited from Omnijack
Instance Method Summary collapse
-
#initialize(name, args) ⇒ Metadata
constructor
A new instance of Metadata.
-
#m ⇒ TrueClass, FalseClass
Whether to enable prerelease and/or nightly packages.
-
#machine_arch(arg = nil) ⇒ String
The machine architecture of the desired platform.
-
#platform(arg = nil) ⇒ String
The name of the desired platform.
-
#platform_version(arg = nil) ⇒ String
The version of the desired platform.
-
#to_h ⇒ Hash
Offer a hash representation of the metadata.
-
#version(arg = nil) ⇒ String
The version of the project.
Methods inherited from Omnijack::Endpoint
#[], #base_url, #method_missing
Constructor Details
#initialize(name, args) ⇒ Metadata
Returns a new instance of Metadata.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/omnijack/endpoint/metadata.rb', line 32 def initialize(name, args) super [:platform, :platform_version, :machine_arch].each do |i| send(i, args[i]) args.delete(i) end args.each { |k, v| send(k, v) unless v.nil? } unless args.nil? version(to_h[:version]) to_h end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Omnijack::Endpoint
Instance Method Details
#m ⇒ TrueClass, FalseClass
Whether to enable prerelease and/or nightly packages
82 83 84 85 86 87 88 89 |
# File 'lib/omnijack/endpoint/metadata.rb', line 82 [:prerelease, :nightlies].each do |m| define_method(m) do |arg = nil| set_or_return(m, arg, kind_of: [TrueClass, FalseClass], default: false) end end |
#machine_arch(arg = nil) ⇒ String
The machine architecture of the desired platform
122 123 124 |
# File 'lib/omnijack/endpoint/metadata.rb', line 122 def machine_arch(arg = nil) set_or_return(:machine_arch, arg, kind_of: String, required: true) end |
#platform(arg = nil) ⇒ String
The name of the desired platform
97 98 99 |
# File 'lib/omnijack/endpoint/metadata.rb', line 97 def platform(arg = nil) set_or_return(:platform, arg, kind_of: String, required: true) end |
#platform_version(arg = nil) ⇒ String
The version of the desired platform
107 108 109 110 111 112 113 114 |
# File 'lib/omnijack/endpoint/metadata.rb', line 107 def platform_version(arg = nil) !arg.nil? && arg = case platform when 'mac_os_x' then platform_version_mac_os_x(arg) when 'windows' then platform_version_windows(arg) else arg end set_or_return(:platform_version, arg, kind_of: String, required: true) end |
#to_h ⇒ Hash
Offer a hash representation of the metadata
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/omnijack/endpoint/metadata.rb', line 55 def to_h raw_data.split("\n").each_with_object({}) do |line, hsh| key, val = line.split.entries key = key.to_sym val = true if val == 'true' val = false if val == 'false' hsh[key] = val key == :url && hsh.merge!(parse_url_data(val)) end end |
#version(arg = nil) ⇒ String
The version of the project
72 73 74 |
# File 'lib/omnijack/endpoint/metadata.rb', line 72 def version(arg = nil) set_or_return(:version, arg, kind_of: String, default: 'latest') end |