dev 2.0.41 → 2.0.42

Sign up to get free protection for your applications and to get access to all the features.
data/lib/msbuild.rb ADDED
@@ -0,0 +1,70 @@
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
+
56
+ def self.get_build_commands sln_filename
57
+ build_commands=nil
58
+ vs_version=MSBuild.get_vs_version(sln_filename)
59
+ if(MSBuild.has_version?(vs_version))
60
+ MSBuild.get_configurations(sln_filename).each{ |configuration|
61
+ MSBuild.get_platforms(sln_filename).each{|platform|
62
+ build_commands=Array.new if build_commands.nil?
63
+ build_commands << "\"#{MSBuild.get_version(vs_version)}\" \"#{sln_filename}\" /nologo /p:Configuration=#{configuration} /p:Platform=\"#{platform}\""
64
+ }
65
+ }
66
+ end
67
+ build_commands
68
+ end
69
+ end
70
+
data/lib/project.rb ADDED
@@ -0,0 +1,66 @@
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
+ #puts "rake (#{self.wrk_dir})"
59
+ #puts `rake`
60
+ rake.execute
61
+ puts rake.summary
62
+ end
63
+ end
64
+ end
65
+ end
66
+
data/lib/projects.rb ADDED
@@ -0,0 +1,67 @@
1
+ require 'json'
2
+ require 'rake'
3
+ #require 'dev_git'
4
+ #require 'dev_svn'
5
+ #require 'dev_msbuild'
6
+ #require 'dev_environment'
7
+ require_relative 'project.rb'
8
+
9
+ class Projects < Hash
10
+ attr_accessor :filename
11
+
12
+ def initialize
13
+ @filename=''
14
+ end
15
+
16
+ def update
17
+ self.each{|k,v|
18
+ self[k]=Project.new(v) if(v.is_a?(String))
19
+ self[k]=Project.new(v) if(!v.is_a?(Project) && v.is_a?(Hash))
20
+ self[k][:name]=k
21
+ #self[k].update if self[k].respond_to?("update".to_sym)
22
+ }
23
+ end
24
+
25
+ def save filename=''
26
+ @filename=filename if !filename.nil? && filename.length > 0
27
+ File.open(@filename,'w'){|f|f.write(JSON.pretty_generate(self))} if @filename.length > 0
28
+ end
29
+
30
+ def open filename=''
31
+ @filename=filename if filename.length > 0
32
+ JSON.parse(IO.read(@filename)).each{|k,v| self[k]=v}
33
+ update
34
+ end
35
+
36
+ def self.user_projects_filename
37
+ FileUtils.mkdir("#{Environment.dev_root}/data") if(!File.exists?("#{Environment.dev_root}/data"))
38
+ "#{Environment.dev_root}/data/PROJECTS.json"
39
+ end
40
+
41
+ def self.current
42
+ project=nil
43
+ url=Git.remote_origin
44
+ url=Svn.url if url.length==0
45
+ if(Rake.application.original_dir.include?('/wrk/') &&
46
+ url.length > 0)
47
+ project=Project.new(url)
48
+ name=Rake.application.original_dir.gsub("#{Environment.dev_root}/wrk/",'')
49
+ project[:name] = name if(name.length>0 && !name.include?(Environment.dev_root))
50
+ if(defined?(PROJECTS))
51
+ PROJECTS[name]=project if(!PROJECTS.has_key?(name))
52
+ project.each{|k,v|PROJECTS[name][k]=v}
53
+ PROJECTS.save
54
+ else
55
+ project[:name]=name
56
+ end
57
+ end
58
+ project
59
+ end
60
+
61
+ def pull
62
+ self.each{|k,v| v.pull if v.respond_to?("pull".to_sym)}
63
+ end
64
+ def rake
65
+ self.each{|k,v| v.rake if v.respond_to?("rake".to_sym)}
66
+ end
67
+ end
data/lib/publish.rb ADDED
@@ -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
data/lib/pull.rb ADDED
@@ -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
data/lib/push.rb ADDED
@@ -0,0 +1,9 @@
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 ADDED
@@ -0,0 +1,25 @@
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 ADDED
@@ -0,0 +1,99 @@
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 ADDED
@@ -0,0 +1,82 @@
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 ADDED
@@ -0,0 +1,58 @@
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 ADDED
@@ -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
data/lib/timeout.rb ADDED
@@ -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
+
data/lib/timer.rb ADDED
@@ -0,0 +1,41 @@
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 ADDED
@@ -0,0 +1,6 @@
1
+ require_relative('internet.rb')
2
+ class Update < Array
3
+ def update
4
+ self .add 'svn update' if File.exists?('.svn') && Internet.available?
5
+ end
6
+ end
data/lib/upgrade.rb ADDED
@@ -0,0 +1,6 @@
1
+ class Upgrade < Array
2
+ def update
3
+ if(File.exists?('Gemfile'))
4
+ end
5
+ end
6
+ end