dev 2.1.75 → 2.1.76
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +202 -202
- data/lib/apps/svn.rb +151 -151
- data/lib/apps/xcodebuild.rb +15 -15
- data/lib/base.rb +4 -4
- data/lib/base/dir.rb +98 -98
- data/lib/base/file.rb +34 -34
- data/lib/base/gemspec.rb +50 -50
- data/lib/base/hash.rb +20 -20
- data/lib/base/history.rb +38 -38
- data/lib/base/internet.rb +24 -24
- data/lib/base/project.rb +458 -458
- data/lib/base/string.rb +6 -6
- data/lib/base/text.rb +29 -29
- data/lib/base/timeout.rb +121 -121
- data/lib/base/timer.rb +44 -44
- data/lib/base/version.rb +82 -82
- data/lib/dev.config.rb +7 -7
- data/lib/tasks/clean.rb +9 -9
- data/lib/tasks/clobber.rb +25 -25
- data/lib/tasks/doc.rb +9 -9
- data/lib/tasks/info.rb +9 -9
- data/lib/tasks/publish.rb +33 -33
- data/lib/tasks/pull.rb +11 -11
- data/lib/tasks/update.rb +14 -14
- metadata +17 -3
data/lib/base/string.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
puts __FILE__ if defined?(DEBUG)
|
2
|
-
|
3
|
-
class String
|
4
|
-
def fix(size,padstr=' ')
|
5
|
-
self[0...size].rjust(size,padstr)
|
6
|
-
end
|
1
|
+
puts __FILE__ if defined?(DEBUG)
|
2
|
+
|
3
|
+
class String
|
4
|
+
def fix(size,padstr=' ')
|
5
|
+
self[0...size].rjust(size,padstr)
|
6
|
+
end
|
7
7
|
end
|
data/lib/base/text.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
puts __FILE__ if defined?(DEBUG)
|
2
|
-
|
3
|
-
class Text
|
4
|
-
def self.replace_in_glob(glob,search,replace)
|
5
|
-
Dir.glob(glob).each{ |f| replace_in_file(f,search,replace) }
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.replace_in_file(filename,search,replace)
|
9
|
-
text1 = IO.read(filename)
|
10
|
-
text2 = text1.gsub(search) { |str| str=replace }
|
11
|
-
unless text1==text2
|
12
|
-
File.open(filename,"w") { |f| f.puts text2 }
|
13
|
-
return true
|
14
|
-
end
|
15
|
-
false
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.copy_if_different(source,destination)
|
19
|
-
if(!File.exists?(destination))
|
20
|
-
FileUtils.cp source, destination
|
21
|
-
else
|
22
|
-
source_text=IO.read(source)
|
23
|
-
destination_text=IO.read(destination)
|
24
|
-
if(source_text != destination_text)
|
25
|
-
FileUtils.rm destination
|
26
|
-
FileUtils.cp source, destination
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
1
|
+
puts __FILE__ if defined?(DEBUG)
|
2
|
+
|
3
|
+
class Text
|
4
|
+
def self.replace_in_glob(glob,search,replace)
|
5
|
+
Dir.glob(glob).each{ |f| replace_in_file(f,search,replace) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.replace_in_file(filename,search,replace)
|
9
|
+
text1 = IO.read(filename)
|
10
|
+
text2 = text1.gsub(search) { |str| str=replace }
|
11
|
+
unless text1==text2
|
12
|
+
File.open(filename,"w") { |f| f.puts text2 }
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.copy_if_different(source,destination)
|
19
|
+
if(!File.exists?(destination))
|
20
|
+
FileUtils.cp source, destination
|
21
|
+
else
|
22
|
+
source_text=IO.read(source)
|
23
|
+
destination_text=IO.read(destination)
|
24
|
+
if(source_text != destination_text)
|
25
|
+
FileUtils.rm destination
|
26
|
+
FileUtils.cp source, destination
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
30
|
end
|
data/lib/base/timeout.rb
CHANGED
@@ -1,121 +1,121 @@
|
|
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
|
-
|
18
|
-
Open3.popen2e(command, :chdir=>directory) { |stdin,stderrout,thread|
|
19
|
-
pid = thread.pid
|
20
|
-
|
21
|
-
start = Time.now
|
22
|
-
while (Time.now - start) < timeout and thread.alive?
|
23
|
-
# Wait up to `tick` seconds for output/error data
|
24
|
-
Kernel.select([stderrout], nil, nil, tick)
|
25
|
-
# Try to read the data
|
26
|
-
begin
|
27
|
-
output << stderrout.read_nonblock(BUFFER_SIZE)
|
28
|
-
rescue IO::WaitReadable
|
29
|
-
# A read would block, so loop around for another select
|
30
|
-
rescue EOFError
|
31
|
-
# Command has completed, not really an error...
|
32
|
-
exit_code=wait_thread.value
|
33
|
-
break
|
34
|
-
end
|
35
|
-
|
36
|
-
sleep(0.5)
|
37
|
-
end
|
38
|
-
|
39
|
-
exit_code=wait_thread.value
|
40
|
-
|
41
|
-
# Give Ruby time to clean up the other thread
|
42
|
-
sleep 1
|
43
|
-
|
44
|
-
if thread.alive?
|
45
|
-
# We need to kill the process, because killing the thread leaves
|
46
|
-
# the process alive but detached, annoyingly enough.
|
47
|
-
Process.kill("TERM", pid)
|
48
|
-
exit_code=5
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
|
54
|
-
return [output,exit_code]
|
55
|
-
end
|
56
|
-
# begin
|
57
|
-
# # Start task in another thread, which spawns a process
|
58
|
-
# stdin, stderrout, thread = Open3.popen2e(command, :chdir=>directory)
|
59
|
-
# # Get the pid of the spawned process
|
60
|
-
# pid = thread[:pid]
|
61
|
-
# start = Time.now
|
62
|
-
#
|
63
|
-
# while (Time.now - start) < timeout and thread.alive?
|
64
|
-
# # Wait up to `tick` seconds for output/error data
|
65
|
-
# Kernel.select([stderrout], nil, nil, tick)
|
66
|
-
# # Try to read the data
|
67
|
-
# begin
|
68
|
-
# output << stderrout.read_nonblock(BUFFER_SIZE)
|
69
|
-
# rescue IO::WaitReadable
|
70
|
-
# # A read would block, so loop around for another select
|
71
|
-
# rescue EOFError
|
72
|
-
# # Command has completed, not really an error...
|
73
|
-
# exit_code=$?.exitstatus
|
74
|
-
# break
|
75
|
-
# end
|
76
|
-
# end
|
77
|
-
#
|
78
|
-
# # Give Ruby time to clean up the other thread
|
79
|
-
# sleep 1
|
80
|
-
|
81
|
-
# if thread.alive?
|
82
|
-
# We need to kill the process, because killing the thread leaves
|
83
|
-
# the process alive but detached, annoyingly enough.
|
84
|
-
# Process.kill("TERM", pid)
|
85
|
-
# exit_code=5
|
86
|
-
# else
|
87
|
-
# sleep 1
|
88
|
-
# end
|
89
|
-
|
90
|
-
# ensure
|
91
|
-
# stdin.close if stdin
|
92
|
-
# stderrout.close if stderrout
|
93
|
-
# end
|
94
|
-
# return [output,exit_code]
|
95
|
-
#end
|
96
|
-
|
97
|
-
require 'timeout'
|
98
|
-
def run_with_timeout2(directory,command,timeout)
|
99
|
-
# stdout, stderr pipes
|
100
|
-
rout, wout = IO.pipe
|
101
|
-
rerr, werr = IO.pipe
|
102
|
-
output=''
|
103
|
-
error=''
|
104
|
-
exit_code=1
|
105
|
-
pid = Process.spawn(command, :chdir => directory, :out => wout, :err => werr)
|
106
|
-
begin
|
107
|
-
Timeout.timeout(timeout) do
|
108
|
-
exit_code = Process.wait2(pid)
|
109
|
-
output = rout.readlines.join("\n")
|
110
|
-
error = rerr.readlines.join("\n")
|
111
|
-
end
|
112
|
-
rescue
|
113
|
-
Proces.kill('TERM',pid)
|
114
|
-
output = output + 'timeout occurred.'
|
115
|
-
ensure
|
116
|
-
rout.close
|
117
|
-
rerr.close
|
118
|
-
end
|
119
|
-
[output,exit_code]
|
120
|
-
end
|
121
|
-
|
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
|
+
|
18
|
+
Open3.popen2e(command, :chdir=>directory) { |stdin,stderrout,thread|
|
19
|
+
pid = thread.pid
|
20
|
+
|
21
|
+
start = Time.now
|
22
|
+
while (Time.now - start) < timeout and thread.alive?
|
23
|
+
# Wait up to `tick` seconds for output/error data
|
24
|
+
Kernel.select([stderrout], nil, nil, tick)
|
25
|
+
# Try to read the data
|
26
|
+
begin
|
27
|
+
output << stderrout.read_nonblock(BUFFER_SIZE)
|
28
|
+
rescue IO::WaitReadable
|
29
|
+
# A read would block, so loop around for another select
|
30
|
+
rescue EOFError
|
31
|
+
# Command has completed, not really an error...
|
32
|
+
exit_code=wait_thread.value
|
33
|
+
break
|
34
|
+
end
|
35
|
+
|
36
|
+
sleep(0.5)
|
37
|
+
end
|
38
|
+
|
39
|
+
exit_code=wait_thread.value
|
40
|
+
|
41
|
+
# Give Ruby time to clean up the other thread
|
42
|
+
sleep 1
|
43
|
+
|
44
|
+
if thread.alive?
|
45
|
+
# We need to kill the process, because killing the thread leaves
|
46
|
+
# the process alive but detached, annoyingly enough.
|
47
|
+
Process.kill("TERM", pid)
|
48
|
+
exit_code=5
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
}
|
53
|
+
|
54
|
+
return [output,exit_code]
|
55
|
+
end
|
56
|
+
# begin
|
57
|
+
# # Start task in another thread, which spawns a process
|
58
|
+
# stdin, stderrout, thread = Open3.popen2e(command, :chdir=>directory)
|
59
|
+
# # Get the pid of the spawned process
|
60
|
+
# pid = thread[:pid]
|
61
|
+
# start = Time.now
|
62
|
+
#
|
63
|
+
# while (Time.now - start) < timeout and thread.alive?
|
64
|
+
# # Wait up to `tick` seconds for output/error data
|
65
|
+
# Kernel.select([stderrout], nil, nil, tick)
|
66
|
+
# # Try to read the data
|
67
|
+
# begin
|
68
|
+
# output << stderrout.read_nonblock(BUFFER_SIZE)
|
69
|
+
# rescue IO::WaitReadable
|
70
|
+
# # A read would block, so loop around for another select
|
71
|
+
# rescue EOFError
|
72
|
+
# # Command has completed, not really an error...
|
73
|
+
# exit_code=$?.exitstatus
|
74
|
+
# break
|
75
|
+
# end
|
76
|
+
# end
|
77
|
+
#
|
78
|
+
# # Give Ruby time to clean up the other thread
|
79
|
+
# sleep 1
|
80
|
+
|
81
|
+
# if thread.alive?
|
82
|
+
# We need to kill the process, because killing the thread leaves
|
83
|
+
# the process alive but detached, annoyingly enough.
|
84
|
+
# Process.kill("TERM", pid)
|
85
|
+
# exit_code=5
|
86
|
+
# else
|
87
|
+
# sleep 1
|
88
|
+
# end
|
89
|
+
|
90
|
+
# ensure
|
91
|
+
# stdin.close if stdin
|
92
|
+
# stderrout.close if stderrout
|
93
|
+
# end
|
94
|
+
# return [output,exit_code]
|
95
|
+
#end
|
96
|
+
|
97
|
+
require 'timeout'
|
98
|
+
def run_with_timeout2(directory,command,timeout)
|
99
|
+
# stdout, stderr pipes
|
100
|
+
rout, wout = IO.pipe
|
101
|
+
rerr, werr = IO.pipe
|
102
|
+
output=''
|
103
|
+
error=''
|
104
|
+
exit_code=1
|
105
|
+
pid = Process.spawn(command, :chdir => directory, :out => wout, :err => werr)
|
106
|
+
begin
|
107
|
+
Timeout.timeout(timeout) do
|
108
|
+
exit_code = Process.wait2(pid)
|
109
|
+
output = rout.readlines.join("\n")
|
110
|
+
error = rerr.readlines.join("\n")
|
111
|
+
end
|
112
|
+
rescue
|
113
|
+
Proces.kill('TERM',pid)
|
114
|
+
output = output + 'timeout occurred.'
|
115
|
+
ensure
|
116
|
+
rout.close
|
117
|
+
rerr.close
|
118
|
+
end
|
119
|
+
[output,exit_code]
|
120
|
+
end
|
121
|
+
|
data/lib/base/timer.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
puts __FILE__ if defined?(DEBUG)
|
2
|
-
|
3
|
-
class Timer
|
4
|
-
attr_accessor :start_time
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@start_time=Time.now
|
8
|
-
end
|
9
|
-
|
10
|
-
def elapsed # in seconds
|
11
|
-
return Time.now-@start_time
|
12
|
-
end
|
13
|
-
|
14
|
-
def elapsed_str
|
15
|
-
elapsed_str="[" + "%.0f" %(elapsed) + "s]"
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.elapsed_exceeds?(name,duration_seconds)
|
19
|
-
if(Timer.get_elapsed(name).nil? || Timer.get_elapsed(name) > duration_seconds)
|
20
|
-
return true
|
21
|
-
end
|
22
|
-
return false
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.get_elapsed(name)
|
26
|
-
timestamp=get_timestamp(name)
|
27
|
-
return Time.now-timestamp if(!timestamp.nil?)
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.get_timestamp(name)
|
32
|
-
dir=Rake.application.original_dir
|
33
|
-
if(File.exists?("#{DEV[:dev_root]}/log/#{name}.timestamp"))
|
34
|
-
return Time.parse(File.read("#{DEV[:dev_root]}/log/#{name}.timestamp").strip)
|
35
|
-
end
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.set_timestamp(name)
|
40
|
-
Dir.mkdir("#{DEV_TASKS[:dev_root]}/log") if(!Dir.exists?("#{DEV_TASKS[:dev_root]}/log"))
|
41
|
-
File.open("#{DEV_TASKS[:dev_root]}/log/#{name}.timestamp",'w'){|f|f.puts(Time.now.to_s)}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
1
|
+
puts __FILE__ if defined?(DEBUG)
|
2
|
+
|
3
|
+
class Timer
|
4
|
+
attr_accessor :start_time
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@start_time=Time.now
|
8
|
+
end
|
9
|
+
|
10
|
+
def elapsed # in seconds
|
11
|
+
return Time.now-@start_time
|
12
|
+
end
|
13
|
+
|
14
|
+
def elapsed_str
|
15
|
+
elapsed_str="[" + "%.0f" %(elapsed) + "s]"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.elapsed_exceeds?(name,duration_seconds)
|
19
|
+
if(Timer.get_elapsed(name).nil? || Timer.get_elapsed(name) > duration_seconds)
|
20
|
+
return true
|
21
|
+
end
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get_elapsed(name)
|
26
|
+
timestamp=get_timestamp(name)
|
27
|
+
return Time.now-timestamp if(!timestamp.nil?)
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.get_timestamp(name)
|
32
|
+
dir=Rake.application.original_dir
|
33
|
+
if(File.exists?("#{DEV[:dev_root]}/log/#{name}.timestamp"))
|
34
|
+
return Time.parse(File.read("#{DEV[:dev_root]}/log/#{name}.timestamp").strip)
|
35
|
+
end
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.set_timestamp(name)
|
40
|
+
Dir.mkdir("#{DEV_TASKS[:dev_root]}/log") if(!Dir.exists?("#{DEV_TASKS[:dev_root]}/log"))
|
41
|
+
File.open("#{DEV_TASKS[:dev_root]}/log/#{name}.timestamp",'w'){|f|f.puts(Time.now.to_s)}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
45
|
TIMER=Timer.new
|
data/lib/base/version.rb
CHANGED
@@ -1,83 +1,83 @@
|
|
1
|
-
class Version
|
2
|
-
def self.extract text
|
3
|
-
[/VERSION\s*=\s*['"]([\d.]+)['"]/,
|
4
|
-
/[Vv]ersion\s*=\s*['"]([\d.]+)['"]/,
|
5
|
-
/Version\(\s*"([\d.]+)"\s*\)/].each{|regex|
|
6
|
-
scan=text.scan(regex)
|
7
|
-
if(!scan.nil?)
|
8
|
-
return scan[0][0] if(scan.length > 0 && !scan[0].nil? && scan[0].length > 0)
|
9
|
-
end
|
10
|
-
}
|
11
|
-
nil
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.extract_from_file filename
|
15
|
-
Version.extract IO.read(filename)
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.extract_from_filelist filelist
|
19
|
-
version=nil
|
20
|
-
filelist.each{|f|
|
21
|
-
version=extract_from_file f
|
22
|
-
return version if !version.nil?
|
23
|
-
}
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.update_text text, version
|
28
|
-
text=text.gsub(/version\s*=\s*'[\d.]+'/,"version='#{version}'")
|
29
|
-
text=text.gsub(/VERSION\s*=\s*'[\d.]+'/,"VERSION='#{version}'")
|
30
|
-
text=text.gsub(/version\s*=\s*"[\d.]+"/,"version=\"#{version}\"")
|
31
|
-
text=text.gsub(/Version\s*=\s*'[\d.]+'/,"Version='#{version}'")
|
32
|
-
text=text.gsub(/Version\s*=\s*"[\d.]+"/,"Version=\"#{version}\"")
|
33
|
-
text=text.gsub(/Version\(\s*"[\d.]+"\s*\)/,"Version(\"#{version}\")")
|
34
|
-
text=text.gsub(/Name\s*=\s*"Version"\s*Value\s*=\s*"[\d.]+"/,"Name=\"Version\" Value=\"#{version}\"")
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.update_file filename, version
|
38
|
-
if(File.exists?(filename))
|
39
|
-
orig=IO.read(filename)
|
40
|
-
text=Version.update_text orig,version
|
41
|
-
File.open(filename,'w'){|f|f.write(text)} if(orig!=text)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.update_filelist filelist,version
|
46
|
-
filelist.each{|f|
|
47
|
-
Version.update_file f,version
|
48
|
-
}
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.read filename
|
52
|
-
return "#{Gem::Specification.load(filename).version.to_s}" if filename.include?('.gemspec')
|
53
|
-
if filename.include?('AssemblyInfo.cs')
|
54
|
-
scan=IO.read(filename).scan(/Version\(\"([\d.]+)\"\)/)
|
55
|
-
if(!scan.nil?)
|
56
|
-
return scan[0][0] if(scan.length > 0 && !scan[0].nil? && scan[0].length > 0)
|
57
|
-
end
|
58
|
-
#return IO.read(filename).scan(/Version\(\"([\d.]+)\"\)/)[0][0]
|
59
|
-
scan=IO.read(filename).scan(/Version=\"([\d.]+)\"/)
|
60
|
-
if(!scan.nil?)
|
61
|
-
return scan[0][0] if(scan.length > 0 && !scan[0].nil? && scan[0].length > 0)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
'0.0'
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.get_version
|
68
|
-
Dir.glob('**/*.gemspec').each{|gemspec|
|
69
|
-
return Version.read gemspec
|
70
|
-
}
|
71
|
-
Dir.glob('**/AssemblyInfo.cs').each{|assemblyInfo|
|
72
|
-
return Version.read assemblyInfo
|
73
|
-
}
|
74
|
-
Dir.glob('**/*.wxs').each{|wxs|
|
75
|
-
return Version.read wxs
|
76
|
-
}
|
77
|
-
'0.0'
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
if(!defined?(VERSION))
|
82
|
-
VERSION=Version.get_version
|
1
|
+
class Version
|
2
|
+
def self.extract text
|
3
|
+
[/VERSION\s*=\s*['"]([\d.]+)['"]/,
|
4
|
+
/[Vv]ersion\s*=\s*['"]([\d.]+)['"]/,
|
5
|
+
/Version\(\s*"([\d.]+)"\s*\)/].each{|regex|
|
6
|
+
scan=text.scan(regex)
|
7
|
+
if(!scan.nil?)
|
8
|
+
return scan[0][0] if(scan.length > 0 && !scan[0].nil? && scan[0].length > 0)
|
9
|
+
end
|
10
|
+
}
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.extract_from_file filename
|
15
|
+
Version.extract IO.read(filename)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.extract_from_filelist filelist
|
19
|
+
version=nil
|
20
|
+
filelist.each{|f|
|
21
|
+
version=extract_from_file f
|
22
|
+
return version if !version.nil?
|
23
|
+
}
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.update_text text, version
|
28
|
+
text=text.gsub(/version\s*=\s*'[\d.]+'/,"version='#{version}'")
|
29
|
+
text=text.gsub(/VERSION\s*=\s*'[\d.]+'/,"VERSION='#{version}'")
|
30
|
+
text=text.gsub(/version\s*=\s*"[\d.]+"/,"version=\"#{version}\"")
|
31
|
+
text=text.gsub(/Version\s*=\s*'[\d.]+'/,"Version='#{version}'")
|
32
|
+
text=text.gsub(/Version\s*=\s*"[\d.]+"/,"Version=\"#{version}\"")
|
33
|
+
text=text.gsub(/Version\(\s*"[\d.]+"\s*\)/,"Version(\"#{version}\")")
|
34
|
+
text=text.gsub(/Name\s*=\s*"Version"\s*Value\s*=\s*"[\d.]+"/,"Name=\"Version\" Value=\"#{version}\"")
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.update_file filename, version
|
38
|
+
if(File.exists?(filename))
|
39
|
+
orig=IO.read(filename)
|
40
|
+
text=Version.update_text orig,version
|
41
|
+
File.open(filename,'w'){|f|f.write(text)} if(orig!=text)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.update_filelist filelist,version
|
46
|
+
filelist.each{|f|
|
47
|
+
Version.update_file f,version
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.read filename
|
52
|
+
return "#{Gem::Specification.load(filename).version.to_s}" if filename.include?('.gemspec')
|
53
|
+
if filename.include?('AssemblyInfo.cs')
|
54
|
+
scan=IO.read(filename).scan(/Version\(\"([\d.]+)\"\)/)
|
55
|
+
if(!scan.nil?)
|
56
|
+
return scan[0][0] if(scan.length > 0 && !scan[0].nil? && scan[0].length > 0)
|
57
|
+
end
|
58
|
+
#return IO.read(filename).scan(/Version\(\"([\d.]+)\"\)/)[0][0]
|
59
|
+
scan=IO.read(filename).scan(/Version=\"([\d.]+)\"/)
|
60
|
+
if(!scan.nil?)
|
61
|
+
return scan[0][0] if(scan.length > 0 && !scan[0].nil? && scan[0].length > 0)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
'0.0'
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.get_version
|
68
|
+
Dir.glob('**/*.gemspec').each{|gemspec|
|
69
|
+
return Version.read gemspec
|
70
|
+
}
|
71
|
+
Dir.glob('**/AssemblyInfo.cs').each{|assemblyInfo|
|
72
|
+
return Version.read assemblyInfo
|
73
|
+
}
|
74
|
+
Dir.glob('**/*.wxs').each{|wxs|
|
75
|
+
return Version.read wxs
|
76
|
+
}
|
77
|
+
'0.0'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
if(!defined?(VERSION))
|
82
|
+
VERSION=Version.get_version
|
83
83
|
end
|