Class: RakeTasksDockerSync::Services

Inherits:
RakeTasksDocker::Services
  • Object
show all
Defined in:
lib/rake-tasks-docker-sync/services.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(syncs) ⇒ Services

Returns a new instance of Services.



14
15
16
# File 'lib/rake-tasks-docker-sync/services.rb', line 14

def initialize(syncs)
  @services = syncs
end

Class Method Details

.from_args(_args) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/rake-tasks-docker-sync/services.rb', line 6

def self.from_args(_args)
  raise 'No docker-sync.yml configuration found in your path' unless File.exist?('docker-sync.yml')

  docker_sync_config = YAML.load_file('docker-sync.yml')

  self.new(docker_sync_config['syncs'].keys)
end

Instance Method Details

#downObject



26
27
28
# File 'lib/rake-tasks-docker-sync/services.rb', line 26

def down
  system 'docker-sync', 'clean'
end

#exec(user, command) ⇒ Object



30
31
32
33
34
# File 'lib/rake-tasks-docker-sync/services.rb', line 30

def exec(user, command)
  @services.each do |service|
    system 'docker', 'exec', '--user', user, service, command
  end
end

#stopObject



22
23
24
# File 'lib/rake-tasks-docker-sync/services.rb', line 22

def stop
  system 'docker-sync', 'stop'
end

#upObject



18
19
20
# File 'lib/rake-tasks-docker-sync/services.rb', line 18

def up
  system 'docker-sync', 'start'
end