clenver 0.1.2 → 0.1.3
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 +8 -8
- data/lib/clenver/assets/sample.yml +14 -0
- data/lib/clenver/link.rb +24 -0
- data/lib/clenver/project.rb +93 -0
- data/lib/clenver/repository.rb +23 -0
- data/lib/clenver/version.rb +1 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODFkYWU5OTk2NDQ3MzM0NDUyMjllZTAxYmFhNWVjMzI5MzAzMmNhMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjMxMGY1M2FjYzQ5OGU3Nzc0YWQ2ZGQ3ZDhlNTZhNjg3NmE3YjYxZg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2M0NjI0YWIxYTA5OWU2Mzk0YTY4NzhmYzZiNmYxZTYwZWUxNTg4NjY2YjAw
|
10
|
+
OWRhZTE4NWY4NjVhNWIwMjUyYTNkNDdlZmFlYWFjMTI5NDI2ZWQ0ZWUwMzMx
|
11
|
+
NzI0OGE0MDJkMTAzMjlkOGJhMDMxZTRiZTQ0MjUxNGNjYzNlZWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGZkMzQxNDhjMDA4NjU1MzYwYmJkYTNjM2JhMzM4YmZiOGNiODllNjM5MGYx
|
14
|
+
MzQ2ODllZDcyMDU2YTYxMjU1ODJkYjFhYzc5NWRjZWQ1NDgyYmEzNzBlYzMw
|
15
|
+
NjM5ZGNlOWViODE3NDUzODVmMmU2OTY4MzA4MzJiMTk1OGUwZjQ=
|
@@ -0,0 +1,14 @@
|
|
1
|
+
https://github.com/pietrushnic/workspace.git:
|
2
|
+
links:
|
3
|
+
dotfiles/gitignore:
|
4
|
+
- $HOME/.gitignore
|
5
|
+
dotfiles/bashrc:
|
6
|
+
- ~/.bashrc
|
7
|
+
dotfiles/bashrc1:
|
8
|
+
- abc/.bashrc
|
9
|
+
mkdirs:
|
10
|
+
- workspace1
|
11
|
+
- workspace2
|
12
|
+
remotes:
|
13
|
+
upstream: https://github.com/pietrushnic/workspace.git
|
14
|
+
run: echo "Finished"
|
data/lib/clenver/link.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class Link
|
2
|
+
def initialize(src,dst)
|
3
|
+
@src = src
|
4
|
+
@dst = expand_dst(dst)
|
5
|
+
end
|
6
|
+
def create
|
7
|
+
puts "Link.create"
|
8
|
+
puts @dst
|
9
|
+
@dst.each do |d|
|
10
|
+
puts "src:#{@src}"
|
11
|
+
puts "d:#{d} "
|
12
|
+
|
13
|
+
File.symlink(@src, d.to_s)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
def expand_dst(dst)
|
17
|
+
ret = Array.new()
|
18
|
+
dst.each do |d|
|
19
|
+
path = %x[ echo #{d}]
|
20
|
+
ret.push(path.strip)
|
21
|
+
end
|
22
|
+
return ret
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'clenver/repository'
|
2
|
+
require 'clenver/link'
|
3
|
+
|
4
|
+
class Project
|
5
|
+
def initialize(name, repos)
|
6
|
+
@name = name
|
7
|
+
@repos = repos
|
8
|
+
@abs_path = Dir::pwd + "/" + @name
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_abs_path
|
12
|
+
@abs_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_repos(dst=nil)
|
16
|
+
puts "create_repos:"
|
17
|
+
if dst
|
18
|
+
path = self.get_abs_path + "/../" + dst.to_s + "/" + @name
|
19
|
+
puts path
|
20
|
+
FileUtils.mkdir_p(path)
|
21
|
+
else
|
22
|
+
path = get_abs_path
|
23
|
+
Dir::mkdir(path)
|
24
|
+
end
|
25
|
+
Dir::chdir(path)
|
26
|
+
case @repos
|
27
|
+
when Hash
|
28
|
+
@repos.each do |uri, content|
|
29
|
+
#TODO: verify if r is a supported repo
|
30
|
+
begin
|
31
|
+
r = Repository.new(uri, dst)
|
32
|
+
r.clone
|
33
|
+
@repos[uri]['object'] = r
|
34
|
+
rescue Exception => msg
|
35
|
+
puts msg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
when String
|
39
|
+
begin
|
40
|
+
repo = Repository.new(@repos, dst)
|
41
|
+
repo.clone
|
42
|
+
rescue Exception => msg
|
43
|
+
puts msg
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def init_repos
|
49
|
+
puts "init_repos"
|
50
|
+
case @repos
|
51
|
+
when Hash
|
52
|
+
@repos.each do |uri, content|
|
53
|
+
begin
|
54
|
+
unless content.nil?
|
55
|
+
#links
|
56
|
+
unless content['links'].nil?
|
57
|
+
content['links'].each do |s,d|
|
58
|
+
s_path = content['object'].get_abs_path + "/" + s
|
59
|
+
Link.new(s_path,d).create
|
60
|
+
end
|
61
|
+
end
|
62
|
+
#remotes
|
63
|
+
unless content['remotes'].nil?
|
64
|
+
content['remotes'].each do |name, uri|
|
65
|
+
Dir::chdir(content['object'].get_abs_path)
|
66
|
+
content['object'].add_remote(name, uri)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
#run
|
70
|
+
unless content['run'].nil?
|
71
|
+
content['run'].each do |cmd|
|
72
|
+
Dir::chdir(content['object'].get_abs_path)
|
73
|
+
puts %x[#{cmd}]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
rescue Exception => msg
|
78
|
+
puts msg
|
79
|
+
end
|
80
|
+
end
|
81
|
+
when String
|
82
|
+
begin
|
83
|
+
unless @repos.nil?
|
84
|
+
@repos['links'].each do |s,d|
|
85
|
+
Link.new(s,d).create
|
86
|
+
end
|
87
|
+
end
|
88
|
+
rescue Exception => msg
|
89
|
+
puts msg
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'git'
|
2
|
+
|
3
|
+
class Repository
|
4
|
+
def initialize(repo, dst)
|
5
|
+
@repo_uri = repo
|
6
|
+
@dst = dst
|
7
|
+
@abs_path = nil
|
8
|
+
@repo = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def clone
|
12
|
+
repo_basename = File.basename("#{@repo_uri}",".git")
|
13
|
+
@repo = Git.clone(@repo_uri, repo_basename)
|
14
|
+
@abs_path = Dir::pwd + "/" + repo_basename
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_abs_path
|
18
|
+
@abs_path
|
19
|
+
end
|
20
|
+
def add_remote(name, uri)
|
21
|
+
@repo.add_remote(name, uri)
|
22
|
+
end
|
23
|
+
end
|
data/lib/clenver/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clenver
|
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
|
- Piotr Król
|
@@ -106,6 +106,10 @@ extra_rdoc_files:
|
|
106
106
|
files:
|
107
107
|
- bin/clenver
|
108
108
|
- lib/clenver/version.rb
|
109
|
+
- lib/clenver/project.rb
|
110
|
+
- lib/clenver/repository.rb
|
111
|
+
- lib/clenver/link.rb
|
112
|
+
- lib/clenver/assets/sample.yml
|
109
113
|
- lib/clenver.rb
|
110
114
|
- README.rdoc
|
111
115
|
- clenver.rdoc
|