Class: Vendor::VendorFile::Library::Base
- Inherits:
-
Object
- Object
- Vendor::VendorFile::Library::Base
- Defined in:
- lib/vendor/vendor_file/library/base.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#require ⇒ Object
Returns the value of attribute require.
-
#targets ⇒ Object
Returns the value of attribute targets.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #build_settings ⇒ Object
- #cache_path ⇒ Object
- #dependencies ⇒ Object
- #description ⇒ Object
- #display_name ⇒ Object
- #download ⇒ Object
- #files ⇒ Object
- #frameworks ⇒ Object
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
- #per_file_flag ⇒ Object
- #resources ⇒ Object
- #version_matches_any?(other_versions) ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
16 17 18 19 20 |
# File 'lib/vendor/vendor_file/library/base.rb', line 16 def initialize(attributes = {}) @source_tree = :group @targets = [ :all ] attributes.each { |k, v| self.send("#{k}=", v) } end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/vendor/vendor_file/library/base.rb', line 11 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
9 10 11 |
# File 'lib/vendor/vendor_file/library/base.rb', line 9 def parent @parent end |
#require ⇒ Object
Returns the value of attribute require.
13 14 15 |
# File 'lib/vendor/vendor_file/library/base.rb', line 13 def require @require end |
#targets ⇒ Object
Returns the value of attribute targets.
12 13 14 |
# File 'lib/vendor/vendor_file/library/base.rb', line 12 def targets @targets end |
#version ⇒ Object
Returns the value of attribute version.
14 15 16 |
# File 'lib/vendor/vendor_file/library/base.rb', line 14 def version @version end |
Instance Method Details
#<=>(other) ⇒ Object
135 136 137 138 |
# File 'lib/vendor/vendor_file/library/base.rb', line 135 def <=>(other) v = other.respond_to?(:version) ? other.version : other Vendor::Version.create(version) <=> Vendor::Version.create(v) end |
#==(other) ⇒ Object
140 141 142 |
# File 'lib/vendor/vendor_file/library/base.rb', line 140 def ==(other) other.name == name && other.version == version end |
#build_settings ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vendor/vendor_file/library/base.rb', line 69 def build_settings # If the cache doesn't exist, download it download unless cache_exists? # Find the build settings build_settings = if manifest manifest['build_settings'] elsif vendor_spec vendor_spec.build_settings end build_settings || [] end |
#cache_path ⇒ Object
30 31 32 |
# File 'lib/vendor/vendor_file/library/base.rb', line 30 def cache_path File.join(Vendor.library_path, self.class.name.split('::').last.downcase, name) end |
#dependencies ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vendor/vendor_file/library/base.rb', line 38 def dependencies # If the cache doesn't exist, download it download unless cache_exists? # Find the dependencies dependencies = if manifest manifest['dependencies'] elsif vendor_spec vendor_spec.dependencies end # Create remote objects to represent the dependencies (dependencies || []).map do |d| Vendor::VendorFile::Library::Remote.new(:name => d[0], :version => d[1], :parent => self, :targets => @targets) end end |
#description ⇒ Object
148 149 150 |
# File 'lib/vendor/vendor_file/library/base.rb', line 148 def description [ name, version ].compact.join(" ") end |
#display_name ⇒ Object
144 145 146 |
# File 'lib/vendor/vendor_file/library/base.rb', line 144 def display_name description end |
#download ⇒ Object
34 35 36 |
# File 'lib/vendor/vendor_file/library/base.rb', line 34 def download # Do nothing by default, leave that up to the implementation end |
#files ⇒ Object
83 84 85 |
# File 'lib/vendor/vendor_file/library/base.rb', line 83 def files install_files_for_files_in 'files' end |
#frameworks ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/vendor/vendor_file/library/base.rb', line 55 def frameworks # If the cache doesn't exist, download it download unless cache_exists? # Find the frameworks frameworks = if manifest manifest['frameworks'] elsif vendor_spec vendor_spec.frameworks end frameworks || [] end |
#per_file_flag ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/vendor/vendor_file/library/base.rb', line 101 def per_file_flag # If the cache doesn't exist, download it download unless cache_exists? # Find the build settings per_file_flag = if manifest manifest['per_file_flag'] elsif vendor_spec vendor_spec.per_file_flag end per_file_flag end |
#resources ⇒ Object
87 88 89 |
# File 'lib/vendor/vendor_file/library/base.rb', line 87 def resources install_files_for_files_in 'resources' end |
#version_matches_any?(other_versions) ⇒ Boolean
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/vendor/vendor_file/library/base.rb', line 116 def version_matches_any?(other_versions) # If we have an equality matcher, we need sort through # the versions, and try and find the best match wants = Vendor::Version.new(version) # Sort them from the latest versions first versions = other_versions.map{|v| Vendor::Version.create(v) }.sort.reverse # We don't want to include pre-releases if the wants version # isn't a pre-release itself. If we're after "2.5.alpha", then # we should be able to include that, however if we're asking for # "2.5", then pre-releases shouldn't be included. unless wants.prerelease? versions = versions.reject { |v| v.prerelease? } end versions.find { |has| wants == has } end |