Class: NeedsManager
- Inherits:
-
Object
- Object
- NeedsManager
- Defined in:
- lib/needs_manager.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#log_file ⇒ Object
readonly
Returns the value of attribute log_file.
-
#needs ⇒ Object
readonly
Returns the value of attribute needs.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #configure ⇒ Object
- #create_bundler ⇒ Object
- #create_migrator ⇒ Object
- #create_repo ⇒ Object
- #create_shell ⇒ Object
- #create_test_runner ⇒ Object
-
#initialize(task, needs, options) ⇒ NeedsManager
constructor
A new instance of NeedsManager.
- #log_file_for(task) ⇒ Object
- #repo_class ⇒ Object
- #set_working_directory ⇒ Object
- #shell_class ⇒ Object
Constructor Details
#initialize(task, needs, options) ⇒ NeedsManager
Returns a new instance of NeedsManager.
17 18 19 20 21 22 |
# File 'lib/needs_manager.rb', line 17 def initialize(task, needs, ) @log_file = log_file_for(task) @needs = needs = @env = {} end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
16 17 18 |
# File 'lib/needs_manager.rb', line 16 def env @env end |
#log_file ⇒ Object (readonly)
Returns the value of attribute log_file.
16 17 18 |
# File 'lib/needs_manager.rb', line 16 def log_file @log_file end |
#needs ⇒ Object (readonly)
Returns the value of attribute needs.
16 17 18 |
# File 'lib/needs_manager.rb', line 16 def needs @needs end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/needs_manager.rb', line 16 def end |
Class Method Details
.configure(task, needs, options) ⇒ Object
12 13 14 |
# File 'lib/needs_manager.rb', line 12 def self.configure(task, needs, ) new(task, needs, ).configure end |
Instance Method Details
#configure ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/needs_manager.rb', line 24 def configure set_working_directory create_shell create_repo if needs.include? :repo create_bundler if needs.include? :bundler create_migrator if needs.include? :migrator create_test_runner if needs.include? :test_runner return env end |
#create_bundler ⇒ Object
67 68 69 |
# File 'lib/needs_manager.rb', line 67 def create_bundler env[:bundler] = BundleManager.new(shell: env[:shell], repo: env[:repo]) end |
#create_migrator ⇒ Object
71 72 73 |
# File 'lib/needs_manager.rb', line 71 def create_migrator env[:migrator] = Migrator.new(shell: env[:shell], repo: env[:repo]) end |
#create_repo ⇒ Object
53 54 55 |
# File 'lib/needs_manager.rb', line 53 def create_repo env[:repo] = repo_class.new(shell: env[:shell]) end |
#create_shell ⇒ Object
41 42 43 |
# File 'lib/needs_manager.rb', line 41 def create_shell env[:shell] = shell_class.new(log_file, @working_directory) end |
#create_test_runner ⇒ Object
75 76 77 78 79 80 |
# File 'lib/needs_manager.rb', line 75 def create_test_runner env[:test_runner] = TestRunner.new( shell: env[:shell], all_engines: [:all_engines] ) end |
#log_file_for(task) ⇒ Object
82 83 84 |
# File 'lib/needs_manager.rb', line 82 def log_file_for(task) "/tmp/#{task}.log" end |
#repo_class ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/needs_manager.rb', line 57 def repo_class if [:repo_type] == :active ActiveRepo elsif [:repo_type] == :lazy LazyRepo else Repo end end |
#set_working_directory ⇒ Object
36 37 38 39 |
# File 'lib/needs_manager.rb', line 36 def set_working_directory @working_directory = Repo.root_dir Dir.chdir(@working_directory) end |
#shell_class ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/needs_manager.rb', line 45 def shell_class if [:loud] LoudShellRunner else ShellRunner end end |