Class: Yoda::Store::Objects::Library::Gem
Defined Under Namespace
Classes: Connected
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#contain_requirable_file?, #find_requirable_file
#==, #derive, #eql?, #hash, included, #to_json
Constructor Details
#initialize(name:, version:, source_path:, full_gem_path:, require_paths:, doc_dir:, source_type:) ⇒ Gem
Returns a new instance of Gem.
68
69
70
71
72
73
74
75
76
|
# File 'lib/yoda/store/objects/library/gem.rb', line 68
def initialize(name:, version:, source_path:, full_gem_path:, require_paths:, doc_dir:, source_type:)
@name = name
@version = version
@source_path = source_path
@full_gem_path = full_gem_path
@require_paths = require_paths
@doc_dir = doc_dir
@source_type = source_type&.to_sym
end
|
Instance Attribute Details
#doc_dir ⇒ String
12
13
14
|
# File 'lib/yoda/store/objects/library/gem.rb', line 12
def doc_dir
@doc_dir
end
|
#full_gem_path ⇒ String
12
13
14
|
# File 'lib/yoda/store/objects/library/gem.rb', line 12
def full_gem_path
@full_gem_path
end
|
#name ⇒ String
12
13
14
|
# File 'lib/yoda/store/objects/library/gem.rb', line 12
def name
@name
end
|
#require_paths ⇒ Array<String>
15
16
17
|
# File 'lib/yoda/store/objects/library/gem.rb', line 15
def require_paths
@require_paths
end
|
#source_path ⇒ String
12
13
14
|
# File 'lib/yoda/store/objects/library/gem.rb', line 12
def source_path
@source_path
end
|
#source_type ⇒ Symbol?
18
19
20
|
# File 'lib/yoda/store/objects/library/gem.rb', line 18
def source_type
@source_type
end
|
#version ⇒ String
12
13
14
|
# File 'lib/yoda/store/objects/library/gem.rb', line 12
def version
@version
end
|
Class Method Details
.from_gem_spec(spec) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/yoda/store/objects/library/gem.rb', line 22
def from_gem_spec(spec)
if spec.respond_to?(:full_gem_path)
new(
name: spec.name,
version: spec.version.version,
source_path: spec.source.respond_to?(:path) ? spec.source.path : nil,
require_paths: spec.full_require_paths,
full_gem_path: spec.full_gem_path,
doc_dir: spec.doc_dir,
source_type: source_type_of(spec.source),
)
else
new(
name: spec.name,
version: spec.version.version,
source_path: nil,
require_paths: [],
full_gem_path: nil,
doc_dir: nil,
source_type: nil,
)
end
end
|
.source_type_of(source) ⇒ Symbol?
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/yoda/store/objects/library/gem.rb', line 50
def source_type_of(source)
return nil unless source
case source
when Bundler::Source::Git
:git
when Bundler::Source::Gemspec
:gemspec
when Bundler::Source::Rubygems
:rubygems
when Bundler::Source::Path
:path
else
nil
end
end
|
Instance Method Details
#id ⇒ Object
78
79
80
|
# File 'lib/yoda/store/objects/library/gem.rb', line 78
def id
"#{name}:#{version}"
end
|
#installed? ⇒ Boolean
99
100
101
|
# File 'lib/yoda/store/objects/library/gem.rb', line 99
def installed?
full_gem_path && File.exists?(full_gem_path)
end
|
#local? ⇒ Boolean
82
83
84
|
# File 'lib/yoda/store/objects/library/gem.rb', line 82
def local?
source_path
end
|
#managed_by_rubygems? ⇒ Boolean
103
104
105
|
# File 'lib/yoda/store/objects/library/gem.rb', line 103
def managed_by_rubygems?
source_type == :rubygems
end
|
#to_h ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/yoda/store/objects/library/gem.rb', line 86
def to_h
{
name: name,
version: version,
source_path: source_path,
full_gem_path: full_gem_path,
require_paths: require_paths,
doc_dir: doc_dir,
source_type: source_type,
}
end
|
#with_project_connection(**kwargs) ⇒ Connected
108
109
110
|
# File 'lib/yoda/store/objects/library/gem.rb', line 108
def with_project_connection(**kwargs)
self.class.const_get(:Connected).new(self, **kwargs)
end
|