gitenv 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/gitenv.gemspec +6 -4
- data/lib/gitenv.rb +2 -2
- data/lib/gitenv/action.rb +18 -0
- data/lib/gitenv/config.rb +5 -14
- data/lib/gitenv/context.rb +13 -20
- data/lib/gitenv/controller.rb +7 -3
- data/lib/gitenv/copy.rb +1 -2
- data/lib/gitenv/enumerator.rb +2 -19
- data/lib/gitenv/enumerator/all_files.rb +10 -0
- data/lib/gitenv/enumerator/dot_files.rb +10 -0
- data/lib/gitenv/enumerator/enumerator.rb +14 -0
- data/lib/gitenv/enumerator/one_file.rb +14 -0
- data/lib/gitenv/symlink.rb +1 -2
- data/lib/program.rb +2 -1
- metadata +6 -4
- data/lib/gitenv/actions.rb +0 -28
- data/lib/gitenv/all_files.rb +0 -10
- data/lib/gitenv/dot_files.rb +0 -10
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/gitenv.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gitenv"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["AlphaHydrae"]
|
@@ -31,14 +31,16 @@ Gem::Specification.new do |s|
|
|
31
31
|
"bin/gitenv",
|
32
32
|
"gitenv.gemspec",
|
33
33
|
"lib/gitenv.rb",
|
34
|
-
"lib/gitenv/
|
35
|
-
"lib/gitenv/all_files.rb",
|
34
|
+
"lib/gitenv/action.rb",
|
36
35
|
"lib/gitenv/config.rb",
|
37
36
|
"lib/gitenv/context.rb",
|
38
37
|
"lib/gitenv/controller.rb",
|
39
38
|
"lib/gitenv/copy.rb",
|
40
|
-
"lib/gitenv/dot_files.rb",
|
41
39
|
"lib/gitenv/enumerator.rb",
|
40
|
+
"lib/gitenv/enumerator/all_files.rb",
|
41
|
+
"lib/gitenv/enumerator/dot_files.rb",
|
42
|
+
"lib/gitenv/enumerator/enumerator.rb",
|
43
|
+
"lib/gitenv/enumerator/one_file.rb",
|
42
44
|
"lib/gitenv/symlink.rb",
|
43
45
|
"lib/program.rb",
|
44
46
|
"spec/helper.rb",
|
data/lib/gitenv.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
require 'paint'
|
3
3
|
|
4
4
|
module Gitenv
|
5
|
-
VERSION = '0.0.
|
5
|
+
VERSION = '0.0.4'
|
6
6
|
end
|
7
7
|
|
8
|
-
[ :context, :config, :controller, :symlink, :copy, :enumerator, :
|
8
|
+
[ :context, :config, :controller, :symlink, :copy, :enumerator, :action ].each do |lib|
|
9
9
|
require File.join(File.dirname(__FILE__), 'gitenv', lib.to_s)
|
10
10
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
module Gitenv
|
3
|
+
|
4
|
+
class Action
|
5
|
+
include Context
|
6
|
+
|
7
|
+
def initialize config, type, files
|
8
|
+
@type, @files = type, files
|
9
|
+
copy! config
|
10
|
+
end
|
11
|
+
|
12
|
+
def each &block
|
13
|
+
@files.each File.join(*[repository, from_path].compact) do |f|
|
14
|
+
block.call @type.new(self, f)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/gitenv/config.rb
CHANGED
@@ -10,7 +10,7 @@ module Gitenv
|
|
10
10
|
|
11
11
|
def initialize home
|
12
12
|
@home = home
|
13
|
-
@actions =
|
13
|
+
@actions = []
|
14
14
|
end
|
15
15
|
|
16
16
|
def repo path
|
@@ -18,16 +18,7 @@ module Gitenv
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def symlink file
|
21
|
-
|
22
|
-
scope = self
|
23
|
-
current_actions = Actions.new
|
24
|
-
enumerator(file).each do |f|
|
25
|
-
current_actions << Symlink.new(scope, f).tap do |action|
|
26
|
-
@actions << action
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
current_actions
|
21
|
+
Action.new(self, Symlink, enumerator(file)).tap{ |a| @actions << a }
|
31
22
|
end
|
32
23
|
|
33
24
|
def all_files
|
@@ -42,11 +33,11 @@ module Gitenv
|
|
42
33
|
|
43
34
|
def enumerator file
|
44
35
|
if file == :all_files
|
45
|
-
AllFiles.new
|
36
|
+
AllFiles.new
|
46
37
|
elsif file == :dot_files
|
47
|
-
DotFiles.new
|
38
|
+
DotFiles.new
|
48
39
|
else
|
49
|
-
|
40
|
+
OneFile.new file
|
50
41
|
end
|
51
42
|
end
|
52
43
|
end
|
data/lib/gitenv/context.rb
CHANGED
@@ -2,45 +2,38 @@
|
|
2
2
|
module Gitenv
|
3
3
|
|
4
4
|
module Context
|
5
|
+
attr_accessor :home, :repository
|
6
|
+
attr_accessor :from_paths, :to_paths
|
5
7
|
|
6
8
|
def from path, &block
|
7
|
-
(@
|
9
|
+
(@from_paths ||= []) << path
|
8
10
|
if block
|
9
11
|
instance_eval &block
|
10
|
-
@
|
12
|
+
@from_paths.pop
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
16
|
def from_path
|
15
|
-
@
|
16
|
-
end
|
17
|
-
|
18
|
-
def from_paths
|
19
|
-
@from_path || []
|
20
|
-
end
|
21
|
-
|
22
|
-
def from_paths= paths
|
23
|
-
@from_path = paths
|
17
|
+
@from_paths ? File.join(*@from_paths) : nil
|
24
18
|
end
|
25
19
|
|
26
20
|
def to path, &block
|
27
|
-
(@
|
21
|
+
(@to_paths ||= []) << path
|
28
22
|
if block
|
29
23
|
instance_eval &block
|
30
|
-
@
|
24
|
+
@to_paths.pop
|
31
25
|
end
|
32
26
|
end
|
33
27
|
|
34
28
|
def to_path
|
35
|
-
@
|
36
|
-
end
|
37
|
-
|
38
|
-
def to_paths
|
39
|
-
@to_path || []
|
29
|
+
@to_paths ? File.join(*@to_paths) : nil
|
40
30
|
end
|
41
31
|
|
42
|
-
def
|
43
|
-
|
32
|
+
def copy! source
|
33
|
+
self.from_paths = source.from_paths ? source.from_paths.dup : []
|
34
|
+
self.to_paths = source.to_paths ? source.to_paths.dup : []
|
35
|
+
self.repository = source.repository
|
36
|
+
self.home = source.home
|
44
37
|
end
|
45
38
|
end
|
46
39
|
end
|
data/lib/gitenv/controller.rb
CHANGED
@@ -14,9 +14,13 @@ module Gitenv
|
|
14
14
|
|
15
15
|
def run
|
16
16
|
load_config_file!
|
17
|
-
@config.actions.each
|
18
|
-
|
19
|
-
|
17
|
+
@config.actions.each do |a|
|
18
|
+
a.each do |impl|
|
19
|
+
impl.build!
|
20
|
+
impl.update! if @action == :update
|
21
|
+
puts impl
|
22
|
+
end
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
private
|
data/lib/gitenv/copy.rb
CHANGED
data/lib/gitenv/enumerator.rb
CHANGED
@@ -1,20 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
class FileEnumerator
|
5
|
-
|
6
|
-
def initialize path
|
7
|
-
@path = path
|
8
|
-
end
|
9
|
-
|
10
|
-
def files
|
11
|
-
raise '#files not implemented'
|
12
|
-
end
|
13
|
-
|
14
|
-
def each &block
|
15
|
-
files.each do |f|
|
16
|
-
block.call f
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
1
|
+
[ :enumerator, :all_files, :dot_files, :one_file ].each do |lib|
|
2
|
+
require File.join(File.dirname(__FILE__), 'enumerator', lib.to_s)
|
20
3
|
end
|
data/lib/gitenv/symlink.rb
CHANGED
data/lib/program.rb
CHANGED
@@ -17,7 +17,8 @@ command :update do |c|
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
global_option '-
|
20
|
+
global_option '-r', '--repo PATH', 'Specify the path to the environment repository'
|
21
|
+
global_option '-c', '--config PATH', 'Use a custom configuration file (defaults to ~/.gitenv.rb)'
|
21
22
|
|
22
23
|
default_command :info
|
23
24
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -193,14 +193,16 @@ files:
|
|
193
193
|
- bin/gitenv
|
194
194
|
- gitenv.gemspec
|
195
195
|
- lib/gitenv.rb
|
196
|
-
- lib/gitenv/
|
197
|
-
- lib/gitenv/all_files.rb
|
196
|
+
- lib/gitenv/action.rb
|
198
197
|
- lib/gitenv/config.rb
|
199
198
|
- lib/gitenv/context.rb
|
200
199
|
- lib/gitenv/controller.rb
|
201
200
|
- lib/gitenv/copy.rb
|
202
|
-
- lib/gitenv/dot_files.rb
|
203
201
|
- lib/gitenv/enumerator.rb
|
202
|
+
- lib/gitenv/enumerator/all_files.rb
|
203
|
+
- lib/gitenv/enumerator/dot_files.rb
|
204
|
+
- lib/gitenv/enumerator/enumerator.rb
|
205
|
+
- lib/gitenv/enumerator/one_file.rb
|
204
206
|
- lib/gitenv/symlink.rb
|
205
207
|
- lib/program.rb
|
206
208
|
- spec/helper.rb
|
data/lib/gitenv/actions.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
|
2
|
-
module Gitenv
|
3
|
-
|
4
|
-
class Actions
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@actions = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def each &block
|
11
|
-
@actions.each &block
|
12
|
-
end
|
13
|
-
|
14
|
-
def from path
|
15
|
-
@actions.each{ |a| a.from path }
|
16
|
-
@actions
|
17
|
-
end
|
18
|
-
|
19
|
-
def to path
|
20
|
-
@actions.each{ |a| a.to path }
|
21
|
-
@actions
|
22
|
-
end
|
23
|
-
|
24
|
-
def << action
|
25
|
-
@actions << action
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/gitenv/all_files.rb
DELETED