Class: Rucola::Dependencies::Dependency
- Defined in:
- lib/rucola/dependencies.rb
Constant Summary collapse
- RUBY_BIN =
File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
- RESOLVER_BIN =
File.("../dependencies/resolver.rb", __FILE__)
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #copy_to(path, options = {}) ⇒ Object
- #gem_lib? ⇒ Boolean
-
#initialize(name, version = '>=0') ⇒ Dependency
constructor
A new instance of Dependency.
- #other_lib? ⇒ Boolean
- #pretty_print_name ⇒ Object
- #require! ⇒ Object
-
#required_files ⇒ Object
Returns an array of required files sorted by their full_path.
- #required_files_of_types(*types) ⇒ Object
- #resolve! ⇒ Object
- #standard_lib? ⇒ Boolean
Constructor Details
#initialize(name, version = '>=0') ⇒ Dependency
Returns a new instance of Dependency.
74 75 76 |
# File 'lib/rucola/dependencies.rb', line 74 def initialize(name, version = '>=0') @name, @version, @required_files = name, version, [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
72 73 74 |
# File 'lib/rucola/dependencies.rb', line 72 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
72 73 74 |
# File 'lib/rucola/dependencies.rb', line 72 def version @version end |
Instance Method Details
#copy_to(path, options = {}) ⇒ Object
108 109 110 111 |
# File 'lib/rucola/dependencies.rb', line 108 def copy_to(path, = {}) puts "\nCopying dependency '#{pretty_print_name}':\n\n" if Dependencies.verbose required_files_of_types([:types]).each {|file| file.copy_to(path) } end |
#gem_lib? ⇒ Boolean
96 97 98 |
# File 'lib/rucola/dependencies.rb', line 96 def gem_lib? @required_files.first.gem_lib? end |
#other_lib? ⇒ Boolean
104 105 106 |
# File 'lib/rucola/dependencies.rb', line 104 def other_lib? @required_files.first.other_lib? end |
#pretty_print_name ⇒ Object
126 127 128 |
# File 'lib/rucola/dependencies.rb', line 126 def pretty_print_name "#{@name}#{' (' + @version + ')' unless @version == '>=0'}" end |
#require! ⇒ Object
78 79 80 81 |
# File 'lib/rucola/dependencies.rb', line 78 def require! activate_gem! unless Rucola::RCApp.release? Kernel.require(@name) end |
#required_files ⇒ Object
Returns an array of required files sorted by their full_path.
114 115 116 |
# File 'lib/rucola/dependencies.rb', line 114 def required_files @required_files.sort_by {|f| f.full_path } end |
#required_files_of_types(*types) ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/rucola/dependencies.rb', line 118 def required_files_of_types(*types) sorted_types = types.flatten.compact return required_files if sorted_types.empty? required_files.select do |file| sorted_types.any? {|type| file.send "#{type}_lib?" } end end |
#resolve! ⇒ Object
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rucola/dependencies.rb', line 85 def resolve! unless Dependencies.exclude?(@name) without_changing_loaded_features do cmd = "'#{RUBY_BIN}' '#{RESOLVER_BIN}' '#{@name}' '#{@version}' '#{YAML.dump($LOAD_PATH)}'" files = YAML.load(`#{cmd}`) require! files.each { |file| @required_files << RequiredFile.new(file) } end end end |
#standard_lib? ⇒ Boolean
100 101 102 |
# File 'lib/rucola/dependencies.rb', line 100 def standard_lib? @required_files.first.standard_lib? end |