Class: Statixite::DeploymentService

Inherits:
Object
  • Object
show all
Defined in:
app/services/statixite/deployment_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ DeploymentService

Returns a new instance of DeploymentService.



5
6
7
# File 'app/services/statixite/deployment_service.rb', line 5

def initialize(site)
  @site = site
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



3
4
5
# File 'app/services/statixite/deployment_service.rb', line 3

def directory
  @directory
end

#error_messageObject (readonly)

Returns the value of attribute error_message.



3
4
5
# File 'app/services/statixite/deployment_service.rb', line 3

def error_message
  @error_message
end

Instance Method Details

#deployObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/services/statixite/deployment_service.rb', line 9

def deploy
  gs = GitService.new(@site.site_build_path, @site.site_remote)
  if gs.successful?
    begin
      git_info_from_build = build_deploy_branch(gs)
      perform_deploy
      deployment = @site.deployments.create(
        :version => git_info_from_build[0],
        :sha => git_info_from_build[1]
      )
      @status = :success
    rescue => e
      Rails.logger.error e
      @error_message = e.message
      @status = :failed
    end
  else
    @error_message = gs.error_message
    @status = :failed
  end
  self
end

#successful?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/services/statixite/deployment_service.rb', line 32

def successful?
  @status == :success
end