dev 1.0.21 → 1.0.22
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dev.rb +7 -1
- data/lib/dev/Dep.rb +4 -2
- data/lib/dev/Project.rb +39 -10
- data/lib/dev/SystemCall.rb +94 -55
- metadata +7 -51
data/lib/dev.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
#require 'bundler/setup'
|
3
|
-
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rainbow'
|
6
|
+
rescue
|
7
|
+
puts "require 'rainbow' threw an exception"
|
8
|
+
end
|
9
|
+
|
4
10
|
require 'semver'
|
5
11
|
|
6
12
|
# if DEV_DEBUG is defined, puts_debug will send message to the console
|
data/lib/dev/Dep.rb
CHANGED
@@ -75,11 +75,13 @@ class Dep < Hash
|
|
75
75
|
array = Array.new
|
76
76
|
if(File.exists?(get_wrk_dir))
|
77
77
|
unless self[:rake].nil?
|
78
|
-
array << "{cmd: 'rake pull', dir: '#{get_wrk_dir}'
|
78
|
+
array << "{cmd: 'rake pull', dir: '#{get_wrk_dir}'}"
|
79
|
+
#array << "{cmd: 'rake pull', dir: '#{get_wrk_dir}', capture_output: false}"
|
79
80
|
#array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_wrk_dir}'}"
|
80
81
|
rakefile="#{get_wrk_dir}/rakefile.rb"
|
81
82
|
array << "<%Dev::Svn::update_revision_variables('#{rakefile}')%>"
|
82
|
-
array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_wrk_dir}'
|
83
|
+
array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_wrk_dir}'}"
|
84
|
+
#array << "{cmd: 'rake #{self.get_value("rake").to_s}', dir: '#{get_wrk_dir}', capture_output: false}"
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
data/lib/dev/Project.rb
CHANGED
@@ -79,13 +79,30 @@ class Project < Hash
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def check
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
puts " default.taskstamp exists." if File.exists?("default.taskstamp")
|
83
|
+
puts " default.taskstamp does not exist" unless File.exists?("default.taskstamp")
|
84
|
+
|
85
|
+
begin
|
86
|
+
hasdiff = has_diff
|
87
|
+
rescue
|
88
|
+
puts "has_diff threw an exception."
|
89
|
+
end
|
90
|
+
|
91
|
+
puts " no differences detected." unless hasdiff
|
92
|
+
puts " detected differences." if hasdiff
|
93
|
+
|
94
|
+
if File.exists?("default.taskstamp") && !hasdiff
|
95
|
+
puts " nothing to do"
|
85
96
|
exit
|
86
97
|
end
|
87
|
-
|
88
|
-
|
98
|
+
|
99
|
+
#if !has_diff and File.exists?("default.taskstamp")
|
100
|
+
# puts " no differences detected."
|
101
|
+
# puts " default.taskstamp exists."
|
102
|
+
# exit
|
103
|
+
#end
|
104
|
+
#puts " detected differences" if has_diff
|
105
|
+
#puts " default.taskstamp does not exist" unless File.exists?("default.taskstamp")
|
89
106
|
end
|
90
107
|
|
91
108
|
def stamp_task(name)
|
@@ -135,8 +152,15 @@ class Project < Hash
|
|
135
152
|
|
136
153
|
def has_diff
|
137
154
|
call=nil
|
138
|
-
call=Dev::SystemCall.new('git diff') if File.exists?(".git")
|
155
|
+
call=Dev::SystemCall.new('git diff --name-only') if File.exists?(".git")
|
139
156
|
call=Dev::SystemCall.new('svn diff') if File.exists?(".svn")
|
157
|
+
#if File.exists?(".svn")
|
158
|
+
# puts_debug "calling svn diff"
|
159
|
+
# #call=Dev::SystemCall.new('svn diff')
|
160
|
+
# call=Dev::SystemCall.new("{ cmd: 'svn diff', capture_error: false}")
|
161
|
+
# puts_debug " svn diff status = " + call.status.to_s
|
162
|
+
#end
|
163
|
+
#call=Dev::SystemCall.new("{ cmd: 'svn diff', capture_output: false}") if File.exists?(".svn")
|
140
164
|
unless call.nil? || call.output.length==0
|
141
165
|
return true # differences detected
|
142
166
|
else
|
@@ -237,7 +261,8 @@ class Project < Hash
|
|
237
261
|
|
238
262
|
array=Array.new
|
239
263
|
if(key=="setup")
|
240
|
-
array << "bundle install" if File.exists?("Gemfile")
|
264
|
+
#array << "bundle install" if File.exists?("Gemfile")
|
265
|
+
array << "{ cmd: 'bundle install', capture_output: false}" if File.exists?("Gemfile")
|
241
266
|
|
242
267
|
# dep,svn directives
|
243
268
|
dep_hash=self.get_value("dep")
|
@@ -267,7 +292,10 @@ class Project < Hash
|
|
267
292
|
end
|
268
293
|
end
|
269
294
|
if(key=="compile")
|
270
|
-
Dir.glob("*.gemspec").each { |gs|
|
295
|
+
Dir.glob("*.gemspec").each { |gs|
|
296
|
+
#array << "gem build #{gs}"
|
297
|
+
array << "{ cmd: 'gem build #{gs}', capture_output: false}"
|
298
|
+
} if self[:type]=="gem"
|
271
299
|
|
272
300
|
if self[:type]=="C#"
|
273
301
|
if(!has_key?(:x86_release_compile_flags))
|
@@ -279,7 +307,8 @@ class Project < Hash
|
|
279
307
|
if(key=="test")
|
280
308
|
|
281
309
|
Dir.glob("*.gemspec").each { |gs|
|
282
|
-
array << "{cmd: 'gem install ./#{gs.gsub('.gemspec','')}-#{self[:version]}.gem', capture_output: false}"
|
310
|
+
#array << "{cmd: 'gem install ./#{gs.gsub('.gemspec','')}-#{self[:version]}.gem', capture_output: false}"
|
311
|
+
array << "{cmd: 'gem install #{gs.gsub('.gemspec','')}-#{self[:version]}.gem', capture_output: false}"
|
283
312
|
#array << "gem install ./#{gs.gsub('.gemspec','')}-#{self[:version]}.gem"
|
284
313
|
} if self[:type]=="gem"
|
285
314
|
|
@@ -295,7 +324,7 @@ class Project < Hash
|
|
295
324
|
end
|
296
325
|
if(key=="has_diff")
|
297
326
|
array << 'git diff' if File.exists?(".git")
|
298
|
-
array << 'svn diff' if File.exists?(".svn")
|
327
|
+
array << "{ cmd: 'svn diff', capture_output: false}" if File.exists?(".svn")
|
299
328
|
end
|
300
329
|
if(key=="commit")
|
301
330
|
array << 'git commit -a -m "rake commit all"' if File.exists?(".git")
|
data/lib/dev/SystemCall.rb
CHANGED
@@ -7,13 +7,15 @@ require 'systemu'
|
|
7
7
|
module Dev
|
8
8
|
|
9
9
|
class SystemCall
|
10
|
-
attr_accessor :output,:error,:status,:command,:start_time,:end_time,:timed_out,:dir,:cache, :capture_output
|
10
|
+
attr_accessor :output,:error,:status,:command,:start_time,:end_time,:timed_out,:dir,:cache, :capture_output, :capture_error
|
11
11
|
|
12
12
|
def initialize(cmd)
|
13
13
|
if(cmd.kind_of?(Hash))
|
14
14
|
set_hash(cmd)
|
15
15
|
else
|
16
|
-
|
16
|
+
hash=Dev::Environment.s_to_hash(cmd)
|
17
|
+
set_hash(hash) unless hash.nil?
|
18
|
+
@command=cmd if hash.nil?
|
17
19
|
end
|
18
20
|
execute(@command);
|
19
21
|
end
|
@@ -42,6 +44,7 @@ class SystemCall
|
|
42
44
|
hash[:timed_out]=@timed_out
|
43
45
|
hash[:cache]=@cache
|
44
46
|
hash[:capture_output]=@capture_output
|
47
|
+
hash[:capture_error]=@capture_error
|
45
48
|
return hash
|
46
49
|
end
|
47
50
|
|
@@ -56,6 +59,7 @@ class SystemCall
|
|
56
59
|
@timed_out=hash[:timed_out] unless hash[:timed_out].nil?
|
57
60
|
@cache=hash[:cache] unless hash[:cache].nil?
|
58
61
|
@capture_output=hash[:capture_output] unless hash[:capture_output].nil?
|
62
|
+
@capture_error=hash[:capture_error] unless hash[:capture_error].nil?
|
59
63
|
end
|
60
64
|
|
61
65
|
def write_cache
|
@@ -73,74 +77,109 @@ class SystemCall
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def execute(cmd)
|
76
|
-
|
77
80
|
if !@cache.nil? && has_cache
|
78
81
|
load_cache
|
79
82
|
return
|
80
83
|
end
|
81
|
-
|
82
|
-
|
84
|
+
|
85
|
+
pwd=Dir.pwd
|
83
86
|
@start_time=Time.now
|
84
|
-
filename=Dir.tmpdir + "/" + (0...8).map{65.+(rand(25)).chr}.join
|
85
87
|
begin
|
86
|
-
if
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
puts_debug " executing: #{@command} >>#{filename}.out 2>>#{filename}.err"
|
93
|
-
system("#{@command} >>#{filename}.out 2>>#{filename}.err")
|
94
|
-
end
|
95
|
-
else
|
96
|
-
puts_debug "not capturing output...."
|
97
|
-
system(@command)
|
98
|
-
#system("logcmd #{filename} #{@command}")
|
99
|
-
#status,@output,@error=systemu(@command)
|
100
|
-
end
|
101
|
-
else
|
102
|
-
puts_debug " changing directory to " + dir
|
103
|
-
Dir.chdir(dir) do
|
104
|
-
if(@capture_output.nil?)
|
105
|
-
if(!@outfile.nil?)
|
106
|
-
system("#{@command} > #{outfile}")
|
107
|
-
else
|
108
|
-
system("#{@command} >#{filename}.out 2>#{filename}.err")
|
109
|
-
end
|
110
|
-
else
|
111
|
-
#system("logcmd #{filename} #{@command}")
|
112
|
-
system(@command)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
puts_debug " command execution completed"
|
117
|
-
if(File.exist?("#{filename}.out"))
|
118
|
-
File.open("#{filename}.out",'r') {|f|
|
119
|
-
@output = f.read
|
120
|
-
f.close
|
121
|
-
}
|
122
|
-
end
|
123
|
-
if(File.exist?("#{filename}.err"))
|
124
|
-
File.open("#{filename}.err",'r') {|f|
|
125
|
-
@error = f.read
|
126
|
-
f.close
|
127
|
-
}
|
128
|
-
end
|
129
|
-
@status=$?.exitstatus
|
88
|
+
capture_output=true if capture_output.nil?
|
89
|
+
capture_output=false if capture_output == "false"
|
90
|
+
capture_error=true if capture_error.nil?
|
91
|
+
capture_error=false unless capture_output
|
92
|
+
capture_error=false if capture_error == "false"
|
93
|
+
@status,@output,@error=system2(@dir,@command,@capture_output,@capture_error)
|
130
94
|
@end_time=Time.now
|
131
95
|
rescue
|
132
96
|
puts "error executing ruby code"
|
97
|
+
@status="1"
|
98
|
+
@end_time=Time.now
|
133
99
|
ensure
|
100
|
+
Dir.chdir(pwd) if Dir.pwd != pwd
|
134
101
|
write_cache if !@cache.nil?
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def system2(working_dir,command,capture_output,capture_error)
|
106
|
+
capture_output=true if capture_output.nil?
|
107
|
+
capture_output=false if capture_output == "false"
|
108
|
+
capture_error=true if capture_error.nil?
|
109
|
+
capture_error=false unless capture_output
|
110
|
+
capture_error=false if capture_error == "false"
|
111
|
+
|
112
|
+
puts_debug "system2(" + working_dir.to_s + "," + command + ") capture_output(" + capture_output.to_s + ") capture_error(" + capture_error.to_s + ")"
|
113
|
+
filename=Dir.tmpdir + "/" + (0...8).map{65.+(rand(25)).chr}.join
|
114
|
+
working_dir = Dir.pwd if working_dir.nil? || working_dir.empty?
|
115
|
+
status=0
|
116
|
+
output=""
|
117
|
+
error=""
|
118
|
+
puts_debug " Dir.chdir(" + working_dir + ")"
|
119
|
+
Dir.chdir(working_dir) do
|
120
|
+
if(capture_output)
|
121
|
+
if(capture_error)
|
122
|
+
system("#{@command} >#{filename}.out 2>#{filename}.err")
|
123
|
+
else
|
124
|
+
system("#{@command} >#{filename}.out")
|
125
|
+
end
|
126
|
+
else
|
127
|
+
if(capture_error)
|
128
|
+
system("#{@command} 2>#{filename}.err")
|
129
|
+
else
|
130
|
+
system(@command)
|
140
131
|
end
|
132
|
+
end
|
141
133
|
end
|
134
|
+
|
135
|
+
if(File.exist?("#{filename}.out"))
|
136
|
+
File.open("#{filename}.out",'r') {|f|
|
137
|
+
output = f.read
|
138
|
+
f.close
|
139
|
+
}
|
140
|
+
end
|
141
|
+
if(File.exist?("#{filename}.err"))
|
142
|
+
File.open("#{filename}.err",'r') {|f|
|
143
|
+
error = f.read
|
144
|
+
f.close
|
145
|
+
}
|
146
|
+
end
|
147
|
+
status=$?.exitstatus
|
148
|
+
|
149
|
+
puts_debug("status = " + status.to_s)
|
150
|
+
return status,output,error
|
142
151
|
end
|
143
152
|
|
153
|
+
def system3(working_dir,command,capture_output,capture_error)
|
154
|
+
puts_debug "system3(" + working_dir.to_s + "," + command + ")"
|
155
|
+
status = 0
|
156
|
+
output = ""
|
157
|
+
error = ""
|
158
|
+
working_dir = Dir.pwd if working_dir.nil? || working_dir.empty?
|
159
|
+
puts_debug " Dir.chdir(" + working_dir + ")"
|
160
|
+
Dir.chdir(working_dir) do
|
161
|
+
if(capture_output && capture_error)
|
162
|
+
puts_debug " calling status,output,error=systemu(" + command + ")"
|
163
|
+
status,output,error=systemu(command)
|
164
|
+
else
|
165
|
+
error=""
|
166
|
+
if(capture_error)
|
167
|
+
puts_debug " calling system(" + command + ")"
|
168
|
+
system(command)
|
169
|
+
status=$?.exitstatus
|
170
|
+
output=""
|
171
|
+
else
|
172
|
+
puts_debug " calling output=`#{command}`"
|
173
|
+
output=`#{command}`
|
174
|
+
status=$?.exitstatus
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
puts_debug("status = " + status.to_s)
|
180
|
+
return status,output,error
|
181
|
+
end
|
182
|
+
|
144
183
|
def puts_summary
|
145
184
|
if(@status != 0)
|
146
185
|
summary = " [".foreground(:cyan) + "X".foreground(:red).bright + "]".foreground(:cyan) + " system(\"" + @command.foreground(:green) + "\") has exit status of " + @status.to_s
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.22
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-03 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &24130800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *24130800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: semver
|
27
|
-
requirement: &
|
27
|
+
requirement: &24130092 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *24130092
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: countloc
|
38
|
-
requirement: &
|
38
|
+
requirement: &24129216 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,51 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rainbow
|
49
|
-
requirement: &23961060 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :runtime
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *23961060
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: rspec
|
60
|
-
requirement: &23960604 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ! '>='
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: '0'
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *23960604
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: cucumber
|
71
|
-
requirement: &23960196 !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
|
-
requirements:
|
74
|
-
- - ! '>='
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: *23960196
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: bundler
|
82
|
-
requirement: &23959764 !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
|
-
requirements:
|
85
|
-
- - ! '>='
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0'
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *23959764
|
46
|
+
version_requirements: *24129216
|
91
47
|
description: development tasks
|
92
48
|
email: lou.parslow@gmail.com
|
93
49
|
executables:
|