Class: Rpremote::Mrbgems::Definition
- Inherits:
-
Object
- Object
- Rpremote::Mrbgems::Definition
- Defined in:
- lib/rpremote/mrbgems.rb
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#vm_name ⇒ Object
readonly
Returns the value of attribute vm_name.
Instance Method Summary collapse
- #gem(github: nil, path: nil, branch: "main", commit: nil, require: nil) ⇒ Object
-
#initialize(filename) ⇒ Definition
constructor
A new instance of Definition.
- #vm(name) ⇒ Object
Constructor Details
#initialize(filename) ⇒ Definition
Returns a new instance of Definition.
262 263 264 265 |
# File 'lib/rpremote/mrbgems.rb', line 262 def initialize(filename) @directory = File.dirname(filename) @dependencies = [] end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
260 261 262 |
# File 'lib/rpremote/mrbgems.rb', line 260 def dependencies @dependencies end |
#vm_name ⇒ Object (readonly)
Returns the value of attribute vm_name.
260 261 262 |
# File 'lib/rpremote/mrbgems.rb', line 260 def vm_name @vm_name end |
Instance Method Details
#gem(github: nil, path: nil, branch: "main", commit: nil, require: nil) ⇒ Object
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/rpremote/mrbgems.rb', line 275 def gem(github: nil, path: nil, branch: "main", commit: nil, require: nil) sources = [github, path].compact raise DefinitionError, "gem requires exactly one of github or path" unless sources.length == 1 unless require.nil? || (require.is_a?(String) && !require.empty? && !require.match?(/[\x00-\x1f\x7f]/)) raise DefinitionError, "invalid mrbgem require name: #{require.inspect}" end dependency = if github github_dependency(github, branch, commit, require) else path_dependency(path, branch, commit, require) end key = [dependency.type, dependency.source] raise DefinitionError, "duplicate mrbgem: #{dependency.source}" if dependencies.any? do |item| [item.type, item.source] == key end dependencies << dependency end |
#vm(name) ⇒ Object
267 268 269 270 271 272 273 |
# File 'lib/rpremote/mrbgems.rb', line 267 def vm(name) value = name.to_sym raise DefinitionError, "unsupported mrbgems VM: #{name.inspect}" unless VMS.include?(value) raise DefinitionError, "mrbgems VM specified more than once" if vm_name @vm_name = value end |