Class: GTA::Manager
- Inherits:
-
Object
- Object
- GTA::Manager
- Defined in:
- lib/gta/manager.rb
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
Class Method Summary collapse
Instance Method Summary collapse
- #app_name ⇒ Object
- #checkout(name) ⇒ Object (also: #co)
- #config ⇒ Object
- #database_config_path ⇒ Object
- #fetch ⇒ Object
- #fetch! ⇒ Object
- #final_stage ⇒ Object
- #find_database_config(path) ⇒ Object
- #hotfixer(stage_name = nil) ⇒ Object
-
#initialize(config_path = nil) ⇒ Manager
constructor
A new instance of Manager.
- #push_to(name, forced = nil) ⇒ Object
- #setup ⇒ Object
- #stage(name) ⇒ Object
- #stage!(name) ⇒ Object
- #stages ⇒ Object
Constructor Details
#initialize(config_path = nil) ⇒ Manager
Returns a new instance of Manager.
5 6 7 |
# File 'lib/gta/manager.rb', line 5 def initialize(config_path = nil) @config_path = config_path || "#{Dir.pwd}/config/gta.yml" end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
3 4 5 |
# File 'lib/gta/manager.rb', line 3 def config_path @config_path end |
Class Method Details
.env_config ⇒ Object
84 85 86 |
# File 'lib/gta/manager.rb', line 84 def self.env_config ENV['GTA_CONFIG_PATH'] end |
.stage_name_error ⇒ Object
88 89 90 |
# File 'lib/gta/manager.rb', line 88 def self.stage_name_error "Stage name required. Run rake with argument - `rake:deploy[staging]`" end |
Instance Method Details
#app_name ⇒ Object
19 20 21 |
# File 'lib/gta/manager.rb', line 19 def app_name @app_name || config && @app_name end |
#checkout(name) ⇒ Object Also known as: co
27 28 29 30 |
# File 'lib/gta/manager.rb', line 27 def checkout(name) stage!(name).fetch stage!(name).checkout end |
#config ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/gta/manager.rb', line 46 def config return @config if @config parsed = YAML.load(File.read(config_path)) @app_name = parsed['name'] @database_config_path = find_database_config(parsed['database_config']) @config = parsed['stages'] end |
#database_config_path ⇒ Object
23 24 25 |
# File 'lib/gta/manager.rb', line 23 def database_config_path @database_config_path || config && @database_config_path end |
#fetch ⇒ Object
34 35 36 |
# File 'lib/gta/manager.rb', line 34 def fetch stages.each(&:fetch) end |
#fetch! ⇒ Object
38 39 40 |
# File 'lib/gta/manager.rb', line 38 def fetch! stages.each(&:fetch!) end |
#final_stage ⇒ Object
70 71 72 |
# File 'lib/gta/manager.rb', line 70 def final_stage stages.detect{|s| s.final? } || stages.last end |
#find_database_config(path) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/gta/manager.rb', line 54 def find_database_config(path) if path File.dirname(config_path) + "/#{path}" else LocalDB.default_database_config_path end end |
#hotfixer(stage_name = nil) ⇒ Object
74 75 76 77 78 |
# File 'lib/gta/manager.rb', line 74 def hotfixer(stage_name=nil) hotfixers = stages.select{|s| s.hotfixable?} default = stage_name == nil ? hotfixers.first : nil hotfixers.detect{|s| s.name == stage_name} || default end |
#push_to(name, forced = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/gta/manager.rb', line 9 def push_to(name, forced = nil) s = stage!(name) fetch! if forced == :force s.force_push else s.push end end |
#setup ⇒ Object
42 43 44 |
# File 'lib/gta/manager.rb', line 42 def setup stages.each(&:add_remote) end |
#stage(name) ⇒ Object
66 67 68 |
# File 'lib/gta/manager.rb', line 66 def stage(name) stages.detect{|s| s.name == name.to_s} end |
#stage!(name) ⇒ Object
80 81 82 |
# File 'lib/gta/manager.rb', line 80 def stage!(name) stage(name) || (raise ArgumentError.new("Stage #{name} not found")) end |