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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58cc124b47263409cda163a8b9b4291118dcc773
|
4
|
+
data.tar.gz: caf6fd96371112b0d3274fa46b06f1d2f033d880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc691db4f918c25fbde92e53ab23b6b75ff60c5bb4ef95e703f02067ec7ca0fb78e878e96d1e96463b3cd190c05633af5f6046e10c5a1ecf483710c6c43ad464
|
7
|
+
data.tar.gz: c47e969696e69d8324469608ad13b110d16defaabeb909b2e151f4a9d4cc53342f7fa0a90fc8b360442cf9eecb74b7b08ee9431ec92e48b220b296157363e336
|
data/lib/command.rb
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'open3'
|
2
|
+
#require_relative('./array.rb')
|
3
|
+
#require_relative('./hash.rb')
|
4
|
+
#require_relative('./timer.rb')
|
5
|
+
|
6
|
+
BUFFER_SIZE=1024 if(!defined?(BUFFER_SIZE))
|
7
|
+
|
8
|
+
# = Command
|
9
|
+
#
|
10
|
+
# execution of system commands
|
11
|
+
#
|
12
|
+
# = Keys
|
13
|
+
#
|
14
|
+
# - :input The input of the commands.
|
15
|
+
# - :timeout The timeout in seconds.
|
16
|
+
# a value of zero is to infinite timeout.
|
17
|
+
# defaults to zero
|
18
|
+
# - :directory The working directory for the command.
|
19
|
+
# defaults to the current directory
|
20
|
+
# - :exit_code The exit code of the command
|
21
|
+
# - :output The output contains the stdout output of the command
|
22
|
+
# - :error The error contains stderr output of the command
|
23
|
+
# - :machine The name of the machine the command executed on
|
24
|
+
# - :user The user name
|
25
|
+
# - :start_time
|
26
|
+
# - :end_time
|
27
|
+
#
|
28
|
+
class Command < Hash
|
29
|
+
def initialize command
|
30
|
+
|
31
|
+
self[:input] = ''
|
32
|
+
self[:timeout] = 0
|
33
|
+
self[:directory] = ''
|
34
|
+
self[:exit_code] = 0
|
35
|
+
self[:output] = ''
|
36
|
+
self[:error] = ''
|
37
|
+
self[:machine] = ''
|
38
|
+
self[:user] = ''
|
39
|
+
self[:start_time] = nil
|
40
|
+
self[:end_time] = nil
|
41
|
+
|
42
|
+
if(command.kind_of?(String))
|
43
|
+
self[:input] = command
|
44
|
+
end
|
45
|
+
|
46
|
+
if(command.kind_of?(Hash))
|
47
|
+
command.each{|k,v|
|
48
|
+
self[k.to_sym]=v
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def quiet?
|
54
|
+
(self.has_key?(:quiet) && self[:quiet])
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute value=nil
|
58
|
+
|
59
|
+
if(!value.nil? && value.is_a?(Hash))
|
60
|
+
value.each{|k,v|self[k]=v}
|
61
|
+
end
|
62
|
+
|
63
|
+
pwd=Dir.pwd
|
64
|
+
self[:directory] = pwd if(!self.has_key?(:directory) || self[:directory].length==0)
|
65
|
+
|
66
|
+
if(self[:timeout] > 0)
|
67
|
+
puts "#{self[:input]} (#{self[:directory]}) timeout #{self[:timeout].to_s}" if(!quiet?)
|
68
|
+
else
|
69
|
+
puts "#{self[:input]} (#{self[:directory]})" if(!quiet?)
|
70
|
+
end
|
71
|
+
|
72
|
+
self[:machine] = Command.machine
|
73
|
+
self[:user] = Command.user
|
74
|
+
|
75
|
+
self[:start_time]=Time.now
|
76
|
+
timer=Timer.new
|
77
|
+
|
78
|
+
Dir.chdir(self[:directory]) do
|
79
|
+
if self[:input].include?('<%') && self[:input].include?('%>')
|
80
|
+
ruby = self[:input].gsub("<%","").gsub("%>","")
|
81
|
+
|
82
|
+
begin
|
83
|
+
self[:output]=eval(ruby)
|
84
|
+
rescue
|
85
|
+
self[:exit_code]=1
|
86
|
+
self[:error]="unable to eval(#{ruby})"
|
87
|
+
end
|
88
|
+
|
89
|
+
self[:elapsed] = timer.elapsed_str
|
90
|
+
self[:end_time] = Time.now
|
91
|
+
else
|
92
|
+
begin
|
93
|
+
if(self[:timeout] <= 0)
|
94
|
+
self[:output],self[:error],status= Open3.capture3(self[:input])
|
95
|
+
self[:exit_code]=status.to_i
|
96
|
+
self[:elapsed] = timer.elapsed_str
|
97
|
+
self[:end_time] = Time.now
|
98
|
+
else
|
99
|
+
require_relative 'timeout.rb'
|
100
|
+
#puts run_with_timeout(self[:input], self[:timeout], 1).to_s
|
101
|
+
#self[:output] = run_with_timeout(self[:input], self[:timeout], 1)
|
102
|
+
result=run_with_timeout2(self[:directory],self[:input], self[:timeout], 2)
|
103
|
+
self[:output]=result[0]
|
104
|
+
self[:error]=result[1]
|
105
|
+
self[:exit_code]=result[2]
|
106
|
+
|
107
|
+
self[:elapsed] = timer.elapsed_str
|
108
|
+
self[:end_time] = Time.now
|
109
|
+
|
110
|
+
if(timer.elapsed >= self[:timeout])
|
111
|
+
self[:exit_code]=1
|
112
|
+
self[:error] = self[:error] + "timed out"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
rescue Exception => e
|
116
|
+
self[:elapsed] = timer.elapsed_str
|
117
|
+
self[:end_time] = Time.now
|
118
|
+
self[:error] = "Exception: " + e.to_s
|
119
|
+
self[:exit_code]=1
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
if(self[:exit_code] != 0)
|
126
|
+
if(!quiet?)
|
127
|
+
puts "exit_code=#{self[:exit_code]}"
|
128
|
+
puts self[:output]
|
129
|
+
puts self[:error]
|
130
|
+
end
|
131
|
+
if(!self.has_key?(:ignore_failure) || !self[:ignore_failure])
|
132
|
+
raise "#{self[:input]} failed"
|
133
|
+
end #unless (self.has_key?(:ignore_failure) && self[:ignore_failure]==true)
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.machine
|
139
|
+
if !ENV['COMPUTERNAME'].nil?
|
140
|
+
return ENV['COMPUTERNAME']
|
141
|
+
end
|
142
|
+
|
143
|
+
machine = `hostname`
|
144
|
+
machine = machine.split('.')[0] if machine.include?('.')
|
145
|
+
return machine.strip
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.user
|
149
|
+
ENV['USER'].nil? ? ENV['USERNAME'] : ENV['USER']
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.home
|
153
|
+
["USERPROFILE","HOME"].each {|v|
|
154
|
+
return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
155
|
+
}
|
156
|
+
dir="~"
|
157
|
+
dir=ENV["HOME"] unless ENV["HOME"].nil?
|
158
|
+
dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
|
159
|
+
return dir
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.dev_root
|
163
|
+
["DEV_HOME","DEV_ROOT"].each {|v|
|
164
|
+
return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
165
|
+
}
|
166
|
+
dir=home
|
167
|
+
#dir=ENV["DEV_ROOT"].gsub('\\','/') unless ENV["DEV_ROOT"].nil?
|
168
|
+
return dir
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.exit_code command
|
172
|
+
cmd = Command.new(command)
|
173
|
+
cmd[:ignore_failure]=true
|
174
|
+
cmd[:quiet]=true
|
175
|
+
cmd.execute
|
176
|
+
cmd[:exit_code]
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.output command
|
180
|
+
cmd = Command.new(command)
|
181
|
+
cmd[:ignore_failure]=true
|
182
|
+
cmd[:quiet]=true
|
183
|
+
cmd.execute
|
184
|
+
cmd[:output]
|
185
|
+
end
|
186
|
+
|
187
|
+
def getFormattedTimeSpan timespan
|
188
|
+
seconds = timespan
|
189
|
+
seconds.to_s + " sec"
|
190
|
+
end
|
191
|
+
|
192
|
+
def summary
|
193
|
+
duration=""
|
194
|
+
duration=getFormattedTimeSpan(self[:end_time]-[:start_time]) + " - " if(!self[:end_time].nil?)
|
195
|
+
duration + "#{self[:exit_code].to_s} #{self[:input]} (#{self[:directory]})"
|
196
|
+
end
|
197
|
+
|
198
|
+
def to_html
|
199
|
+
if self[:exit_code] == 0
|
200
|
+
[
|
201
|
+
'<div><table><tr><td width="20"></td><td><pre>',
|
202
|
+
self[:input],
|
203
|
+
'</pre></td></tr></table></div>'
|
204
|
+
].join
|
205
|
+
else
|
206
|
+
[
|
207
|
+
'<div><table><tr><td width="20"></td><td><pre>',
|
208
|
+
self[:input],
|
209
|
+
'</pre><table><tr><td width="20"></td><td><table>',
|
210
|
+
map { |k, v| ["<tr><td><strong>#{k}</strong></td>", v.respond_to?(:to_html) ? v.to_html : "<td><span><pre>#{v}</pre></span></td></tr>"] },
|
211
|
+
'</table>',
|
212
|
+
'</td></tr></table></td></tr></table></div>'
|
213
|
+
].join
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
data/lib/commands/add.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class Add < Array
|
2
|
+
def update
|
3
|
+
if(File.exists?('.git') && File.exists?('.gitignore'))
|
4
|
+
add 'git add --all'
|
5
|
+
else
|
6
|
+
if(defined?(SOURCE))
|
7
|
+
if(File.exists?('.svn'))
|
8
|
+
SOURCE.each{|f|
|
9
|
+
|
10
|
+
add "svn add #{f} --parents" if Command.output("svn status #{f}").include?('?')
|
11
|
+
add "svn add #{f} --parents" if Command.exit_code("svn status #{f}") != 0
|
12
|
+
}
|
13
|
+
end
|
14
|
+
if(File.exists?('.git'))
|
15
|
+
SOURCE.each{|f|
|
16
|
+
add "git add #{f} -v" if `git status #{f}`.include?('untracked')
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Array
|
2
|
+
def execute value=nil
|
3
|
+
i=0
|
4
|
+
while i < self.length
|
5
|
+
self[i]=Command.new(self[i]) if(self[i].is_a?(String))
|
6
|
+
self[i]=Command.new(self[i]) if(self[i].is_a?(Hash) && !self[i].is_a?(Command))
|
7
|
+
|
8
|
+
if(!value.nil? && value.is_a?(Hash))
|
9
|
+
value.each{|k,v|self[i][k]=v}
|
10
|
+
end
|
11
|
+
|
12
|
+
self[i].execute if(self[i].is_a?(Command))
|
13
|
+
i=i+1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def add command
|
18
|
+
self << command if(!include?(command))
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_html
|
22
|
+
html=Array.new
|
23
|
+
html << '<div>'
|
24
|
+
self.each{|e|
|
25
|
+
html << e.to_html if e.respond_to?(:to_html)
|
26
|
+
}
|
27
|
+
html << '</div>'
|
28
|
+
html.join
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
SLN_FILES=FileList.new('*.sln','*/*.sln','*/*/*.sln')
|
4
|
+
|
5
|
+
class Build < Array
|
6
|
+
def update
|
7
|
+
|
8
|
+
changed = true
|
9
|
+
#changed = Git.has_changes? if(File.exists?('.git') && defined?(Git))
|
10
|
+
#changed = Svn.has_changes? if(File.exists?('.svn') && defined?(Svn))
|
11
|
+
if(changed)
|
12
|
+
Dir.glob('*.gemspec'){|gemspec|
|
13
|
+
add "gem build #{gemspec}" if !File.exist?(Gemspec.gemfile gemspec)
|
14
|
+
}
|
15
|
+
|
16
|
+
SLN_FILES.each{|sln_file|
|
17
|
+
vs_version=MSBuild.get_vs_version(sln_file)
|
18
|
+
if(MSBuild.has_version?(vs_version))
|
19
|
+
MSBuild.get_configurations(sln_file).each{ |configuration|
|
20
|
+
MSBuild.get_platforms(sln_file).each{|platform|
|
21
|
+
#Console.debug "configuration='#{configuration}', platform='#{platform}'"
|
22
|
+
self.add "\"#{MSBuild.get_version(vs_version)}\" \"#{sln_file}\" /nologo /p:Configuration=#{configuration} /p:Platform=\"#{platform}\""
|
23
|
+
}
|
24
|
+
}
|
25
|
+
else
|
26
|
+
"puts version #{vs_version} not found for MsBuild"
|
27
|
+
end
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Clobber < Array
|
2
|
+
def update
|
3
|
+
['bin'].each{|dir|
|
4
|
+
CLOBBER.include(dir) if File.exists?(dir)
|
5
|
+
}
|
6
|
+
|
7
|
+
clean=Clean.new
|
8
|
+
clean.update
|
9
|
+
|
10
|
+
CLOBBER.include('*.gem')
|
11
|
+
|
12
|
+
#add '<%Rake::Task[:clobber].reenable%>'
|
13
|
+
add '<%Rake::Task[:clobber].invoke%>'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
require 'open3'
|
2
|
+
#require_relative('./array.rb')
|
3
|
+
#require_relative('./hash.rb')
|
4
|
+
#require_relative('./timer.rb')
|
5
|
+
|
6
|
+
BUFFER_SIZE=1024 if(!defined?(BUFFER_SIZE))
|
7
|
+
|
8
|
+
# = Command
|
9
|
+
#
|
10
|
+
# execution of system commands
|
11
|
+
#
|
12
|
+
# = Keys
|
13
|
+
#
|
14
|
+
# - :input The input of the commands.
|
15
|
+
# - :timeout The timeout in seconds.
|
16
|
+
# a value of zero is to infinite timeout.
|
17
|
+
# defaults to zero
|
18
|
+
# - :directory The working directory for the command.
|
19
|
+
# defaults to the current directory
|
20
|
+
# - :exit_code The exit code of the command
|
21
|
+
# - :output The output contains the stdout output of the command
|
22
|
+
# - :error The error contains stderr output of the command
|
23
|
+
# - :machine The name of the machine the command executed on
|
24
|
+
# - :user The user name
|
25
|
+
# - :start_time
|
26
|
+
# - :end_time
|
27
|
+
#
|
28
|
+
class Command < Hash
|
29
|
+
def initialize command
|
30
|
+
|
31
|
+
self[:input] = ''
|
32
|
+
self[:timeout] = 0
|
33
|
+
self[:directory] = ''
|
34
|
+
self[:exit_code] = 0
|
35
|
+
self[:output] = ''
|
36
|
+
self[:error] = ''
|
37
|
+
self[:machine] = ''
|
38
|
+
self[:user] = ''
|
39
|
+
self[:start_time] = nil
|
40
|
+
self[:end_time] = nil
|
41
|
+
|
42
|
+
if(command.kind_of?(String))
|
43
|
+
self[:input] = command
|
44
|
+
end
|
45
|
+
|
46
|
+
if(command.kind_of?(Hash))
|
47
|
+
command.each{|k,v|
|
48
|
+
self[k.to_sym]=v
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def quiet?
|
54
|
+
(self.has_key?(:quiet) && self[:quiet])
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute value=nil
|
58
|
+
|
59
|
+
if(!value.nil? && value.is_a?(Hash))
|
60
|
+
value.each{|k,v|self[k]=v}
|
61
|
+
end
|
62
|
+
|
63
|
+
pwd=Dir.pwd
|
64
|
+
self[:directory] = pwd if(!self.has_key?(:directory) || self[:directory].length==0)
|
65
|
+
|
66
|
+
if(self[:timeout] > 0)
|
67
|
+
puts "#{self[:input]} (#{self[:directory]}) timeout #{self[:timeout].to_s}" if(!quiet?)
|
68
|
+
else
|
69
|
+
puts "#{self[:input]} (#{self[:directory]})" if(!quiet?)
|
70
|
+
end
|
71
|
+
|
72
|
+
self[:machine] = Command.machine
|
73
|
+
self[:user] = Command.user
|
74
|
+
|
75
|
+
self[:start_time]=Time.now
|
76
|
+
timer=Timer.new
|
77
|
+
|
78
|
+
Dir.chdir(self[:directory]) do
|
79
|
+
if self[:input].include?('<%') && self[:input].include?('%>')
|
80
|
+
ruby = self[:input].gsub("<%","").gsub("%>","")
|
81
|
+
|
82
|
+
begin
|
83
|
+
self[:output]=eval(ruby)
|
84
|
+
rescue
|
85
|
+
self[:exit_code]=1
|
86
|
+
self[:error]="unable to eval(#{ruby})"
|
87
|
+
end
|
88
|
+
|
89
|
+
self[:elapsed] = timer.elapsed_str
|
90
|
+
self[:end_time] = Time.now
|
91
|
+
else
|
92
|
+
begin
|
93
|
+
if(self[:timeout] <= 0)
|
94
|
+
self[:output],self[:error],status= Open3.capture3(self[:input])
|
95
|
+
self[:exit_code]=status.to_i
|
96
|
+
self[:elapsed] = timer.elapsed_str
|
97
|
+
self[:end_time] = Time.now
|
98
|
+
else
|
99
|
+
require_relative 'timeout.rb'
|
100
|
+
#puts run_with_timeout(self[:input], self[:timeout], 1).to_s
|
101
|
+
#self[:output] = run_with_timeout(self[:input], self[:timeout], 1)
|
102
|
+
result=run_with_timeout2(self[:directory],self[:input], self[:timeout], 2)
|
103
|
+
self[:output]=result[0]
|
104
|
+
self[:error]=result[1]
|
105
|
+
self[:exit_code]=result[2]
|
106
|
+
|
107
|
+
self[:elapsed] = timer.elapsed_str
|
108
|
+
self[:end_time] = Time.now
|
109
|
+
|
110
|
+
if(timer.elapsed >= self[:timeout])
|
111
|
+
self[:exit_code]=1
|
112
|
+
self[:error] = self[:error] + "timed out"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
rescue Exception => e
|
116
|
+
self[:elapsed] = timer.elapsed_str
|
117
|
+
self[:end_time] = Time.now
|
118
|
+
self[:error] = "Exception: " + e.to_s
|
119
|
+
self[:exit_code]=1
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
if(self[:exit_code] != 0)
|
126
|
+
if(!quiet?)
|
127
|
+
puts "exit_code=#{self[:exit_code]}"
|
128
|
+
puts self[:output]
|
129
|
+
puts self[:error]
|
130
|
+
end
|
131
|
+
if(!self.has_key?(:ignore_failure) || !self[:ignore_failure])
|
132
|
+
raise "#{self[:input]} failed"
|
133
|
+
end #unless (self.has_key?(:ignore_failure) && self[:ignore_failure]==true)
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.machine
|
139
|
+
if !ENV['COMPUTERNAME'].nil?
|
140
|
+
return ENV['COMPUTERNAME']
|
141
|
+
end
|
142
|
+
|
143
|
+
machine = `hostname`
|
144
|
+
machine = machine.split('.')[0] if machine.include?('.')
|
145
|
+
return machine.strip
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.user
|
149
|
+
ENV['USER'].nil? ? ENV['USERNAME'] : ENV['USER']
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.home
|
153
|
+
["USERPROFILE","HOME"].each {|v|
|
154
|
+
return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
155
|
+
}
|
156
|
+
dir="~"
|
157
|
+
dir=ENV["HOME"] unless ENV["HOME"].nil?
|
158
|
+
dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
|
159
|
+
return dir
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.dev_root
|
163
|
+
["DEV_HOME","DEV_ROOT"].each {|v|
|
164
|
+
return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
165
|
+
}
|
166
|
+
dir=home
|
167
|
+
#dir=ENV["DEV_ROOT"].gsub('\\','/') unless ENV["DEV_ROOT"].nil?
|
168
|
+
return dir
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.exit_code command
|
172
|
+
cmd = Command.new(command)
|
173
|
+
cmd[:ignore_failure]=true
|
174
|
+
cmd[:quiet]=true
|
175
|
+
cmd.execute
|
176
|
+
cmd[:exit_code]
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.output command
|
180
|
+
cmd = Command.new(command)
|
181
|
+
cmd[:ignore_failure]=true
|
182
|
+
cmd[:quiet]=true
|
183
|
+
cmd.execute
|
184
|
+
cmd[:output]
|
185
|
+
end
|
186
|
+
|
187
|
+
def getFormattedTimeSpan timespan
|
188
|
+
seconds = timespan
|
189
|
+
seconds.to_s + " sec"
|
190
|
+
end
|
191
|
+
|
192
|
+
def self.execute command
|
193
|
+
cmd = Command.new(command)
|
194
|
+
cmd.execute
|
195
|
+
cmd[:exit_code]
|
196
|
+
end
|
197
|
+
|
198
|
+
def summary
|
199
|
+
duration=""
|
200
|
+
duration=getFormattedTimeSpan(self[:end_time]-self[:start_time]) + " - " if(!self[:end_time].nil?)
|
201
|
+
duration + "#{self[:exit_code].to_s} #{self[:input]} (#{self[:directory]})"
|
202
|
+
end
|
203
|
+
|
204
|
+
def to_html
|
205
|
+
if self[:exit_code] == 0
|
206
|
+
[
|
207
|
+
'<div><table><tr><td width="20"></td><td><pre>',
|
208
|
+
self[:input],
|
209
|
+
'</pre></td></tr></table></div>'
|
210
|
+
].join
|
211
|
+
else
|
212
|
+
[
|
213
|
+
'<div><table><tr><td width="20"></td><td><pre>',
|
214
|
+
self[:input],
|
215
|
+
'</pre><table><tr><td width="20"></td><td><table>',
|
216
|
+
map { |k, v| ["<tr><td><strong>#{k}</strong></td>", v.respond_to?(:to_html) ? v.to_html : "<td><span><pre>#{v}</pre></span></td></tr>"] },
|
217
|
+
'</table>',
|
218
|
+
'</td></tr></table></td></tr></table></div>'
|
219
|
+
].join
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#require_relative('hash.rb')
|
2
|
+
#require_relative('pull.rb')
|
3
|
+
#require_relative('update.rb')
|
4
|
+
#require_relative('setup.rb')
|
5
|
+
#require_relative('build.rb')
|
6
|
+
#require_relative('test.rb')
|
7
|
+
#require_relative('analyze.rb')
|
8
|
+
#require_relative('publish.rb')
|
9
|
+
#require_relative('doc.rb')
|
10
|
+
#require_relative('clean.rb')
|
11
|
+
#require_relative('clobber.rb')
|
12
|
+
#require_relative('add.rb')
|
13
|
+
#require_relative('commit.rb')
|
14
|
+
#require_relative('push.rb')
|
15
|
+
|
16
|
+
class Commands < Hash
|
17
|
+
|
18
|
+
def initialize directory=Dir.pwd
|
19
|
+
Dir.chdir(directory) do
|
20
|
+
self[:pull]=Pull.new
|
21
|
+
self[:update]=Update.new
|
22
|
+
self[:setup]=Setup.new
|
23
|
+
self[:build]=Build.new
|
24
|
+
self[:test]=Test.new
|
25
|
+
self[:analyze]=Analyze.new
|
26
|
+
self[:doc]=Doc.new
|
27
|
+
self[:clean]=Clean.new
|
28
|
+
self[:publish]=Publish.new
|
29
|
+
self[:clobber]=Clobber.new
|
30
|
+
self[:add]=Add.new
|
31
|
+
self[:commit]=Commit.new
|
32
|
+
self[:push]=Push.new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#require_relative('internet.rb')
|
2
|
+
|
3
|
+
class Commit < Array
|
4
|
+
def update
|
5
|
+
if(File.exists?('.git') && `git config --list`.include?('user.name='))
|
6
|
+
if(!`git status`.include?('nothing to commit') &&
|
7
|
+
!`git status`.include?('untracked files present'))
|
8
|
+
if(File.exists?('commit.message') && File.read('commit.message').gsub(/\s+/,"").length >0)
|
9
|
+
add "git commit -a -v -m \"#{File.read('commit.message')}\""
|
10
|
+
else
|
11
|
+
add "git commit -m'all'"
|
12
|
+
end
|
13
|
+
add "<%FileUtils.rm('commit.message')%>" if File.exists?('commit.message')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
if(File.exists?('.svn') && Internet.available?)
|
17
|
+
add 'svn commit -m"commit all"'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/commands/doc.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
class Doc < Array
|
2
|
+
def update
|
3
|
+
#cmd=Command.new ({ :input => 'yard --version', :ignore_failure => true})
|
4
|
+
#cmd.execute
|
5
|
+
if(Command.exit_code('yard --version'))
|
6
|
+
add 'yard doc - LICENSE' if File.exists?('README.md') && File.exists?('LICENSE')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Gemspec
|
2
|
+
def self.update gemspec_file
|
3
|
+
Text.replace_in_file gemspec_file,
|
4
|
+
/('\d{4}-\d{2}-\d{2}')/,
|
5
|
+
"'#{Time.now.strftime('%Y-%m-%d')}'"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.gemfile gemspec_file
|
9
|
+
spec=Gem::Specification.load(gemspec_file)
|
10
|
+
return "#{spec.name}-#{spec.version}.gem" if !spec.nil?
|
11
|
+
return ""
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.version gemspec_file
|
15
|
+
spec=Gem::Specification.load(gemspec_file)
|
16
|
+
return spec.version.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.published_version gemspec_file
|
20
|
+
published_version=''
|
21
|
+
spec=Gem::Specification.load(gemspec_file)
|
22
|
+
begin
|
23
|
+
published_version = `gem list -r #{spec.name}`.scan(/\((\d+.\d+.\d+)\)/)[0][0]
|
24
|
+
rescue
|
25
|
+
published_version=''
|
26
|
+
end
|
27
|
+
published_version
|
28
|
+
end
|
29
|
+
def self.published? gemspec_file
|
30
|
+
published_version(gemspec_file)==version(gemspec_file) ? true : false
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.normalize gemspec_file
|
34
|
+
spec=Gem::Specification.load(gemspec_file)
|
35
|
+
File.open(gemspec_file,'w'){|f|f.write(spec.to_ruby)}
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.upgrade gemspec_file
|
39
|
+
end
|
40
|
+
end
|