Class: Sprout::LibraryTask

Inherits:
Rake::Task
  • Object
show all
Defined in:
lib/sprout/tasks/library_task.rb

Overview

:include: ../../../doc/Library

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gem_nameObject

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_libObject

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

#versionObject

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:

Yields:

  • (t)


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_nameObject

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

#defineObject

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_pathObject

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_pathObject

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