dev_commands 0.0.49 → 0.0.50

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,149 +1,149 @@
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({ :input => 'ruby --version', :quiet => true})
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({ :input => 'ruby --version', :quiet => true})
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 timeout" do
70
- cmd=Command.new({ :input => 'ftp', :timeout => 0.5, :ignore_failure => true, :quiet => true})
71
- cmd.execute
72
- expect(cmd[:exit_code]).not_to eq(0)
73
- end
74
-
75
- it "should be able to execute rake command in specific directory" do
76
- dir="#{File.dirname(__FILE__)}/tmp2/rake_test"
77
- FileUtils.mkpath(dir) if(!File.exists?(dir))
78
- File.open("#{dir}/rakefile.rb","w") { |f|
79
- f.puts "task :default do"
80
- f.puts " puts 'rake_test'"
81
- f.puts "end"
82
- f.close
83
- }
84
- expect(File.exists?("#{dir}/rakefile.rb")).to eq(true)
85
- cmd=Command.new({ :input => 'rake default', :quiet => true})#, :timeout => 2 })
86
- cmd[:directory]=dir
87
- expect(File.exists?(cmd[:directory])).to eq(true)
88
- cmd.execute
89
- #FileUtils.rm_r("#{File.dirname(__FILE__)}/tmp")
90
- #expect(cmd[:output].include?('rake_test')).to eq(true)
91
- FileUtils.rm_r(dir)
92
- end
93
-
94
- it "should fail when calling rake produces an error" do
95
- dir="#{File.dirname(__FILE__)}/tmp/rake_error_test"
96
- FileUtils.mkdir_p(dir) if(!File.exists?(dir))
97
- File.open("#{dir}/rakefile.rb","w") { |f|
98
- f.puts "task :default do"
99
- f.puts " raise 'rake_test'"
100
- f.puts "end"
101
- }
102
- cmd=Command.new({ :input => 'rake', :ignore_failure => true, :quiet => true})
103
- cmd[:directory]=dir
104
- expect(File.exists?(cmd[:directory])).to eq(true)
105
- cmd.execute({:quiet => true})
106
-
107
- expect(cmd[:exit_code]).not_to eq(0)
108
-
109
- cmd=Command.new({ :input => 'rake bogus', :ignore_failure => true, :quiet => true})
110
- cmd[:directory]=dir
111
- expect(File.exists?(cmd[:directory])).to eq(true)
112
- cmd.execute
113
- expect(cmd[:exit_code]).not_to eq(0)
114
-
115
- cmd=Command.new({ :input => 'rake bogus', :timeout => 3, :ignore_failure => true, :quiet => true})
116
- cmd[:directory]=dir
117
- cmd.execute
118
- expect(cmd[:exit_code]).not_to eq(0)
119
-
120
- FileUtils.rm_r("#{dir}")
121
- end
122
-
123
- it "should be able to execute an array of commands" do
124
- help=['git --help','rake --help','ruby --help']
125
- help.execute({:quiet => true})
126
- File.open('help.html','w'){|f|f.write(help.to_html)}
127
- end
128
-
129
- it "should be able to execute a hash with arrays or commands" do
130
- commands=Hash.new
131
- commands[:help]=['git --help','rake --help','ruby --help']
132
- commands[:version]=['git --version','rake --version','ruby --version']
133
- commands.execute({:quiet => true})
134
- File.open('commands.html','w'){|f|f.write(commands.to_html)}
135
- end
136
-
137
- it "should be able to get the output" do
138
- expect(Command.output('git --version').include?('git version')).to eq(true)
139
- expect(Command.output('bogus --version').include?('bogus version')).to eq(false)
140
- end
141
-
142
- it "should be able to get the exit_code" do
143
- expect(Command.exit_code('rake --version')).to eq(0)
144
- expect(Command.exit_code('bogus --version')).not_to eq(0)
145
- end
146
- #it "should fail this test" do
147
- # expect(false).to eq(true)
148
- #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({ :input => 'ruby --version', :quiet => true})
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({ :input => 'ruby --version', :quiet => true})
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 timeout" do
70
+ cmd=Command.new({ :input => 'ftp', :timeout => 0.5, :ignore_failure => true, :quiet => true})
71
+ cmd.execute
72
+ expect(cmd[:exit_code]).not_to eq(0)
73
+ end
74
+
75
+ it "should be able to execute rake command in specific directory" do
76
+ dir="#{File.dirname(__FILE__)}/tmp2/rake_test"
77
+ FileUtils.mkpath(dir) if(!File.exists?(dir))
78
+ File.open("#{dir}/rakefile.rb","w") { |f|
79
+ f.puts "task :default do"
80
+ f.puts " puts 'rake_test'"
81
+ f.puts "end"
82
+ f.close
83
+ }
84
+ expect(File.exists?("#{dir}/rakefile.rb")).to eq(true)
85
+ cmd=Command.new({ :input => 'rake default', :quiet => true})#, :timeout => 2 })
86
+ cmd[:directory]=dir
87
+ expect(File.exists?(cmd[:directory])).to eq(true)
88
+ cmd.execute
89
+ #FileUtils.rm_r("#{File.dirname(__FILE__)}/tmp")
90
+ #expect(cmd[:output].include?('rake_test')).to eq(true)
91
+ FileUtils.rm_r(dir)
92
+ end
93
+
94
+ it "should fail when calling rake produces an error" do
95
+ dir="#{File.dirname(__FILE__)}/tmp/rake_error_test"
96
+ FileUtils.mkdir_p(dir) if(!File.exists?(dir))
97
+ File.open("#{dir}/rakefile.rb","w") { |f|
98
+ f.puts "task :default do"
99
+ f.puts " raise 'rake_test'"
100
+ f.puts "end"
101
+ }
102
+ cmd=Command.new({ :input => 'rake', :ignore_failure => true, :quiet => true})
103
+ cmd[:directory]=dir
104
+ expect(File.exists?(cmd[:directory])).to eq(true)
105
+ cmd.execute({:quiet => true})
106
+
107
+ expect(cmd[:exit_code]).not_to eq(0)
108
+
109
+ cmd=Command.new({ :input => 'rake bogus', :ignore_failure => true, :quiet => true})
110
+ cmd[:directory]=dir
111
+ expect(File.exists?(cmd[:directory])).to eq(true)
112
+ cmd.execute
113
+ expect(cmd[:exit_code]).not_to eq(0)
114
+
115
+ cmd=Command.new({ :input => 'rake bogus', :timeout => 3, :ignore_failure => true, :quiet => true})
116
+ cmd[:directory]=dir
117
+ cmd.execute
118
+ expect(cmd[:exit_code]).not_to eq(0)
119
+
120
+ FileUtils.rm_r("#{dir}")
121
+ end
122
+
123
+ it "should be able to execute an array of commands" do
124
+ help=['git --help','rake --help','ruby --help']
125
+ help.execute({:quiet => true})
126
+ File.open('help.html','w'){|f|f.write(help.to_html)}
127
+ end
128
+
129
+ it "should be able to execute a hash with arrays or commands" do
130
+ commands=Hash.new
131
+ commands[:help]=['git --help','rake --help','ruby --help']
132
+ commands[:version]=['git --version','rake --version','ruby --version']
133
+ commands.execute({:quiet => true})
134
+ File.open('commands.html','w'){|f|f.write(commands.to_html)}
135
+ end
136
+
137
+ it "should be able to get the output" do
138
+ expect(Command.output('git --version').include?('git version')).to eq(true)
139
+ expect(Command.output('bogus --version').include?('bogus version')).to eq(false)
140
+ end
141
+
142
+ it "should be able to get the exit_code" do
143
+ expect(Command.exit_code('rake --version')).to eq(0)
144
+ expect(Command.exit_code('bogus --version')).not_to eq(0)
145
+ end
146
+ #it "should fail this test" do
147
+ # expect(false).to eq(true)
148
+ #end
149
149
  end
@@ -1,28 +1,28 @@
1
- require_relative '../lib/publish.rb'
2
- require 'rake'
3
- describe Publish do
4
- it "should be able to publish file to subversion" do
5
- #FileUtils.rm_r('tmp') if(File.exists?('tmp'))
6
- #FileUtils.mkdir('tmp') if(!File.exists?('tmp'))
7
- #svn_repo="file:///#{Rake.application.original_dir}/tmp/svn_test_repo"
8
- #Dir.chdir('tmp') do
9
- #FileUtils.rm_r('tmp/svn_test_repo') if File.exists?('tmp/svn_test_repo')
10
- #puts `svnadmin create svn_test_repo`
11
- #expect(File.exists?('svn_test_repo')).to eq(true)
12
-
13
- #FileUtils.mkdir('publish') if(!File.exists?('publish'))
14
- #File.open('publish/file1.txt','w'){|f|f.write('abc')}
15
- #File.open('publish/file2.txt','w'){|f|f.write('def')}
16
-
17
-
18
- #expect(Command.exit_code('svn info #{svn_repo}/publish_test')).not_to eq(0)
19
- #Publish.to_subversion(FileList.new('publish/*.txt'),"#{svn_repo}/publish_test")
20
- #expect(Command.exit_code('svn info #{svn_repo}/publish_test')).to eq(0)
21
-
22
- #{}`svn checkout #{svn_repo} svn_test`
23
- #expect(File.exists?('svn_test'))
24
- #end
25
-
26
-
27
- end
1
+ require_relative '../lib/publish.rb'
2
+ require 'rake'
3
+ describe Publish do
4
+ it "should be able to publish file to subversion" do
5
+ #FileUtils.rm_r('tmp') if(File.exists?('tmp'))
6
+ #FileUtils.mkdir('tmp') if(!File.exists?('tmp'))
7
+ #svn_repo="file:///#{Rake.application.original_dir}/tmp/svn_test_repo"
8
+ #Dir.chdir('tmp') do
9
+ #FileUtils.rm_r('tmp/svn_test_repo') if File.exists?('tmp/svn_test_repo')
10
+ #puts `svnadmin create svn_test_repo`
11
+ #expect(File.exists?('svn_test_repo')).to eq(true)
12
+
13
+ #FileUtils.mkdir('publish') if(!File.exists?('publish'))
14
+ #File.open('publish/file1.txt','w'){|f|f.write('abc')}
15
+ #File.open('publish/file2.txt','w'){|f|f.write('def')}
16
+
17
+
18
+ #expect(Command.exit_code('svn info #{svn_repo}/publish_test')).not_to eq(0)
19
+ #Publish.to_subversion(FileList.new('publish/*.txt'),"#{svn_repo}/publish_test")
20
+ #expect(Command.exit_code('svn info #{svn_repo}/publish_test')).to eq(0)
21
+
22
+ #{}`svn checkout #{svn_repo} svn_test`
23
+ #expect(File.exists?('svn_test'))
24
+ #end
25
+
26
+
27
+ end
28
28
  end
@@ -1,12 +1,12 @@
1
- require_relative('../../lib/dev_commands.rb')
2
-
3
- CLOBBER.include('csharp-library/bin','csharp-library/obj','cpp-library/bin','cpp-library/obj')
4
- desc 'build'
5
- task :build do
6
- COMMANDS[:build].update
7
- COMMANDS[:build].execute
8
- end
9
-
10
- task :default do
11
- COMMANDS.execute
1
+ require_relative('../../lib/dev_commands.rb')
2
+
3
+ CLOBBER.include('csharp-library/bin','csharp-library/obj','cpp-library/bin','cpp-library/obj')
4
+ desc 'build'
5
+ task :build do
6
+ COMMANDS[:build].update
7
+ COMMANDS[:build].execute
8
+ end
9
+
10
+ task :default do
11
+ COMMANDS.execute
12
12
  end
@@ -1,12 +1,12 @@
1
- require_relative('../../lib/dev_commands.rb')
2
-
3
- CLOBBER.include('csharp-library/bin','csharp-library/obj','cpp-library/bin','cpp-library/obj')
4
- desc 'build'
5
- task :build do
6
- COMMANDS[:build].update
7
- COMMANDS[:build].execute
8
- end
9
-
10
- task :default do
11
- COMMANDS.execute
1
+ require_relative('../../lib/dev_commands.rb')
2
+
3
+ CLOBBER.include('csharp-library/bin','csharp-library/obj','cpp-library/bin','cpp-library/obj')
4
+ desc 'build'
5
+ task :build do
6
+ COMMANDS[:build].update
7
+ COMMANDS[:build].execute
8
+ end
9
+
10
+ task :default do
11
+ COMMANDS.execute
12
12
  end
@@ -1,12 +1,12 @@
1
- require_relative '../lib/text.rb'
2
-
3
- describe Text do
4
- it "should be able to replace text in file" do
5
- FileUtils.mkdir('tmp') if(!File.exists?('tmp'))
6
- File.open('tmp/test.txt','w'){|f|
7
- f.write("test thing")
8
- }
9
- Text.replace_in_file('tmp/test.txt','thing','string')
10
- expect(IO.read('tmp/test.txt').include?('test string')).to eq(true)
11
- end
1
+ require_relative '../lib/text.rb'
2
+
3
+ describe Text do
4
+ it "should be able to replace text in file" do
5
+ FileUtils.mkdir('tmp') if(!File.exists?('tmp'))
6
+ File.open('tmp/test.txt','w'){|f|
7
+ f.write("test thing")
8
+ }
9
+ Text.replace_in_file('tmp/test.txt','thing','string')
10
+ expect(IO.read('tmp/test.txt').include?('test string')).to eq(true)
11
+ end
12
12
  end
metadata CHANGED
@@ -1,69 +1,78 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.49
4
+ version: 0.0.50
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Lou Parslow
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-01-19 00:00:00.000000000 Z
12
+ date: 2015-01-21 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '10.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
29
  version: '10.0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rspec
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - "~>"
35
+ - - ~>
32
36
  - !ruby/object:Gem::Version
33
37
  version: '3.0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - "~>"
43
+ - - ~>
39
44
  - !ruby/object:Gem::Version
40
45
  version: '3.0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: yard
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - "~>"
51
+ - - ~>
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0.8'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - "~>"
59
+ - - ~>
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0.8'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: bundler
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - "~>"
67
+ - - ~>
60
68
  - !ruby/object:Gem::Version
61
69
  version: '1.7'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - "~>"
75
+ - - ~>
67
76
  - !ruby/object:Gem::Version
68
77
  version: '1.7'
69
78
  description: execution of system commands
@@ -72,8 +81,6 @@ executables: []
72
81
  extensions: []
73
82
  extra_rdoc_files: []
74
83
  files:
75
- - LICENSE
76
- - README.md
77
84
  - lib/add.rb
78
85
  - lib/analyze.rb
79
86
  - lib/array.rb
@@ -98,39 +105,41 @@ files:
98
105
  - lib/test.rb
99
106
  - lib/text.rb
100
107
  - lib/timeout.rb
101
- - lib/timer.rb
108
+ - lib/Timer.rb
102
109
  - lib/update.rb
103
110
  - lib/upgrade.rb
104
- - spec/command_spec.rb
105
111
  - spec/commands_spec.rb
112
+ - spec/command_spec.rb
106
113
  - spec/gem-example/rakefile.rb
107
114
  - spec/publish_spec.rb
108
115
  - spec/sln-vs12-example/rakefile.rb
109
116
  - spec/sln-vs9-example/rakefile.rb
110
117
  - spec/text_spec.rb
118
+ - LICENSE
119
+ - README.md
111
120
  homepage: http://github.com/lou-parslow/dev_commands.gem
112
121
  licenses:
113
122
  - Apache 2.0
114
- metadata: {}
115
123
  post_install_message:
116
124
  rdoc_options: []
117
125
  require_paths:
118
126
  - lib
119
127
  required_ruby_version: !ruby/object:Gem::Requirement
128
+ none: false
120
129
  requirements:
121
- - - ">="
130
+ - - ! '>='
122
131
  - !ruby/object:Gem::Version
123
132
  version: '0'
124
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
+ none: false
125
135
  requirements:
126
- - - ">="
136
+ - - ! '>='
127
137
  - !ruby/object:Gem::Version
128
138
  version: '0'
129
139
  requirements: []
130
140
  rubyforge_project:
131
- rubygems_version: 2.2.2
141
+ rubygems_version: 1.8.24
132
142
  signing_key:
133
- specification_version: 4
143
+ specification_version: 3
134
144
  summary: gem to execute system commands
135
145
  test_files: []
136
- has_rdoc: