dev_commands 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/gemspec.rb CHANGED
@@ -1,36 +1,36 @@
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"
11
- end
12
-
13
- def self.version gemspec_file
14
- spec=Gem::Specification.load(gemspec_file)
15
- return spec.version.to_s
16
- end
17
-
18
- def self.published_version gemspec_file
19
- published_version=''
20
- spec=Gem::Specification.load(gemspec_file)
21
- begin
22
- published_version = `gem list #{spec.name} -r`.scan(/\((\d+.\d+.\d+)\)/)[0][0]
23
- rescue
24
- published_version=''
25
- end
26
- published_version
27
- end
28
- def self.published? gemspec_file
29
- published_version(gemspec_file)==version(gemspec_file) ? true : false
30
- end
31
-
32
- def self.normalize gemspec_file
33
- spec=Gem::Specification.load(gemspec_file)
34
- File.open(gemspec_file,'w'){|f|f.write(spec.to_ruby)}
35
- end
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"
11
+ end
12
+
13
+ def self.version gemspec_file
14
+ spec=Gem::Specification.load(gemspec_file)
15
+ return spec.version.to_s
16
+ end
17
+
18
+ def self.published_version gemspec_file
19
+ published_version=''
20
+ spec=Gem::Specification.load(gemspec_file)
21
+ begin
22
+ published_version = `gem list -r #{spec.name} -r`.scan(/\((\d+.\d+.\d+)\)/)[0][0]
23
+ rescue
24
+ published_version=''
25
+ end
26
+ published_version
27
+ end
28
+ def self.published? gemspec_file
29
+ published_version(gemspec_file)==version(gemspec_file) ? true : false
30
+ end
31
+
32
+ def self.normalize gemspec_file
33
+ spec=Gem::Specification.load(gemspec_file)
34
+ File.open(gemspec_file,'w'){|f|f.write(spec.to_ruby)}
35
+ end
36
36
  end
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 ADDED
@@ -0,0 +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
17
+ end
data/lib/msbuild.rb CHANGED
@@ -8,6 +8,24 @@ class MSBuild < Hash
8
8
  self[:vs9]="C:\\Windows\\Microsoft.NET\\Framework\\v3.5\\msbuild.exe" if(File.exists?("C:\\Windows\\Microsoft.NET\\Framework\\v3.5\\msbuild.exe"))
9
9
  self[:vs12]="C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\msbuild.exe" if(File.exists?("C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\msbuild.exe"))
10
10
  end
11
+
12
+ def self.has_version? version
13
+ if(defined?(MSBUILD))
14
+ MSBUILD.has_key?(version)
15
+ else
16
+ msb=MSBuild.new
17
+ return msb.has_key? version
18
+ end
19
+ end
20
+
21
+ def self.get_version version
22
+ if(defined?(MSBUILD))
23
+ MSBUILD[version]
24
+ else
25
+ msb=MSBuild.new
26
+ return msb[version]
27
+ end
28
+ end
11
29
 
12
30
  def self.get_vs_version(sln_filename)
13
31
  sln_text=File.read(sln_filename,:encoding=>'UTF-8')
data/lib/publish.rb CHANGED
@@ -1,7 +1,10 @@
1
- class Publish < Array
2
- def update
3
- Dir.glob('*.gemspec').each{|gemspec_file|
4
- add "gem push #{Gemspec.gemfile(gemspec_file)}" if !Gemspec.published? gemspec_file
5
- }
6
- end
1
+ require_relative('internet.rb')
2
+ class Publish < Array
3
+ def update
4
+ if(Internet.available?)
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
7
10
  end
data/lib/pull.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  require_relative('git.rb')
2
+ require_relative('internet.rb')
2
3
 
3
4
  class Pull < Array
4
5
  def update
5
- if(File.exists?('.git') && `git config --list`.include?('user.name='))
6
- self << 'git pull' if Git.branch != 'develop'
6
+ if(Internet.available?)
7
+ if(File.exists?('.git') && `git config --list`.include?('user.name='))
8
+ self << 'git pull' if Git.branch != 'develop'
9
+ end
7
10
  end
8
11
  end
9
12
  end
data/lib/push.rb CHANGED
@@ -1,8 +1,9 @@
1
- class Push < Array
2
- def update
3
- if(File.exists?('.git') && `git config --list`.include?('user.name='))
4
- add 'git config --global push.default simple'
5
- self << 'git push' if Git.branch != 'develop'
6
- end
7
- 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
8
9
  end
data/lib/setup.rb CHANGED
@@ -1,9 +1,25 @@
1
- class Setup < Array
2
- def update
3
- add 'bundle install' if(File.exists?('Gemfile'))
4
-
5
- Dir.glob('*.gemspec').each{|gemspec_file|
6
- add "<%Gemspec.update('#{gemspec_file}')%>"
7
- }
8
- 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
9
25
  end
data/lib/test.rb CHANGED
@@ -1,5 +1,50 @@
1
- class Test < Array
2
- def update
3
- add 'rspec' if File.exists?('spec')
4
- end
1
+ #
2
+ # nunit dlls may be specified with
3
+ # NUNIT=FileList.new('**/*.Test.dll')
4
+ #
5
+ # for nunit dlls that must be run in x86 mode,
6
+ # NUNIT_x86=FileList.new('**/*.x86.Test.dll')
7
+ #
8
+ class Test < Array
9
+ def update
10
+ add 'rspec' if File.exists?('spec')
11
+
12
+ if(defined?(NUNIT))
13
+ NUNIT.each{|nunit_dll|
14
+ add "\"#{Test.nunit_console}\" \"#{Rake.application.original_dir}\\#{nunit_dll}\" /xml:\"#{nunit_dll}.TestResults.xml\""
15
+ }
16
+ end
17
+
18
+ if(defined?(NUNIT_X86))
19
+ NUNIT_X86.each{|nunit_dll|
20
+ add "\"#{Test.nunit_console_x86}\" \"#{Rake.application.original_dir}\\#{nunit_dll}\" /xml:\"#{nunit_dll}.TestResults.xml\""
21
+ }
22
+ end
23
+ end
24
+
25
+ @@nunit_console=''
26
+ def self.nunit_console
27
+ if(!File.exists?(@@nunit_console))
28
+ @@nunit_console = NUNIT_CONSOLE if(defined(NUNIT_CONSOLE))
29
+ @@nunit_console = "C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console.exe" if(!File.exists?(@@nunit_console))
30
+ @@nunit_console = "C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console.exe" if(!File.exists?(@@nunit_console))
31
+ end
32
+ if(!File.exists?(@@nunit_console))
33
+ raise "unable to locate nunit-console.exe, assign NUNIT_CONSOLE to the correct location."
34
+ end
35
+ @@nunit_console
36
+ end
37
+
38
+ @@nunit_console_x86=''
39
+ def self.nunit_console_x86
40
+ if(!File.exists?(@@nunit_console_x86))
41
+ @@nunit_console_x86 = NUNIT_CONSOLE_X86 if(defined(NUNIT_CONSOLE_X86))
42
+ @@nunit_console_x86 = "C:\\Program Files (x86)\\NUnit 2.6.4\\bin\\nunit-console-x86.exe" if(!File.exists?(@@nunit_console_x86))
43
+ @@nunit_console_x86 = "C:\\Program Files (x86)\\NUnit 2.6.3\\bin\\nunit-console-x86.exe" if(!File.exists?(@@nunit_console_x86))
44
+ end
45
+ if(!File.exists?(@@nunit_console_x86))
46
+ raise "unable to locate nunit-console-x86.exe, assign NUNIT_CONSOLE_X86 to the correct location."
47
+ end
48
+ @@nunit_console_x86
49
+ end
5
50
  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_text_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/update.rb CHANGED
@@ -1,5 +1,6 @@
1
+ require_relative('internet.rb')
1
2
  class Update < Array
2
3
  def update
3
- self .add 'svn update' if File.exists?('.svn')
4
+ self .add 'svn update' if File.exists?('.svn') && Internet.available?
4
5
  end
5
6
  end
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