sem 0.3.5 → 0.4.0

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
  SHA1:
3
- metadata.gz: a5c756f0ab72795c94aba3b3f7e93c50f24dd32c
4
- data.tar.gz: 21b1f932e4c142076af6704103f52b9b7f572415
3
+ metadata.gz: 0d6cad3568c4070fd455a3b3a847eb9cdbfa4b01
4
+ data.tar.gz: 19741e275c1a27637594542589cc61e535bb7445
5
5
  SHA512:
6
- metadata.gz: ad7e48574b8c7368708dc53d35840ef9002f5df136205e68a61100fcad23f0700d448664aabbcf52f665a8614b3060ff73034a50ebac1a57ec9cdd60749c2a54
7
- data.tar.gz: 83d53d911f1184e22f67bf2b4ea96d21f668dbbfbbe1fb1290f9643f30f16214aed6fc6de2624ba05968ba19ef6d37c118e9f3e3ab3c75be967c2f4b3133e838
6
+ metadata.gz: 7ae5e86225473f3cb5c53c99377d36a7caf7b64b1656fc58821f3684c2966d4e37ddb223bd54baa2c70ebf10dbce0e60165532686adf4b6219b9e38f95ecf0c8
7
+ data.tar.gz: a1c05d01cbe0da43c1af69b6de53cbebb0a2916d1e112e3d73b6f7ecf0220c782c1284b12cf44f8018668a73aa85c13ee1e4a35cb79abc293b2461f7916dc11e
data/README.md CHANGED
@@ -5,27 +5,19 @@
5
5
 
6
6
  ![Semaphore logo](https://d1dkupr86d302v.cloudfront.net/assets/application_bootstrap/layout/semaphore-logo-a6d954e176b6975b511f314a0cc808dc94a8030210077e3a6e904fbe69dc5354.svg)
7
7
 
8
- __Note: This tool is still in the early phase of development.__
8
+ __Note: The Semaphore CLI gem is still an alpha release.__
9
9
 
10
10
  The Semaphore CLI is used to manage Semaphore projects from the command line.
11
11
 
12
- For more info about Semaphore see <https://www.semaphoreci.com>
12
+ For more info about Semaphore see <https://semaphoreci.com>
13
13
 
14
- ## Semaphore Resource Name (SRN)
14
+ ## Usage
15
15
 
16
- SRN is a way of identifying Semaphore resources. This CLI uses SRNs as arguments
17
- for all actions.
16
+ Install the gem with:
18
17
 
19
- Formats for individual resources are the following:
20
-
21
- - Organization: `organization_name`
22
- - Team: `organization_name/team_name`
23
- - Project: `organization_name/project_name`
24
- - Shared Configuration: `organization_name/shared_configuration_name`
25
-
26
- ## Using custom API URL
27
-
28
- Create a file at `~/.sem/api_url` containing only the custom url.
18
+ ``` ruby
19
+ gem install sem
20
+ ```
29
21
 
30
22
  ## Issues
31
23
 
@@ -42,3 +34,19 @@ Developing the CLI locally requires Ruby.
42
34
  While developing please follow the [CLI development guide](guides.md).
43
35
 
44
36
  To run the CLI locally, use the `bundle exec sem`.
37
+
38
+ #### Semaphore Resource Name (SRN)
39
+
40
+ SRN is a way of identifying Semaphore resources. This CLI uses SRNs as arguments
41
+ for all actions.
42
+
43
+ Formats for individual resources are the following:
44
+
45
+ - Organization: `organization_name`
46
+ - Team: `organization_name/team_name`
47
+ - Project: `organization_name/project_name`
48
+ - Shared Configuration: `organization_name/shared_configuration_name`
49
+
50
+ #### Using custom API URL
51
+
52
+ Create a file at `~/.sem/api_url` containing only the custom url.
data/lib/sem/api/base.rb CHANGED
@@ -2,12 +2,25 @@ module Sem::API::Base
2
2
  module_function
3
3
 
4
4
  def client
5
- @client ||= SemaphoreClient.new(
6
- Sem::Configuration.auth_token,
7
- :api_url => Sem::Configuration.api_url,
8
- :verbose => (Sem.log_level == Sem::LOG_LEVEL_TRACE),
9
- :auto_paginate => true
10
- )
5
+ @client ||= create_new_api_client(
6
+ Sem::Configuration.api_url,
7
+ Sem::Configuration.auth_token)
8
+ end
9
+
10
+ def create_new_api_client(api_url, auth_token)
11
+ SemaphoreClient.new(auth_token, :api_url => api_url,
12
+ :logger => api_logger,
13
+ :auto_paginate => true)
14
+ end
15
+
16
+ def api_logger
17
+ return nil unless Sem.trace?
18
+ return @api_logger if defined?(@api_logger)
19
+
20
+ @api_logger = Logger.new(STDOUT)
21
+ @api_logger.level = Logger::DEBUG
22
+
23
+ @api_logger
11
24
  end
12
25
 
13
26
  end
@@ -7,13 +7,7 @@ module Sem
7
7
 
8
8
  class << self
9
9
  def valid_auth_token?(auth_token)
10
- client = SemaphoreClient.new(
11
- auth_token,
12
- :api_url => api_url,
13
- :verbose => (Sem.log_level == Sem::LOG_LEVEL_TRACE)
14
- )
15
-
16
- client.orgs.list!
10
+ Sem::API::Base.create_new_api_client(api_url, auth_token).orgs.list!
17
11
 
18
12
  true
19
13
  rescue SemaphoreClient::Exceptions::Base
data/lib/sem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sem
2
- VERSION = "0.3.5".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
data/lib/sem.rb CHANGED
@@ -13,20 +13,17 @@ module Sem
13
13
  require "sem/api"
14
14
  require "sem/views"
15
15
 
16
- LOG_LEVEL_TRACE = :trace
17
- LOG_LEVEL_ERROR = :error
18
-
19
16
  class << self
20
17
  attr_writer :log_level
21
18
 
22
- def log_level
23
- @log_level || LOG_LEVEL_ERROR
19
+ def trace?
20
+ @trace_mode == true
24
21
  end
25
22
 
26
23
  # Returns exit status as a number.
27
24
  def start(args)
28
25
  if args.include?("--trace")
29
- @log_level = LOG_LEVEL_TRACE
26
+ @trace_mode = true
30
27
 
31
28
  args.delete("--trace")
32
29
  end
data/sem.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_dependency "semaphore_client", "2.6.0"
24
+ spec.add_dependency "semaphore_client", "2.7.0"
25
25
  spec.add_dependency "dracula", "~> 0.4.0"
26
26
  spec.add_dependency "pmap", "~> 1.1.1"
27
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Šarčević
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.6.0
19
+ version: 2.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.6.0
26
+ version: 2.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dracula
29
29
  requirement: !ruby/object:Gem::Requirement