dev 2.0.46 → 2.0.47
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.
- data/lib/dev_commands.rb +1063 -0
- data/lib/dev_environment.rb +42 -1
- data/lib/dev_git.rb +50 -3
- data/lib/dev_msbuild.rb +72 -0
- data/lib/dev_projects.rb +136 -5
- data/lib/dev_svn.rb +98 -1
- data/lib/dev_tasks.rb +84 -2
- metadata +2 -33
- data/lib/add.rb +0 -22
- data/lib/analyze.rb +0 -8
- data/lib/array.rb +0 -30
- data/lib/build.rb +0 -33
- data/lib/clean.rb +0 -12
- data/lib/clobber.rb +0 -15
- data/lib/command.rb +0 -208
- data/lib/commands.rb +0 -36
- data/lib/commit.rb +0 -20
- data/lib/doc.rb +0 -9
- data/lib/environment.rb +0 -49
- data/lib/gemspec.rb +0 -40
- data/lib/git.rb +0 -51
- data/lib/hash.rb +0 -21
- data/lib/info.rb +0 -3
- data/lib/internet.rb +0 -24
- data/lib/msbuild.rb +0 -70
- data/lib/project.rb +0 -64
- data/lib/projects.rb +0 -66
- data/lib/publish.rb +0 -21
- data/lib/pull.rb +0 -12
- data/lib/push.rb +0 -9
- data/lib/setup.rb +0 -25
- data/lib/svn.rb +0 -99
- data/lib/tasks.rb +0 -82
- data/lib/test.rb +0 -58
- data/lib/text.rb +0 -16
- data/lib/timeout.rb +0 -81
- data/lib/timer.rb +0 -41
- data/lib/update.rb +0 -6
- data/lib/upgrade.rb +0 -6
data/lib/pull.rb
DELETED
@@ -1,12 +0,0 @@
|
|
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
|
data/lib/push.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
require_relative('internet.rb')
|
2
|
-
class Push < Array
|
3
|
-
def update
|
4
|
-
if(File.exists?('.git') && `git config --list`.include?('user.name='))
|
5
|
-
add 'git config --global push.default simple'
|
6
|
-
self << 'git push' if Git.branch != 'develop' && Internet.available?
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
data/lib/setup.rb
DELETED
@@ -1,25 +0,0 @@
|
|
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
|
-
end
|
25
|
-
end
|
data/lib/svn.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'tmpdir'
|
3
|
-
class Svn
|
4
|
-
|
5
|
-
def self.latest_revision
|
6
|
-
if(Dir.exists?(".svn"))
|
7
|
-
`svn update`
|
8
|
-
`svn info`.scan(/Last Changed Rev: ([\d]+)/).each{|m|
|
9
|
-
return m.first.to_s
|
10
|
-
}
|
11
|
-
end
|
12
|
-
"0"
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.url
|
16
|
-
if(Dir.exists?(".svn"))
|
17
|
-
`svn info`.scan(/URL: ([:\/\.\-\d\w]+)/).each{|m|
|
18
|
-
return m.first.to_s
|
19
|
-
}
|
20
|
-
end
|
21
|
-
''
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.export url, destination
|
25
|
-
if(!File.exists?(destination.chomp('@')))
|
26
|
-
`svn export #{url} #{destination}`
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.has_changes? directory=''
|
31
|
-
directory=Dir.pwd if directory.length==0
|
32
|
-
Dir.chdir(directory) do
|
33
|
-
if(File.exists?('.svn'))
|
34
|
-
return true if `svn status`.scan(/^[MA]/).length>0
|
35
|
-
end
|
36
|
-
end
|
37
|
-
false
|
38
|
-
end
|
39
|
-
|
40
|
-
# publish a directory to a new subversion path
|
41
|
-
# source_dir is the directory with the files to be published
|
42
|
-
# destination is the new subversion path URL
|
43
|
-
# source_glob is a string or array of glob directives to specify files in source_dir to be publish
|
44
|
-
# source_glob defaults to '**/*' to publish all files in the source_dir
|
45
|
-
def self.publish source_dir, destination, source_glob='**/*'
|
46
|
-
|
47
|
-
output = "\n"
|
48
|
-
raise "Svn.publish: destination #{destination} already exists" if(`svn info #{destination} 2>&1`.include?('Revision:'))
|
49
|
-
|
50
|
-
# create subversion directory
|
51
|
-
output = output + "svn mkdir #{destination} --parents --message mkdir_for_publishing"
|
52
|
-
if(!`svn mkdir #{destination} --parents --message mkdir_for_publishing`.include?('Committed'))
|
53
|
-
raise "failure 'svn mkdir #{destination} --parents --message mkdir_for_publishing'"
|
54
|
-
end
|
55
|
-
|
56
|
-
files=nil
|
57
|
-
Dir.chdir(source_dir) do
|
58
|
-
files=FileList.new(source_glob).to_a
|
59
|
-
end
|
60
|
-
output = output + "\nfiles: #{files}.to_s"
|
61
|
-
|
62
|
-
pwd=Dir.pwd
|
63
|
-
Dir.mktmpdir{|dir|
|
64
|
-
|
65
|
-
# checkout new subversion directory
|
66
|
-
output = output + "\nsvn checkout #{destination} #{dir}/to_publish_checkout"
|
67
|
-
if(!`svn checkout #{destination} #{dir}/to_publish_checkout`.include?('Checked out'))
|
68
|
-
raise "failure 'svn checkout #{destination} #{dir}/to_publish_checkout'"
|
69
|
-
end
|
70
|
-
|
71
|
-
# copy files into the checkout out subversion directory to_publish
|
72
|
-
raise "#{dir}/to_publish_checkout does not exist" if(!File.exists?("#{dir}/to_publish_checkout"))
|
73
|
-
Dir.chdir("#{dir}/to_publish_checkout") do
|
74
|
-
File.open('add.txt','w'){|add_file|
|
75
|
-
|
76
|
-
files.each{|f|
|
77
|
-
fdir=File.dirname(f)
|
78
|
-
FileUtils.mkdir_p(fdir) if(fdir.length > 0 && !File.exists?(fdir))
|
79
|
-
FileUtils.cp("#{source_dir}/#{f}","#{f}")
|
80
|
-
add_file.puts f
|
81
|
-
}
|
82
|
-
add_file.close
|
83
|
-
}
|
84
|
-
|
85
|
-
output = output + "\nsvn add --parents --targets add.txt 2>&1"
|
86
|
-
`svn add --parents --targets add.txt 2>&1`
|
87
|
-
commit_output = `svn commit -m"add" 2>&1`
|
88
|
-
output = output + "\n#{commit_output}"
|
89
|
-
if(!commit_output.include?("Committed"))
|
90
|
-
raise "failure 'svn commit -m'added files''"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
#begin
|
95
|
-
FileUtils.rm_r "#{dir}/to_publish_checkout"
|
96
|
-
output
|
97
|
-
}
|
98
|
-
end
|
99
|
-
end
|
data/lib/tasks.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
|
4
|
-
class Tasks
|
5
|
-
#@@commands=nil
|
6
|
-
@@quiet=false
|
7
|
-
|
8
|
-
def self.quiet
|
9
|
-
@@quiet
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.execute value
|
13
|
-
if(value.respond_to?(:execute))
|
14
|
-
value.update if value.respond_to?(:update)
|
15
|
-
value.execute
|
16
|
-
else
|
17
|
-
if(value.is_a?(String))
|
18
|
-
puts `#{value}`
|
19
|
-
else
|
20
|
-
if(value.is_a?(Array))
|
21
|
-
value.each{|e| execute(e)}
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.execute_task task
|
28
|
-
if(defined?(COMMANDS))
|
29
|
-
if(COMMANDS.has_key?(task))
|
30
|
-
puts "[:#{task}]" if(!Tasks.quiet)
|
31
|
-
Tasks.execute(COMMANDS[task])
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
desc 'performs a git pull'
|
38
|
-
task :pull do Tasks.execute_task :pull; end
|
39
|
-
|
40
|
-
desc 'performs svn update'
|
41
|
-
task :update do Tasks.execute_task :update; end
|
42
|
-
|
43
|
-
desc 'performs setup commands'
|
44
|
-
task :setup do Tasks.execute_task :setup;end
|
45
|
-
|
46
|
-
desc 'performs build commands'
|
47
|
-
task :build do Tasks.execute_task :build;end
|
48
|
-
|
49
|
-
desc 'performs test commands'
|
50
|
-
task :test => [:build] do Tasks.execute_task :test;end
|
51
|
-
|
52
|
-
desc 'performs analyze commands'
|
53
|
-
task :analyze do Tasks.execute_task :analyze;end
|
54
|
-
|
55
|
-
desc 'performs documentation commands'
|
56
|
-
task :doc do Tasks.execute_task :doc;end
|
57
|
-
|
58
|
-
desc 'performs clean commands'
|
59
|
-
task :clean do Tasks.execute_task :clean;end
|
60
|
-
|
61
|
-
desc 'performs publish commands'
|
62
|
-
task :publish do Tasks.execute_task :publish; end
|
63
|
-
|
64
|
-
desc 'performs clobber commands'
|
65
|
-
task :clobber => [:clean] do Tasks.execute_task :clobber;end
|
66
|
-
|
67
|
-
desc 'adds source files to git or subversion'
|
68
|
-
task :add do Tasks.execute_task :add;end
|
69
|
-
|
70
|
-
desc 'commits source files to git or subversion'
|
71
|
-
task :commit do Tasks.execute_task :commit;end
|
72
|
-
|
73
|
-
desc 'performs a git push'
|
74
|
-
task :push do Tasks.execute_task :push;end
|
75
|
-
|
76
|
-
desc 'displays project info'
|
77
|
-
task :info do
|
78
|
-
if(defined?(INFO) && INFO.length > 0)
|
79
|
-
puts "[:info]" if(!Tasks.quiet)
|
80
|
-
INFO.each{|l|puts l}
|
81
|
-
end
|
82
|
-
end
|
data/lib/test.rb
DELETED
@@ -1,58 +0,0 @@
|
|
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
|
-
class Test < Array
|
9
|
-
def update
|
10
|
-
add 'rspec' if File.exists?('spec')
|
11
|
-
|
12
|
-
if(defined?(NUNIT))
|
13
|
-
NUNIT.each{|nunit_dll|
|
14
|
-
add "\"#{Test.nunit_console}\" \"#{Rake.application.original_dir}\\#{nunit_dll}\" /xml:\"#{nunit_dll}.TestResults.xml\""
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
if(defined?(NUNIT_X86))
|
19
|
-
NUNIT_X86.each{|nunit_dll|
|
20
|
-
add "\"#{Test.nunit_console_x86}\" \"#{Rake.application.original_dir}\\#{nunit_dll}\" /xml:\"#{nunit_dll}.TestResults.xml\""
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
if(defined?(TESTS))
|
25
|
-
TEST.each{|t| add t}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
@@nunit_console=''
|
30
|
-
def self.nunit_console
|
31
|
-
if(!File.exists?(@@nunit_console))
|
32
|
-
if(defined?(NUNIT_CONSOLE))
|
33
|
-
@@nunit_console = NUNIT_CONSOLE
|
34
|
-
end
|
35
|
-
@@nunit_console = "C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console.exe" if(!File.exists?(@@nunit_console))
|
36
|
-
@@nunit_console = "C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe" if(!File.exists?(@@nunit_console))
|
37
|
-
end
|
38
|
-
if(!File.exists?(@@nunit_console))
|
39
|
-
raise "unable to locate nunit-console.exe, assign NUNIT_CONSOLE to the correct location."
|
40
|
-
end
|
41
|
-
@@nunit_console
|
42
|
-
end
|
43
|
-
|
44
|
-
@@nunit_console_x86=''
|
45
|
-
def self.nunit_console_x86
|
46
|
-
if(!File.exists?(@@nunit_console_x86))
|
47
|
-
if(defined?(NUNIT_CONSOLE_X86))
|
48
|
-
@@nunit_console_x86 = NUNIT_CONSOLE_X86
|
49
|
-
end
|
50
|
-
@@nunit_console_x86 = "C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console-x86.exe" if(!File.exists?(@@nunit_console_x86))
|
51
|
-
@@nunit_console_x86 = "C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console-x86.exe" if(!File.exists?(@@nunit_console_x86))
|
52
|
-
end
|
53
|
-
if(!File.exists?(@@nunit_console_x86))
|
54
|
-
raise "unable to locate nunit-console-x86.exe, assign NUNIT_CONSOLE_X86 to the correct location."
|
55
|
-
end
|
56
|
-
@@nunit_console_x86
|
57
|
-
end
|
58
|
-
end
|
data/lib/text.rb
DELETED
@@ -1,16 +0,0 @@
|
|
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
|
data/lib/timeout.rb
DELETED
@@ -1,81 +0,0 @@
|
|
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
|
-
|
data/lib/timer.rb
DELETED
@@ -1,41 +0,0 @@
|
|
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
|
data/lib/update.rb
DELETED