Class: Vendor::VendorFile::Library::Remote
- Inherits:
-
Base
- Object
- Base
- Vendor::VendorFile::Library::Remote
show all
- Defined in:
- lib/vendor/vendor_file/library/remote.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#name, #parent, #require, #targets
Instance Method Summary
collapse
Methods inherited from Base
#<=>, #build_settings, #dependencies, #files, #frameworks, #initialize, #per_file_flag, #resources
Instance Attribute Details
#equality ⇒ Object
Returns the value of attribute equality.
9
10
11
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 9
def equality
@equality
end
|
#sources ⇒ Object
Returns the value of attribute sources.
10
11
12
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 10
def sources
@sources
end
|
Instance Method Details
#==(other) ⇒ Object
118
119
120
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 118
def ==(other)
other.name == @name && other.version == @version && other.equality == @equality
end
|
#cache_path ⇒ Object
114
115
116
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 114
def cache_path
File.join(Vendor.library_path, "remote", name, matched_version.to_s)
end
|
#description ⇒ Object
126
127
128
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 126
def description
[ @name, @equality, @version ].compact.join(" ")
end
|
#display_name ⇒ Object
122
123
124
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 122
def display_name
[ name, matched_version ].compact.join(" ")
end
|
#download ⇒ Object
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 103
def download
unless File.exist?(cache_path)
file = Vendor::API.download(name, matched_version)
unzip_file file.path, cache_path
end
end
|
#matched_version ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 33
def matched_version
if version && !equality
return version
end
unless version
return meta['release']
end
other_versions = meta['versions'].map { |v| v[0] }
found = version_matches_any?(other_versions)
unless found
Vendor.ui.error "Could not find a valid version '#{equality} #{version}' in '#{other_versions}'"
exit 1
else
found
end
end
|
#version ⇒ Object
12
13
14
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 12
def version
@version
end
|
#version=(value) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 16
def version=(value)
if value
if value.match(/^(\<\=|\>\=|\~\>|\>|\<)?\s*([a-zA-Z0-9\.]+)$/)
@equality = $1
@version = $2
else
Vendor.ui.error "Invalid version format '#{value}' for '#{name}'"
exit 1
end
else
@equality = nil
@version = nil
end
value
end
|
#version_matches_any?(other_versions) ⇒ Boolean
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/vendor/vendor_file/library/remote.rb', line 58
def version_matches_any?(other_versions)
wants = Vendor::Version.new(version)
versions = other_versions.map{|v| Vendor::Version.create(v) }.sort.reverse
unless wants.prerelease?
versions = versions.reject { |v| v.prerelease? }
end
if equality == "~>"
segments = wants.segments
versions.find do |has|
segments == has.segments.slice(0, segments.length)
end
elsif equality
versions.find do |has|
wants.send(:"#{equality}", has)
end
else
versions.find do |has|
wants == has
end
end
end
|