Class: Gel::StoreGem
- Inherits:
-
Object
- Object
- Gel::StoreGem
- Defined in:
- lib/gel/store_gem.rb
Direct Known Subclasses
Constant Summary collapse
- EXTENSION_SUBDIR_TOKEN =
".."
Instance Attribute Summary collapse
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #bindir ⇒ Object
- #dependencies ⇒ Object
- #executables ⇒ Object
- #hash ⇒ Object
-
#initialize(root, name, version, extensions, info) ⇒ StoreGem
constructor
A new instance of StoreGem.
- #libs ⇒ Object
- #path(file, subdir = nil) ⇒ Object
- #require_paths ⇒ Object
- #satisfies?(requirements) ⇒ Boolean
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
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
6 7 8 |
# File 'lib/gel/store_gem.rb', line 6 def extensions @extensions end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
6 7 8 |
# File 'lib/gel/store_gem.rb', line 6 def info @info end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/gel/store_gem.rb', line 6 def name @name end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/gel/store_gem.rb', line 6 def root @root end |
#version ⇒ Object (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 |
#bindir ⇒ Object
35 36 37 |
# File 'lib/gel/store_gem.rb', line 35 def bindir @info[:bindir] || "bin" end |
#dependencies ⇒ Object
39 40 41 |
# File 'lib/gel/store_gem.rb', line 39 def dependencies @info[:dependencies] end |
#executables ⇒ Object
43 44 45 |
# File 'lib/gel/store_gem.rb', line 43 def executables @info[:executables] end |
#hash ⇒ Object
20 21 22 |
# File 'lib/gel/store_gem.rb', line 20 def hash @name.hash ^ @version.hash end |
#libs ⇒ Object
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_paths ⇒ Object
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
24 25 26 |
# File 'lib/gel/store_gem.rb', line 24 def satisfies?(requirements) requirements.satisfied_by?(gem_version) end |