Class: Reap::Project

Inherits:
Manager show all
Defined in:
lib/reap/project.rb,
lib/reap/metadata.rb,
lib/reap/settings.rb

Overview

Project

The Project class is the main class of Reap. It provides the tools for working with a project. The CLI Application class delegates to this class, for instance.

Defined Under Namespace

Classes: Metadata, Settings

Constant Summary

Constants inherited from Manager

Manager::DEFAULT

Instance Attribute Summary

Attributes included from Utilities::OptionUtils

#dryrun, #force, #trace, #verbose

Instance Method Summary collapse

Methods inherited from Manager

#announce, #announce_message, #check_load, #check_syntax, #clean, #clobber, #clobber_packages, #clobber_rdoc, #clobber_ridoc, #compiles?, #extension_directories, #extension_scripts, #extensions, #gem_clobber, #gem_install, #gem_package, #gem_uninstall, #html, #log, #log_changes, #log_notes, #make, #make_clean, #make_distclean, #make_extconf, #make_static, #package, #package_docs, #package_gem, #package_tgz, #package_zip, #prepare, #publish, #rdoc, #release, #ridoc, #rubyforge_release, #scaffold, #scaffold_rakefile, #scaffold_setup_rb, #scaffold_skeleton, #scaffold_task, #scaffold_tasks, #scm_branch, #scm_log, #scm_tag, #site_install, #site_uninstall, #spec, #spec_doc, #stamp, #stats, #svn_branch, #svn_log, #svn_tag, #test_cross, #test_load, #test_solo, #test_unit, #unfold_paragraphs

Methods included from Utilities::NetUtils

#email

Methods included from Utilities::FileUtils

#bin?, #cd, #command_paths, #dir!, #dir?, directory!, directory?, exist!, exist?, #exists!, #exists?, #file!, #file?, #file_read, #file_write, #fileutils, #glob, #multiglob, #multiglob_r, #out_of_date?, path!, path?, #rm_r, #safe?, #stage, #stage_manifest, #tar_bzip, #tgz, #zip, #ziputils

Methods included from Utilities::ShellUtils

#ask, #password, #sh, #status

Constructor Details

#initialize(options = nil) ⇒ Project

New Project.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/reap/project.rb', line 16

def initialize(options=nil)
  @options        = options || {}
  begin
    @location       = locate
    raise LoadError, "no .reap configuration file" unless @location

    @metadata = Metadata.read(location)
    @settings = Settings.read(location, @metadata)
  rescue LoadError => e
    abort e.message.capitalize + '.'
  end
end

Instance Method Details

#chdir_to_project(&block) ⇒ Object

Change directory to project’s root location, and execute block if given. If a block is provided, the current directory will revert back to what it was prior to this call, otherwise it will remain changed.



91
92
93
94
95
96
97
# File 'lib/reap/project.rb', line 91

def chdir_to_project(&block)
  if block
    Dir.chdir(location, &block)
  else
    Dir.chdir(location)
  end
end

#debug=(x) ⇒ Object



59
# File 'lib/reap/project.rb', line 59

def debug=(x)   ; options['debug']   = x ; end

#debug?Boolean

Returns:

  • (Boolean)


53
# File 'lib/reap/project.rb', line 53

def debug?      ; options['debug']   ; end

#display_locationObject

Display the project’s root location.



81
82
83
# File 'lib/reap/project.rb', line 81

def display_location
  puts "[#{location}]"
end

#dryrun=(x) ⇒ Object Also known as: noharm=



55
# File 'lib/reap/project.rb', line 55

def dryrun=(x)  ; options['dryrun']  = x ; end

#dryrun?Boolean Also known as: noharm?

Returns:

  • (Boolean)


49
# File 'lib/reap/project.rb', line 49

def dryrun?     ; options['dryrun']  ; end

#force=(x) ⇒ Object



57
# File 'lib/reap/project.rb', line 57

def force=(x)   ; options['force']   = x ; end

#force?Boolean

Returns:

  • (Boolean)


51
# File 'lib/reap/project.rb', line 51

def force?      ; options['force']   ; end

#introspect(options) ⇒ Object

Query infromation about reap settings and/or the current project.

NOTE: This would dhave been naed #inspect but for the built-in method.



110
111
112
113
114
115
116
117
118
119
# File 'lib/reap/project.rb', line 110

def introspect(options)
  args = options['arguments']
  if args
    args.each do |field|
      puts .send(field)
    end
  else
    y self
  end
end

#invoke(command, *args) ⇒ Object

Invoke a tool.



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/reap/project.rb', line 66

def invoke(command, *args)
  #display_location
  meth = method(command)
  chdir_to_project do
    case meth.arity
    when 0
      meth.call
    else
      meth.call(*args)
    end
  end
end

#locationObject

Location of project.



31
# File 'lib/reap/project.rb', line 31

def location ; @location ; end

#metadataObject

Project metadata.



35
# File 'lib/reap/project.rb', line 35

def  ; @metadata  ; end

#optionsObject

Common options.



47
# File 'lib/reap/project.rb', line 47

def options  ; @options  ; end

#settingsObject Also known as: configuration

Configuration data.



39
# File 'lib/reap/project.rb', line 39

def settings ; @settings ; end

#trace=(x) ⇒ Object



56
# File 'lib/reap/project.rb', line 56

def trace=(x)   ; options['trace']   = x ; end

#trace?Boolean

Returns:

  • (Boolean)


50
# File 'lib/reap/project.rb', line 50

def trace?      ; options['trace']   ; end

#verbose=(x) ⇒ Object



58
# File 'lib/reap/project.rb', line 58

def verbose=(x) ; options['verbose'] = x ; end

#verbose?Boolean

Returns:

  • (Boolean)


52
# File 'lib/reap/project.rb', line 52

def verbose?    ; options['verbose'] ; end