Class: NeedsManager
- Inherits:
-
Object
- Object
- NeedsManager
- Defined in:
- lib/sfb_scripts/needs_manager.rb
Constant Summary collapse
- BUNDLER_MAX_THREAD_COUNT =
2- MIGRATOR_MAX_THREAD_COUNT =
8
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_folder_guard ⇒ 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.
13 14 15 16 17 18 |
# File 'lib/sfb_scripts/needs_manager.rb', line 13 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.
12 13 14 |
# File 'lib/sfb_scripts/needs_manager.rb', line 12 def env @env end |
#log_file ⇒ Object (readonly)
Returns the value of attribute log_file.
12 13 14 |
# File 'lib/sfb_scripts/needs_manager.rb', line 12 def log_file @log_file end |
#needs ⇒ Object (readonly)
Returns the value of attribute needs.
12 13 14 |
# File 'lib/sfb_scripts/needs_manager.rb', line 12 def needs @needs end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/sfb_scripts/needs_manager.rb', line 12 def end |
Class Method Details
.configure(task, needs, options) ⇒ Object
8 9 10 |
# File 'lib/sfb_scripts/needs_manager.rb', line 8 def self.configure(task, needs, ) new(task, needs, ).configure end |
Instance Method Details
#configure ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sfb_scripts/needs_manager.rb', line 20 def configure set_working_directory create_shell create_folder_guard 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
72 73 74 75 |
# File 'lib/sfb_scripts/needs_manager.rb', line 72 def create_bundler queue = WorkQueue.new(BUNDLER_MAX_THREAD_COUNT, nil) env[:bundler] = BundleManager.new(shell: env[:shell], repo: env[:repo], queue: queue, folder_guard: env[:folder_guard]) end |
#create_folder_guard ⇒ Object
53 54 55 56 |
# File 'lib/sfb_scripts/needs_manager.rb', line 53 def create_folder_guard denied_folders = [:ignore] || [] env[:folder_guard] = FolderGuard.new(denied_folders) end |
#create_migrator ⇒ Object
77 78 79 80 |
# File 'lib/sfb_scripts/needs_manager.rb', line 77 def create_migrator queue = WorkQueue.new(MIGRATOR_MAX_THREAD_COUNT, nil) env[:migrator] = Migrator.new(shell: env[:shell], repo: env[:repo], queue: queue, folder_guard: env[:folder_guard]) end |
#create_repo ⇒ Object
58 59 60 |
# File 'lib/sfb_scripts/needs_manager.rb', line 58 def create_repo env[:repo] = repo_class.new(shell: env[:shell]) end |
#create_shell ⇒ Object
39 40 41 |
# File 'lib/sfb_scripts/needs_manager.rb', line 39 def create_shell env[:shell] = shell_class.new(log_file, @working_directory) end |
#create_test_runner ⇒ Object
82 83 84 85 86 87 |
# File 'lib/sfb_scripts/needs_manager.rb', line 82 def create_test_runner env[:test_runner] = TestRunner.new( shell: env[:shell], all_engines: [:all_engines] ) end |
#log_file_for(task) ⇒ Object
89 90 91 |
# File 'lib/sfb_scripts/needs_manager.rb', line 89 def log_file_for(task) "/tmp/#{task}.log" end |
#repo_class ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/sfb_scripts/needs_manager.rb', line 62 def repo_class if [:repo_type] == :active ActiveRepo elsif [:repo_type] == :lazy LazyRepo else Repo end end |
#set_working_directory ⇒ Object
34 35 36 37 |
# File 'lib/sfb_scripts/needs_manager.rb', line 34 def set_working_directory @working_directory = Repo.root_dir Dir.chdir(@working_directory) end |
#shell_class ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/sfb_scripts/needs_manager.rb', line 43 def shell_class if [:verbose] VerboseShellRunner elsif [:loud] LoudShellRunner else ShellRunner end end |