mr-shipper 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62a89124cd13c7f9c9bb8172289206e0a07a415c049798327e1499cec74616c6
4
- data.tar.gz: 96d6c8002ec688c7354722281d79073393429af6ca762566e7a5ccd4a94d24a5
3
+ metadata.gz: 1d8bafba34011cd5cae3f192c1295fe9000a7e7fef372e87dff5d5aa9ddc3e87
4
+ data.tar.gz: 037550c907e063a829f97b66a039a1fda746c500572c07728c6e2c8c7ebe156c
5
5
  SHA512:
6
- metadata.gz: a921c5767e5a4c01d935db8d1a609894672f7b6afae51891a5eee5cda6144302ce868ca5fbc691e6ff716736d5b1daa9dc78cf0b4cc9d64543714ef24e22eafb
7
- data.tar.gz: c6fbf4fad5b3cb7335e330d170f396c24c673cc5dc623c68e89f15a1d296fd35420db09d31eb05a5f4674e4167f56bab5421acc01cca5170e4af3f2cbb646825
6
+ metadata.gz: 905efb0a06fb836bbee45683da2a0c7c5d13a3f21b48ff9b1036865201536548b10f95c5615f6091e95c552e8fb4f0b5aac3d0f456c27eb05210b1b593cee526
7
+ data.tar.gz: c84bbf53143af3e6272e1e10f4f047ce3c92e9c37d7d4cd00f91e9c471acf39551ca77f1fa194405ed0f5afaf7e34f95aa654a89631bbe6594d772566cff7b65
data/bin/ship CHANGED
@@ -3,5 +3,4 @@
3
3
 
4
4
  require 'shipper'
5
5
 
6
- specified_services = ARGV.empty? ? nil : ARGV
7
- Shipper::Deploy.new(specified_services).perform
6
+ Shipper::Run.new(ARGV).perform
@@ -4,9 +4,9 @@ module Shipper
4
4
  class Deploy
5
5
  attr_reader :config, :specified_services
6
6
 
7
- def initialize(specified_services = nil)
7
+ def initialize(config, specified_services = nil)
8
+ @config = config
8
9
  @specified_services = specified_services
9
- @config = Shipper::Config.instance
10
10
  end
11
11
 
12
12
  def perform
data/lib/shipper/host.rb CHANGED
@@ -2,22 +2,24 @@
2
2
 
3
3
  module Shipper
4
4
  class Host
5
- attr_accessor :ssh_entry, :location, :executor
5
+ attr_accessor :user, :host, :location, :executor
6
6
 
7
7
  def initialize(options)
8
- @ssh_entry = options['ssh_entry']
8
+ @user, @host = options['ssh_entry'].split('@')
9
9
  @location = options['location']
10
10
  @executor = nil
11
11
  end
12
12
 
13
13
  def update!
14
- user, host = ssh_entry.split('@')
14
+ restart!(pull_changes: true)
15
+ end
15
16
 
17
+ def restart!(pull_changes: false)
16
18
  ::Net::SSH.start(host, user) do |ssh|
17
19
  load_executor(ssh)
18
20
 
19
21
  executor.cd location
20
- exec 'docker-compose pull'
22
+ exec 'docker-compose pull' if pull_changes
21
23
  exec 'docker-compose down'
22
24
  exec 'docker-compose up -d'
23
25
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shipper
4
+ class Run
5
+ attr_reader :config, :options
6
+
7
+ def initialize(options)
8
+ @options = options.empty? ? nil : options
9
+ @config = ::Shipper::Config.instance
10
+ end
11
+
12
+ def perform
13
+ if restart?
14
+ ::Shipper::Host.new(config.host).restart!
15
+ else
16
+ ::Shipper::Deploy.new(config, options).perform
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def restart?
23
+ options&.size == 1 && options[0] == 'restart'
24
+ end
25
+ end
26
+ end
data/lib/shipper.rb CHANGED
@@ -7,4 +7,5 @@ require 'shipper/executor'
7
7
  require 'shipper/host'
8
8
  require 'shipper/service'
9
9
  require 'shipper/logger'
10
+ require 'shipper/run'
10
11
  require 'shipper/deploy'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mr-shipper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rostyslav Safonov
@@ -52,13 +52,14 @@ files:
52
52
  - lib/shipper/executor.rb
53
53
  - lib/shipper/host.rb
54
54
  - lib/shipper/logger.rb
55
+ - lib/shipper/run.rb
55
56
  - lib/shipper/service.rb
56
57
  homepage: https://rubygemspecs.org/gems/mr-shipper
57
58
  licenses:
58
59
  - MIT
59
60
  metadata:
60
- source_code_uri: https://github.com/elhowm/shipper
61
- documentation_uri: https://github.com/elhowm/shipper
61
+ source_code_uri: https://github.com/elhowm/mr-shipper
62
+ documentation_uri: https://github.com/elhowm/mr-shipper
62
63
  post_install_message:
63
64
  rdoc_options: []
64
65
  require_paths:
@@ -74,8 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.7.9
78
+ rubygems_version: 3.0.3
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Docker shipping