sem 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sem/api/base.rb +1 -5
- data/lib/sem/api/users_with_permissions.rb +6 -2
- data/lib/sem/cli.rb +4 -2
- data/lib/sem/credentials.rb +19 -0
- data/lib/sem/version.rb +1 -1
- data/lib/sem.rb +47 -40
- data/sem.gemspec +2 -2
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e338e38dab6f7b14d032d7ae279fad4784553be
|
4
|
+
data.tar.gz: 8237dfa704deaeb14de9785d9b3924fd6d24ce05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 993d2cabeba3a1c8c6f8e36e08af620fe9fadcb9084e4854400aff50b5b83e53e8ea645927cf917fd3311c35d67b00fa16767919b69c2258d6e47f7e47759653
|
7
|
+
data.tar.gz: df2289f9b071ef252358663d7ec87cfd3f1e3070124fca4c0775746a830e19d255d6089ecc98c50da40e8807c65c970fcbcc39af11292289c55cce4acac6b2e9
|
data/lib/sem/api/base.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
module Sem
|
2
2
|
module API
|
3
3
|
class Base
|
4
|
-
CREDENTIALS_PATH = "~/.sem/credentials".freeze
|
5
|
-
|
6
4
|
def self.client
|
7
5
|
@client ||= begin
|
8
|
-
|
9
|
-
|
10
|
-
auth_token = File.read(path).delete("\n")
|
6
|
+
auth_token = Sem::Credentials.read
|
11
7
|
|
12
8
|
SemaphoreClient.new(auth_token)
|
13
9
|
end
|
@@ -27,7 +27,7 @@ module Sem
|
|
27
27
|
def teams_by_permission(all_teams)
|
28
28
|
groups = all_teams.group_by(&:permission)
|
29
29
|
|
30
|
-
groups.sort_by { |permission, _| LEVELS[permission] }.
|
30
|
+
to_hash(groups.sort_by { |permission, _| LEVELS[permission] }).values
|
31
31
|
end
|
32
32
|
|
33
33
|
def users_for_team_groups(groups)
|
@@ -41,12 +41,16 @@ module Sem
|
|
41
41
|
def users_for_team(team)
|
42
42
|
users = client.users.list_for_team(team.id)
|
43
43
|
|
44
|
-
users.map { |user| [user.username, transform_user(user, team)] }
|
44
|
+
to_hash(users.map { |user| [user.username, transform_user(user, team)] })
|
45
45
|
end
|
46
46
|
|
47
47
|
def transform_user(user, team)
|
48
48
|
Users.to_hash(user).merge(:permission => team.permission)
|
49
49
|
end
|
50
|
+
|
51
|
+
def to_hash(array)
|
52
|
+
Hash[array]
|
53
|
+
end
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
data/lib/sem/cli.rb
CHANGED
@@ -8,8 +8,10 @@ module Sem
|
|
8
8
|
require_relative "cli/shared_configs"
|
9
9
|
|
10
10
|
desc "login", "log in to semaphore from the command line"
|
11
|
-
def login
|
12
|
-
|
11
|
+
def login(auth_token)
|
12
|
+
Sem::Credentials.write(auth_token)
|
13
|
+
|
14
|
+
puts "Your credentials have been saved to #{Sem::Credentials::PATH}"
|
13
15
|
end
|
14
16
|
|
15
17
|
register "orgs", "manage organizations", Sem::CLI::Orgs
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Sem
|
2
|
+
class Credentials
|
3
|
+
PATH = File.expand_path("~/.sem/credentials").freeze
|
4
|
+
|
5
|
+
def self.write(auth_token)
|
6
|
+
dirname = File.dirname(PATH)
|
7
|
+
FileUtils.mkdir_p(dirname)
|
8
|
+
|
9
|
+
File.write(PATH, auth_token)
|
10
|
+
File.chmod(0o0600, PATH)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.read
|
14
|
+
raise Sem::Errors::Auth::NoCredentials unless File.file?(PATH)
|
15
|
+
|
16
|
+
File.read(PATH).strip
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/sem/version.rb
CHANGED
data/lib/sem.rb
CHANGED
@@ -1,53 +1,60 @@
|
|
1
1
|
require "sem/version"
|
2
2
|
require "dracula"
|
3
3
|
require "semaphore_client"
|
4
|
+
require "fileutils"
|
4
5
|
|
5
6
|
module Sem
|
6
7
|
require "sem/errors"
|
8
|
+
require "sem/credentials"
|
7
9
|
require "sem/cli"
|
8
10
|
require "sem/api"
|
9
11
|
require "sem/views"
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
13
|
+
class << self
|
14
|
+
|
15
|
+
# Returns exit status as a number.
|
16
|
+
def start(args)
|
17
|
+
Sem::CLI.start(args)
|
18
|
+
|
19
|
+
0
|
20
|
+
rescue Sem::Errors::Auth::NoCredentials
|
21
|
+
on_no_credentials
|
22
|
+
|
23
|
+
1
|
24
|
+
rescue Sem::Errors::Auth::InvalidCredentials
|
25
|
+
on_invalid_credentials
|
26
|
+
|
27
|
+
1
|
28
|
+
rescue StandardError => e
|
29
|
+
on_unhandled_error(e)
|
30
|
+
|
31
|
+
1
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def on_no_credentials
|
37
|
+
puts "[ERROR] You are not logged in."
|
38
|
+
puts ""
|
39
|
+
puts "Log in with '#{Sem::CLI.program_name} login --auth-token <token>'"
|
40
|
+
end
|
41
|
+
|
42
|
+
def on_invalid_credentials
|
43
|
+
puts "[ERROR] Your credentials are invalid."
|
44
|
+
puts ""
|
45
|
+
puts "Log in with '#{Sem::CLI.program_name} login --auth-token <token>'"
|
46
|
+
end
|
47
|
+
|
48
|
+
def on_unhandled_error(exception)
|
49
|
+
puts "[PANIC] Unhandled error."
|
50
|
+
puts ""
|
51
|
+
puts "Well, this is emberassing. An unknown error was detected."
|
52
|
+
puts ""
|
53
|
+
puts "Backtrace: "
|
54
|
+
puts exception.backtrace
|
55
|
+
puts ""
|
56
|
+
puts "Please report this issue to https://semaphoreci.com/support."
|
57
|
+
end
|
51
58
|
end
|
52
59
|
|
53
60
|
end
|
data/sem.gemspec
CHANGED
@@ -22,13 +22,13 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_dependency "semaphore_client", "~> 2.0.5"
|
25
|
-
spec.add_dependency "dracula", "~> 0.1.
|
25
|
+
spec.add_dependency "dracula", "~> 0.1.1"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.14"
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
30
|
spec.add_development_dependency "rubocop", "~> 0.47.1"
|
31
|
-
spec.add_development_dependency "rubocop-rspec", "
|
31
|
+
spec.add_development_dependency "rubocop-rspec", "1.5.0"
|
32
32
|
spec.add_development_dependency "simplecov", "~> 0.13"
|
33
33
|
spec.add_development_dependency "byebug"
|
34
34
|
end
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Šarčević
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.
|
40
|
+
version: 0.1.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: rubocop-rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: 1.5.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: 1.5.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/sem/cli/projects.rb
|
176
176
|
- lib/sem/cli/shared_configs.rb
|
177
177
|
- lib/sem/cli/teams.rb
|
178
|
+
- lib/sem/credentials.rb
|
178
179
|
- lib/sem/errors.rb
|
179
180
|
- lib/sem/version.rb
|
180
181
|
- lib/sem/views.rb
|