Class: Yoda::Store::Objects::Library::Gem
- Inherits:
-
Object
- Object
- Yoda::Store::Objects::Library::Gem
show all
- Includes:
- Serializable
- Defined in:
- lib/yoda/store/objects/library/gem.rb
Defined Under Namespace
Classes: Connected
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #derive, #eql?, #hash, included, #to_json
Constructor Details
#initialize(name:, version:, source_path:, full_gem_path:, doc_dir:, source_type:) ⇒ Gem
Returns a new instance of Gem.
60
61
62
63
64
65
66
67
|
# File 'lib/yoda/store/objects/library/gem.rb', line 60
def initialize(name:, version:, source_path:, full_gem_path:, doc_dir:, source_type:)
@name = name
@version = version
@source_path = source_path
@full_gem_path = full_gem_path
@doc_dir = doc_dir
@source_type = source_type&.to_sym
end
|
Instance Attribute Details
#doc_dir ⇒ String
9
10
11
|
# File 'lib/yoda/store/objects/library/gem.rb', line 9
def doc_dir
@doc_dir
end
|
#full_gem_path ⇒ String
9
10
11
|
# File 'lib/yoda/store/objects/library/gem.rb', line 9
def full_gem_path
@full_gem_path
end
|
#name ⇒ String
9
10
11
|
# File 'lib/yoda/store/objects/library/gem.rb', line 9
def name
@name
end
|
#source_path ⇒ String
9
10
11
|
# File 'lib/yoda/store/objects/library/gem.rb', line 9
def source_path
@source_path
end
|
#source_type ⇒ Symbol?
12
13
14
|
# File 'lib/yoda/store/objects/library/gem.rb', line 12
def source_type
@source_type
end
|
#version ⇒ String
9
10
11
|
# File 'lib/yoda/store/objects/library/gem.rb', line 9
def version
@version
end
|
Class Method Details
.from_gem_spec(spec) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/yoda/store/objects/library/gem.rb', line 16
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,
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,
full_gem_path: nil,
doc_dir: nil,
source_type: nil,
)
end
end
|
.source_type_of(source) ⇒ Symbol?
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/yoda/store/objects/library/gem.rb', line 42
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
69
70
71
|
# File 'lib/yoda/store/objects/library/gem.rb', line 69
def id
"#{name}:#{version}"
end
|
#installed? ⇒ Boolean
89
90
91
|
# File 'lib/yoda/store/objects/library/gem.rb', line 89
def installed?
full_gem_path && File.exists?(full_gem_path)
end
|
#local? ⇒ Boolean
73
74
75
|
# File 'lib/yoda/store/objects/library/gem.rb', line 73
def local?
source_path
end
|
#managed_by_rubygems? ⇒ Boolean
93
94
95
|
# File 'lib/yoda/store/objects/library/gem.rb', line 93
def managed_by_rubygems?
source_type == :rubygems
end
|
#to_h ⇒ Object
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/yoda/store/objects/library/gem.rb', line 77
def to_h
{
name: name,
version: version,
source_path: source_path,
full_gem_path: full_gem_path,
doc_dir: doc_dir,
source_type: source_type,
}
end
|
#with_project_connection(**kwargs) ⇒ Connected
98
99
100
|
# File 'lib/yoda/store/objects/library/gem.rb', line 98
def with_project_connection(**kwargs)
self.class.const_get(:Connected).new(self, **kwargs)
end
|