dev_commands 0.0.33 → 0.0.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/analyze.rb +7 -7
- data/lib/array.rb +24 -24
- data/lib/command.rb +151 -151
- data/lib/doc.rb +8 -8
- data/lib/gemspec.rb +38 -35
- data/lib/git.rb +8 -8
- data/lib/hash.rb +20 -20
- data/lib/internet.rb +16 -16
- data/lib/publish.rb +10 -10
- data/lib/push.rb +8 -8
- data/lib/setup.rb +24 -24
- data/lib/text.rb +14 -14
- data/lib/timer.rb +40 -40
- data/lib/upgrade.rb +6 -0
- data/spec/command_spec.rb +109 -109
- data/spec/publish_spec.rb +27 -27
- data/spec/sln-vs12-example/rakefile.rb +11 -11
- data/spec/sln-vs9-example/rakefile.rb +11 -11
- data/spec/text_spec.rb +11 -11
- metadata +24 -41
data/lib/git.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
class Git
|
2
|
-
def self.branch
|
3
|
-
begin
|
4
|
-
`git branch`.scan(/\* ([.\w-]+)/)[0][0]
|
5
|
-
rescue
|
6
|
-
''
|
7
|
-
end
|
8
|
-
end
|
1
|
+
class Git
|
2
|
+
def self.branch
|
3
|
+
begin
|
4
|
+
`git branch`.scan(/\* ([.\w-]+)/)[0][0]
|
5
|
+
rescue
|
6
|
+
''
|
7
|
+
end
|
8
|
+
end
|
9
9
|
end
|
data/lib/hash.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
class Hash
|
2
|
-
def execute
|
3
|
-
self.each{|k,v|
|
4
|
-
v.update if v.respond_to?(:update)
|
5
|
-
if(v.is_a?(Array) && v.length==0)
|
6
|
-
self.delete k
|
7
|
-
else
|
8
|
-
#puts "executing #{k}"
|
9
|
-
|
10
|
-
v.execute if v.respond_to?(:execute)
|
11
|
-
end
|
12
|
-
}
|
13
|
-
end
|
14
|
-
def to_html
|
15
|
-
[
|
16
|
-
'<div>',
|
17
|
-
map { |k, v| ["<br/><div><strong>#{k}</strong>", v.respond_to?(:to_html) ? v.to_html : "<span>#{v}</span></div><br/>"] },
|
18
|
-
'</div>'
|
19
|
-
].join
|
20
|
-
end
|
1
|
+
class Hash
|
2
|
+
def execute
|
3
|
+
self.each{|k,v|
|
4
|
+
v.update if v.respond_to?(:update)
|
5
|
+
if(v.is_a?(Array) && v.length==0)
|
6
|
+
self.delete k
|
7
|
+
else
|
8
|
+
#puts "executing #{k}"
|
9
|
+
|
10
|
+
v.execute if v.respond_to?(:execute)
|
11
|
+
end
|
12
|
+
}
|
13
|
+
end
|
14
|
+
def to_html
|
15
|
+
[
|
16
|
+
'<div>',
|
17
|
+
map { |k, v| ["<br/><div><strong>#{k}</strong>", v.respond_to?(:to_html) ? v.to_html : "<span>#{v}</span></div><br/>"] },
|
18
|
+
'</div>'
|
19
|
+
].join
|
20
|
+
end
|
21
21
|
end
|
data/lib/internet.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
|
3
|
-
class Internet
|
4
|
-
|
5
|
-
@@available=nil
|
6
|
-
|
7
|
-
def self.available?
|
8
|
-
return @@available if !@@available.nil?
|
9
|
-
|
10
|
-
begin
|
11
|
-
@@available = true if open('http://www.google.com')
|
12
|
-
rescue
|
13
|
-
@@available = false
|
14
|
-
end
|
15
|
-
@@available
|
16
|
-
end
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
class Internet
|
4
|
+
|
5
|
+
@@available=nil
|
6
|
+
|
7
|
+
def self.available?
|
8
|
+
return @@available if !@@available.nil?
|
9
|
+
|
10
|
+
begin
|
11
|
+
@@available = true if open('http://www.google.com')
|
12
|
+
rescue
|
13
|
+
@@available = false
|
14
|
+
end
|
15
|
+
@@available
|
16
|
+
end
|
17
17
|
end
|
data/lib/publish.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative('internet.rb')
|
2
|
-
class Publish < Array
|
3
|
-
def update
|
4
|
-
if(Internet.available? && `git branch`.include?('* master'))
|
5
|
-
Dir.glob('*.gemspec').each{|gemspec_file|
|
6
|
-
add "gem push #{Gemspec.gemfile(gemspec_file)}" if !Gemspec.published? gemspec_file
|
7
|
-
}
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require_relative('internet.rb')
|
2
|
+
class Publish < Array
|
3
|
+
def update
|
4
|
+
if(Internet.available? && `git branch`.include?('* master'))
|
5
|
+
Dir.glob('*.gemspec').each{|gemspec_file|
|
6
|
+
add "gem push #{Gemspec.gemfile(gemspec_file)}" if !Gemspec.published? gemspec_file
|
7
|
+
}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/push.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require_relative('internet.rb')
|
2
|
-
class Push < Array
|
3
|
-
def update
|
4
|
-
if(File.exists?('.git') && `git config --list`.include?('user.name='))
|
5
|
-
add 'git config --global push.default simple'
|
6
|
-
self << 'git push' if Git.branch != 'develop' && Internet.available?
|
7
|
-
end
|
8
|
-
end
|
1
|
+
require_relative('internet.rb')
|
2
|
+
class Push < Array
|
3
|
+
def update
|
4
|
+
if(File.exists?('.git') && `git config --list`.include?('user.name='))
|
5
|
+
add 'git config --global push.default simple'
|
6
|
+
self << 'git push' if Git.branch != 'develop' && Internet.available?
|
7
|
+
end
|
8
|
+
end
|
9
9
|
end
|
data/lib/setup.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
#
|
2
|
-
# use the SVN_EXPORTS hash to define svn exports destined for DEV_ROOT/dep
|
3
|
-
#
|
4
|
-
# SVN_EXPORT={ 'System.Data.SQLite/1.0.93.0' => 'https://third-party.googlecode.com/svn/trunk/System.Data.SQLite/1.0.93.0' }
|
5
|
-
#
|
6
|
-
class Setup < Array
|
7
|
-
def update
|
8
|
-
add 'bundle install' if(File.exists?('Gemfile'))
|
9
|
-
|
10
|
-
Dir.glob('*.gemspec').each{|gemspec_file|
|
11
|
-
add "<%Gemspec.update('#{gemspec_file}')%>"
|
12
|
-
}
|
13
|
-
|
14
|
-
if(defined?(SVN_EXPORTS))
|
15
|
-
SVN_EXPORTS.each{|k,v|
|
16
|
-
if(!File.exists?("#{Command.dev_root}/dep/#{k}"))
|
17
|
-
FileUtils.mkdir_p(File.dirname("#{Command.dev_root}/dep/#{k}")) if !File.exists?("#{Command.dev_root}/dep/#{k}")
|
18
|
-
dest="#{Command.dev_root}/dep/#{k}"
|
19
|
-
add "svn export #{v} #{Command.dev_root}/dep/#{k}" if !dest.include?("@")
|
20
|
-
add "svn export #{v} #{Command.dev_root}/dep/#{k}@" if dest.include?("@")
|
21
|
-
end
|
22
|
-
}
|
23
|
-
end
|
24
|
-
end
|
1
|
+
#
|
2
|
+
# use the SVN_EXPORTS hash to define svn exports destined for DEV_ROOT/dep
|
3
|
+
#
|
4
|
+
# SVN_EXPORT={ 'System.Data.SQLite/1.0.93.0' => 'https://third-party.googlecode.com/svn/trunk/System.Data.SQLite/1.0.93.0' }
|
5
|
+
#
|
6
|
+
class Setup < Array
|
7
|
+
def update
|
8
|
+
add 'bundle install' if(File.exists?('Gemfile'))
|
9
|
+
|
10
|
+
Dir.glob('*.gemspec').each{|gemspec_file|
|
11
|
+
add "<%Gemspec.update('#{gemspec_file}')%>"
|
12
|
+
}
|
13
|
+
|
14
|
+
if(defined?(SVN_EXPORTS))
|
15
|
+
SVN_EXPORTS.each{|k,v|
|
16
|
+
if(!File.exists?("#{Command.dev_root}/dep/#{k}"))
|
17
|
+
FileUtils.mkdir_p(File.dirname("#{Command.dev_root}/dep/#{k}")) if !File.exists?("#{Command.dev_root}/dep/#{k}")
|
18
|
+
dest="#{Command.dev_root}/dep/#{k}"
|
19
|
+
add "svn export #{v} #{Command.dev_root}/dep/#{k}" if !dest.include?("@")
|
20
|
+
add "svn export #{v} #{Command.dev_root}/dep/#{k}@" if dest.include?("@")
|
21
|
+
end
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
25
|
end
|
data/lib/text.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
class Text
|
2
|
-
def self.replace_in_glob(glob,search,replace)
|
3
|
-
Dir.glob(glob).each{ |f| replace_in_file(f,search,replace) }
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.replace_in_file(filename,search,replace)
|
7
|
-
text1 = IO.read(filename).force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
|
8
|
-
#File.read(f,:encoding=>'UTF-8')
|
9
|
-
text2 = text1.gsub(search) { |str| str=replace }
|
10
|
-
unless text1==text2
|
11
|
-
File.open(filename,"w") { |f| f.puts text2 }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
1
|
+
class Text
|
2
|
+
def self.replace_in_glob(glob,search,replace)
|
3
|
+
Dir.glob(glob).each{ |f| replace_in_file(f,search,replace) }
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.replace_in_file(filename,search,replace)
|
7
|
+
text1 = IO.read(filename).force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
|
8
|
+
#File.read(f,:encoding=>'UTF-8')
|
9
|
+
text2 = text1.gsub(search) { |str| str=replace }
|
10
|
+
unless text1==text2
|
11
|
+
File.open(filename,"w") { |f| f.puts text2 }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
15
|
end
|
data/lib/timer.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
class Timer
|
2
|
-
attr_accessor :start_time
|
3
|
-
|
4
|
-
def initialize
|
5
|
-
@start_time=Time.now
|
6
|
-
end
|
7
|
-
|
8
|
-
def elapsed # in seconds
|
9
|
-
return Time.now-@start_time
|
10
|
-
end
|
11
|
-
|
12
|
-
def elapsed_str
|
13
|
-
elapsed_str="[" + "%.0f" %(elapsed) + "s]"
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.elapsed_exceeds?(name,duration_seconds)
|
17
|
-
if(Timer.get_elapsed(name).nil? || Timer.get_elapsed(name) > duration_seconds)
|
18
|
-
return true
|
19
|
-
end
|
20
|
-
return false
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.get_elapsed(name)
|
24
|
-
timestamp=get_timestamp(name)
|
25
|
-
return Time.now-timestamp if(!timestamp.nil?)
|
26
|
-
nil
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.get_timestamp(name)
|
30
|
-
dir=Rake.application.original_dir
|
31
|
-
if(File.exists?("#{DEV[:dev_root]}/log/#{name}.timestamp"))
|
32
|
-
return Time.parse(File.read("#{DEV[:dev_root]}/log/#{name}.timestamp").strip)
|
33
|
-
end
|
34
|
-
nil
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.set_timestamp(name)
|
38
|
-
Dir.mkdir("#{DEV_TASKS[:dev_root]}/log") if(!Dir.exists?("#{DEV_TASKS[:dev_root]}/log"))
|
39
|
-
File.open("#{DEV_TASKS[:dev_root]}/log/#{name}.timestamp",'w'){|f|f.puts(Time.now.to_s)}
|
40
|
-
end
|
1
|
+
class Timer
|
2
|
+
attr_accessor :start_time
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@start_time=Time.now
|
6
|
+
end
|
7
|
+
|
8
|
+
def elapsed # in seconds
|
9
|
+
return Time.now-@start_time
|
10
|
+
end
|
11
|
+
|
12
|
+
def elapsed_str
|
13
|
+
elapsed_str="[" + "%.0f" %(elapsed) + "s]"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.elapsed_exceeds?(name,duration_seconds)
|
17
|
+
if(Timer.get_elapsed(name).nil? || Timer.get_elapsed(name) > duration_seconds)
|
18
|
+
return true
|
19
|
+
end
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.get_elapsed(name)
|
24
|
+
timestamp=get_timestamp(name)
|
25
|
+
return Time.now-timestamp if(!timestamp.nil?)
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.get_timestamp(name)
|
30
|
+
dir=Rake.application.original_dir
|
31
|
+
if(File.exists?("#{DEV[:dev_root]}/log/#{name}.timestamp"))
|
32
|
+
return Time.parse(File.read("#{DEV[:dev_root]}/log/#{name}.timestamp").strip)
|
33
|
+
end
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.set_timestamp(name)
|
38
|
+
Dir.mkdir("#{DEV_TASKS[:dev_root]}/log") if(!Dir.exists?("#{DEV_TASKS[:dev_root]}/log"))
|
39
|
+
File.open("#{DEV_TASKS[:dev_root]}/log/#{name}.timestamp",'w'){|f|f.puts(Time.now.to_s)}
|
40
|
+
end
|
41
41
|
end
|
data/lib/upgrade.rb
ADDED
data/spec/command_spec.rb
CHANGED
@@ -1,110 +1,110 @@
|
|
1
|
-
require_relative '../lib/command.rb'
|
2
|
-
require 'json'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
describe Command do
|
6
|
-
it "should be able to execute ruby --version command" do
|
7
|
-
cmd=Command.new("ruby --version")
|
8
|
-
# Timeout
|
9
|
-
expect(cmd[:timeout]).to eq(0)
|
10
|
-
cmd[:timeout]=3000
|
11
|
-
expect(cmd[:timeout]).to eq(3000)
|
12
|
-
|
13
|
-
# Directory
|
14
|
-
expect(cmd[:directory]).to eq("")
|
15
|
-
cmd[:directory] = File.dirname(__FILE__)
|
16
|
-
expect(cmd[:directory]).to eq(File.dirname(__FILE__))
|
17
|
-
|
18
|
-
# ExitCode
|
19
|
-
expect(cmd[:exit_code]).to eq(0)
|
20
|
-
cmd[:exit_code] = 1
|
21
|
-
expect(cmd[:exit_code]).to eq(1)
|
22
|
-
|
23
|
-
# Input
|
24
|
-
expect(cmd[:input]).to eq("ruby --version")
|
25
|
-
cmd2 = Command.new('')
|
26
|
-
expect(cmd2[:input]).to eq('')
|
27
|
-
|
28
|
-
# Output
|
29
|
-
expect(cmd[:output]).to eq('')
|
30
|
-
cmd[:output]='test'
|
31
|
-
expect(cmd[:output]).to eq('test')
|
32
|
-
|
33
|
-
# Error
|
34
|
-
expect(cmd[:error]).to eq('')
|
35
|
-
cmd[:error]='error_test'
|
36
|
-
expect(cmd[:error]).to eq('error_test')
|
37
|
-
|
38
|
-
# Machine
|
39
|
-
expect(cmd[:machine]).to eq('')
|
40
|
-
cmd[:machine]='machine_test'
|
41
|
-
expect(cmd[:machine]).to eq('machine_test')
|
42
|
-
|
43
|
-
# User
|
44
|
-
expect(cmd[:user]).to eq('')
|
45
|
-
cmd[:user]='user_test'
|
46
|
-
expect(cmd[:user]).to eq('user_test')
|
47
|
-
|
48
|
-
# StartTime
|
49
|
-
expect(cmd[:start_time]).to eq(nil)
|
50
|
-
cmd[:start_time]=Time.now
|
51
|
-
expect(cmd[:start_time]).not_to eq(nil)
|
52
|
-
|
53
|
-
# EndTime
|
54
|
-
expect(cmd[:end_time]).to eq(nil)
|
55
|
-
cmd[:end_time]=Time.now
|
56
|
-
expect(cmd[:end_time]).not_to eq(nil)
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should be able to write to/load from JSON" do
|
61
|
-
cmd=Command.new("ruby --version")
|
62
|
-
expect(cmd[:timeout]).to eq(0)
|
63
|
-
expect(cmd[:input]).to eq("ruby --version")
|
64
|
-
cmd2=Command.new(JSON.parse(cmd.to_json))
|
65
|
-
expect(cmd2[:timeout]).to eq(0)
|
66
|
-
expect(cmd2[:input]).to eq("ruby --version")
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should be able to execute rake command in specific directory" do
|
70
|
-
dir="#{File.dirname(__FILE__)}/tmp/rake_test"
|
71
|
-
FileUtils.mkdir_p(dir) if(!File.exists?(dir))
|
72
|
-
File.open("#{dir}/rakefile.rb","w") { |f|
|
73
|
-
f.puts "task :default do"
|
74
|
-
f.puts " puts 'rake_test'"
|
75
|
-
f.puts "end"
|
76
|
-
}
|
77
|
-
cmd=Command.new("rake")
|
78
|
-
cmd[:directory]=dir
|
79
|
-
cmd.execute
|
80
|
-
FileUtils.rm_r("#{File.dirname(__FILE__)}/tmp")
|
81
|
-
expect(cmd[:output].include?('rake_test')).to eq(true)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should be able to execute an array of commands" do
|
85
|
-
help=['git --help','rake --help','ruby --help']
|
86
|
-
help.execute
|
87
|
-
File.open('help.html','w'){|f|f.write(help.to_html)}
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should be able to execute a hash with arrays or commands" do
|
91
|
-
commands=Hash.new
|
92
|
-
commands[:help]=['git --help','rake --help','ruby --help']
|
93
|
-
commands[:version]=['git --version','rake --version','ruby --version']
|
94
|
-
commands.execute
|
95
|
-
File.open('commands.html','w'){|f|f.write(commands.to_html)}
|
96
|
-
end
|
97
|
-
|
98
|
-
it "hsould be able to get the output" do
|
99
|
-
expect(Command.output('git --version').include?('git version')).to eq(true)
|
100
|
-
expect(Command.output('bogus --version').include?('bogus version')).to eq(false)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should be able to get the exit_code" do
|
104
|
-
expect(Command.exit_code('rake --version')).to eq(0)
|
105
|
-
expect(Command.exit_code('bogus --version')).not_to eq(0)
|
106
|
-
end
|
107
|
-
#it "should fail this test" do
|
108
|
-
# expect(false).to eq(true)
|
109
|
-
#end
|
1
|
+
require_relative '../lib/command.rb'
|
2
|
+
require 'json'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
describe Command do
|
6
|
+
it "should be able to execute ruby --version command" do
|
7
|
+
cmd=Command.new("ruby --version")
|
8
|
+
# Timeout
|
9
|
+
expect(cmd[:timeout]).to eq(0)
|
10
|
+
cmd[:timeout]=3000
|
11
|
+
expect(cmd[:timeout]).to eq(3000)
|
12
|
+
|
13
|
+
# Directory
|
14
|
+
expect(cmd[:directory]).to eq("")
|
15
|
+
cmd[:directory] = File.dirname(__FILE__)
|
16
|
+
expect(cmd[:directory]).to eq(File.dirname(__FILE__))
|
17
|
+
|
18
|
+
# ExitCode
|
19
|
+
expect(cmd[:exit_code]).to eq(0)
|
20
|
+
cmd[:exit_code] = 1
|
21
|
+
expect(cmd[:exit_code]).to eq(1)
|
22
|
+
|
23
|
+
# Input
|
24
|
+
expect(cmd[:input]).to eq("ruby --version")
|
25
|
+
cmd2 = Command.new('')
|
26
|
+
expect(cmd2[:input]).to eq('')
|
27
|
+
|
28
|
+
# Output
|
29
|
+
expect(cmd[:output]).to eq('')
|
30
|
+
cmd[:output]='test'
|
31
|
+
expect(cmd[:output]).to eq('test')
|
32
|
+
|
33
|
+
# Error
|
34
|
+
expect(cmd[:error]).to eq('')
|
35
|
+
cmd[:error]='error_test'
|
36
|
+
expect(cmd[:error]).to eq('error_test')
|
37
|
+
|
38
|
+
# Machine
|
39
|
+
expect(cmd[:machine]).to eq('')
|
40
|
+
cmd[:machine]='machine_test'
|
41
|
+
expect(cmd[:machine]).to eq('machine_test')
|
42
|
+
|
43
|
+
# User
|
44
|
+
expect(cmd[:user]).to eq('')
|
45
|
+
cmd[:user]='user_test'
|
46
|
+
expect(cmd[:user]).to eq('user_test')
|
47
|
+
|
48
|
+
# StartTime
|
49
|
+
expect(cmd[:start_time]).to eq(nil)
|
50
|
+
cmd[:start_time]=Time.now
|
51
|
+
expect(cmd[:start_time]).not_to eq(nil)
|
52
|
+
|
53
|
+
# EndTime
|
54
|
+
expect(cmd[:end_time]).to eq(nil)
|
55
|
+
cmd[:end_time]=Time.now
|
56
|
+
expect(cmd[:end_time]).not_to eq(nil)
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should be able to write to/load from JSON" do
|
61
|
+
cmd=Command.new("ruby --version")
|
62
|
+
expect(cmd[:timeout]).to eq(0)
|
63
|
+
expect(cmd[:input]).to eq("ruby --version")
|
64
|
+
cmd2=Command.new(JSON.parse(cmd.to_json))
|
65
|
+
expect(cmd2[:timeout]).to eq(0)
|
66
|
+
expect(cmd2[:input]).to eq("ruby --version")
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should be able to execute rake command in specific directory" do
|
70
|
+
dir="#{File.dirname(__FILE__)}/tmp/rake_test"
|
71
|
+
FileUtils.mkdir_p(dir) if(!File.exists?(dir))
|
72
|
+
File.open("#{dir}/rakefile.rb","w") { |f|
|
73
|
+
f.puts "task :default do"
|
74
|
+
f.puts " puts 'rake_test'"
|
75
|
+
f.puts "end"
|
76
|
+
}
|
77
|
+
cmd=Command.new("rake")
|
78
|
+
cmd[:directory]=dir
|
79
|
+
cmd.execute
|
80
|
+
FileUtils.rm_r("#{File.dirname(__FILE__)}/tmp")
|
81
|
+
expect(cmd[:output].include?('rake_test')).to eq(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should be able to execute an array of commands" do
|
85
|
+
help=['git --help','rake --help','ruby --help']
|
86
|
+
help.execute
|
87
|
+
File.open('help.html','w'){|f|f.write(help.to_html)}
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should be able to execute a hash with arrays or commands" do
|
91
|
+
commands=Hash.new
|
92
|
+
commands[:help]=['git --help','rake --help','ruby --help']
|
93
|
+
commands[:version]=['git --version','rake --version','ruby --version']
|
94
|
+
commands.execute
|
95
|
+
File.open('commands.html','w'){|f|f.write(commands.to_html)}
|
96
|
+
end
|
97
|
+
|
98
|
+
it "hsould be able to get the output" do
|
99
|
+
expect(Command.output('git --version').include?('git version')).to eq(true)
|
100
|
+
expect(Command.output('bogus --version').include?('bogus version')).to eq(false)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should be able to get the exit_code" do
|
104
|
+
expect(Command.exit_code('rake --version')).to eq(0)
|
105
|
+
expect(Command.exit_code('bogus --version')).not_to eq(0)
|
106
|
+
end
|
107
|
+
#it "should fail this test" do
|
108
|
+
# expect(false).to eq(true)
|
109
|
+
#end
|
110
110
|
end
|