Class: OpenHAB::DSL::Imports::Bundle

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/openhab/dsl/imports.rb

Constant Summary collapse

INSTALLED =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*jar_args) ⇒ Bundle

Returns a new instance of Bundle.



100
101
102
103
104
105
# File 'lib/rspec/openhab/dsl/imports.rb', line 100

def initialize(*jar_args)
  file = Jars.find_jar(*jar_args)
  @jar = java.util.jar.JarFile.new(file)
  @symbolic_name = jar_args[1]
  @version = org.osgi.framework.Version.new(jar_args[2].tr("-", "."))
end

Instance Attribute Details

#symbolic_nameObject (readonly)

Returns the value of attribute symbolic_name.



107
108
109
# File 'lib/rspec/openhab/dsl/imports.rb', line 107

def symbolic_name
  @symbolic_name
end

#versionObject (readonly)

Returns the value of attribute version.



107
108
109
# File 'lib/rspec/openhab/dsl/imports.rb', line 107

def version
  @version
end

Instance Method Details

#find_entries(path, pattern, recurse) ⇒ Object



113
114
115
116
117
118
119
120
# File 'lib/rspec/openhab/dsl/imports.rb', line 113

def find_entries(path, pattern, recurse)
  pattern ||= recurse ? "**" : "*"
  full_pattern = File.join(path, pattern)
  entries = @jar.entries.select do |e|
    File.fnmatch(full_pattern, e.name)
  end
  java.util.Collections.enumeration(entries.map { |e| java.net.URL.new("jar:file://#{@jar.name}!/#{e.name}") })
end

#stateObject



109
110
111
# File 'lib/rspec/openhab/dsl/imports.rb', line 109

def state
  INSTALLED
end