ruby_fly 0.27.0 → 0.32.0.pre.1

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: 9a51cab475fee762ba99cafe67c2e797d22c3d9f564b23e1b3e4ebb2fb133d13
4
- data.tar.gz: ce8399a8af389013f0836adf870fd04a34e13a82b27a2d3818cee6662473dc9f
3
+ metadata.gz: abcd3cc91c09e86f00c971d1473d3503021ec51ca355cecace76e433f50c2541
4
+ data.tar.gz: 2e50a3435fd3695b9876f0a3b91654c9a8d20c92975ba5d213c98aaef9108925
5
5
  SHA512:
6
- metadata.gz: '0828f4b252f8b18337b63f46f287563caa83b8535af96d13bb9e73568f8b075f9ba3d70983fc01587dced3ff4c5e5da19268ce537663c00d03ff65256b7000eb'
7
- data.tar.gz: 863c71bc854bd329fd1735537d38cb23715a5463fdf03c1d9db71787a7ef73769ca4ad102c9d36032436a92bf340e72f440828bc5aa2ef0c159ea8a6912804dd
6
+ metadata.gz: 9f7c37edaa05cf66d1563624d6a7ab83e91aa9eb04c9d01a8cdad7fd9f6352fe225e55edfa0ad6d8aa1efd67943f48455208c288899a598fc9ecd6abc9936182
7
+ data.tar.gz: 5eb7edb2b646994c056601edac7540f2dab962428243dd1b862a4917f1b2b4b0c7df18e560015b68a1fb4f7cc38d509682826efe0f64e4325738930ab3ba86ee
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_fly (0.27.0)
4
+ ruby_fly (0.32.0.pre.1)
5
5
  lino (>= 1.5)
6
6
 
7
7
  GEM
@@ -104,4 +104,4 @@ DEPENDENCIES
104
104
  ruby_fly!
105
105
 
106
106
  BUNDLED WITH
107
- 2.2.4
107
+ 2.2.7
@@ -24,6 +24,10 @@ module RubyFly
24
24
  Commands::Login.new.execute(opts)
25
25
  end
26
26
 
27
+ def status(opts = {})
28
+ Commands::Status.new.execute(opts)
29
+ end
30
+
27
31
  def get_pipeline(opts = {})
28
32
  Commands::GetPipeline.new.execute(opts)
29
33
  end
@@ -36,6 +40,10 @@ module RubyFly
36
40
  Commands::UnpausePipeline.new.execute(opts)
37
41
  end
38
42
 
43
+ def destroy_pipeline(opts = {})
44
+ Commands::DestroyPipeline.new.execute(opts)
45
+ end
46
+
39
47
  def version
40
48
  Commands::Version.new.execute
41
49
  end
@@ -47,10 +55,13 @@ module RubyFly
47
55
  end
48
56
 
49
57
  class Configuration
50
- attr_accessor :binary
58
+ attr_accessor :binary, :stdin, :stdout, :stderr
51
59
 
52
60
  def initialize
53
61
  @binary = 'fly'
62
+ @stdin = ''
63
+ @stdout = $stdout
64
+ @stderr = $stderr
54
65
  end
55
66
  end
56
67
  end
@@ -1,7 +1,9 @@
1
1
  require_relative 'commands/login'
2
+ require_relative 'commands/status'
2
3
  require_relative 'commands/get_pipeline'
3
4
  require_relative 'commands/set_pipeline'
4
5
  require_relative 'commands/unpause_pipeline'
6
+ require_relative 'commands/destroy_pipeline'
5
7
  require_relative 'commands/version'
6
8
 
7
9
  module RubyFly
@@ -3,34 +3,27 @@ require 'lino'
3
3
  module RubyFly
4
4
  module Commands
5
5
  class Base
6
- attr_reader :binary
6
+ attr_reader :binary, :stdin, :stdout, :stderr
7
7
 
8
8
  def initialize(binary: nil)
9
9
  @binary = binary || RubyFly.configuration.binary
10
- end
11
-
12
- def stdin
13
- ''
14
- end
15
-
16
- def stdout
17
- STDOUT
18
- end
19
-
20
- def stderr
21
- STDERR
10
+ @stdin = stdin || RubyFly.configuration.stdin
11
+ @stdout = stdout || RubyFly.configuration.stdout
12
+ @stderr = stderr || RubyFly.configuration.stderr
22
13
  end
23
14
 
24
15
  def execute(opts = {})
25
16
  builder = instantiate_builder
26
17
 
27
18
  do_before(opts)
28
- configure_command(builder, opts)
29
- .build
30
- .execute(
31
- stdin: stdin,
32
- stdout: stdout,
33
- stderr: stderr)
19
+ do_around(opts) do |new_opts|
20
+ configure_command(builder, new_opts)
21
+ .build
22
+ .execute(
23
+ stdin: stdin,
24
+ stdout: stdout,
25
+ stderr: stderr)
26
+ end
34
27
  do_after(opts)
35
28
  end
36
29
 
@@ -43,6 +36,10 @@ module RubyFly
43
36
  def do_before(opts)
44
37
  end
45
38
 
39
+ def do_around(opts, &block)
40
+ block.call(opts)
41
+ end
42
+
46
43
  def configure_command(builder, opts)
47
44
  builder
48
45
  end
@@ -0,0 +1,37 @@
1
+ require 'lino'
2
+ require_relative 'base'
3
+ require_relative 'mixins/environment'
4
+
5
+ module RubyFly
6
+ module Commands
7
+ class DestroyPipeline < Base
8
+ include Mixins::Environment
9
+
10
+ def configure_command(builder, opts)
11
+ builder = super(builder, opts)
12
+
13
+ missing_params = [
14
+ :target,
15
+ :pipeline
16
+ ].select { |param| opts[param].nil? }
17
+
18
+ unless missing_params.empty?
19
+ description = missing_params.map { |p| "'#{p}'" }.join(', ')
20
+ raise(
21
+ ArgumentError,
22
+ "Error: #{description} required but not provided.")
23
+ end
24
+
25
+ target = opts[:target]
26
+ pipeline = opts[:pipeline]
27
+
28
+ builder
29
+ .with_subcommand('destroy-pipeline') do |sub|
30
+ sub = sub.with_option('-t', target)
31
+ sub = sub.with_option('-p', pipeline)
32
+ sub
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,62 @@
1
+ require 'lino'
2
+ require_relative 'base'
3
+ require_relative 'mixins/environment'
4
+
5
+ module RubyFly
6
+ module Commands
7
+ class Status < Base
8
+ include Mixins::Environment
9
+
10
+ def initialize(*args)
11
+ super(*args)
12
+ @stdout = StringIO.new unless
13
+ (defined?(@stdout) && @stdout.respond_to?(:string))
14
+ @stderr = StringIO.new unless
15
+ (defined?(@stderr) && @stderr.respond_to?(:string))
16
+ end
17
+
18
+ def configure_command(builder, opts)
19
+ builder = super(builder, opts)
20
+
21
+ missing_params = [
22
+ :target
23
+ ].select { |param| opts[param].nil? }
24
+
25
+ unless missing_params.empty?
26
+ description = missing_params.map { |p| "'#{p}'" }.join(', ')
27
+ raise(
28
+ ArgumentError,
29
+ "Error: #{description} required but not provided.")
30
+ end
31
+
32
+ target = opts[:target]
33
+
34
+ builder
35
+ .with_subcommand('status') do |sub|
36
+ sub = sub.with_option('-t', target)
37
+ sub
38
+ end
39
+ end
40
+
41
+ def do_around(opts, &block)
42
+ begin
43
+ block.call(opts)
44
+ rescue Open4::SpawnError => e
45
+ raise e unless e.status.exitstatus == 1
46
+ end
47
+ end
48
+
49
+ def do_after(opts)
50
+ output = stdout.string
51
+ error = stderr.string
52
+
53
+ return :logged_in if output =~ /logged in successfully/
54
+ return :logged_out if error =~ /logged out/
55
+ return :session_expired if error =~ /please login again/
56
+ return :unknown_target if error =~ /error: unknown target/
57
+
58
+ :unknown_status
59
+ end
60
+ end
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyFly
2
- VERSION = '0.27.0'
2
+ VERSION = '0.32.0.pre.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_fly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.32.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-05 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lino
@@ -183,10 +183,12 @@ files:
183
183
  - lib/ruby_fly.rb
184
184
  - lib/ruby_fly/commands.rb
185
185
  - lib/ruby_fly/commands/base.rb
186
+ - lib/ruby_fly/commands/destroy_pipeline.rb
186
187
  - lib/ruby_fly/commands/get_pipeline.rb
187
188
  - lib/ruby_fly/commands/login.rb
188
189
  - lib/ruby_fly/commands/mixins/environment.rb
189
190
  - lib/ruby_fly/commands/set_pipeline.rb
191
+ - lib/ruby_fly/commands/status.rb
190
192
  - lib/ruby_fly/commands/unpause_pipeline.rb
191
193
  - lib/ruby_fly/commands/version.rb
192
194
  - lib/ruby_fly/rc.rb
@@ -206,9 +208,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
208
  version: '2.6'
207
209
  required_rubygems_version: !ruby/object:Gem::Requirement
208
210
  requirements:
209
- - - ">="
211
+ - - ">"
210
212
  - !ruby/object:Gem::Version
211
- version: '0'
213
+ version: 1.3.1
212
214
  requirements: []
213
215
  rubygems_version: 3.0.1
214
216
  signing_key: