Module: Miniploy::DSL

Included in:
Deploy
Defined in:
lib/miniploy/dsl.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#appObject

Returns the value of attribute app.



3
4
5
# File 'lib/miniploy/dsl.rb', line 3

def app
  @app
end

#bundle_addObject

Returns the value of attribute bundle_add.



3
4
5
# File 'lib/miniploy/dsl.rb', line 3

def bundle_add
  @bundle_add
end

#repositoryObject

Returns the value of attribute repository.



3
4
5
# File 'lib/miniploy/dsl.rb', line 3

def repository
  @repository
end

#ssh_argsObject

Returns the value of attribute ssh_args.



3
4
5
# File 'lib/miniploy/dsl.rb', line 3

def ssh_args
  @ssh_args
end

#targetObject

Returns the value of attribute target.



3
4
5
# File 'lib/miniploy/dsl.rb', line 3

def target
  @target
end

Class Method Details

.hook(*methods) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/miniploy/dsl.rb', line 30

def self.hook(*methods)
  methods.each do |method|
    eval <<-eoh
      def #{method}(&block)
        @hooks ||= {}
        if block_given?
          @hooks[:#{method}] = block
        else
          @hooks[:#{method}].call
        end
      end
    eoh
  end
end

Instance Method Details

#app_pathObject



5
6
7
# File 'lib/miniploy/dsl.rb', line 5

def app_path
  "apps/#{app}"
end

#append(filepath, content) ⇒ Object



9
10
11
# File 'lib/miniploy/dsl.rb', line 9

def append(filepath, content)
  run "echo \"#{content}\" >> #{filepath}"
end

#bundle_run(cmd) ⇒ Object



13
14
15
# File 'lib/miniploy/dsl.rb', line 13

def bundle_run(cmd)
  run "cd #{app_path} && RACK_ENV=production bundle exec #{cmd}"
end

#rake(task) ⇒ Object



17
18
19
# File 'lib/miniploy/dsl.rb', line 17

def rake(task)
  bundle_run "rake #{task}"
end

#run(cmd) ⇒ Object

Raises:

  • (RuntimeError)


21
22
23
24
# File 'lib/miniploy/dsl.rb', line 21

def run(cmd)
  puts ">> `#{cmd}`"
  raise RuntimeError unless ssh(cmd)
end

#run_pathObject



26
27
28
# File 'lib/miniploy/dsl.rb', line 26

def run_path
  "#{app_path}/tmp/run"
end