Class: Sprout::LibraryTask
- Inherits:
-
Rake::Task
- Object
- Rake::Task
- Sprout::LibraryTask
- Defined in:
- lib/sprout/tasks/library_task.rb
Overview
:include: ../../../doc/Library
Instance Attribute Summary collapse
-
#gem_name ⇒ Object
The full gem name like ‘sprout-asunit3-library’.
-
#project_lib ⇒ Object
Override the the project folder where the library will be installed.
-
#version ⇒ Object
The RubyGems gem version string for this library (e.g., version = ‘0.0.1’).
Class Method Summary collapse
Instance Method Summary collapse
-
#clean_name ⇒ Object
Ensure that namespaced rake tasks only use the final part for name-based features.
-
#define ⇒ Object
Unlike other rake tasks, Library tasks are actually resolved at ‘define’ time.
-
#execute(*args) ⇒ Object
:nodoc:.
-
#library_path ⇒ Object
The path to the library source or swc that will be copied into your project.
-
#project_path ⇒ Object
The path within the project where this library is installed.
Instance Attribute Details
#gem_name ⇒ Object
The full gem name like ‘sprout-asunit3-library’
44 45 46 |
# File 'lib/sprout/tasks/library_task.rb', line 44 def gem_name @gem_name ||= "sprout-#{clean_name}-library" end |
#project_lib ⇒ Object
Override the the project folder where the library will be installed.
By default, libraries are installed into Sprout::ProjectModel lib_dir.
64 65 66 67 68 69 70 |
# File 'lib/sprout/tasks/library_task.rb', line 64 def project_lib if(library_path.index('.swc')) @project_lib ||= ProjectModel.instance.swc_dir else @project_lib ||= ProjectModel.instance.lib_dir end end |
#version ⇒ Object
The RubyGems gem version string for this library (e.g., version = ‘0.0.1’)
32 33 34 |
# File 'lib/sprout/tasks/library_task.rb', line 32 def version @version end |
Class Method Details
.define_task(args) {|t| ... } ⇒ Object
:nodoc:
37 38 39 40 41 |
# File 'lib/sprout/tasks/library_task.rb', line 37 def self.define_task(args, &block) # :nodoc: t = super yield t if block_given? t.define end |
Instance Method Details
#clean_name ⇒ Object
Ensure that namespaced rake tasks only use the final part for name-based features
50 51 52 |
# File 'lib/sprout/tasks/library_task.rb', line 50 def clean_name return name.split(':').pop end |
#define ⇒ Object
Unlike other rake tasks, Library tasks are actually resolved at ‘define’ time. This allows the tool tasks to build their own dependencies (like file deps)
(I'm sure there's a better way to do this, if you know how to fix this,
and would like to contribute to sprouts, this might be a good spot for it)
77 78 79 80 81 |
# File 'lib/sprout/tasks/library_task.rb', line 77 def define @file_target = sprout(gem_name, version) @library_path = File.join(@file_target.installed_path, @file_target.archive_path) define_file_task(library_path, project_path) end |
#execute(*args) ⇒ Object
:nodoc:
83 84 85 |
# File 'lib/sprout/tasks/library_task.rb', line 83 def execute(*args) # :nodoc: super end |
#library_path ⇒ Object
The path to the library source or swc that will be copied into your project. This can actually be any full or relative path on your system, but should almost always be left alone for automatic resolution.
57 58 59 |
# File 'lib/sprout/tasks/library_task.rb', line 57 def library_path @library_path ||= nil end |
#project_path ⇒ Object
The path within the project where this library is installed
88 89 90 91 92 93 94 95 96 |
# File 'lib/sprout/tasks/library_task.rb', line 88 def project_path if(File.directory?(@library_path)) # library is source dir File.join(project_lib, clean_name) else # library is a binary (like swc, jar, etc) File.join(project_lib, File.basename(@file_target.archive_path)) end end |