overapp 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/VERSION +1 -1
- data/lib/overapp/files.rb +11 -47
- data/lib/overapp/from_command.rb +1 -11
- data/lib/overapp/load/base.rb +20 -0
- data/lib/overapp/load/factory.rb +19 -0
- data/lib/overapp/load/instance.rb +35 -0
- data/lib/overapp/load/types/command.rb +19 -0
- data/lib/overapp/load/types/empty.rb +9 -0
- data/lib/overapp/load/types/local_dir.rb +15 -0
- data/lib/overapp/load/types/project.rb +12 -0
- data/lib/overapp/load/types/raw_dir.rb +22 -0
- data/lib/overapp/load/types/repo.rb +13 -0
- data/lib/overapp/project/config.rb +28 -0
- data/lib/overapp/project/config_entry.rb +6 -0
- data/lib/overapp/project/write.rb +21 -0
- data/lib/overapp/project.rb +27 -85
- data/lib/overapp/util/cmd.rb +7 -0
- data/lib/overapp/util/dir.rb +23 -0
- data/lib/overapp/util/git.rb +25 -0
- data/lib/overapp/util/tmp_dir.rb +32 -0
- data/lib/overapp/util/write.rb +9 -0
- data/lib/overapp.rb +23 -27
- data/overapp.gemspec +60 -6
- data/spec/from_command_spec.rb +19 -7
- data/spec/input/rails_post_overlay/.overapp +1 -0
- data/spec/input/rails_post_overlay/app/models/post.rb +2 -0
- data/spec/input/rails_widget_overlay/.overapp +1 -0
- data/spec/input/rails_widget_overlay/app/models/widget.rb +2 -0
- data/spec/input/repo/.abc +1 -0
- data/spec/input/repo/README.md +1 -0
- data/spec/input/repo/b.txt +4 -0
- data/spec/input/repo/git_dir/COMMIT_EDITMSG +1 -0
- data/spec/input/repo/git_dir/HEAD +1 -0
- data/{lib/overapp/thor_file.rb → spec/input/repo/git_dir/MERGE_RR} +0 -0
- data/spec/input/repo/git_dir/config +7 -0
- data/spec/input/repo/git_dir/description +1 -0
- data/spec/input/repo/git_dir/hooks/applypatch-msg.sample +15 -0
- data/spec/input/repo/git_dir/hooks/commit-msg.sample +24 -0
- data/spec/input/repo/git_dir/hooks/post-update.sample +8 -0
- data/spec/input/repo/git_dir/hooks/pre-applypatch.sample +14 -0
- data/spec/input/repo/git_dir/hooks/pre-commit.sample +50 -0
- data/spec/input/repo/git_dir/hooks/pre-push.sample +53 -0
- data/spec/input/repo/git_dir/hooks/pre-rebase.sample +169 -0
- data/spec/input/repo/git_dir/hooks/prepare-commit-msg.sample +36 -0
- data/spec/input/repo/git_dir/hooks/update.sample +128 -0
- data/spec/input/repo/git_dir/index +0 -0
- data/spec/input/repo/git_dir/info/exclude +6 -0
- data/spec/input/repo/git_dir/logs/HEAD +3 -0
- data/spec/input/repo/git_dir/logs/refs/heads/master +3 -0
- data/spec/input/repo/git_dir/objects/0f/0920d9d41f24629586ec1c20d2283d7df3a950 +0 -0
- data/spec/input/repo/git_dir/objects/16/b5741fe01104ea0bdf50603b4c5d42ae5dcbc1 +2 -0
- data/spec/input/repo/git_dir/objects/20/508dfdb202a80e2c533f259a526205448b0152 +0 -0
- data/spec/input/repo/git_dir/objects/59/c5d2b4bc66e952a99b3b18a89cbc1e6704ffa0 +0 -0
- data/spec/input/repo/git_dir/objects/7b/1c8984cafd98a5b369ef325a85cb80e3985148 +2 -0
- data/spec/input/repo/git_dir/objects/bf/9307f21baa545173db65a417026088a033aa91 +2 -0
- data/spec/input/repo/git_dir/objects/d6/8dd4031d2ad5b7a3829ad7df6635e27a7daa22 +0 -0
- data/spec/input/repo/git_dir/objects/d6/cd9e553ef95332f3b77f70d11d0106ca06071c +0 -0
- data/spec/input/repo/git_dir/objects/f8/4c814d15674489c0b41035eb4243ccce522511 +0 -0
- data/spec/input/repo/git_dir/refs/heads/master +1 -0
- data/spec/input/top/.overlay +1 -1
- data/spec/nesting_spec.rb +44 -0
- data/spec/project_note_spec.rb +19 -13
- data/spec/spec_helper.rb +36 -1
- data/spec/support/output_dir.rb +6 -9
- data/spec/support/tmp_dir.rb +11 -0
- data/tmp/.gitkeep +0 -0
- metadata +59 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzYzNmI4Y2M5OWRmYTE0M2E4OGM5MzZlZWQwODE5NGQ0ZjFkMTg5Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmZiN2JkMmJhNmZhNjc0ZjllZGEzZmJiMDY3OGY3OGQ1OTFiMmMwMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmMxNDFjZTVmMWM5YjY0MWQzZGQ5NzQ0YjBiZTYwZTE2YTk1ODI5NTI3NmZl
|
10
|
+
NTQ2ZmVlNjczZDI4OGUwMTBjMmI0ZjAzMWMwMTQzZGVjNDU1NzY2ZmFmNWM0
|
11
|
+
Yzg0NDM4NTk1NzIwZGFkZjEwYTQ3M2ViZmEzOWQ1N2UyNzUxMWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTA1YzNjMzc1NTk0Mjc2NDM2MjJmNzBlMjUzMmRlZDA3YzE3ZTg2NzY5NjU4
|
14
|
+
NThhYTQ3NWVlMGRjMWIxZGU0YmVjZGYwOWIxZjM3ZDc4YjVmYzJiNDY0NDZk
|
15
|
+
ZGU4OGVjNDA1YzIxY2I2YzRhNmUyODk5ZDJiZTM5MTUzYTQwNTU=
|
data/Gemfile
CHANGED
@@ -21,7 +21,7 @@ group :development do
|
|
21
21
|
gem 'lre'
|
22
22
|
end
|
23
23
|
|
24
|
-
gem 'mharris_ext'
|
24
|
+
gem 'mharris_ext',">= 1.7.1"
|
25
25
|
#gem "rchoice", :path => "/users/mharris717/gems/rchoice-0.2.0"
|
26
26
|
#gem 'rchoice','0.2.0'
|
27
27
|
#gem 'rchoice', :git => "git@github.com:mharris717/rchoice.git", :branch => "gemdir"
|
data/Gemfile.lock
CHANGED
@@ -61,7 +61,7 @@ GEM
|
|
61
61
|
watchr
|
62
62
|
lumberjack (1.0.4)
|
63
63
|
method_source (0.8.2)
|
64
|
-
mharris_ext (1.7.
|
64
|
+
mharris_ext (1.7.1)
|
65
65
|
facets
|
66
66
|
fattr
|
67
67
|
multi_json (1.8.2)
|
@@ -115,7 +115,7 @@ DEPENDENCIES
|
|
115
115
|
guard-spork
|
116
116
|
jeweler (~> 1.8.4)
|
117
117
|
lre
|
118
|
-
mharris_ext
|
118
|
+
mharris_ext (>= 1.7.1)
|
119
119
|
rb-fsevent (~> 0.9)
|
120
120
|
rdoc (~> 3.12)
|
121
121
|
rspec (~> 2.8.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/overapp/files.rb
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
module Overapp
|
2
|
+
class MissingBaseFileError < RuntimeError
|
3
|
+
include FromHash
|
4
|
+
attr_accessor :top_file, :base
|
5
|
+
def message
|
6
|
+
res = "Cannot overlay onto missing file #{top_file.path}\nBase File Count: #{base.files.size}\n"
|
7
|
+
res += base.map { |x| x.path }.join("\n")
|
8
|
+
res
|
9
|
+
end
|
10
|
+
end
|
2
11
|
class Files
|
3
12
|
include FromHash
|
4
13
|
include Enumerable
|
@@ -19,7 +28,7 @@ module Overapp
|
|
19
28
|
new_file = top_file.combined(existing)
|
20
29
|
res << new_file if new_file
|
21
30
|
elsif top_file.has_note?
|
22
|
-
raise
|
31
|
+
raise MissingBaseFileError.new(:top_file => top_file, :base => self)
|
23
32
|
else
|
24
33
|
res << top_file
|
25
34
|
end
|
@@ -34,58 +43,13 @@ module Overapp
|
|
34
43
|
each do |f|
|
35
44
|
f.write_to! dir
|
36
45
|
end
|
46
|
+
self
|
37
47
|
end
|
38
48
|
|
39
49
|
class << self
|
40
|
-
def dir_files(dir)
|
41
|
-
res = Dir["#{dir}/**/*"] + Dir["#{dir}/**/.*"]
|
42
|
-
res - [".","..",".git"]
|
43
|
-
end
|
44
|
-
def load_dir(dir,ops={})
|
45
|
-
raise "Bad dir" unless dir.present?
|
46
|
-
raise "Dir not there #{dir}" unless FileTest.exist?(dir)
|
47
|
-
res = new
|
48
|
-
res.file_class = ops[:file_class] if ops[:file_class]
|
49
|
-
dir_files(dir).each do |full_file|
|
50
|
-
if FileTest.file?(full_file)
|
51
|
-
f = full_file.gsub("#{dir}/","")
|
52
|
-
raise "bad #{f}" if f == full_file
|
53
|
-
res.add :file => f, :body => File.read(full_file)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
res
|
57
|
-
end
|
58
|
-
|
59
50
|
def load_command(cmd,ops)
|
60
51
|
FromCommand.new(:command => cmd, :path => ops[:path]||".").files
|
61
52
|
end
|
62
|
-
|
63
|
-
def load(descriptor, ops={})
|
64
|
-
raise "bad #{descriptor}" if descriptor.blank?
|
65
|
-
if ops[:type] == :command
|
66
|
-
load_command(descriptor,ops)
|
67
|
-
elsif descriptor =~ /\.git/ || descriptor =~ /file:\/\//
|
68
|
-
load_repo(descriptor)
|
69
|
-
else
|
70
|
-
load_dir(descriptor,ops)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def write_combined(base_dir, top_dir, output_dir)
|
75
|
-
base = load(base_dir)
|
76
|
-
top = load(top_dir)
|
77
|
-
combined = base.apply(top)
|
78
|
-
combined.write_to! output_dir
|
79
|
-
end
|
80
|
-
|
81
|
-
def load_repo(url)
|
82
|
-
url = url.gsub "ROOT_DIR", File.expand_path(File.dirname(__FILE__) + "/../..")
|
83
|
-
dir = "/tmp/#{rand(1000000000000000000)}"
|
84
|
-
ec "git clone #{url} #{dir} 2>&1", :silent => true
|
85
|
-
load dir
|
86
|
-
ensure
|
87
|
-
ec "rm -rf #{dir}", :silent => true
|
88
|
-
end
|
89
53
|
end
|
90
54
|
end
|
91
55
|
end
|
data/lib/overapp/from_command.rb
CHANGED
@@ -3,18 +3,8 @@ module Overapp
|
|
3
3
|
include FromHash
|
4
4
|
attr_accessor :command, :path
|
5
5
|
|
6
|
-
def with_tmp_dir
|
7
|
-
dir = "/tmp/#{rand(1000000000000000000)}"
|
8
|
-
`mkdir #{dir}`
|
9
|
-
Dir.chdir(dir) do
|
10
|
-
yield dir
|
11
|
-
end
|
12
|
-
ensure
|
13
|
-
ec "rm -rf #{dir}", :silent => true
|
14
|
-
end
|
15
|
-
|
16
6
|
fattr(:files) do
|
17
|
-
with_tmp_dir do |dir|
|
7
|
+
Overapp.with_tmp_dir do |dir|
|
18
8
|
Overapp.ec command, :silent => true
|
19
9
|
Files.load [dir,path].select { |x| x.present? }.join("/"), :file_class => BasicFile
|
20
10
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Overapp
|
2
|
+
module Load
|
3
|
+
class Base
|
4
|
+
include FromHash
|
5
|
+
attr_accessor :descriptor
|
6
|
+
|
7
|
+
def apply_to(base,ops)
|
8
|
+
base.apply(load(base,ops))
|
9
|
+
end
|
10
|
+
|
11
|
+
def commit_message
|
12
|
+
"Message Pending"
|
13
|
+
end
|
14
|
+
|
15
|
+
def load(*args)
|
16
|
+
raise "load unimplemented"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Overapp
|
2
|
+
module Load
|
3
|
+
class Factory
|
4
|
+
include FromHash
|
5
|
+
attr_accessor :descriptor, :type, :entry_ops
|
6
|
+
|
7
|
+
def loader
|
8
|
+
raise "bad #{descriptor}" if descriptor.blank?
|
9
|
+
if type.to_s.to_sym == :command
|
10
|
+
Command.new(:descriptor => descriptor).tap { |x| x.relative_output_path = entry_ops[:path] if entry_ops[:path].present? }
|
11
|
+
elsif Git.repo?(descriptor)
|
12
|
+
Repo.new(:descriptor => descriptor)
|
13
|
+
else
|
14
|
+
LocalDir.new(:descriptor => descriptor)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Overapp
|
2
|
+
module Load
|
3
|
+
class Instance
|
4
|
+
include FromHash
|
5
|
+
attr_accessor :path, :overlays
|
6
|
+
|
7
|
+
fattr(:starting_files) do
|
8
|
+
raise "path doesn't exist #{path}" unless FileTest.exist?(path)
|
9
|
+
if Overapp.dir_files(path).empty?
|
10
|
+
Overapp::Files.new
|
11
|
+
else
|
12
|
+
RawDir.new(:descriptor => path).load(nil,{})
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
fattr(:combined_files) do
|
17
|
+
files = starting_files
|
18
|
+
|
19
|
+
overlays.each do |overlay|
|
20
|
+
files = apply_overlay(files,overlay)
|
21
|
+
end
|
22
|
+
|
23
|
+
files
|
24
|
+
end
|
25
|
+
|
26
|
+
def apply_overlay(base,overlay)
|
27
|
+
Overapp::Git.commit(path,overlay.commit_message) do
|
28
|
+
overlay.apply_to(base, :path => path).tap do |res|
|
29
|
+
res.write_to! path
|
30
|
+
end
|
31
|
+
end.tap { |res| raise "nil return" unless res }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Overapp
|
2
|
+
module Load
|
3
|
+
class Command < Base
|
4
|
+
attr_accessor :relative_output_path
|
5
|
+
def command; descriptor; end
|
6
|
+
def load(base,ops={})
|
7
|
+
if relative_output_path.present?
|
8
|
+
TmpDir.with do |dir|
|
9
|
+
Overapp.ec "cd #{dir} && #{command}", :silent => true
|
10
|
+
RawDir.new(:descriptor => "#{dir}/#{relative_output_path}").load(base,ops)
|
11
|
+
end
|
12
|
+
else
|
13
|
+
Overapp.ec "cd #{ops[:path]} && #{command}", :silent => true
|
14
|
+
RawDir.new(:descriptor => ops[:path]).load(base,ops)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Overapp
|
2
|
+
module Load
|
3
|
+
class LocalDir < Base
|
4
|
+
def path; Overapp.to_proper_dir(descriptor); end
|
5
|
+
|
6
|
+
def load(base,ops)
|
7
|
+
if Overapp::Project.project? path
|
8
|
+
Project.new(:descriptor => path).load(base,ops)
|
9
|
+
else
|
10
|
+
RawDir.new(:descriptor => path).load(base,ops)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Overapp
|
2
|
+
module Load
|
3
|
+
class Project < Base
|
4
|
+
def path; descriptor; end
|
5
|
+
def load(base,ops={})
|
6
|
+
project = Overapp::Project.new(:path => path)
|
7
|
+
project.write_to! ops[:path]
|
8
|
+
RawDir.new(:descriptor => ops[:path]).load(base,ops)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Overapp
|
2
|
+
module Load
|
3
|
+
class RawDir < Base
|
4
|
+
def dir; Overapp.to_proper_dir(descriptor); end
|
5
|
+
def load(base,ops)
|
6
|
+
ops = {}
|
7
|
+
raise "Bad dir" unless dir.present?
|
8
|
+
raise "Dir not there #{dir}" unless FileTest.exist?(dir)
|
9
|
+
res = Files.new
|
10
|
+
res.file_class = ops[:file_class] if ops[:file_class]
|
11
|
+
Overapp.dir_files(dir).each do |full_file|
|
12
|
+
if FileTest.file?(full_file)
|
13
|
+
f = full_file.gsub("#{dir}/","")
|
14
|
+
raise "bad #{f}" if f == full_file
|
15
|
+
res.add :file => f, :body => File.read(full_file)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
res
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Overapp
|
2
|
+
class ProjectConfig
|
3
|
+
include FromHash
|
4
|
+
attr_accessor :body, :base_ops
|
5
|
+
fattr(:overapps) { [] }
|
6
|
+
|
7
|
+
def base(*args)
|
8
|
+
overapp(*args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def overapp(name)
|
12
|
+
self.overapps << ConfigEntry.new(:descriptor => name, :type => :overapp)
|
13
|
+
end
|
14
|
+
|
15
|
+
def overlay(name)
|
16
|
+
overapp(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def command(cmd,ops={})
|
20
|
+
self.overapps << ConfigEntry.new(:descriptor => cmd, :type => :command, :entry_ops => ops)
|
21
|
+
end
|
22
|
+
|
23
|
+
def load!
|
24
|
+
c = self
|
25
|
+
eval(body)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Overapp
|
2
|
+
class Project
|
3
|
+
class Write
|
4
|
+
include FromHash
|
5
|
+
attr_accessor :output_path, :project
|
6
|
+
|
7
|
+
fattr(:instance) do
|
8
|
+
Load::Instance.new(:path => output_path, :overlays => project.overapps)
|
9
|
+
end
|
10
|
+
|
11
|
+
def combined_files
|
12
|
+
instance.combined_files
|
13
|
+
end
|
14
|
+
|
15
|
+
def write!
|
16
|
+
raise "no combined files" unless combined_files
|
17
|
+
combined_files.write_to!(output_path)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/overapp/project.rb
CHANGED
@@ -3,15 +3,22 @@ module Overapp
|
|
3
3
|
include FromHash
|
4
4
|
attr_accessor :path
|
5
5
|
|
6
|
+
class << self
|
7
|
+
def project_files
|
8
|
+
%w(.fstemplate .overapp .overlay)
|
9
|
+
end
|
10
|
+
|
11
|
+
def project?(path)
|
12
|
+
!!project_files.map { |x| "#{path}/#{x}" }.find { |x| FileTest.exist?(x) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
6
16
|
def config_body
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
File.read("#{path}/.overapp")
|
11
|
-
elsif FileTest.exist?("#{path}/.overlay")
|
12
|
-
File.read("#{path}/.overlay")
|
17
|
+
file = klass.project_files.map { |x| "#{path}/#{x}" }.find { |x| FileTest.exist?(x) }
|
18
|
+
if file
|
19
|
+
File.read(file)
|
13
20
|
else
|
14
|
-
raise "no config"
|
21
|
+
raise "no config found in #{path}"
|
15
22
|
end
|
16
23
|
end
|
17
24
|
|
@@ -22,92 +29,27 @@ module Overapp
|
|
22
29
|
res
|
23
30
|
end
|
24
31
|
|
25
|
-
def
|
26
|
-
config.overapps + [path]
|
27
|
-
end
|
28
|
-
|
29
|
-
def commands(phase)
|
30
|
-
config.commands.select { |x| x[:phase] == phase }.map { |x| x[:command] }
|
31
|
-
end
|
32
|
-
|
33
|
-
fattr(:overapps) do
|
34
|
-
overapp_paths.map { |x| Files.load(x) }
|
32
|
+
def overapp_entries
|
33
|
+
config.overapps + [ConfigEntry.new(:descriptor => path)]
|
35
34
|
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
def overapps
|
37
|
+
overapp_entries.map do |entry|
|
38
|
+
if path == entry.descriptor
|
39
|
+
Load::RawDir.new(:descriptor => path)
|
40
|
+
else
|
41
|
+
Load::Factory.new(:descriptor => entry.descriptor, :type => entry.type, :entry_ops => entry.entry_ops).loader
|
42
|
+
end
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
fattr(:combined_files) do
|
46
|
-
res = base_files
|
47
|
-
overapps.each do |overapp|
|
48
|
-
res = res.apply(overapp)
|
49
|
-
end
|
50
|
-
res
|
51
|
-
end
|
52
|
-
|
53
|
-
def git_commit(output_path,message,init=false)
|
54
|
-
if init
|
55
|
-
`rm -rf #{output_path}/.git`
|
56
|
-
ec "cd #{output_path} && git init && git config user.email johnsmith@fake.com && git config user.name 'John Smith'", :silent => true
|
57
|
-
end
|
58
|
-
ec "cd #{output_path} && git add . && git commit -m '#{message}'", :silent => true
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
46
|
def write_to!(output_path)
|
63
|
-
|
64
|
-
Overapp.ec "cd #{output_path} && #{cmd}", :silent => true
|
65
|
-
git_commit output_path, "Ran Command: #{cmd}"
|
66
|
-
end
|
67
|
-
|
68
|
-
base_files.write_to! output_path
|
69
|
-
|
70
|
-
git_commit output_path, "Base Files #{config.base}", true
|
71
|
-
combined_files.write_to!(output_path)
|
72
|
-
git_commit output_path, "Overapp Files #{path}"
|
73
|
-
|
74
|
-
commands(:after).each do |cmd|
|
75
|
-
Overapp.ec "cd #{output_path} && #{cmd}", :silent => true
|
76
|
-
git_commit output_path, "Ran Command: #{cmd}"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
class ProjectConfig
|
82
|
-
include FromHash
|
83
|
-
attr_accessor :body, :base, :base_ops
|
84
|
-
fattr(:overapps) { [] }
|
85
|
-
fattr(:commands) { [] }
|
86
|
-
|
87
|
-
def base(*args)
|
88
|
-
if args.empty?
|
89
|
-
@base
|
90
|
-
else
|
91
|
-
@base = args.first
|
92
|
-
@base_ops = args[1] || {}
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def overapp(name)
|
97
|
-
self.overapps << name
|
98
|
-
end
|
99
|
-
|
100
|
-
def overlay(name)
|
101
|
-
overapp(name)
|
102
|
-
end
|
103
|
-
|
104
|
-
def command(cmd,phase=:after)
|
105
|
-
self.commands << {:command => cmd, :phase => phase}
|
47
|
+
Write.new(:output_path => output_path, :project => self).write!
|
106
48
|
end
|
107
49
|
|
108
|
-
def
|
109
|
-
|
110
|
-
|
50
|
+
def combined_files(output_path)
|
51
|
+
raise 'here'
|
52
|
+
Write.new(:output_path => output_path, :project => self).combined_files
|
111
53
|
end
|
112
54
|
end
|
113
55
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Overapp
|
2
|
+
class << self
|
3
|
+
def dir_files(dir)
|
4
|
+
res = Dir["#{dir}/**/*"] + Dir["#{dir}/**/.*"]
|
5
|
+
res - [".","..",".git"]
|
6
|
+
end
|
7
|
+
|
8
|
+
def with_local_path(overapp_path,&b)
|
9
|
+
if Git.repo?(overapp_path)
|
10
|
+
TmpDir.with_repo_path(overapp_path) do |dir|
|
11
|
+
b[dir]
|
12
|
+
end
|
13
|
+
else
|
14
|
+
yield overapp_path
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_proper_dir(dir)
|
19
|
+
base = File.expand_path(File.dirname(__FILE__) + "/../../..")
|
20
|
+
dir.gsub("OVERAPP_ROOT_DIR",base)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Overapp
|
2
|
+
class Git
|
3
|
+
class << self
|
4
|
+
def commit_inner(output_path,message,init,&b)
|
5
|
+
res = nil
|
6
|
+
res = yield if block_given?
|
7
|
+
if init
|
8
|
+
`rm -rf #{output_path}/.git`
|
9
|
+
ec "cd #{output_path} && git init && git config user.email johnsmith@fake.com && git config user.name 'John Smith'", :silent => true
|
10
|
+
end
|
11
|
+
|
12
|
+
ec "cd #{output_path} && git add . && git commit -m '#{message}'", :silent => true
|
13
|
+
res
|
14
|
+
end
|
15
|
+
def commit(output_path,message,&b)
|
16
|
+
init = !FileTest.exist?("#{output_path}/.git")
|
17
|
+
commit_inner(output_path,message,init,&b)
|
18
|
+
end
|
19
|
+
|
20
|
+
def repo?(path)
|
21
|
+
path =~ /\.git/ || path =~ /file:\/\// || path =~ /git:\/\//
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Overapp
|
2
|
+
class TmpDir
|
3
|
+
class << self
|
4
|
+
def base_dir
|
5
|
+
File.expand_path(File.dirname(__FILE__) + "/../../../tmp")
|
6
|
+
end
|
7
|
+
def with(ops={})
|
8
|
+
dir = "#{base_dir}/#{rand(1000000000000000000)}"
|
9
|
+
`mkdir #{dir}`
|
10
|
+
if block_given?
|
11
|
+
Dir.chdir(dir) do
|
12
|
+
yield dir
|
13
|
+
end
|
14
|
+
else
|
15
|
+
dir
|
16
|
+
end
|
17
|
+
ensure
|
18
|
+
if block_given?
|
19
|
+
ec "rm -rf #{dir}", :silent => true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def with_repo_path(url)
|
24
|
+
url = Overapp.to_proper_dir(url)
|
25
|
+
with do |dir|
|
26
|
+
`git clone #{url} . 2>&1`
|
27
|
+
yield dir
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|