dev 1.0.247 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +4 -4
- data/lib/dev.rb +8 -60
- metadata +26 -69
- data/README +0 -103
- data/bin/devgem +0 -71
- data/lib/dev/Array.rb +0 -17
- data/lib/dev/BoostBuild.rb +0 -94
- data/lib/dev/Commands.rb +0 -185
- data/lib/dev/Database.rb +0 -134
- data/lib/dev/Dep.rb +0 -117
- data/lib/dev/Deps.rb +0 -44
- data/lib/dev/Environment.rb +0 -142
- data/lib/dev/Hash.rb +0 -92
- data/lib/dev/MsBuild.rb +0 -17
- data/lib/dev/Paths.rb +0 -50
- data/lib/dev/Project.rb +0 -175
- data/lib/dev/Scm.rb +0 -125
- data/lib/dev/Svn.rb +0 -55
- data/lib/dev/SystemCall.rb +0 -288
- data/lib/dev/Tasks.rb +0 -140
- data/lib/dev/cmd/Build.rb +0 -112
- data/lib/dev/cmd/Commit.rb +0 -19
- data/lib/dev/cmd/Compile.rb +0 -35
- data/lib/dev/cmd/DeepPull.rb +0 -56
- data/lib/dev/cmd/Info.rb +0 -16
- data/lib/dev/cmd/Pull.rb +0 -46
- data/lib/dev/cmd/Replace.rb +0 -69
- data/lib/dev/cmd/Setup.rb +0 -28
- data/lib/dev/cmd/Test.rb +0 -34
- data/lib/dev/cmd/Update.rb +0 -10
data/lib/dev/Tasks.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
puts_debug "read " + __FILE__
|
2
|
-
|
3
|
-
require 'rake'
|
4
|
-
require 'tmpdir'
|
5
|
-
|
6
|
-
if("#{RUBY_VERSION}">"1.9.1")
|
7
|
-
include Rake::DSL
|
8
|
-
end
|
9
|
-
|
10
|
-
def task_start(task_name)
|
11
|
-
puts " "
|
12
|
-
if(RUBY_VERSION == "1.8.7")
|
13
|
-
puts "[:#{task_name}]" + " " + Dir.pwd
|
14
|
-
else
|
15
|
-
puts "[:#{task_name}]" + " " + Dir.pwd
|
16
|
-
#puts Rainbow("[:#{task_name}]").foreground(:yellow).bright + " " + Dir.pwd
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
task :clean do; task_start "clean";
|
21
|
-
end
|
22
|
-
task :clobber do; task_start "clobber"; end
|
23
|
-
|
24
|
-
require 'rake/clean'
|
25
|
-
CLEAN.include('doc','*.taskstamp*','**/*.{suo,sdf}')
|
26
|
-
CLOBBER.include('bin','obj',"#{Dir.tmpdir}/*{err,out}",'*.gem')
|
27
|
-
|
28
|
-
def generate_task_hash(project)
|
29
|
-
task_hash = {
|
30
|
-
:info=> { :desc=> 'display information about the rakefile' },
|
31
|
-
#:test=> { :desc=> 'run unit tests' },
|
32
|
-
:loc=> { :desc=> 'count the lines of code' },
|
33
|
-
#:setup=> { :desc=> 'setup the project environment' },
|
34
|
-
:pull=> { :desc=> 'update dependencies in rakefile.rb to latest revision' },
|
35
|
-
:deep_pull=> { :desc=> 'pull and rake dependencies (nested dependencies first)' },
|
36
|
-
:check=> { :desc=> 'checks if the project default task may be skipped' }
|
37
|
-
}
|
38
|
-
if(!CMD[:setup].nil? && CMD[:setup].length > 0)
|
39
|
-
task_hash[:setup]={ :desc=> 'setup the project environment' }
|
40
|
-
end
|
41
|
-
|
42
|
-
if(project[:scm_type]=="svn" || project[:scm_type]=="git")
|
43
|
-
task_hash[:add] ={ :desc=> 'add files defined by src_glob to source code management' }
|
44
|
-
task_hash[:commit]={ :desc=> 'commit changes to source code management' }
|
45
|
-
task_hash[:update]={ :desc=> 'updates changes from source code management' }
|
46
|
-
end
|
47
|
-
|
48
|
-
task_hash[:compile] = { :desc=> 'compile source code' } if CMD.has_key?(:compile) && CMD[:compile].length > 0 #project.has_key?(:compile) && project[:compile].length > 0
|
49
|
-
task_hash[:replace] = { :desc=> 'replace text' } if CMD.has_key?(:replace) && CMD[:replace].length > 0
|
50
|
-
task_hash[:test]={:desc=>'run unit tests'} if CMD.has_key?(:test) && CMD[:test].length > 0
|
51
|
-
|
52
|
-
if project[:type]=="gem" || project[:type]=="ruby"
|
53
|
-
task_hash[:features] = { :desc=> 'tests cucumber features' }
|
54
|
-
end
|
55
|
-
return task_hash
|
56
|
-
end
|
57
|
-
|
58
|
-
def generate_tasks(project)
|
59
|
-
puts_debug "generate_tasks"
|
60
|
-
hash=generate_task_hash project
|
61
|
-
|
62
|
-
hash.each do |k,v|
|
63
|
-
name=k.to_s
|
64
|
-
puts_debug "checking if task #{name} should be autogenerated"
|
65
|
-
desc=nil
|
66
|
-
desc=v[:desc] if v.has_key?(:desc)
|
67
|
-
#ruby="task :#{name} do; task_start '#{name}'; PROJECT.#{name}; end" if PROJECT.respond_to?(name)
|
68
|
-
ruby="task :#{name} do; task_start '#{name}'; CMD.#{name}; end"
|
69
|
-
ruby="desc '#{desc}'; " + ruby unless desc.nil?
|
70
|
-
if !task_exists?(name)
|
71
|
-
if(RUBY_VERSION != "1.8.7")
|
72
|
-
puts_debug "defining task #{name} with '#{ruby}'"
|
73
|
-
eval(ruby)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
# generate default task
|
80
|
-
if(!defined?(DEV_NO_DEFAULT_TASK) && RUBY_VERSION != "1.8.7")
|
81
|
-
Rake.application.instance_variable_get('@tasks').delete('default')
|
82
|
-
task_list=""
|
83
|
-
default_task_order=["check","setup","replace","pre_compile","compile","post_compile","pre_test","test","post_test","add","commit","update","finalize"]
|
84
|
-
if(defined?(DEFAULT_TASK_ORDER))
|
85
|
-
default_task_order = DEFAULT_TASK_ORDER
|
86
|
-
end
|
87
|
-
default_task_order.each {|t|
|
88
|
-
if(hash.has_key?(t.to_sym) || task_exists?(t) || (CMD.has_key?(t.to_sym) && CMD[t.to_sym].length > 0) )
|
89
|
-
task_list = "#{task_list}," if task_list.length > 0
|
90
|
-
task_list = "#{task_list} :#{t}"
|
91
|
-
default_code = "#{default_code} :#{t},"
|
92
|
-
end
|
93
|
-
}
|
94
|
-
desc="desc '#{task_list}'".gsub(' ',"").gsub(':',"")
|
95
|
-
eval("#{desc}; task :default => [#{task_list}] do; task_start('default'); end")
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def task_exists?(name)
|
100
|
-
if("#{RUBY_VERSION}">"1.9.1")
|
101
|
-
return Rake::Task.task_defined?(name)
|
102
|
-
else
|
103
|
-
return false
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
module Dev
|
108
|
-
class Tasks < Hash
|
109
|
-
def refresh
|
110
|
-
puts_debug "Dev::Tasks.refresh"
|
111
|
-
start_time=Time.now
|
112
|
-
DEV.refresh
|
113
|
-
CMD.refresh
|
114
|
-
generate_tasks(DEV)
|
115
|
-
puts_debug "Tasks refresh elapsed time " + (Time.now-start_time).to_s
|
116
|
-
end
|
117
|
-
end # class Tasks
|
118
|
-
end # module Dev
|
119
|
-
|
120
|
-
if(RUBY_VERSION=="1.8.7")
|
121
|
-
task :compile do
|
122
|
-
task_start "compile"
|
123
|
-
CMD.compile
|
124
|
-
end
|
125
|
-
task :test do
|
126
|
-
task_start "test"
|
127
|
-
CMD.test
|
128
|
-
end
|
129
|
-
task :commit do
|
130
|
-
task_start "commit"
|
131
|
-
CMD.commit
|
132
|
-
end
|
133
|
-
task :update do
|
134
|
-
task_start "update"
|
135
|
-
CMD.update
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
TASKS=Dev::Tasks.new
|
140
|
-
TASKS.refresh
|
data/lib/dev/cmd/Build.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
module Cmd
|
3
|
-
class Build
|
4
|
-
|
5
|
-
def self.build(branch)
|
6
|
-
db=Dev::Database.new
|
7
|
-
|
8
|
-
puts " "
|
9
|
-
puts "building branch " + branch.foreground(:green)
|
10
|
-
h=Dev::Cmd::Build.get_branch_hash(branch)
|
11
|
-
Hash.print_hash("",h)
|
12
|
-
|
13
|
-
# does a result already exist?
|
14
|
-
results=db.get_results({:uri=>"#{h[:uri]}", :revision=>"#{h[:revision]}", :user=>"#{h[:user]}", :machine=>"#{h[:machine]}"})
|
15
|
-
|
16
|
-
result=results[0] if !results.empty?
|
17
|
-
if(results.empty?)
|
18
|
-
result=h
|
19
|
-
|
20
|
-
# export to local directory
|
21
|
-
FileUtils.mkdir("#{Dev::Environment.dev_root}/exp") if !File.exists?("#{Dev::Environment.dev_root}/exp")
|
22
|
-
FileUtils.rm_r(h[:dir]) if File.exists? h[:dir]
|
23
|
-
|
24
|
-
puts "svn exporting #{h[:uri]}@#{h[:revision]} to #{h[:dir]}"
|
25
|
-
Dev::Scm::export("#{h[:uri]}@#{h[:revision]}","#{h[:dir]}",'svn')
|
26
|
-
# Dev::Commands.execute_cmd("svn export #{h[:uri]}@#{h[:revision]} #{h[:dir]}")
|
27
|
-
|
28
|
-
# rake in local directory
|
29
|
-
call=Dev::SystemCall.new({:cmd=>'rake default',:dir=>h[:dir],:capture_output=>true,:capture_error=>true})
|
30
|
-
call.puts_summary
|
31
|
-
|
32
|
-
ch=call.get_hash
|
33
|
-
[:cmd,:status,:start_time,:end_time,:elapsed,:timeout,:timed_out,:output,:error].each{ |k| h[k]=ch[k]; }
|
34
|
-
|
35
|
-
# store results to database
|
36
|
-
|
37
|
-
db.add_result(result)
|
38
|
-
db=nil
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
puts "results hash:"
|
43
|
-
puts " "
|
44
|
-
Hash.print_hash("",result)
|
45
|
-
|
46
|
-
Dev::SystemCall.puts_hash_summary(result)
|
47
|
-
|
48
|
-
return 0
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.status(branch)
|
52
|
-
db=Dev::Database.new
|
53
|
-
h=Dev::Cmd::Build.get_branch_hash(branch)
|
54
|
-
puts "status of branch " + branch.foreground(:green) + "@#{h[:revision]}"
|
55
|
-
|
56
|
-
# do any results exist for latest revision?
|
57
|
-
results=db.get_results({:uri=>"#{h[:uri]}", :revision=>"#{h[:revision]}"})
|
58
|
-
#resultss=db.get_results({:branch=>h[:branch]})
|
59
|
-
#results=db.get_results({:uri=>"#{h[:uri]}"})
|
60
|
-
db=nil
|
61
|
-
|
62
|
-
puts " no results" if results.empty?
|
63
|
-
|
64
|
-
fail=" [".foreground(:cyan) + "X".foreground(:red).bright + "]".foreground(:cyan)
|
65
|
-
pass=" [".foreground(:cyan) + "+".foreground(:green) + "]".foreground(:cyan)
|
66
|
-
results.each{ |r|
|
67
|
-
status=pass
|
68
|
-
status=fail if r[:status] != 0 && r[:status] != "0"
|
69
|
-
elapsed="[" + "%.0f" %(r[:elapsed]) + "s]".foreground(:cyan)
|
70
|
-
context="#{r[:user]}@#{r[:machine]}".foreground(:green)
|
71
|
-
puts "#{status} #{context} #{elapsed} #{r[:end_time]}"
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.work(branch)
|
76
|
-
#db=Dev::Database.new
|
77
|
-
|
78
|
-
puts " "
|
79
|
-
puts "working on branch " + branch.foreground(:green)
|
80
|
-
h=Dev::Cmd::Build.get_branch_hash(branch)
|
81
|
-
h[:dir]="#{Dev::Environment.dev_root}/wrk/#{branch}"
|
82
|
-
#Hash.print_hash("",h)
|
83
|
-
|
84
|
-
# export to local directory
|
85
|
-
FileUtils.mkdir("#{Dev::Enviroment.dev_root}/wrk") if !File.exists?("#{Dev::Environment.dev_root}/wrk")
|
86
|
-
Dev::Commands.execute_cmd("svn co #{h[:uri]} #{h[:dir]}") if !File.exists? h[:dir]
|
87
|
-
|
88
|
-
# rake in local directory
|
89
|
-
call=Dev::SystemCall.new({:cmd=>'rake default',:dir=>h[:dir],:capture_output=>true,:capture_error=>true})
|
90
|
-
puts "------------------------------------------------------------".foreground(:green)
|
91
|
-
call.puts_summary
|
92
|
-
puts "------------------------------------------------------------".foreground(:green)
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
def self.get_branch_hash(branch)
|
97
|
-
db=Dev::Database.new
|
98
|
-
h=Hash.new
|
99
|
-
h[:uri]=db.get_branch_uri(branch)
|
100
|
-
db=nil
|
101
|
-
h[:revision]=Dev::Svn.last_changed_revision(h[:uri])
|
102
|
-
h[:dir]="#{Dev::Environment.dev_root}/exp/#{branch}@#{h[:revision]}"
|
103
|
-
h[:user]="#{Dev::Environment.user}"
|
104
|
-
h[:machine]="#{Dev::Environment.machine}"
|
105
|
-
h[:ruby_version]=RUBY_VERSION
|
106
|
-
h[:ruby_platform]=RUBY_PLATFORM
|
107
|
-
return h
|
108
|
-
end
|
109
|
-
|
110
|
-
end # class Setup
|
111
|
-
end # module Cmd
|
112
|
-
end # module Dev
|
data/lib/dev/cmd/Commit.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
module Cmd
|
3
|
-
class Commit < Array
|
4
|
-
def refresh
|
5
|
-
strip_auto_entries
|
6
|
-
File.open('commit.message','w'){|f|f.puts "commit all"} if !File.exists?('commit.message')
|
7
|
-
scm_type = Scm.get_default_scm_type
|
8
|
-
if scm_type == "svn"
|
9
|
-
self << "{:cmd=>'svn commit -F commit.message',:auto=>true,:throw_on_error=>false}"
|
10
|
-
else
|
11
|
-
if scm_type == "git"
|
12
|
-
self << "{:cmd=>'git commit -a -F commit.message',:auto=>true}"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
end # class Compile
|
18
|
-
end # module Cmd
|
19
|
-
end # module Dev
|
data/lib/dev/cmd/Compile.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
module Cmd
|
3
|
-
class Compile < Array
|
4
|
-
def refresh
|
5
|
-
|
6
|
-
puts_debug "Dev::Cmd::Compile.refresh"
|
7
|
-
start_time=Time.now
|
8
|
-
strip_auto_entries
|
9
|
-
windows=RUBY_PLATFORM.include?("w32")
|
10
|
-
|
11
|
-
# jamfiles
|
12
|
-
|
13
|
-
# vcxproj
|
14
|
-
Dir.glob('**/*.vcxproj').each { |vcxproj| self << "{:cmd=> '<paths,msbuild> #{vcxproj} /property:Configuration=Release /property:Platform=Win32', :auto=>true}" } if windows
|
15
|
-
|
16
|
-
# csproj
|
17
|
-
csbuild="<paths,msbuild>"
|
18
|
-
csbuild="xbuild" if !RUBY_PLATFORM.include?("w32")
|
19
|
-
Dir.glob('**/*.csproj').each { |csproj|
|
20
|
-
platforms=Dev::MsBuild.extract_platforms(csproj)
|
21
|
-
platforms.each { |platform|
|
22
|
-
skip=(!RUBY_PLATFORM.include?("w32") && platform=="x64")
|
23
|
-
self << "{:cmd=> '#{csbuild} #{csproj} /property:Configuration=Release /property:Platform=\"#{platform}\" /p:OutputPath=./bin/#{platform}/Release', :auto=>true}" if !skip
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
# gemspec
|
28
|
-
Dir.glob("*.gemspec").each { |gs| self << "{:cmd=> 'gem build #{gs}', :capture_output=> false, :auto=> true}" }
|
29
|
-
|
30
|
-
puts_debug "refresh elapsed time " + (Time.now-start_time).to_s
|
31
|
-
end
|
32
|
-
|
33
|
-
end # class Compile
|
34
|
-
end # module Cmd
|
35
|
-
end # module Dev
|
data/lib/dev/cmd/DeepPull.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
module Cmd
|
3
|
-
class DeepPull
|
4
|
-
def self.execute
|
5
|
-
|
6
|
-
puts "checking dependencies in #{DEV[:directory]}"
|
7
|
-
# loop over each DEP with dir: NAME@REVISION format
|
8
|
-
DEV[:dep].each {|key,value|
|
9
|
-
if(value.has_key?(:dir) && value[:dir].include?('@'))
|
10
|
-
|
11
|
-
# make sure working directory exist
|
12
|
-
dep_wrk_dir="#{DEV[:dev_root]}/wrk/#{value[:dir].gsub(/@[\d]+/,'')}"
|
13
|
-
dep_uri="#{value[:uri].gsub('@REV','')}"
|
14
|
-
|
15
|
-
puts "#{dep_wrk_dir}"
|
16
|
-
|
17
|
-
if(File.exists?(dep_wrk_dir))
|
18
|
-
Dir.chdir(dep_wrk_dir){|dir|
|
19
|
-
call=Dev::SystemCall.new('svn update')
|
20
|
-
call.puts_summary
|
21
|
-
}
|
22
|
-
else
|
23
|
-
call=Dev::SystemCall.new("svn co #{dep_uri} #{dep_wrk_dir}")
|
24
|
-
call.puts_summary
|
25
|
-
end
|
26
|
-
|
27
|
-
if(value.has_key?(:rake))
|
28
|
-
task=value[:rake]
|
29
|
-
Dir.chdir(dep_wrk_dir){ |dir|
|
30
|
-
original_text = File.read("#{dep_wrk_dir}/rakefile.rb")
|
31
|
-
call=Dev::SystemCall.new('rake deep_pull')
|
32
|
-
call.puts_summary
|
33
|
-
call=Dev::SystemCall.new('rake pull')
|
34
|
-
call.puts_summary
|
35
|
-
current_text = File.read("#{dep_wrk_dir}/rakefile.rb")
|
36
|
-
if(original_text != current_text)
|
37
|
-
if(task=='default')
|
38
|
-
call=Dev::SystemCall.new('rake setup')
|
39
|
-
call.puts_summary2(false)
|
40
|
-
end
|
41
|
-
call=Dev::SystemCall.new("rake #{task}")
|
42
|
-
call.puts_summary
|
43
|
-
end
|
44
|
-
}
|
45
|
-
end
|
46
|
-
end
|
47
|
-
}
|
48
|
-
|
49
|
-
# shallow pull in this
|
50
|
-
puts ""
|
51
|
-
Pull.execute
|
52
|
-
|
53
|
-
end
|
54
|
-
end # class DeepPull
|
55
|
-
end # module Cmd
|
56
|
-
end # module Dev
|
data/lib/dev/cmd/Info.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
module Cmd
|
3
|
-
class Info
|
4
|
-
def self.execute
|
5
|
-
puts "DEV"
|
6
|
-
Hash.print_hash("",DEV)
|
7
|
-
puts " "
|
8
|
-
puts "CLEAN " + CLEAN.to_s
|
9
|
-
puts "CLOBBER " + CLOBBER.to_s
|
10
|
-
puts "CMD"
|
11
|
-
Hash.print_hash("",CMD)
|
12
|
-
puts " "
|
13
|
-
end
|
14
|
-
end # class Info
|
15
|
-
end # module Cmd
|
16
|
-
end # module Dev
|
data/lib/dev/cmd/Pull.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
if(RUBY_VERSION != "1.8.7")
|
2
|
-
module Dev
|
3
|
-
module Cmd
|
4
|
-
class Pull
|
5
|
-
def self.execute
|
6
|
-
puts "checking dependencies in #{DEV[:directory]}"
|
7
|
-
|
8
|
-
text = File.read("#{DEV[:directory]}/rakefile.rb")
|
9
|
-
new_text = text
|
10
|
-
|
11
|
-
DEV[:dep].each {|key,value|
|
12
|
-
puts_debug "checking dep key #{key}"
|
13
|
-
if(value.has_key?(:dir) && value[:dir].include?('@'))
|
14
|
-
cmd="svn info #{value[:uri].gsub(/@[\d\w]+/,'')}"
|
15
|
-
puts_debug cmd
|
16
|
-
call=Dev::SystemCall.new(cmd)
|
17
|
-
call.puts_summary
|
18
|
-
info =call.output# %x[cmd]
|
19
|
-
new_revision="0"
|
20
|
-
if(RUBY_VERSION=="1.8.7")
|
21
|
-
info.each_line do |line|
|
22
|
-
if(line.include?("Last Changed Rev:"))
|
23
|
-
new_revision=line.split(':')[1].strip
|
24
|
-
end
|
25
|
-
end
|
26
|
-
else
|
27
|
-
new_revision = info.match(/Last Changed Rev: (?<rev>\d+)/)[:rev]
|
28
|
-
end
|
29
|
-
new_dir = value[:dir].gsub(/@[\d]+/,"@#{new_revision}")
|
30
|
-
puts_debug "new_dir=#{new_dir}"
|
31
|
-
if(new_dir != value[:dir])
|
32
|
-
puts "updating from #{value[:dir]} to #{new_dir}"
|
33
|
-
new_text = new_text.gsub(value[:dir],new_dir)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
}
|
37
|
-
|
38
|
-
if(text != new_text)
|
39
|
-
File.open("#{DEV[:directory]}/rakefile.rb",'w') { |f|f.write(new_text) }
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end # class Info
|
44
|
-
end # module Cmd
|
45
|
-
end # module Dev
|
46
|
-
end
|
data/lib/dev/cmd/Replace.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
module Dev
|
2
|
-
module Cmd
|
3
|
-
class Replace < Hash
|
4
|
-
def refresh(dep_hash)
|
5
|
-
puts_debug "Dev::Cmd::Replace.refresh"
|
6
|
-
refresh_start_time=Time.now
|
7
|
-
# remove all auto generated entries
|
8
|
-
self.each { |k,v|
|
9
|
-
self.delete k if v.kind_of?(Hash) && v.has_key?(:auto) && v[:auto]
|
10
|
-
}
|
11
|
-
|
12
|
-
# auto generate replace entry based on dep values
|
13
|
-
#if File.exists?(".svn") || File.exists?(".git")
|
14
|
-
if(Scm.get_default_scm_type == "svn" || Scm.get_default_scm_type =="git")
|
15
|
-
["vcxproj","csproj"].each { |ext|
|
16
|
-
if(Dir.glob("**/*.#{ext}").length > 0)
|
17
|
-
puts_debug "Dev::Cmd::Replace.refresh found file with extension #{ext}"
|
18
|
-
puts_debug "dep_hash nil" if dep_hash.nil?
|
19
|
-
puts_debug "dep_hash is empty" if dep_hash.empty?
|
20
|
-
dep_hash.each{ |k,v|
|
21
|
-
puts_debug "Dev::Cmd::Replace.refresh found dep of key #{k.to_s}"
|
22
|
-
if !v.nil? && v.kind_of?(Hash) && v.has_key?(:rev) && v.has_key?(:dir) && !has_key?(k)
|
23
|
-
puts_debug "adding key #{k.to_s}"
|
24
|
-
if(v[:dir].include?('@'))
|
25
|
-
words=v[:dir].split('@')
|
26
|
-
parts=words[0].split('/');
|
27
|
-
searchRegex=Regexp.new "#{parts[0]}\\\\#{parts[1]}\\\\#{parts[2]}@[\\d]+"
|
28
|
-
#searchRegex=Regexp.new "#{words[0].gsub('/','\\\\')}@[\\d]+"
|
29
|
-
self[k]={ glob: "**/*.#{ext}", search: searchRegex, replace: "#{words[0].gsub('/','\\')}@#{v[:rev]}", auto: true }
|
30
|
-
else
|
31
|
-
group=v[:dir].split('/')[0]
|
32
|
-
name=v[:dir].split('/')[1]
|
33
|
-
searchRegex=Regexp.new "#{group}\\\\#{name}\\\\[\\d]+"
|
34
|
-
self[k]={ glob: "**/*.#{ext}", search: searchRegex, replace: "#{group}\\#{name}\\#{v[:rev]}", auto: true }
|
35
|
-
end
|
36
|
-
else
|
37
|
-
puts_debug "skipping key #{k.to_s}"
|
38
|
-
end
|
39
|
-
}
|
40
|
-
end
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
refresh_end_time=Time.now
|
45
|
-
puts_debug "replace refresh elapsed time " + (refresh_end_time-refresh_start_time).to_s
|
46
|
-
end
|
47
|
-
|
48
|
-
def execute
|
49
|
-
self.each do |k,v|
|
50
|
-
unless v.nil?
|
51
|
-
file=v[:file]
|
52
|
-
search=v[:search]
|
53
|
-
replace=v[:replace]
|
54
|
-
glob=v[:glob]
|
55
|
-
unless search.nil? || replace.nil?
|
56
|
-
unless file.nil?
|
57
|
-
Dev::Environment.replace_text_in_file(file,search,replace)
|
58
|
-
end
|
59
|
-
unless glob.nil?
|
60
|
-
Dev::Environment.replace_text_in_glob(glob,search,replace)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
end # class Replace
|
68
|
-
end # module Cmd
|
69
|
-
end # module Dev
|