ruby_fly 0.26.0.pre.1 → 0.31.0

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: f9009ca11dd23325ac48457a3e328ebbea4238b740a45c4d1eb632e77e7cf056
4
- data.tar.gz: f88791482aa8f5e21b16ae05c829679898258ce09cc33eb757fd35099cc3ffcf
3
+ metadata.gz: 1aec81474f0e12fc29330cc203f355ecf8d7c3bf7e0e6c5416114d19cbcdb260
4
+ data.tar.gz: ef2ef9f67bb65f2280ecc229cce167c54f1cdb92986cd32eadcdef6f274f5297
5
5
  SHA512:
6
- metadata.gz: 7514713d9964c05883b85f4aaa09fff06d5508cb142ac6049ef435c413f029e50fbb05674d048be0b8b130fe0207c965e28b1afa0cedf21b0f5e9e793afd0952
7
- data.tar.gz: 7b652df06e8441359f38fbb2513f06ee3d8d25effd293147cdf1b16ee1bfcfeefcc2d52d6f0f487e1cf4036955d577a6b6605fedfeb72f38bd57230ab1040d50
6
+ metadata.gz: 742493d392c7a4dd0cc2f265706e98655248b3b40b02c0ac5c9fde5c5acbec50e73446ad403fdbebc78069673b9bddfae4de6e7ce3e778ada8e4577e430d16a4
7
+ data.tar.gz: b8b06eee78c37cbb4944eaca495e5cb26bf0c9217b7586422ecea78d0e669972c878c45b51e78bfa07d89ffcb471b6f61592f11792bafc969713ca9c525b2f07
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_fly (0.26.0.pre.1)
4
+ ruby_fly (0.31.0)
5
5
  lino (>= 1.5)
6
6
 
7
7
  GEM
@@ -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
@@ -47,10 +51,13 @@ module RubyFly
47
51
  end
48
52
 
49
53
  class Configuration
50
- attr_accessor :binary
54
+ attr_accessor :binary, :stdin, :stdout, :stderr
51
55
 
52
56
  def initialize
53
57
  @binary = 'fly'
58
+ @stdin = ''
59
+ @stdout = $stdout
60
+ @stderr = $stderr
54
61
  end
55
62
  end
56
63
  end
@@ -1,4 +1,5 @@
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'
@@ -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,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.26.0.pre.1'
2
+ VERSION = '0.31.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_fly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0.pre.1
4
+ version: 0.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
@@ -187,6 +187,7 @@ files:
187
187
  - lib/ruby_fly/commands/login.rb
188
188
  - lib/ruby_fly/commands/mixins/environment.rb
189
189
  - lib/ruby_fly/commands/set_pipeline.rb
190
+ - lib/ruby_fly/commands/status.rb
190
191
  - lib/ruby_fly/commands/unpause_pipeline.rb
191
192
  - lib/ruby_fly/commands/version.rb
192
193
  - lib/ruby_fly/rc.rb
@@ -206,9 +207,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
207
  version: '2.6'
207
208
  required_rubygems_version: !ruby/object:Gem::Requirement
208
209
  requirements:
209
- - - ">"
210
+ - - ">="
210
211
  - !ruby/object:Gem::Version
211
- version: 1.3.1
212
+ version: '0'
212
213
  requirements: []
213
214
  rubygems_version: 3.0.1
214
215
  signing_key: