superbot-cloud 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db593e16a528d6b2d3962fc3cbf698c371c33ab782f7a4c466863655e06779eb
4
- data.tar.gz: 4852ae8c8b4edb93faecdc2fc90e58eeaab958ce66e42f04df7f45496f426789
3
+ metadata.gz: 974b01bdf05f6ef310b1d8350a3828b5fc2195e91cd46d88ca7e4298416fd800
4
+ data.tar.gz: 6795a9122f33dfeeebc40804eb528a700351d760abc872275a1abe2446a8a2ab
5
5
  SHA512:
6
- metadata.gz: 83306afd7af5b132ff46d96be8b3e4fe5c1fc3f52c5836b7fa8a6a41e2a130dfe1ff08cb6d5a337da96e978861a02227f4ac06bcf8cf5bce7ffe7f367e75cfb6
7
- data.tar.gz: 9ab8d305a398c82d6cf8e24c774466940fb6f036a301d7d72ef74b37f506a7186415eac68dd8cdf483a76c2b8ba1208067b0138e81584e6378f65733ffded570
6
+ metadata.gz: a7a3ac1f4bf6b972cdffd1e4414f60e74bae3f6ef02c3c25f13df17eac4d9cea5d9c911c9623c621be428c4f2ac0bb38b54970923e6623e97b1858a060b71815
7
+ data.tar.gz: 65595db9d9a843c7b90209171ee557be310e71a064c62dcbc0a02795c1a5683c01c3f91800f3583c757dc2a9ecfdb745dbe92559178fe547aa29c602a8146985
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superbot-cloud (0.3.0)
4
+ superbot-cloud (0.3.1)
5
5
  marcel (= 0.3.3)
6
6
  multipart-post (= 2.0.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.5.2)
11
+ addressable (2.6.0)
12
12
  public_suffix (>= 2.0.2, < 4.0)
13
13
  archive-zip (0.11.0)
14
14
  io-like (~> 0.3.0)
@@ -33,7 +33,7 @@ GEM
33
33
  mini_portile2 (2.4.0)
34
34
  multipart-post (2.0.0)
35
35
  mustermann (1.0.3)
36
- nokogiri (1.10.0)
36
+ nokogiri (1.10.1)
37
37
  mini_portile2 (~> 2.4.0)
38
38
  parallel (1.12.1)
39
39
  parser (2.5.1.2)
@@ -41,7 +41,7 @@ GEM
41
41
  powerpack (0.1.2)
42
42
  public_suffix (3.0.3)
43
43
  rack (2.0.6)
44
- rack-protection (2.0.4)
44
+ rack-protection (2.0.5)
45
45
  rack
46
46
  rainbow (3.0.0)
47
47
  rake (10.5.0)
@@ -71,34 +71,34 @@ GEM
71
71
  selenium-webdriver (3.141.0)
72
72
  childprocess (~> 0.5)
73
73
  rubyzip (~> 1.2, >= 1.2.2)
74
- sinatra (2.0.4)
74
+ sinatra (2.0.5)
75
75
  mustermann (~> 1.0)
76
76
  rack (~> 2.0)
77
- rack-protection (= 2.0.4)
77
+ rack-protection (= 2.0.5)
78
78
  tilt (~> 2.0)
79
79
  sinatra-silent (0.0.1)
80
- superbot (0.3.0)
80
+ superbot (0.4.0)
81
81
  clamp (= 1.2.1)
82
82
  kommando (= 0.1.2)
83
83
  launchy (= 2.4.3)
84
- sinatra (= 2.0.4)
84
+ sinatra (= 2.0.5)
85
85
  sinatra-silent (= 0.0.1)
86
- superbot-cloud (= 0.2.1)
86
+ superbot-cloud (= 0.3.0)
87
87
  superbot-record (= 0.1.0)
88
- superbot-runner (= 0.1.2)
88
+ superbot-runner (= 0.1.3)
89
89
  superbot-selenium-webdriver (= 1.0.5)
90
- superbot-teleport (= 0.2.5)
90
+ superbot-teleport (= 0.3.0)
91
91
  zaru (= 0.2.0)
92
92
  superbot-record (0.1.0)
93
93
  superbot-record-chrome
94
94
  superbot-record-chrome (0.1.0)
95
- superbot-runner (0.1.2)
95
+ superbot-runner (0.1.3)
96
96
  superbot-runner-side
97
97
  superbot-runner-side (0.1.0)
98
98
  superbot-selenium-webdriver (1.0.5)
99
99
  chromedriver-helper (= 2.1.0)
100
100
  selenium-webdriver (= 3.141.0)
101
- superbot-teleport (0.2.5)
101
+ superbot-teleport (0.3.0)
102
102
  excon
103
103
  tilt (2.0.9)
104
104
  unicode-display_width (1.4.0)
@@ -112,7 +112,7 @@ DEPENDENCIES
112
112
  rake (~> 10.0)
113
113
  rspec (~> 3.0)
114
114
  rubocop (~> 0.53)
115
- superbot (~> 0.3.0)
115
+ superbot (~> 0.4.0)
116
116
  superbot-cloud!
117
117
 
118
118
  BUNDLED WITH
@@ -26,7 +26,6 @@ module Superbot
26
26
  all_credentials[Superbot::DOMAIN.to_sym] = data.transform_keys!(&:to_sym)
27
27
  FileUtils.mkdir_p CREDENTIALS_PATH
28
28
  File.write CREDENTIALS_FILE_PATH, all_credentials.to_json
29
- puts "Logged in as %<username>s (%<email>s)" % credentials.slice(:username, :email)
30
29
  end
31
30
 
32
31
  def self.remove_credentials
@@ -9,6 +9,7 @@ module Superbot
9
9
  ENDPOINT_MAP = {
10
10
  token: { method: :post, endpoint: 'token' },
11
11
  organization_list: { method: :get, endpoint: 'organizations' },
12
+ get_organization: { method: :get, endpoint: 'organizations', required_param: :name},
12
13
  test_list: { method: :get, endpoint: 'tests' },
13
14
  test_upload: { method: :post_multipart, endpoint: 'tests' },
14
15
  test_download: { method: :get, endpoint: 'tests', required_param: :name },
@@ -34,7 +35,7 @@ module Superbot
34
35
 
35
36
  def self.request(type, params: {})
36
37
  method, endpoint, required_param = ENDPOINT_MAP[type].values
37
- uri = URI.parse([BASE_URI, endpoint, params[required_param]].compact.join('/'))
38
+ uri = URI.parse([BASE_URI, endpoint, params[required_param] && CGI.escape(params[required_param])].compact.join('/'))
38
39
 
39
40
  request_class = Net::HTTP.const_get(method.to_s.split('_').map(&:capitalize).join('::'))
40
41
 
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Superbot
4
+ module Cloud
5
+ module CLI
6
+ module Organization
7
+ class BaseCommand < LoginRequiredCommand
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Superbot
4
+ module Cloud
5
+ module CLI
6
+ module Organization
7
+ class DefaultCommand < BaseCommand
8
+ parameter "NAME", "Organization name", required: true
9
+
10
+ def execute
11
+ organization = Superbot::Cloud::Api.request(:get_organization, params: { name: name })
12
+ new_credentials = Superbot::Cloud.credentials.merge(organization: organization[:name])
13
+ Superbot::Cloud.save_credentials(new_credentials)
14
+
15
+ puts "Default organization: #{Superbot::Cloud.credentials[:organization]}"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -4,14 +4,17 @@ module Superbot
4
4
  module Cloud
5
5
  module CLI
6
6
  module Organization
7
- class ListCommand < Clamp::Command
7
+ class ListCommand < BaseCommand
8
8
  def execute
9
9
  list_organizations
10
10
  end
11
11
 
12
12
  def list_organizations
13
+ default_org = Superbot::Cloud.credentials[:organization]
13
14
  api_response = Superbot::Cloud::Api.request(:organization_list)
14
- puts(api_response.map { |org| org[:name] })
15
+
16
+ puts "Your organizations:"
17
+ puts(api_response.map { |org| org[:name] == default_org ? "#{org[:name]} (default)" : org[:name] })
15
18
  end
16
19
  end
17
20
  end
@@ -4,7 +4,7 @@ module Superbot
4
4
  module Cloud
5
5
  module CLI
6
6
  class OrganizationBasedCommand < LoginRequiredCommand
7
- option ["--org"], "ORGANIZATION", "Name of organization to take action on", environment_variable: "SUPERBOT_ORG", required: ENV['SUPERBOT_TOKEN'].to_s.empty?, attribute_name: :organization
7
+ option ["--org"], "ORGANIZATION", "Name of organization to take action on", environment_variable: "SUPERBOT_ORG", attribute_name: :organization, default: Superbot::Cloud.credentials&.fetch(:organization, nil)
8
8
  end
9
9
  end
10
10
  end
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'organization/base_command'
3
4
  require_relative 'organization/list_command'
5
+ require_relative 'organization/default_command'
4
6
 
5
7
  module Superbot
6
8
  module Cloud
7
9
  module CLI
8
10
  class OrganizationCommand < LoginRequiredCommand
9
11
  subcommand ['list'], "List user organizations from the cloud", Organization::ListCommand
12
+ subcommand ['default'], "Set default organization for CLI", Organization::DefaultCommand
10
13
  end
11
14
  end
12
15
  end
@@ -4,7 +4,7 @@ module Superbot
4
4
  module Cloud
5
5
  module CLI
6
6
  module Run
7
- class CreateCommand < OrganizationBasedCommand
7
+ class CreateCommand < BaseCommand
8
8
  parameter "NAME", "the name of the test to delete", required: true
9
9
  option ['--region'], 'REGION', 'Region for remote webdriver'
10
10
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Superbot
4
4
  module Cloud
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
@@ -5,7 +5,7 @@ module Superbot
5
5
  module Web
6
6
  def self.registered(sinatra)
7
7
  sinatra.get "/login" do
8
- credentials = request.params.slice('username', 'email', 'token')
8
+ credentials = request.params.slice(*%w[username email token organization])
9
9
  Superbot::Cloud.save_credentials(credentials)
10
10
  redirect "#{Superbot::Cloud::LOGIN_URI}/success"
11
11
  end
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_runtime_dependency "multipart-post", "2.0.0"
37
37
  spec.add_runtime_dependency "marcel", "0.3.3"
38
38
 
39
- spec.add_development_dependency "superbot", "~> 0.3.0"
39
+ spec.add_development_dependency "superbot", "~> 0.4.0"
40
40
  spec.add_development_dependency "bundler", "~> 1.16"
41
41
  spec.add_development_dependency "rake", "~> 10.0"
42
42
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superbot-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Superbots
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-11 00:00:00.000000000 Z
11
+ date: 2019-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multipart-post
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.3.0
47
+ version: 0.4.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.3.0
54
+ version: 0.4.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -144,6 +144,8 @@ files:
144
144
  - lib/superbot/cloud/cli/member/list_command.rb
145
145
  - lib/superbot/cloud/cli/member/remove_command.rb
146
146
  - lib/superbot/cloud/cli/member_command.rb
147
+ - lib/superbot/cloud/cli/organization/base_command.rb
148
+ - lib/superbot/cloud/cli/organization/default_command.rb
147
149
  - lib/superbot/cloud/cli/organization/list_command.rb
148
150
  - lib/superbot/cloud/cli/organization_based_command.rb
149
151
  - lib/superbot/cloud/cli/organization_command.rb