dev 2.0.99 → 2.0.100
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/command.rb +216 -0
- data/lib/commands/add.rb +22 -0
- data/lib/commands/analyze.rb +8 -0
- data/lib/commands/array.rb +30 -0
- data/lib/commands/build.rb +31 -0
- data/lib/commands/clean.rb +12 -0
- data/lib/commands/clobber.rb +15 -0
- data/lib/commands/command.rb +222 -0
- data/lib/commands/commands.rb +36 -0
- data/lib/commands/commit.rb +20 -0
- data/lib/commands/doc.rb +9 -0
- data/lib/commands/gemspec.rb +40 -0
- data/lib/commands/git.rb +22 -0
- data/lib/commands/hash.rb +21 -0
- data/lib/commands/info.rb +3 -0
- data/lib/commands/internet.rb +24 -0
- data/lib/commands/msbuild.rb +56 -0
- data/lib/commands/publish.rb +21 -0
- data/lib/commands/pull.rb +12 -0
- data/lib/commands/push.rb +8 -0
- data/lib/commands/setup.rb +41 -0
- data/lib/commands/tag.rb +3 -0
- data/lib/commands/test.rb +62 -0
- data/lib/commands/text.rb +16 -0
- data/lib/commands/timeout.rb +81 -0
- data/lib/commands/timer.rb +43 -0
- data/lib/commands/update.rb +5 -0
- data/lib/commands/upgrade.rb +6 -0
- data/lib/dev.rb +1 -1
- data/lib/{dev_environment.rb → environment.rb} +1 -35
- data/lib/file.rb +34 -0
- data/lib/{dev_git.rb → git.rb} +1 -1
- data/lib/{dev_msbuild.rb → msbuild.rb} +0 -1
- data/lib/project.rb +64 -0
- data/lib/{dev_projects.rb → projects.rb} +0 -71
- data/lib/{dev_svn.rb → svn.rb} +1 -1
- data/lib/{dev_tasks.rb → tasks.rb} +1 -5
- metadata +38 -9
- data/lib/dev_commands.rb +0 -1104
data/lib/commands/git.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class Git
|
2
|
+
def self.branch
|
3
|
+
begin
|
4
|
+
`git branch`.scan(/\* ([.\w-]+)/)[0][0]
|
5
|
+
rescue
|
6
|
+
''
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.remote_origin directory=''
|
11
|
+
url=''
|
12
|
+
directory=Dir.pwd if directory.length == 0
|
13
|
+
Dir.chdir(directory) do
|
14
|
+
begin
|
15
|
+
url=`git remote show origin`.scan(/Fetch URL: ([\.\-:\/\w\d]+)/)[0]
|
16
|
+
rescue
|
17
|
+
url=''
|
18
|
+
end
|
19
|
+
end
|
20
|
+
url
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Hash
|
2
|
+
def execute value=nil
|
3
|
+
self.each{|k,v|
|
4
|
+
v.update if v.respond_to?(:update)
|
5
|
+
if(v.is_a?(Array) && v.length==0)
|
6
|
+
self.delete k
|
7
|
+
else
|
8
|
+
#puts "executing #{k}"
|
9
|
+
|
10
|
+
v.execute(value) if v.respond_to?(:execute)
|
11
|
+
end
|
12
|
+
}
|
13
|
+
end
|
14
|
+
def to_html
|
15
|
+
[
|
16
|
+
'<div>',
|
17
|
+
map { |k, v| ["<br/><div><strong>#{k}</strong>", v.respond_to?(:to_html) ? v.to_html : "<span>#{v}</span></div><br/>"] },
|
18
|
+
'</div>'
|
19
|
+
].join
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
#require 'net/http'
|
3
|
+
require 'timeout'
|
4
|
+
class Internet
|
5
|
+
|
6
|
+
@@available=true
|
7
|
+
|
8
|
+
def self.available?
|
9
|
+
return @@available if !@@available.nil?
|
10
|
+
|
11
|
+
begin
|
12
|
+
index=open('http://www.google.com').read
|
13
|
+
if index.include?('<Title>Google')
|
14
|
+
@@available = true
|
15
|
+
else
|
16
|
+
puts "open('http://www.google.com') returned false"
|
17
|
+
end
|
18
|
+
rescue Exception => e
|
19
|
+
puts "open('http://www.google.com') raised an exception: #{e.to_s}"
|
20
|
+
@@available = false
|
21
|
+
end
|
22
|
+
@@available
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Visual Studio 2008 version 9.0, solution format version 10.00
|
2
|
+
# Visual Studio 2010 version 10.0, solution format version 11.00
|
3
|
+
# Visual Studio 2012 version 11.0, solution format version 12.00
|
4
|
+
# Visual Studio 2013 version 12.0, solution format version 12.00
|
5
|
+
class MSBuild < Hash
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
self[:vs9]="C:\\Windows\\Microsoft.NET\\Framework\\v3.5\\msbuild.exe" if(File.exists?("C:\\Windows\\Microsoft.NET\\Framework\\v3.5\\msbuild.exe"))
|
9
|
+
self[:vs12]="C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\msbuild.exe" if(File.exists?("C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\msbuild.exe"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.has_version? version
|
13
|
+
if(defined?(MSBUILD))
|
14
|
+
MSBUILD.has_key?(version)
|
15
|
+
else
|
16
|
+
msb=MSBuild.new
|
17
|
+
return msb.has_key? version
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.get_version version
|
22
|
+
if(defined?(MSBUILD))
|
23
|
+
MSBUILD[version]
|
24
|
+
else
|
25
|
+
msb=MSBuild.new
|
26
|
+
return msb[version]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.get_vs_version(sln_filename)
|
31
|
+
sln_text=File.read(sln_filename,:encoding=>'UTF-8')
|
32
|
+
return :vs9 if sln_text.include?('Format Version 10.00')
|
33
|
+
return :vs12
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.get_configurations(sln_filename)
|
37
|
+
configs=Array.new
|
38
|
+
sln_text=File.read(sln_filename,:encoding=>'UTF-8')
|
39
|
+
sln_text.scan( /= ([\w]+)\|/ ).each{|m|
|
40
|
+
c=m.first.to_s
|
41
|
+
configs << c if !configs.include?(c)
|
42
|
+
}
|
43
|
+
return configs
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.get_platforms(sln_filename)
|
47
|
+
platforms=Array.new
|
48
|
+
sln_text=File.read(sln_filename,:encoding=>"UTF-8")
|
49
|
+
sln_text.scan( /= [\w]+\|([\w ]+)/ ).each{|m|
|
50
|
+
p=m.first.to_s
|
51
|
+
platforms << p if !platforms.include?(p)
|
52
|
+
}
|
53
|
+
return platforms
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#require_relative('internet.rb')
|
2
|
+
class Publish < Array
|
3
|
+
def update
|
4
|
+
if(Internet.available?)
|
5
|
+
if(File.exists?('.git'))
|
6
|
+
if(`git branch`.include?('* master'))
|
7
|
+
Dir.glob('*.gemspec').each{|gemspec_file|
|
8
|
+
add "gem push #{Gemspec.gemfile(gemspec_file)}" if !Gemspec.published? gemspec_file
|
9
|
+
}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
if(File.exists?('.svn'))
|
13
|
+
if(`svn info`.include?('/trunk'))
|
14
|
+
Dir.glob('*.gemspec').each{|gemspec_file|
|
15
|
+
add "gem push #{Gemspec.gemfile(gemspec_file)}" if !Gemspec.published? gemspec_file
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#require_relative('git.rb')
|
2
|
+
#require_relative('internet.rb')
|
3
|
+
|
4
|
+
class Pull < Array
|
5
|
+
def update
|
6
|
+
if(Internet.available?)
|
7
|
+
if(File.exists?('.git') && `git config --list`.include?('user.name='))
|
8
|
+
self << 'git pull' if Git.branch != 'develop'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# use the SVN_EXPORTS hash to define svn exports destined for DEV_ROOT/dep
|
3
|
+
#
|
4
|
+
# SVN_EXPORT={ 'System.Data.SQLite/1.0.93.0' => 'https://third-party.googlecode.com/svn/trunk/System.Data.SQLite/1.0.93.0' }
|
5
|
+
#
|
6
|
+
class Setup < Array
|
7
|
+
def update
|
8
|
+
add 'bundle install' if(File.exists?('Gemfile'))
|
9
|
+
|
10
|
+
Dir.glob('*.gemspec').each{|gemspec_file|
|
11
|
+
add "<%Gemspec.update('#{gemspec_file}')%>"
|
12
|
+
}
|
13
|
+
|
14
|
+
if(defined?(SVN_EXPORTS))
|
15
|
+
SVN_EXPORTS.each{|k,v|
|
16
|
+
if(!File.exists?("#{Command.dev_root}/dep/#{k}"))
|
17
|
+
FileUtils.mkdir_p(File.dirname("#{Command.dev_root}/dep/#{k}")) if !File.exists?("#{Command.dev_root}/dep/#{k}")
|
18
|
+
dest="#{Command.dev_root}/dep/#{k}"
|
19
|
+
add "svn export #{v} #{Command.dev_root}/dep/#{k}" if !dest.include?("@")
|
20
|
+
add "svn export #{v} #{Command.dev_root}/dep/#{k}@" if dest.include?("@")
|
21
|
+
end
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
if(defined?(GIT_EXPORTS))
|
26
|
+
GIT_EXPORTS.each{|k,v|
|
27
|
+
directory = "#{Command.dev_root}/dep/#{k}"
|
28
|
+
if(!File.exists?(directory))
|
29
|
+
if(v.include?('@'))
|
30
|
+
puts `git clone #{v.split('@')[0]} #{directory}`
|
31
|
+
Dir.chdir(directory) do
|
32
|
+
puts `git reset --hard #{v.split('@')[1]}`
|
33
|
+
end
|
34
|
+
else
|
35
|
+
add "git clone #{v} #{directory}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/commands/tag.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# nunit dlls may be specified with
|
3
|
+
# NUNIT=FileList.new('**/*.Test.dll')
|
4
|
+
#
|
5
|
+
# for nunit dlls that must be run in x86 mode,
|
6
|
+
# NUNIT_x86=FileList.new('**/*.x86.Test.dll')
|
7
|
+
#
|
8
|
+
|
9
|
+
|
10
|
+
class Test < Array
|
11
|
+
def update
|
12
|
+
add 'rspec' if File.exists?('spec')
|
13
|
+
|
14
|
+
if(defined?(NUNIT))
|
15
|
+
NUNIT.each{|nunit_dll|
|
16
|
+
add "\"#{Test.nunit_console}\" \"#{Rake.application.original_dir}\\#{nunit_dll}\" /xml:\"#{nunit_dll}.TestResults.xml\""
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
if(defined?(NUNIT_X86))
|
21
|
+
NUNIT_X86.each{|nunit_dll|
|
22
|
+
add "\"#{Test.nunit_console_x86}\" \"#{Rake.application.original_dir}\\#{nunit_dll}\" /xml:\"#{nunit_dll}.TestResults.xml\""
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
if(defined?(TESTS))
|
27
|
+
TEST.each{|t| add t}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
@@nunit_console=''
|
32
|
+
def self.nunit_console
|
33
|
+
if(!File.exists?(@@nunit_console))
|
34
|
+
if(defined?(NUNIT_CONSOLE))
|
35
|
+
@@nunit_console = NUNIT_CONSOLE
|
36
|
+
end
|
37
|
+
@@nunit_console = "C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console.exe" if(!File.exists?(@@nunit_console))
|
38
|
+
@@nunit_console = "C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe" if(!File.exists?(@@nunit_console))
|
39
|
+
end
|
40
|
+
if(!File.exists?(@@nunit_console))
|
41
|
+
raise "unable to locate nunit-console.exe, assign NUNIT_CONSOLE to the correct location."
|
42
|
+
end
|
43
|
+
@@nunit_console
|
44
|
+
end
|
45
|
+
|
46
|
+
@@nunit_console_x86=''
|
47
|
+
def self.nunit_console_x86
|
48
|
+
if(!File.exists?(@@nunit_console_x86))
|
49
|
+
if(defined?(NUNIT_CONSOLE_X86))
|
50
|
+
@@nunit_console_x86 = NUNIT_CONSOLE_X86
|
51
|
+
end
|
52
|
+
@@nunit_console_x86 = "C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console-x86.exe" if(!File.exists?(@@nunit_console_x86))
|
53
|
+
@@nunit_console_x86 = "C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console-x86.exe" if(!File.exists?(@@nunit_console_x86))
|
54
|
+
end
|
55
|
+
if(!File.exists?(@@nunit_console_x86))
|
56
|
+
raise "unable to locate nunit-console-x86.exe, assign NUNIT_CONSOLE_X86 to the correct location."
|
57
|
+
end
|
58
|
+
@@nunit_console_x86
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
NUNIT=FileList.new('bin/**/*.Test.dll')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Text
|
2
|
+
def self.replace_in_glob(glob,search,replace)
|
3
|
+
Dir.glob(glob).each{ |f| replace_in_file(f,search,replace) }
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.replace_in_file(filename,search,replace)
|
7
|
+
text1 = IO.read(filename)
|
8
|
+
text2 = text1.gsub(search) { |str| str=replace }
|
9
|
+
unless text1==text2
|
10
|
+
File.open(filename,"w") { |f| f.puts text2 }
|
11
|
+
return true
|
12
|
+
end
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
############################################################################
|
2
|
+
# The following code is based on code originally copied from
|
3
|
+
# https://gist.github.com/lpar/1032297
|
4
|
+
# Gist title: lpar/timeout.rb
|
5
|
+
############################################################################
|
6
|
+
# Runs a specified shell command in a separate thread.
|
7
|
+
# If it exceeds the given timeout in seconds, kills it.
|
8
|
+
# Returns any output produced by the command (stdout or stderr) as a String.
|
9
|
+
# Uses Kernel.select to wait up to the tick length (in seconds) between
|
10
|
+
# checks on the command's status
|
11
|
+
#
|
12
|
+
# If you've got a cleaner way of doing this, I'd be interested to see it.
|
13
|
+
# If you think you can do it with Ruby's Timeout module, think again.
|
14
|
+
def run_with_timeout(directory,command, timeout, tick)
|
15
|
+
output = ''
|
16
|
+
exit_code=1
|
17
|
+
begin
|
18
|
+
# Start task in another thread, which spawns a process
|
19
|
+
stdin, stderrout, thread = Open3.popen2e(command, :chdir=>directory)
|
20
|
+
# Get the pid of the spawned process
|
21
|
+
pid = thread[:pid]
|
22
|
+
start = Time.now
|
23
|
+
|
24
|
+
while (Time.now - start) < timeout and thread.alive?
|
25
|
+
# Wait up to `tick` seconds for output/error data
|
26
|
+
Kernel.select([stderrout], nil, nil, tick)
|
27
|
+
# Try to read the data
|
28
|
+
begin
|
29
|
+
output << stderrout.read_nonblock(BUFFER_SIZE)
|
30
|
+
rescue IO::WaitReadable
|
31
|
+
# A read would block, so loop around for another select
|
32
|
+
rescue EOFError
|
33
|
+
# Command has completed, not really an error...
|
34
|
+
break
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Give Ruby time to clean up the other thread
|
39
|
+
sleep 1
|
40
|
+
|
41
|
+
if thread.alive?
|
42
|
+
# We need to kill the process, because killing the thread leaves
|
43
|
+
# the process alive but detached, annoyingly enough.
|
44
|
+
Process.kill("TERM", pid)
|
45
|
+
else
|
46
|
+
exit_code=thread.value
|
47
|
+
sleep 1
|
48
|
+
end
|
49
|
+
|
50
|
+
ensure
|
51
|
+
stdin.close if stdin
|
52
|
+
stderrout.close if stderrout
|
53
|
+
end
|
54
|
+
return [output,exit_code]
|
55
|
+
end
|
56
|
+
|
57
|
+
require 'timeout'
|
58
|
+
def run_with_timeout2(directory,command,timeout)
|
59
|
+
# stdout, stderr pipes
|
60
|
+
rout, wout = IO.pipe
|
61
|
+
rerr, werr = IO.pipe
|
62
|
+
output=''
|
63
|
+
error=''
|
64
|
+
exit_code=1
|
65
|
+
pid = Process.spawn(command, :chdir => directory, :out => wout, :err => werr)
|
66
|
+
begin
|
67
|
+
Timeout.timeout(timeout) do
|
68
|
+
exit_code = Process.wait2(pid)
|
69
|
+
output = rout.readlines.join("\n")
|
70
|
+
error = rerr.readlines.join("\n")
|
71
|
+
end
|
72
|
+
rescue
|
73
|
+
Proces.kill('TERM',pid)
|
74
|
+
output = output + 'timeout occurred.'
|
75
|
+
ensure
|
76
|
+
rout.close
|
77
|
+
rerr.close
|
78
|
+
end
|
79
|
+
[output,exit_code]
|
80
|
+
end
|
81
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Timer
|
2
|
+
attr_accessor :start_time
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@start_time=Time.now
|
6
|
+
end
|
7
|
+
|
8
|
+
def elapsed # in seconds
|
9
|
+
return Time.now-@start_time
|
10
|
+
end
|
11
|
+
|
12
|
+
def elapsed_str
|
13
|
+
elapsed_str="[" + "%.0f" %(elapsed) + "s]"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.elapsed_exceeds?(name,duration_seconds)
|
17
|
+
if(Timer.get_elapsed(name).nil? || Timer.get_elapsed(name) > duration_seconds)
|
18
|
+
return true
|
19
|
+
end
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.get_elapsed(name)
|
24
|
+
timestamp=get_timestamp(name)
|
25
|
+
return Time.now-timestamp if(!timestamp.nil?)
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.get_timestamp(name)
|
30
|
+
dir=Rake.application.original_dir
|
31
|
+
if(File.exists?("#{DEV[:dev_root]}/log/#{name}.timestamp"))
|
32
|
+
return Time.parse(File.read("#{DEV[:dev_root]}/log/#{name}.timestamp").strip)
|
33
|
+
end
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.set_timestamp(name)
|
38
|
+
Dir.mkdir("#{DEV_TASKS[:dev_root]}/log") if(!Dir.exists?("#{DEV_TASKS[:dev_root]}/log"))
|
39
|
+
File.open("#{DEV_TASKS[:dev_root]}/log/#{name}.timestamp",'w'){|f|f.puts(Time.now.to_s)}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
TIMER=Timer.new
|
data/lib/dev.rb
CHANGED
@@ -40,38 +40,4 @@ class Environment < Hash
|
|
40
40
|
end
|
41
41
|
|
42
42
|
|
43
|
-
end
|
44
|
-
require 'fileutils'
|
45
|
-
|
46
|
-
class File
|
47
|
-
def self.amalgamate filename,source
|
48
|
-
File.open(filename,'w'){|file|
|
49
|
-
source.each{|source_file|
|
50
|
-
file.puts IO.read(source_file)
|
51
|
-
}
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.publish destination, source_dir, source_glob='**/*', overwrite_existing=false
|
56
|
-
|
57
|
-
output = "\n"
|
58
|
-
# directory
|
59
|
-
FileUtils.mkdir_p destination if !File.exists? destination
|
60
|
-
|
61
|
-
files=nil
|
62
|
-
Dir.chdir(source_dir) do
|
63
|
-
files=FileList.new(source_glob).to_a
|
64
|
-
end
|
65
|
-
output = output + "\nfiles: #{files}.to_s"
|
66
|
-
|
67
|
-
Dir.chdir(source_dir) do
|
68
|
-
files.each{|f|
|
69
|
-
file="#{destination}/#{f}"
|
70
|
-
dirname=File.dirname(file)
|
71
|
-
FileUtils.mkdir_p dirname if !File.exists? dirname
|
72
|
-
FileUtils.cp(f,file) if !File.exists? file || overwrite_existing
|
73
|
-
}
|
74
|
-
end
|
75
|
-
output
|
76
|
-
end
|
77
|
-
end
|
43
|
+
end
|
data/lib/file.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
class File
|
4
|
+
def self.amalgamate filename,source
|
5
|
+
File.open(filename,'w'){|file|
|
6
|
+
source.each{|source_file|
|
7
|
+
file.puts IO.read(source_file)
|
8
|
+
}
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.publish destination, source_dir, source_glob='**/*', overwrite_existing=false
|
13
|
+
|
14
|
+
output = "\n"
|
15
|
+
# directory
|
16
|
+
FileUtils.mkdir_p destination if !File.exists? destination
|
17
|
+
|
18
|
+
files=nil
|
19
|
+
Dir.chdir(source_dir) do
|
20
|
+
files=FileList.new(source_glob).to_a
|
21
|
+
end
|
22
|
+
output = output + "\nfiles: #{files}.to_s"
|
23
|
+
|
24
|
+
Dir.chdir(source_dir) do
|
25
|
+
files.each{|f|
|
26
|
+
file="#{destination}/#{f}"
|
27
|
+
dirname=File.dirname(file)
|
28
|
+
FileUtils.mkdir_p dirname if !File.exists? dirname
|
29
|
+
FileUtils.cp(f,file) if !File.exists? file || overwrite_existing
|
30
|
+
}
|
31
|
+
end
|
32
|
+
output
|
33
|
+
end
|
34
|
+
end
|
data/lib/{dev_git.rb → git.rb}
RENAMED
data/lib/project.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'json'
|
2
|
+
#require 'dev_commands'
|
3
|
+
|
4
|
+
class Project < Hash
|
5
|
+
attr_accessor :filename
|
6
|
+
def initialize value=''
|
7
|
+
@filename=''
|
8
|
+
self[:url]=''
|
9
|
+
self[:url] = value if value.is_a?(String)
|
10
|
+
if(value.is_a?(Hash))
|
11
|
+
value.each{|k,v|self[k]=v}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def name
|
16
|
+
self[:name]
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_latest_unique_id
|
20
|
+
'51ed9c9d45ba3979c808740d75ba1831c85aff5d'
|
21
|
+
end
|
22
|
+
|
23
|
+
def wrk_dir
|
24
|
+
"#{Environment.dev_root}/wrk/#{self.name}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def pull
|
28
|
+
if(File.exists?(wrk_dir) && File.exists?("#{wrk_dir}/.git"))
|
29
|
+
Dir.chdir(wrk_dir) do
|
30
|
+
puts "git pull (#{wrk_dir})"
|
31
|
+
puts `git pull`
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def clone
|
37
|
+
if(!File.exists?(wrk_dir) && self[:url].include?('.git'))
|
38
|
+
puts "cloning #{self[:url]} to #{self.wrk_dir}"
|
39
|
+
puts `git clone #{self[:url]} #{self.wrk_dir}`
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def checkout
|
44
|
+
if(!File.exists?(wrk_dir) && self[:url].include?('svn'))
|
45
|
+
puts "checkout #{self.url} to #{self.wrk_dir}"
|
46
|
+
puts `svn checkout #{self.url} #{self.wrk_dir}`
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def rake
|
51
|
+
if(!File.exists?(self.wrk_dir))
|
52
|
+
clone
|
53
|
+
checkout
|
54
|
+
end
|
55
|
+
if(File.exists?(self.wrk_dir))
|
56
|
+
Dir.chdir(self.wrk_dir) do
|
57
|
+
rake = Command.new({ :input => 'rake', :timeout => 300, :ignore_failure => true })
|
58
|
+
rake.execute
|
59
|
+
puts rake.summary
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
@@ -1,74 +1,3 @@
|
|
1
|
-
#require 'dev_environment'
|
2
|
-
#require_relative 'projects.rb'
|
3
|
-
#require_relative 'project.rb'
|
4
|
-
|
5
|
-
|
6
|
-
#class DevProjects
|
7
|
-
#end
|
8
|
-
require 'json'
|
9
|
-
#require 'dev_commands'
|
10
|
-
|
11
|
-
class Project < Hash
|
12
|
-
attr_accessor :filename
|
13
|
-
def initialize value=''
|
14
|
-
@filename=''
|
15
|
-
self[:url]=''
|
16
|
-
self[:url] = value if value.is_a?(String)
|
17
|
-
if(value.is_a?(Hash))
|
18
|
-
value.each{|k,v|self[k]=v}
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def name
|
23
|
-
self[:name]
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_latest_unique_id
|
27
|
-
'51ed9c9d45ba3979c808740d75ba1831c85aff5d'
|
28
|
-
end
|
29
|
-
|
30
|
-
def wrk_dir
|
31
|
-
"#{Environment.dev_root}/wrk/#{self.name}"
|
32
|
-
end
|
33
|
-
|
34
|
-
def pull
|
35
|
-
if(File.exists?(wrk_dir) && File.exists?("#{wrk_dir}/.git"))
|
36
|
-
Dir.chdir(wrk_dir) do
|
37
|
-
puts "git pull (#{wrk_dir})"
|
38
|
-
puts `git pull`
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def clone
|
44
|
-
if(!File.exists?(wrk_dir) && self[:url].include?('.git'))
|
45
|
-
puts "cloning #{self[:url]} to #{self.wrk_dir}"
|
46
|
-
puts `git clone #{self[:url]} #{self.wrk_dir}`
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def checkout
|
51
|
-
if(!File.exists?(wrk_dir) && self[:url].include?('svn'))
|
52
|
-
puts "checkout #{self.url} to #{self.wrk_dir}"
|
53
|
-
puts `svn checkout #{self.url} #{self.wrk_dir}`
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def rake
|
58
|
-
if(!File.exists?(self.wrk_dir))
|
59
|
-
clone
|
60
|
-
checkout
|
61
|
-
end
|
62
|
-
if(File.exists?(self.wrk_dir))
|
63
|
-
Dir.chdir(self.wrk_dir) do
|
64
|
-
rake = Command.new({ :input => 'rake', :timeout => 300, :ignore_failure => true })
|
65
|
-
rake.execute
|
66
|
-
puts rake.summary
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
1
|
require 'json'
|
73
2
|
require 'rake'
|
74
3
|
#require 'dev_git'
|
data/lib/{dev_svn.rb → svn.rb}
RENAMED