stf-client 0.3.0.rc8 → 0.3.0.rc9

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
  SHA1:
3
- metadata.gz: df6473be189621a2aeaf56910c4f52983870376f
4
- data.tar.gz: e0c52156044073f2de9fc9ab1684f5ad61896346
3
+ metadata.gz: 8f3cd4d6b212dc0c25d4e73cf47b856df1ebef24
4
+ data.tar.gz: 689022a5a8023bccaaa6c1ec0b2c1b61f46a5bf8
5
5
  SHA512:
6
- metadata.gz: 702e983ad45b61315bc1e562e0c5b5e0efa608c567fbe8ca1778d8f05229bd27e197e72ba74d3a253fefeded4edbf464c4a093eaea8b87971b457b5c5f1db646
7
- data.tar.gz: 5868b248aa1508b2e06d08f4c9663c0cd66a341584b6b58dad7a96978fa2827175fb5d4443eef3fb234b2ef7cc9dd2dcdcff1d246df2369c4636470f14fb842a
6
+ metadata.gz: 22f0b4d6c29be20d704f17ec2fe3714ad322af0ecd0f996ced4fc04c8c22689176ce90a002249906b61cc628094e02410fba4d26f069005db8462435ac7fe38d
7
+ data.tar.gz: ed26145ed4eb3675405313ba312462ca9172dc793b8146f0cb7dba0ec3191a34f7a11dc47b1f5be66b4377e8d3b6b77960d195608f3c584b5dff5f960f166a7e
data/README.md CHANGED
@@ -48,7 +48,7 @@ COMMANDS
48
48
  connect - Search for a device available in STF and attach it to local adb server
49
49
  disconnect - Disconnect device(s) from local adb server and remove device(s) from user devices in STF
50
50
  help - Shows a list of commands or help for one command
51
- keys - Show avaliable keys for filtering
51
+ keys - Show available keys for filtering
52
52
  values - Show known values for the filtering key
53
53
 
54
54
  ENVIRONMENT VARIABLES
data/lib/di.rb CHANGED
@@ -9,6 +9,7 @@ require 'stf/interactor/stop_all_debug_sessions_interactor'
9
9
  require 'stf/interactor/remove_all_user_devices_interactor'
10
10
  require 'stf/interactor/get_keys_interactor'
11
11
  require 'stf/interactor/get_values_interactor'
12
+ require 'stf/validate/uri_validator'
12
13
 
13
14
  class DI
14
15
  class << self
@@ -60,6 +61,9 @@ class DI
60
61
  -> {Stf::RemoveAllUserDevicesInteractor.new},
61
62
  memoize: true)
62
63
 
64
+ c.register(:uri_validator,
65
+ -> {Stf::URIValidator.new},
66
+ memoize: true)
63
67
  end
64
68
 
65
69
  def [](what)
data/lib/stf/client.rb CHANGED
@@ -4,7 +4,6 @@ require 'ostruct'
4
4
 
5
5
  require 'stf/version'
6
6
  require 'stf/log/log'
7
- require 'stf/errors'
8
7
 
9
8
  module Stf
10
9
  class Client
@@ -3,8 +3,6 @@ require 'di'
3
3
 
4
4
  require 'stf/client'
5
5
  require 'stf/log/log'
6
- require 'stf/errors'
7
- require 'stf/model/session'
8
6
  require 'stf/model/device'
9
7
 
10
8
  module Stf
@@ -3,8 +3,6 @@ require 'ADB'
3
3
 
4
4
  require 'stf/client'
5
5
  require 'stf/log/log'
6
- require 'stf/errors'
7
- require 'stf/model/session'
8
6
  require 'stf/model/device'
9
7
 
10
8
  module Stf
@@ -2,8 +2,6 @@ require 'ADB'
2
2
 
3
3
  require 'stf/client'
4
4
  require 'stf/log/log'
5
- require 'stf/errors'
6
- require 'stf/model/session'
7
5
  require 'stf/model/device_list'
8
6
 
9
7
  module Stf
@@ -32,11 +30,11 @@ module Stf
32
30
  begin
33
31
  connect_loop(all_flag, wanted, filter, false, 5, start_timeout)
34
32
  rescue SignalException => e
35
- logger.info "Caught signal #{e.message}"
33
+ logger.info "Caught signal \"#{e.message}\""
36
34
  DI[:stop_all_debug_sessions_interactor].execute
37
35
  return false
38
- rescue
39
- logger.info "Exception #{e.message} during initial connect loop"
36
+ rescue Exception => e
37
+ logger.info "Exception \"#{e.message}\" during initial connect loop"
40
38
  DI[:stop_all_debug_sessions_interactor].execute
41
39
  return false
42
40
  end
@@ -116,25 +114,5 @@ module Stf
116
114
  DI[:stop_debug_session_interactor].execute(url)
117
115
  end
118
116
  end
119
-
120
- def connect(filter, all_flag, wanted)
121
- devices = DeviceList.new(DI[:stf].get_devices)
122
- devices = devices.filterReadyToConnect
123
- devices = devices.byFilter(filter) if filter
124
-
125
- if devices.empty?
126
- logger.error 'There is no available devices with criteria ' + filter
127
- return 0
128
- end
129
-
130
- n = 0
131
- devices.asArray.shuffle.each do |d|
132
- n += 1 if DI[:start_one_debug_session_interactor].execute(d)
133
- break if !all_flag && n >= wanted
134
- end
135
-
136
- n
137
- end
138
-
139
117
  end
140
118
  end
@@ -3,8 +3,6 @@ require 'ADB'
3
3
 
4
4
  require 'stf/client'
5
5
  require 'stf/log/log'
6
- require 'stf/errors'
7
- require 'stf/model/session'
8
6
 
9
7
  module Stf
10
8
  class StartOneDebugSessionInteractor
@@ -3,7 +3,6 @@ require 'ADB'
3
3
 
4
4
  require 'stf/client'
5
5
  require 'stf/log/log'
6
- require 'stf/errors'
7
6
  require 'stf/interactor/stop_debug_session_interactor'
8
7
  require 'stf/model/device_list'
9
8
 
@@ -3,7 +3,6 @@ require 'ADB'
3
3
 
4
4
  require 'stf/client'
5
5
  require 'stf/log/log'
6
- require 'stf/errors'
7
6
 
8
7
  module Stf
9
8
  class StopDebugSessionInteractor
@@ -32,7 +32,6 @@ module Stf
32
32
  end
33
33
 
34
34
  def reject
35
- # DeviceList.new(@devices.reject {|d| yield(d)})
36
35
  DeviceList.new(@devices.select {|d| !yield(d)})
37
36
  end
38
37
 
@@ -0,0 +1,7 @@
1
+ module Stf
2
+ class URIValidator
3
+ def validate(uri)
4
+ return (uri =~ /\A#{URI::regexp(%w(http https))}\z/) != nil
5
+ end
6
+ end
7
+ end
data/lib/stf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Stf
2
- VERSION = '0.3.0.rc8'
2
+ VERSION = '0.3.0.rc9'
3
3
  end
data/lib/stf/view/cli.rb CHANGED
@@ -35,6 +35,9 @@ module Stf
35
35
  Log::verbose(global_options[:verbose])
36
36
 
37
37
  DI.init(global_options)
38
+
39
+ help_now!('Valid STF url is required, e.g. http(s)://openstf.local') if !DI[:uri_validator].validate(global_options[:url])
40
+ true
38
41
  end
39
42
 
40
43
  desc 'Search for a device available in STF and attach it to local adb server'
@@ -61,7 +64,7 @@ module Stf
61
64
  end
62
65
  end
63
66
 
64
- desc 'Show avaliable keys for filtering'
67
+ desc 'Show available keys for filtering'
65
68
  command :keys do |c|
66
69
  c.action {puts DI[:get_keys_interactor].execute}
67
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stf-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.rc8
4
+ version: 0.3.0.rc9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Malinskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-28 00:00:00.000000000 Z
11
+ date: 2018-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -199,7 +199,6 @@ files:
199
199
  - lib/di.rb
200
200
  - lib/stf.rb
201
201
  - lib/stf/client.rb
202
- - lib/stf/errors.rb
203
202
  - lib/stf/interactor/get_keys_interactor.rb
204
203
  - lib/stf/interactor/get_values_interactor.rb
205
204
  - lib/stf/interactor/remove_all_user_devices_interactor.rb
@@ -210,8 +209,8 @@ files:
210
209
  - lib/stf/log/log.rb
211
210
  - lib/stf/model/device.rb
212
211
  - lib/stf/model/device_list.rb
213
- - lib/stf/model/session.rb
214
212
  - lib/stf/system/demonizer.rb
213
+ - lib/stf/validate/uri_validator.rb
215
214
  - lib/stf/version.rb
216
215
  - lib/stf/view/cli.rb
217
216
  - stf-client.gemspec
data/lib/stf/errors.rb DELETED
@@ -1,7 +0,0 @@
1
- module Stf
2
- class DeviceNotAvailableError < StandardError
3
- def message
4
- 'Device not available'
5
- end
6
- end
7
- end
@@ -1,12 +0,0 @@
1
- module Stf
2
- class Session
3
-
4
- attr_accessor :serial, :url
5
-
6
- def initialize(serial, url)
7
- @serial = serial
8
- @url = url
9
- end
10
-
11
- end
12
- end