Class: Rpremote::Mrbgems::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/rpremote/mrbgems.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Definition

Returns a new instance of Definition.



236
237
238
239
# File 'lib/rpremote/mrbgems.rb', line 236

def initialize(filename)
  @directory = File.dirname(filename)
  @dependencies = []
end

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



234
235
236
# File 'lib/rpremote/mrbgems.rb', line 234

def dependencies
  @dependencies
end

#vm_nameObject (readonly)

Returns the value of attribute vm_name.



234
235
236
# File 'lib/rpremote/mrbgems.rb', line 234

def vm_name
  @vm_name
end

Instance Method Details

#gem(github: nil, path: nil, branch: "main", commit: nil) ⇒ Object

Raises:



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/rpremote/mrbgems.rb', line 249

def gem(github: nil, path: nil, branch: "main", commit: nil)
  sources = [github, path].compact
  raise DefinitionError, "gem requires exactly one of github or path" unless sources.length == 1

  dependency = if github
                 github_dependency(github, branch, commit)
               else
                 path_dependency(path, branch, commit)
               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

Raises:



241
242
243
244
245
246
247
# File 'lib/rpremote/mrbgems.rb', line 241

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