dev 2.0.268 → 2.0.269
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dev +1 -1
- data/lib/base/array.rb +34 -4
- data/lib/base/command.rb +101 -12
- data/lib/base/dir.rb +14 -8
- data/lib/base/environment.rb +169 -52
- data/lib/base/gemspec.rb +10 -2
- data/lib/base/history.rb +26 -1
- data/lib/base/project.rb +237 -121
- data/lib/base/projects.rb +130 -66
- data/lib/base/timeout.rb +54 -16
- data/lib/base/version.rb +54 -0
- data/lib/commands.rb +4 -2
- data/lib/dev.rb +50 -44
- data/lib/tasks.rb +20 -12
- data/lib/tasks/add.rb +8 -8
- data/lib/tasks/analyze.rb +1 -1
- data/lib/tasks/build.rb +25 -9
- data/lib/tasks/commit.rb +7 -7
- data/lib/tasks/default.rb +7 -1
- data/lib/tasks/doc.rb +1 -1
- data/lib/tasks/publish.rb +7 -11
- data/lib/tasks/pull.rb +1 -4
- data/lib/tasks/push.rb +2 -2
- data/lib/tasks/setup.rb +36 -15
- data/lib/tasks/test.rb +4 -5
- data/lib/tasks/update.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b589fd7c6e934568a25fedd9390eb9eb34c249b
|
4
|
+
data.tar.gz: f3120161faf84cb33c7ecde90ca3a36f69d0e378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a1005b6587fe75f6552d75f47753651b71f9968a8cfd4a75499d1252ccc4ccec35ce7599322ebb79c9d440613f337b4e65f2ec3bd215d00e5af37cceab91aae
|
7
|
+
data.tar.gz: cdd95c1496bdbca9e0d5cc90fc44a252ab5b51ce391f56fd932b848044316ede3488d7332c6df9d8ab42a5426c8b2e54e2295987eb98595f491a5ae29123c46f
|
data/bin/dev
CHANGED
data/lib/base/array.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative('environment.rb')
|
3
2
|
class Array
|
3
|
+
attr_accessor :env
|
4
|
+
def intialize env=nil
|
5
|
+
@env=env
|
6
|
+
@env=Environment.new() if @env.nil?
|
7
|
+
@env=Environmnet.new() if !@env.kind_of?(Environment)
|
8
|
+
end
|
9
|
+
|
4
10
|
def execute value=nil
|
11
|
+
@env=Environment.new() if @env.nil?
|
5
12
|
i=0
|
6
13
|
while i < self.length
|
7
14
|
self[i]=Command.new(self[i]) if(self[i].is_a?(String))
|
@@ -11,13 +18,36 @@ class Array
|
|
11
18
|
value.each{|k,v|self[i][k]=v}
|
12
19
|
end
|
13
20
|
|
14
|
-
self[i].execute if(self[i].is_a?(Command))
|
21
|
+
#self[i].execute if(self[i].is_a?(Command))
|
22
|
+
if(self[i].is_a?(Command))
|
23
|
+
self[i].execute
|
24
|
+
@env.out self[i].summary
|
25
|
+
end
|
26
|
+
|
15
27
|
i=i+1
|
16
28
|
end
|
17
29
|
end
|
18
30
|
|
19
31
|
def add command
|
20
|
-
self << command if
|
32
|
+
self << command if !has_command? command
|
33
|
+
end
|
34
|
+
|
35
|
+
def has_command? command
|
36
|
+
return true if(command.kind_of?(String) && !include?(command))
|
37
|
+
if(command.kind_of?(Command))
|
38
|
+
self.each{|c|
|
39
|
+
return true if(c[:input] == command[:input])
|
40
|
+
}
|
41
|
+
end
|
42
|
+
false
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_quiet command
|
46
|
+
add Command.new({ :input => command, :quiet => true })
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_passive command
|
50
|
+
add Command.new({ :input => command, :quiet => true, :ignore_failure => true })
|
21
51
|
end
|
22
52
|
|
23
53
|
def to_html
|
data/lib/base/command.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'time'
|
3
2
|
require 'open3'
|
4
3
|
require_relative('timeout.rb')
|
5
4
|
require_relative('timer.rb')
|
6
5
|
require_relative('array.rb')
|
7
6
|
require_relative('hash.rb')
|
7
|
+
require_relative('string.rb')
|
8
|
+
require_relative('environment.rb')
|
9
|
+
require_relative('dir.rb')
|
8
10
|
BUFFER_SIZE=1024 if(!defined?(BUFFER_SIZE))
|
9
11
|
|
10
12
|
# = Command
|
@@ -51,6 +53,10 @@ class Command < Hash
|
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
56
|
+
def save filename
|
57
|
+
File.open(filename,'w'){|f|f.write(to_json)}
|
58
|
+
end
|
59
|
+
|
54
60
|
def open filename=''
|
55
61
|
@filename=filename if filename.length > 0
|
56
62
|
self.clear
|
@@ -63,6 +69,17 @@ class Command < Hash
|
|
63
69
|
(self.has_key?(:quiet) && self[:quiet])
|
64
70
|
end
|
65
71
|
|
72
|
+
def exit_code
|
73
|
+
self[:exit_code]
|
74
|
+
end
|
75
|
+
|
76
|
+
def output
|
77
|
+
self[:output]
|
78
|
+
end
|
79
|
+
def error
|
80
|
+
self[:error]
|
81
|
+
end
|
82
|
+
|
66
83
|
def execute value=nil
|
67
84
|
|
68
85
|
if(!value.nil? && value.is_a?(Hash))
|
@@ -105,11 +122,14 @@ class Command < Hash
|
|
105
122
|
self[:elapsed] = timer.elapsed_str
|
106
123
|
self[:end_time] = Time.now
|
107
124
|
else
|
125
|
+
#puts "command execute with timeout #{self[:timeout]}"
|
108
126
|
require_relative 'timeout.rb'
|
109
127
|
result=run_with_timeout(self[:directory],self[:input], self[:timeout],2)
|
128
|
+
#puts "result #{result}"
|
110
129
|
self[:output]=result[0]
|
111
|
-
self[:
|
112
|
-
self[:
|
130
|
+
self[:exit_code]=result[1]
|
131
|
+
#self[:error]=result[1]
|
132
|
+
#self[:exit_code]=result[2]
|
113
133
|
|
114
134
|
self[:elapsed] = timer.elapsed_str
|
115
135
|
self[:end_time] = Time.now
|
@@ -174,10 +194,19 @@ class Command < Hash
|
|
174
194
|
return dir
|
175
195
|
end
|
176
196
|
|
197
|
+
#def self.execute_quiet command
|
198
|
+
# cmd=Command.new({ :input => command, :quiet => true, :ignore_failure => true})
|
199
|
+
# cmd.execute
|
200
|
+
# cmd
|
201
|
+
#end
|
202
|
+
|
177
203
|
def self.execute command
|
178
|
-
cmd = Command.new(command)
|
204
|
+
cmd = Command.new({ :input => command, :quiet => true}) if command.kind_of?(String)
|
205
|
+
cmd = command if command.kind_of?(Command)
|
206
|
+
cmd = Command.new(command) if command.kind_of?(Hash)
|
179
207
|
cmd.execute
|
180
208
|
cmd[:exit_code]
|
209
|
+
cmd
|
181
210
|
end
|
182
211
|
|
183
212
|
def self.exit_code command
|
@@ -205,17 +234,77 @@ class Command < Hash
|
|
205
234
|
end
|
206
235
|
|
207
236
|
def getFormattedTimeSpan timespan
|
237
|
+
result=''
|
208
238
|
seconds = timespan.round
|
209
|
-
seconds
|
239
|
+
if(seconds > 99)
|
240
|
+
minutes=(seconds/60).round
|
241
|
+
result="#{minutes}m"
|
242
|
+
else
|
243
|
+
result="#{seconds}s" # 99s
|
244
|
+
end
|
245
|
+
result.fix(3)
|
210
246
|
end
|
211
247
|
|
212
|
-
def summary
|
248
|
+
def summary include_directory=false
|
213
249
|
duration=""
|
214
|
-
duration=getFormattedTimeSpan(self[:end_time]-self[:start_time])
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
250
|
+
duration=getFormattedTimeSpan(self[:end_time]-self[:start_time])
|
251
|
+
if(Environment.default.colorize?)
|
252
|
+
require 'ansi/code'
|
253
|
+
cduration = ANSI.reset + duration
|
254
|
+
#code=ANSI.green + '+ ' + ANSI.reset
|
255
|
+
#code=ANSI.red + '- ' + ANSI.reset if exit_code != 0
|
256
|
+
cinput = ANSI.reset + self[:input] + ANSI.reset
|
257
|
+
cinput = ANSI.red + self[:input] + ANSI.reset if exit_code != 0
|
258
|
+
cdirectory = ''
|
259
|
+
cdirectory = "(#{self[:directory]})" if include_directory
|
260
|
+
" #{cduration} #{cinput} #{cdirectory}"
|
261
|
+
else
|
262
|
+
code=' '
|
263
|
+
code='X' if exit_code != 0
|
264
|
+
sdirectory = ''
|
265
|
+
sdirectory = "(#{self[:directory]})" if include_directory
|
266
|
+
"#{code} #{duration} #{self[:input]} #{sdirectory}"
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def format_property name,value
|
271
|
+
if(Environment.default.colorize?)
|
272
|
+
require 'ansi/code'
|
273
|
+
return "#{name}: " + ANSI.yellow + ANSI.bright + value.to_s.strip + ANSI.reset
|
274
|
+
else
|
275
|
+
return "#{name}: #{value}"
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def info
|
280
|
+
result=format_property('input'.fix(15),self[:input]) + "\n"
|
281
|
+
result=result + format_property('directory'.fix(15),self[:directory]) + "\n"
|
282
|
+
result=result + format_property('exit_code'.fix(15),self[:exit_code]) + "\n"
|
283
|
+
result=result + format_property('duration'.fix(15),getFormattedTimeSpan(self[:end_time]-self[:start_time])) + "\n"
|
284
|
+
output=['']
|
285
|
+
output=self[:output].strip.split("\n") if !self[:output].nil?
|
286
|
+
if(output.length <= 1)
|
287
|
+
result=result + format_property('output'.fix(15),output[0]) + "\n"
|
288
|
+
#result=result + format_property('output'.fix(15),'') + "\n" if(output.length==0)
|
289
|
+
#result=result + format_property('output'.fix(15),output) + "\n" if(output.length==1)
|
290
|
+
else
|
291
|
+
result=result + format_property('output'.fix(15),'') + "\n"
|
292
|
+
output.each{|line|
|
293
|
+
result=result + ' '.fix(16) + line + "\n"
|
294
|
+
}
|
295
|
+
end
|
296
|
+
error=['']
|
297
|
+
error=self[:error].strip.split("\n") if !self[:error].nil?
|
298
|
+
if(error.length <= 1)
|
299
|
+
result=result + format_property('error'.fix(15),error[0]) + "\n"
|
300
|
+
#result=result + format_property('error'.fix(15),'') + "\n" if(error.length==0)
|
301
|
+
#result=result + format_property('error'.fix(15),error) + "\n" if(error.length==1)
|
302
|
+
else
|
303
|
+
result=result + format_property('error'.fix(15),'') + "\n"
|
304
|
+
error.each{|line|
|
305
|
+
result=result + ' '.fix(16) + line + "\n"
|
306
|
+
}
|
307
|
+
end
|
219
308
|
end
|
220
309
|
|
221
310
|
def to_html
|
data/lib/base/dir.rb
CHANGED
@@ -1,18 +1,24 @@
|
|
1
|
-
puts __FILE__ if defined?(DEBUG)
|
2
|
-
|
3
1
|
require 'fileutils'
|
4
2
|
|
5
3
|
class Dir
|
6
4
|
def self.make directory
|
7
5
|
FileUtils.mkdir_p directory if !File.exists? directory
|
8
6
|
end
|
9
|
-
def self.remove directory
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
def self.remove directory, remove_empty_parents=false
|
8
|
+
begin
|
9
|
+
FileUtils.rm_rf directory if(!Dir.empty?(directory))
|
10
|
+
FileUtils.rm_r directory if(File.exists?(directory))
|
11
|
+
if(remove_empty_parents)
|
12
|
+
parent_dir=File.dirname(directory)
|
13
|
+
Dir.remove parent_dir, true if(Dir.empty?(parent_dir))
|
15
14
|
end
|
15
|
+
rescue
|
16
|
+
end
|
17
|
+
end
|
18
|
+
def self.empty? directory
|
19
|
+
if((Dir.entries(directory) - %w{ . .. }).empty?)
|
20
|
+
return true
|
16
21
|
end
|
22
|
+
false
|
17
23
|
end
|
18
24
|
end
|
data/lib/base/environment.rb
CHANGED
@@ -3,60 +3,177 @@ puts __FILE__ if defined?(DEBUG)
|
|
3
3
|
require_relative('string.rb')
|
4
4
|
|
5
5
|
class Environment < Hash
|
6
|
+
attr_accessor :output
|
7
|
+
@@default=nil
|
8
|
+
def self.default
|
9
|
+
@@default=Environment.new if @@default.nil?
|
10
|
+
@@default
|
11
|
+
end
|
6
12
|
|
7
|
-
|
8
|
-
|
9
|
-
|
13
|
+
def initialize env=nil
|
14
|
+
@output=''
|
15
|
+
@env=Hash.new
|
16
|
+
@env_aliases={'HOME' => ['USERPROFILE'],
|
17
|
+
'DEV_ROOT' => ['DEV_HOME','HOME','USERPROFILE'],
|
18
|
+
'USERNAME' => ['USER','USR']
|
19
|
+
}
|
20
|
+
env.each{|k,v| @env[k.to_s]=v} if !env.nil?
|
21
|
+
@@default=self if @@default.nil?
|
22
|
+
end
|
10
23
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
self[:user]=Environment.user
|
24
|
+
#####Begin LEGACY support
|
25
|
+
def self.dev_root
|
26
|
+
default.root_dir
|
15
27
|
end
|
16
28
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
29
|
+
#####End LEGACY support
|
30
|
+
def root_dir
|
31
|
+
get_env('DEV_ROOT')
|
32
|
+
end
|
33
|
+
|
34
|
+
def home_dir
|
35
|
+
get_env('HOME')
|
36
|
+
end
|
37
|
+
|
38
|
+
def log_dir
|
39
|
+
dir="#{get_env('DEV_ROOT')}/log/#{user}@#{machine}"
|
40
|
+
FileUtils.mkdir_p dir if !File.exists? dir
|
41
|
+
dir
|
42
|
+
end
|
43
|
+
|
44
|
+
def make_dir
|
45
|
+
dir="#{get_env('DEV_ROOT')}/make"
|
46
|
+
FileUtils.mkdir_p dir if !File.exists? dir
|
47
|
+
dir
|
48
|
+
end
|
49
|
+
|
50
|
+
def publish_dir
|
51
|
+
dir="#{get_env('DEV_ROOT')}/publish"
|
52
|
+
FileUtils.mkdir_p dir if !File.exists? dir
|
53
|
+
dir
|
54
|
+
end
|
55
|
+
|
56
|
+
def wrk_dir
|
57
|
+
dir="#{get_env('DEV_ROOT')}/wrk"
|
58
|
+
FileUtils.mkdir_p dir if !File.exists? dir
|
59
|
+
dir
|
60
|
+
end
|
61
|
+
|
62
|
+
def machine
|
63
|
+
return ENV['COMPUTERNAME'] if !ENV['COMPUTERNAME'].nil?
|
64
|
+
machine = `hostname`
|
65
|
+
machine = machine.split('.')[0] if machine.include?('.')
|
66
|
+
return machine.strip
|
67
|
+
end
|
68
|
+
|
69
|
+
def user
|
70
|
+
get_env('USERNAME')
|
71
|
+
#return ENV['USER'] if !ENV['USER'].nil? #on Unix
|
72
|
+
#ENV['USERNAME']
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_env key
|
76
|
+
if(!@env.nil? && @env.has_key?(key))
|
77
|
+
return @env[key]
|
78
|
+
end
|
79
|
+
value = ENV[key]
|
80
|
+
if(value.nil?)
|
81
|
+
if(@env_aliases.has_key?(key))
|
82
|
+
@env_aliases[key].each{|akey|
|
83
|
+
value=get_env(akey) if value.nil?
|
84
|
+
}
|
85
|
+
end
|
24
86
|
end
|
87
|
+
value
|
25
88
|
end
|
26
89
|
|
27
|
-
def
|
28
|
-
|
90
|
+
def set_env key,value
|
91
|
+
@env[key]=value
|
29
92
|
end
|
30
93
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
dir="~"
|
36
|
-
dir=ENV["HOME"] unless ENV["HOME"].nil?
|
37
|
-
dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
|
38
|
-
return dir
|
94
|
+
def debug?
|
95
|
+
return true if get_env('DEBUG')=='true'
|
96
|
+
false
|
39
97
|
end
|
40
98
|
|
41
|
-
def
|
42
|
-
|
43
|
-
if
|
44
|
-
|
45
|
-
|
99
|
+
def colorize?
|
100
|
+
colorize=true
|
101
|
+
if windows?
|
102
|
+
if(`gem list win32console`.include?('win32console'))
|
103
|
+
require 'ansi/code'
|
104
|
+
else
|
105
|
+
colorize=false
|
106
|
+
end
|
46
107
|
end
|
47
|
-
|
108
|
+
colorize
|
109
|
+
end
|
110
|
+
|
111
|
+
def out message
|
112
|
+
puts message if !get_env('SUPPRESS_CONSOLE_OUTPUT')
|
113
|
+
@output=@output+message+'\n'
|
48
114
|
end
|
49
115
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
end
|
116
|
+
def show_success?
|
117
|
+
true
|
118
|
+
end
|
54
119
|
|
55
|
-
|
56
|
-
|
57
|
-
return machine.strip
|
120
|
+
def windows?
|
121
|
+
Gem.win_platform?
|
58
122
|
end
|
59
123
|
|
124
|
+
#@@debug=true if defined?(DEBUG)
|
125
|
+
#@@debug=false if !defined?(DEBUG)
|
126
|
+
#@@development_root=nil
|
127
|
+
|
128
|
+
#def initialize
|
129
|
+
#self[:home]=Environment.home
|
130
|
+
#self[:machine]=Environment.machine
|
131
|
+
#self[:user]=Environment.user
|
132
|
+
#end
|
133
|
+
|
134
|
+
#def self.set_development_root value
|
135
|
+
# @@development_root=value
|
136
|
+
# if(!value.nil?)
|
137
|
+
# FileUtils.mkdir_p value if(!File.exists?(value))
|
138
|
+
# ['bin','data','log','make','publish','test'].each{|dir|
|
139
|
+
# #FileUtils.mkdir_p("#{value}/#{dir}") if !File.exists? "#{value}/#{dir}"
|
140
|
+
# }
|
141
|
+
# end
|
142
|
+
#end
|
143
|
+
|
144
|
+
#def self.debug
|
145
|
+
# @@debug
|
146
|
+
#end
|
147
|
+
|
148
|
+
#def self.home
|
149
|
+
# ["USERPROFILE","HOME"].each {|v|
|
150
|
+
# return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
151
|
+
# }
|
152
|
+
# dir="~"
|
153
|
+
# dir=ENV["HOME"] unless ENV["HOME"].nil?
|
154
|
+
# dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
|
155
|
+
# return dir
|
156
|
+
#end
|
157
|
+
|
158
|
+
#def self.configuration
|
159
|
+
# config="#{Environment.home}/dev.config.rb"
|
160
|
+
# if(!File.exists?(config))
|
161
|
+
# text=IO.read("#{File.dirname(__FILE__)}/../dev.config.rb")
|
162
|
+
# File.open(config,'w'){|f|f.write(text)}
|
163
|
+
# end
|
164
|
+
# config
|
165
|
+
#end
|
166
|
+
|
167
|
+
#def self.machine
|
168
|
+
# if !ENV['COMPUTERNAME'].nil?
|
169
|
+
# return ENV['COMPUTERNAME']
|
170
|
+
# end
|
171
|
+
|
172
|
+
# machine = `hostname`
|
173
|
+
# machine = machine.split('.')[0] if machine.include?('.')
|
174
|
+
# return machine.strip
|
175
|
+
#end
|
176
|
+
|
60
177
|
def self.remove directory
|
61
178
|
if(File.exists?(directory))
|
62
179
|
begin
|
@@ -67,21 +184,21 @@ class Environment < Hash
|
|
67
184
|
end
|
68
185
|
end
|
69
186
|
|
70
|
-
def self.user
|
71
|
-
|
72
|
-
|
73
|
-
end
|
187
|
+
#def self.user
|
188
|
+
# return ENV['USER'] if !ENV['USER'].nil? #on Unix
|
189
|
+
# ENV['USERNAME']
|
190
|
+
#end
|
74
191
|
|
75
|
-
def self.dev_root
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
192
|
+
#def self.dev_root
|
193
|
+
# if(!@@development_root.nil?)
|
194
|
+
# return @@development_root
|
195
|
+
# end
|
196
|
+
# ["DEV_HOME","DEV_ROOT"].each {|v|
|
197
|
+
# return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
198
|
+
# }
|
199
|
+
# dir=home
|
200
|
+
# return dir
|
201
|
+
#end
|
85
202
|
|
86
203
|
def self.check
|
87
204
|
puts 'checking commands...'
|
@@ -132,7 +249,7 @@ class Environment < Hash
|
|
132
249
|
end
|
133
250
|
|
134
251
|
def self.get_latest_mtime directory
|
135
|
-
mtime=
|
252
|
+
mtime=Time.new(1980)
|
136
253
|
Dir.chdir(directory) do
|
137
254
|
Dir.glob('**/*.*').each{|f|
|
138
255
|
mtime=File.mtime(f) if mtime.nil? || File.mtime(f) > mtime
|