Class: Gel::StoreGem

Inherits:
Object
  • Object
show all
Defined in:
lib/gel/store_gem.rb

Direct Known Subclasses

DirectGem

Constant Summary collapse

EXTENSION_SUBDIR_TOKEN =
".."

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, name, version, extensions, info) ⇒ StoreGem

Returns a new instance of StoreGem.



8
9
10
11
12
13
14
# File 'lib/gel/store_gem.rb', line 8

def initialize(root, name, version, extensions, info)
  @root = root
  @name = name
  @version = version
  @extensions = extensions unless extensions && extensions.empty?
  @info = info
end

Instance Attribute Details

#extensionsObject (readonly)

Returns the value of attribute extensions.



6
7
8
# File 'lib/gel/store_gem.rb', line 6

def extensions
  @extensions
end

#infoObject (readonly)

Returns the value of attribute info.



6
7
8
# File 'lib/gel/store_gem.rb', line 6

def info
  @info
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/gel/store_gem.rb', line 6

def name
  @name
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/gel/store_gem.rb', line 6

def root
  @root
end

#versionObject (readonly)

Returns the value of attribute version.



6
7
8
# File 'lib/gel/store_gem.rb', line 6

def version
  @version
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/gel/store_gem.rb', line 16

def ==(other)
  other.class == self.class && @name == other.name && @version == other.version
end

#bindirObject



35
36
37
# File 'lib/gel/store_gem.rb', line 35

def bindir
  @info[:bindir] || "bin"
end

#dependenciesObject



39
40
41
# File 'lib/gel/store_gem.rb', line 39

def dependencies
  @info[:dependencies]
end

#executablesObject



43
44
45
# File 'lib/gel/store_gem.rb', line 43

def executables
  @info[:executables]
end

#hashObject



20
21
22
# File 'lib/gel/store_gem.rb', line 20

def hash
  @name.hash ^ @version.hash
end

#libsObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/gel/store_gem.rb', line 56

def libs
  _require_paths.each do |subdir|
    prefix = "#{root}/#{subdir}/"
    Dir["#{prefix}**/*.rb"].each do |path|
      next unless path.start_with?(prefix)
      file = path[prefix.size..-1].sub(/\.rb$/, "")
      yield file, subdir
    end
  end
end

#path(file, subdir = nil) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/gel/store_gem.rb', line 47

def path(file, subdir = nil)
  if subdir == EXTENSION_SUBDIR_TOKEN && extensions
    "#{extensions}/#{file}"
  else
    subdir ||= _default_require_path
    "#{root}/#{subdir}/#{file}"
  end
end

#require_pathsObject



28
29
30
31
32
33
# File 'lib/gel/store_gem.rb', line 28

def require_paths
  paths = _require_paths.map { |reqp| "#{root}/#{reqp}" }
  paths << extensions if extensions
  raise(paths.inspect) unless paths.all? { |path| path.is_a?(String) }
  paths
end

#satisfies?(requirements) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/gel/store_gem.rb', line 24

def satisfies?(requirements)
  requirements.satisfied_by?(gem_version)
end