Class: NeedsManager
- Inherits:
-
Object
- Object
- NeedsManager
- Defined in:
- lib/sfb_scripts/needs_manager.rb
Constant Summary collapse
- BUNDLER_MAX_THREAD_COUNT =
4- 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
13 14 15 16 17 18 19 |
# File 'lib/sfb_scripts/needs_manager.rb', line 13 def initialize(task, needs, ) @log_file = log_file_for(task) @needs = needs # symbolize_keys = .inject({}){|results,(k,v)| results[k.to_sym] = v; results} @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
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sfb_scripts/needs_manager.rb', line 21 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
73 74 75 76 |
# File 'lib/sfb_scripts/needs_manager.rb', line 73 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
54 55 56 57 |
# File 'lib/sfb_scripts/needs_manager.rb', line 54 def create_folder_guard denied_folders = [:ignore] || [] env[:folder_guard] = FolderGuard.new(denied_folders) end |
#create_migrator ⇒ Object
78 79 80 81 |
# File 'lib/sfb_scripts/needs_manager.rb', line 78 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], drop_dbs: [:reset]) end |
#create_repo ⇒ Object
59 60 61 |
# File 'lib/sfb_scripts/needs_manager.rb', line 59 def create_repo env[:repo] = repo_class.new(shell: env[:shell]) end |
#create_shell ⇒ Object
40 41 42 |
# File 'lib/sfb_scripts/needs_manager.rb', line 40 def create_shell env[:shell] = shell_class.new(log_file, @working_directory) end |
#create_test_runner ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/sfb_scripts/needs_manager.rb', line 83 def create_test_runner env[:test_runner] = TestRunner.new( shell: env[:shell], all_engines: [:all_engines], always_ask_before_grouping_tests: [:timid] ) end |
#log_file_for(task) ⇒ Object
91 92 93 |
# File 'lib/sfb_scripts/needs_manager.rb', line 91 def log_file_for(task) "/tmp/#{task}.log" end |
#repo_class ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/sfb_scripts/needs_manager.rb', line 63 def repo_class if [:repo_type] == :active ActiveRepo elsif [:repo_type] == :lazy LazyRepo else Repo end end |
#set_working_directory ⇒ Object
35 36 37 38 |
# File 'lib/sfb_scripts/needs_manager.rb', line 35 def set_working_directory @working_directory = Repo.root_dir Dir.chdir(@working_directory) end |
#shell_class ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/sfb_scripts/needs_manager.rb', line 44 def shell_class if [:verbose] VerboseShellRunner elsif [:loud] LoudShellRunner else ShellRunner end end |