Class: Greenhouse::Projects::Project
- Inherits:
-
Object
- Object
- Greenhouse::Projects::Project
- Defined in:
- lib/greenhouse/projects/project.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.subclasses ⇒ Object
readonly
Returns the value of attribute subclasses.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Keep track of inheriting classes (to use as project “types”).
Instance Method Summary collapse
-
#bundle(cmd = 'install') ⇒ Object
Go into the local directory and run Bundler.
- #chdir(&block) ⇒ Object
-
#destroy ⇒ Object
Remove the project directory.
-
#exists? ⇒ Boolean
Check if the repository exists.
- #gemfile ⇒ Object
- #gemfile? ⇒ Boolean
- #ignored ⇒ Object
-
#initialize(name, args = {}) ⇒ Project
constructor
A new instance of Project.
-
#path ⇒ Object
Return the local path to the project repo.
- #to_arg ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(name, args = {}) ⇒ Project
Returns a new instance of Project.
16 17 18 19 20 21 22 |
# File 'lib/greenhouse/projects/project.rb', line 16 def initialize(name, args={}) @name = name @title = args.delete(:title) || name.camelize @ignored = (args.has_key?(:ignore) ? [args.delete(:ignore)] : []).flatten @repository = Repository.new(name, args) @ignore_file = Resources::IgnoreFile.new("#{path}/.ignore") end |
Class Attribute Details
.subclasses ⇒ Object (readonly)
Returns the value of attribute subclasses.
7 8 9 |
# File 'lib/greenhouse/projects/project.rb', line 7 def subclasses @subclasses end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/greenhouse/projects/project.rb', line 4 def name @name end |
#repository ⇒ Object
Returns the value of attribute repository.
4 5 6 |
# File 'lib/greenhouse/projects/project.rb', line 4 def repository @repository end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/greenhouse/projects/project.rb', line 4 def title @title end |
Class Method Details
.inherited(subclass) ⇒ Object
Keep track of inheriting classes (to use as project “types”)
10 11 12 |
# File 'lib/greenhouse/projects/project.rb', line 10 def inherited(subclass) (@subclasses ||= [self]) << subclass end |
Instance Method Details
#bundle(cmd = 'install') ⇒ Object
Go into the local directory and run Bundler
60 61 62 63 64 65 66 67 68 |
# File 'lib/greenhouse/projects/project.rb', line 60 def bundle(cmd='install') raise "Directory does not exist: #{path}" unless exists? Dir.chdir(path) do Bundler.with_clean_env do # TODO look into using Bundler to install instead of executing system cmd Greenhouse::CLI::exec "bundle #{cmd.to_s} 2>&1" end end end |
#chdir(&block) ⇒ Object
28 29 30 |
# File 'lib/greenhouse/projects/project.rb', line 28 def chdir(&block) Dir.chdir(path, &block) end |
#destroy ⇒ Object
Remove the project directory
71 72 73 |
# File 'lib/greenhouse/projects/project.rb', line 71 def destroy @repository.destroy # use the repository object to destroy itself/directory end |
#exists? ⇒ Boolean
Check if the repository exists
47 48 49 |
# File 'lib/greenhouse/projects/project.rb', line 47 def exists? @repository.exists? end |
#gemfile ⇒ Object
37 38 39 40 |
# File 'lib/greenhouse/projects/project.rb', line 37 def gemfile return nil unless gemfile? "#{path}/Gemfile" end |
#gemfile? ⇒ Boolean
42 43 44 |
# File 'lib/greenhouse/projects/project.rb', line 42 def gemfile? chdir { return File.exists?("Gemfile") } end |
#ignored ⇒ Object
24 25 26 |
# File 'lib/greenhouse/projects/project.rb', line 24 def ignored Projects.ignored.concat(@ignore_file.ignored).concat(@ignored) end |
#path ⇒ Object
Return the local path to the project repo
33 34 35 |
# File 'lib/greenhouse/projects/project.rb', line 33 def path @repository.path end |
#to_arg ⇒ Object
55 56 57 |
# File 'lib/greenhouse/projects/project.rb', line 55 def to_arg Scripts::Argument.new(name, :summary => "#{title} (#{type.capitalize})") end |
#type ⇒ Object
51 52 53 |
# File 'lib/greenhouse/projects/project.rb', line 51 def type self.class.name.underscore.split('/').last end |