sem 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sem.rb +1 -0
- data/lib/sem/api/project.rb +10 -0
- data/lib/sem/cli/projects.rb +18 -0
- data/lib/sem/helpers.rb +3 -0
- data/lib/sem/helpers/git_url.rb +37 -0
- data/lib/sem/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a57a0aee22d7a70fc1d7ef78d3ae1a7197f90490
|
4
|
+
data.tar.gz: 709f09561d7c8c3c6549a5fa4732b48f4b250270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7486fbe7452345748698bad75ad28ade92471b53c08e813543d9e33975a83d8cf570e92cc956d1e6ff68c5b02e3fa5d7c3f537ef93fde9d25298e997dd39d10
|
7
|
+
data.tar.gz: 25f64de6ab1be1b59daa71eda710d5638c9fcb2a45d5bbb2d5579699791d45baa9fd448e9aaadfb85d0e456c8ebe686409a7414be1312f50aec792b06dc4521c
|
data/lib/sem.rb
CHANGED
data/lib/sem/api/project.rb
CHANGED
@@ -19,6 +19,16 @@ class Sem::API::Project < SimpleDelegator
|
|
19
19
|
new(org_name, project)
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.create!(project_srn, args)
|
23
|
+
org_name, name = Sem::SRN.parse_project(project_srn)
|
24
|
+
|
25
|
+
project = client.projects.create_for_org(org_name, args.merge(:name => name))
|
26
|
+
|
27
|
+
raise Sem::Errors::ResourceNotCreated.new("Project", [org_name, name]) if project.nil?
|
28
|
+
|
29
|
+
new(org_name, project)
|
30
|
+
end
|
31
|
+
|
22
32
|
attr_reader :org_name
|
23
33
|
|
24
34
|
def initialize(org_name, project)
|
data/lib/sem/cli/projects.rb
CHANGED
@@ -18,6 +18,24 @@ class Sem::CLI::Projects < Dracula
|
|
18
18
|
Sem::Views::Projects.info(project)
|
19
19
|
end
|
20
20
|
|
21
|
+
desc "create", "create a project"
|
22
|
+
option :url, :aliases => "-u", :desc => "Git url to the repository"
|
23
|
+
def create(project_name)
|
24
|
+
url = Sem::Helpers::GitUrl.new(options[:url])
|
25
|
+
|
26
|
+
abort "Git URL #{options[:url]} is invalid." unless url.valid?
|
27
|
+
|
28
|
+
args = {
|
29
|
+
:repo_provider => url.repo_provider,
|
30
|
+
:repo_owner => url.repo_owner,
|
31
|
+
:repo_name => url.repo_name
|
32
|
+
}
|
33
|
+
|
34
|
+
project = Sem::API::Project.create!(project_name, args)
|
35
|
+
|
36
|
+
Sem::Views::Projects.info(project)
|
37
|
+
end
|
38
|
+
|
21
39
|
class Files < Dracula
|
22
40
|
|
23
41
|
desc "list", "list configuration files on project"
|
data/lib/sem/helpers.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
class Sem::Helpers::GitUrl
|
2
|
+
|
3
|
+
SSH_PATTERN = %r{^git@(.+)\..+\:(.+)\/(.+)\.git$} # example: git@github.com:renderedtext/cli.git
|
4
|
+
GITHUB_HTTP_PATTERN = %r{^(https:\/\/)?github.com/(.+)/(.+)$} # example: https://github.com/renderedtext/cli
|
5
|
+
BITBUCKET_HTTP_PATTERN = %r{^(https:\/\/)?bitbucket.org/(.+)/(.+)$} # example: https://bitbucket.org/renderedtext/cli
|
6
|
+
|
7
|
+
attr_reader :repo_name
|
8
|
+
attr_reader :repo_owner
|
9
|
+
attr_reader :repo_provider
|
10
|
+
|
11
|
+
def initialize(url)
|
12
|
+
@repo_provider, @repo_owner, @repo_name = parse(url)
|
13
|
+
end
|
14
|
+
|
15
|
+
def valid?
|
16
|
+
@repo_name && @repo_provider && @repo_owner
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def parse(url)
|
22
|
+
ssh_match = SSH_PATTERN.match(url)
|
23
|
+
github_http_match = GITHUB_HTTP_PATTERN.match(url)
|
24
|
+
bitbucket_http_match = BITBUCKET_HTTP_PATTERN.match(url)
|
25
|
+
|
26
|
+
if ssh_match
|
27
|
+
ssh_match.captures[0..2]
|
28
|
+
elsif github_http_match
|
29
|
+
["github"].concat(github_http_match.captures[1..2])
|
30
|
+
elsif bitbucket_http_match
|
31
|
+
["bitbucket"].concat(bitbucket_http_match.captures[1..2])
|
32
|
+
else
|
33
|
+
[nil, nil, nil]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/sem/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Šarčević
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semaphore_client
|
@@ -214,6 +214,8 @@ files:
|
|
214
214
|
- lib/sem/cli/teams.rb
|
215
215
|
- lib/sem/configuration.rb
|
216
216
|
- lib/sem/errors.rb
|
217
|
+
- lib/sem/helpers.rb
|
218
|
+
- lib/sem/helpers/git_url.rb
|
217
219
|
- lib/sem/srn.rb
|
218
220
|
- lib/sem/version.rb
|
219
221
|
- lib/sem/views.rb
|