dev_tasks 1.0.29 → 1.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/commandarray.rb +11 -11
- data/lib/commands.rb +62 -62
- data/lib/dev_tasks.rb +1 -0
- data/lib/environment.rb +9 -46
- data/lib/spec.json +1 -1
- metadata +30 -4
- data/lib/command.rb +0 -59
- data/spec/command_spec.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db922a39250ac09b7944b49bfc4fc4e9d8763833
|
4
|
+
data.tar.gz: 247d97acea28c9e29f089e117c026d2cc9f07ef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c98904b25f75b7fb9fcf6a9759a2af7b9eb5a45a03fd3123fefcf438f1f355505c8d237803bfc2dde4e94c354c63b9dcdab7329125ff33954bfaab3c8321007
|
7
|
+
data.tar.gz: 01b30177a4042eb7a51cd08a587e59664499f6447d3a22cbd0f76923d910deadc1970bbda747fa0dce24c463efbb2cc6fdbc0e00cb7433a1e1677370eb95b739
|
data/lib/commandarray.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require_relative './command.rb'
|
1
|
+
#require_relative './command.rb'
|
2
2
|
|
3
3
|
class CommandArray < Array
|
4
4
|
|
5
|
-
def update
|
6
|
-
end
|
5
|
+
#def update
|
6
|
+
#end
|
7
7
|
|
8
8
|
def add command
|
9
9
|
self << command if(!include?(command))
|
10
10
|
end
|
11
11
|
|
12
|
-
def execute
|
13
|
-
i=0
|
14
|
-
while i < self.length
|
15
|
-
self[i]=Command.new(self[i]) if(self[i].is_a?(String))
|
16
|
-
self[i].execute
|
17
|
-
i=i+1
|
18
|
-
end
|
19
|
-
end
|
12
|
+
# def execute
|
13
|
+
# i=0
|
14
|
+
# while i < self.length
|
15
|
+
# self[i]=Command.new(self[i]) if(self[i].is_a?(String))
|
16
|
+
# self[i].execute
|
17
|
+
# i=i+1
|
18
|
+
# end
|
19
|
+
# end
|
20
20
|
|
21
21
|
end
|
data/lib/commands.rb
CHANGED
@@ -1,63 +1,63 @@
|
|
1
|
-
require_relative './build.rb'
|
2
|
-
require_relative './test.rb'
|
3
|
-
require_relative './add.rb'
|
4
|
-
require_relative './commit.rb'
|
5
|
-
require_relative './publish.rb'
|
6
|
-
require_relative './pull.rb'
|
7
|
-
require_relative './push.rb'
|
8
|
-
require_relative './setup.rb'
|
9
|
-
require_relative './upgrade.rb'
|
10
|
-
require_relative './timer.rb'
|
11
|
-
require_relative './verify.rb'
|
12
|
-
|
13
|
-
class Commands < Hash
|
14
|
-
attr_accessor :build
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
self[:pull] = Pull.new if(Environment.scm=='git' && Environment.scm_origin.length > 0)
|
18
|
-
self[:upgrade] = Upgrade.new
|
19
|
-
self[:setup] = Setup.new
|
20
|
-
self[:build] = Build.new
|
21
|
-
self[:test] = Test.new
|
22
|
-
self[:add] = Add.new
|
23
|
-
self[:commit] = Commit.new
|
24
|
-
self[:push] = Push.new
|
25
|
-
self[:verify] = Verify.new
|
26
|
-
self[:publish] = Publish.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def update
|
30
|
-
self[:upgrade].update
|
31
|
-
self[:setup].update
|
32
|
-
self[:build].update
|
33
|
-
self[:verify].update
|
34
|
-
self[:publish].update
|
35
|
-
end
|
36
|
-
|
37
|
-
def execute_task task
|
38
|
-
sym_task = task.to_sym
|
39
|
-
if(self.has_key?(sym_task))
|
40
|
-
self[sym_task].update
|
41
|
-
if(self[sym_task].length>0)
|
42
|
-
Logger.start_task task
|
43
|
-
self[sym_task].execute
|
44
|
-
Logger.end_task task
|
45
|
-
else
|
46
|
-
self.delete sym_task
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def show
|
53
|
-
self.each do |key,array|
|
54
|
-
if(array.length > 0)
|
55
|
-
puts key
|
56
|
-
array.each {|v|
|
57
|
-
puts " " + Color.green + v + Color.clear + " "
|
58
|
-
}
|
59
|
-
end
|
60
|
-
end
|
61
|
-
puts " "
|
62
|
-
end
|
1
|
+
require_relative './build.rb'
|
2
|
+
require_relative './test.rb'
|
3
|
+
require_relative './add.rb'
|
4
|
+
require_relative './commit.rb'
|
5
|
+
require_relative './publish.rb'
|
6
|
+
require_relative './pull.rb'
|
7
|
+
require_relative './push.rb'
|
8
|
+
require_relative './setup.rb'
|
9
|
+
require_relative './upgrade.rb'
|
10
|
+
require_relative './timer.rb'
|
11
|
+
require_relative './verify.rb'
|
12
|
+
|
13
|
+
class Commands < Hash
|
14
|
+
attr_accessor :build
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
self[:pull] = Pull.new if(Environment.scm=='git' && Environment.scm_origin.length > 0)
|
18
|
+
self[:upgrade] = Upgrade.new
|
19
|
+
self[:setup] = Setup.new
|
20
|
+
self[:build] = Build.new
|
21
|
+
self[:test] = Test.new
|
22
|
+
self[:add] = Add.new
|
23
|
+
self[:commit] = Commit.new
|
24
|
+
self[:push] = Push.new
|
25
|
+
self[:verify] = Verify.new
|
26
|
+
self[:publish] = Publish.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
self[:upgrade].update
|
31
|
+
self[:setup].update
|
32
|
+
self[:build].update
|
33
|
+
self[:verify].update
|
34
|
+
self[:publish].update
|
35
|
+
end
|
36
|
+
|
37
|
+
def execute_task task
|
38
|
+
sym_task = task.to_sym
|
39
|
+
if(self.has_key?(sym_task))
|
40
|
+
self[sym_task].update if self[sym_task].respond_to?(:update)
|
41
|
+
if(self[sym_task].length>0)
|
42
|
+
Logger.start_task task
|
43
|
+
self[sym_task].execute
|
44
|
+
Logger.end_task task
|
45
|
+
else
|
46
|
+
self.delete sym_task
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def show
|
53
|
+
self.each do |key,array|
|
54
|
+
if(array.length > 0)
|
55
|
+
puts key
|
56
|
+
array.each {|v|
|
57
|
+
puts " " + Color.green + v + Color.clear + " "
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
puts " "
|
62
|
+
end
|
63
63
|
end
|
data/lib/dev_tasks.rb
CHANGED
data/lib/environment.rb
CHANGED
@@ -2,18 +2,15 @@
|
|
2
2
|
|
3
3
|
class Environment #S< Hash#.class_eval do #< Hash do
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
end
|
7
|
-
|
8
5
|
def self.scm
|
9
6
|
return "git" if(Dir.exists?(".git"))
|
10
|
-
|
11
|
-
|
7
|
+
return "svn" if(Dir.exists?(".svn"))
|
8
|
+
"none"
|
12
9
|
end
|
13
10
|
|
14
11
|
def self.copy src,dest
|
15
12
|
FileUtils.mkdir_p File.dirname(dest) if !File.exists?(File.dirname(dest))
|
16
|
-
|
13
|
+
FileUtils.cp(src,dest)
|
17
14
|
end
|
18
15
|
|
19
16
|
def self.copy_files files,dest
|
@@ -59,40 +56,6 @@ class Environment #S< Hash#.class_eval do #< Hash do
|
|
59
56
|
"0"
|
60
57
|
end
|
61
58
|
|
62
|
-
def self.dev_root
|
63
|
-
["DEV_HOME","DEV_ROOT"].each {|v|
|
64
|
-
return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
65
|
-
}
|
66
|
-
dir=home
|
67
|
-
dir=ENV["DEV_ROOT"].gsub('\\','/') unless ENV["DEV_ROOT"].nil?
|
68
|
-
return dir
|
69
|
-
end
|
70
|
-
#
|
71
|
-
def self.home
|
72
|
-
["USERPROFILE","HOME"].each {|v|
|
73
|
-
return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
74
|
-
}
|
75
|
-
dir="~"
|
76
|
-
dir=ENV["HOME"] unless ENV["HOME"].nil?
|
77
|
-
dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
|
78
|
-
return dir
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.machine
|
82
|
-
if !ENV['COMPUTERNAME'].nil?
|
83
|
-
return ENV['COMPUTERNAME']
|
84
|
-
end
|
85
|
-
|
86
|
-
machine = `hostname`
|
87
|
-
machine = machine.split('.')[0] if machine.include?('.')
|
88
|
-
return machine.strip
|
89
|
-
end
|
90
|
-
|
91
|
-
def self.user
|
92
|
-
return ENV['USER'] if !ENV['USER'].nil? #on Unix
|
93
|
-
ENV['USERNAME']
|
94
|
-
end
|
95
|
-
|
96
59
|
def self.working_directory
|
97
60
|
Rake.application.original_dir
|
98
61
|
end
|
@@ -153,10 +116,10 @@ class Environment #S< Hash#.class_eval do #< Hash do
|
|
153
116
|
end
|
154
117
|
end
|
155
118
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
puts `#{cmd}`
|
160
|
-
puts timer.elapsed_str
|
161
|
-
end
|
119
|
+
# def self.execute(cmd)
|
120
|
+
# timer=Timer.new
|
121
|
+
# puts "executing " + cmd
|
122
|
+
# puts `#{cmd}`
|
123
|
+
# puts timer.elapsed_str
|
124
|
+
# end
|
162
125
|
end
|
data/lib/spec.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"dev_tasks","version":"1.0.
|
1
|
+
{"name":"dev_tasks","version":"1.0.30"}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lou Parslow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dev_commands
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: dev_environment
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - '>='
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: dev_commands
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
description: defines rake tasks for ruby and C# projects
|
112
140
|
email: lou.parslow@gmail.com
|
113
141
|
executables: []
|
@@ -118,7 +146,6 @@ files:
|
|
118
146
|
- lib/artifacts.x.rb
|
119
147
|
- lib/build.rb
|
120
148
|
- lib/color.rb
|
121
|
-
- lib/command.rb
|
122
149
|
- lib/commandarray.rb
|
123
150
|
- lib/commands.rb
|
124
151
|
- lib/commit.rb
|
@@ -144,7 +171,6 @@ files:
|
|
144
171
|
- lib/verify.rb
|
145
172
|
- lib/yamllog.rb
|
146
173
|
- lib/spec.json
|
147
|
-
- spec/command_spec.rb
|
148
174
|
- spec/dependencies_spec.rb
|
149
175
|
- spec/dev_tasks_spec.rb
|
150
176
|
- spec/environment_spec.rb
|
data/lib/command.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
class Command < Hash
|
2
|
-
def initialize command
|
3
|
-
|
4
|
-
if(command.kind_of?(String))
|
5
|
-
self[:input] = command
|
6
|
-
self[:timeout] = 0
|
7
|
-
self[:directory] = ''
|
8
|
-
self[:exit_code] = 0
|
9
|
-
self[:output] = ''
|
10
|
-
self[:error] = ''
|
11
|
-
self[:machine_name] = ''
|
12
|
-
self[:user_name] = ''
|
13
|
-
self[:start_time] = nil
|
14
|
-
self[:end_time] = nil
|
15
|
-
end
|
16
|
-
|
17
|
-
if(command.kind_of?(Hash))
|
18
|
-
command.each{|k,v|
|
19
|
-
self[k.to_sym]=v
|
20
|
-
}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def execute
|
25
|
-
|
26
|
-
Logger.start_command self
|
27
|
-
|
28
|
-
pwd=Dir.pwd
|
29
|
-
Dir.chdir(self[:directory]) if(self.has_key?(:directory) && File.exists?(self[:directory]))
|
30
|
-
#print " " + Color.green + self[:input] + Color.clear
|
31
|
-
|
32
|
-
self[:start_time]=Time.now
|
33
|
-
timer=Timer.new
|
34
|
-
if self[:input].include?('<%') && self[:input].include?('%>')
|
35
|
-
ruby = self[:input].gsub("<%","").gsub("%>","")
|
36
|
-
|
37
|
-
begin
|
38
|
-
puts "eval(#{ruby})"
|
39
|
-
self[:output]=eval(ruby)
|
40
|
-
rescue
|
41
|
-
puts "unable to eval(#{ruby})"
|
42
|
-
raise "unable to eval(#{ruby})"
|
43
|
-
end
|
44
|
-
|
45
|
-
#puts " " + timer.elapsed_str
|
46
|
-
self[:elapsed] = timer.elapsed_str
|
47
|
-
self[:end_time] = Time.now
|
48
|
-
else
|
49
|
-
self[:output] = `#{self[:input]}`
|
50
|
-
self[:elapsed] = timer.elapsed_str
|
51
|
-
self[:end_time] = Time.now
|
52
|
-
self[:exit_code]=$?.to_i
|
53
|
-
end
|
54
|
-
|
55
|
-
Dir.chdir(pwd) if pwd != Dir.pwd
|
56
|
-
Logger.end_command self
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
data/spec/command_spec.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require_relative '../lib/command.rb'
|
2
|
-
|
3
|
-
describe Command do
|
4
|
-
it "should be able to execute ruby --version command" do
|
5
|
-
cmd=Command.new("ruby --version")
|
6
|
-
# Timeout
|
7
|
-
expect(cmd[:timeout]).to eq(0)
|
8
|
-
cmd[:timeout]=3000
|
9
|
-
expect(cmd[:timeout]).to eq(3000)
|
10
|
-
|
11
|
-
# Directory
|
12
|
-
expect(cmd[:directory]).to eq("")
|
13
|
-
cmd[:directory] = File.dirname(__FILE__)
|
14
|
-
expect(cmd[:directory]).to eq(File.dirname(__FILE__))
|
15
|
-
|
16
|
-
# ExitCode
|
17
|
-
expect(cmd[:exit_code]).to eq(0)
|
18
|
-
cmd[:exit_code] = 1
|
19
|
-
expect(cmd[:exit_code]).to eq(1)
|
20
|
-
|
21
|
-
# Input
|
22
|
-
expect(cmd[:input]).to eq("ruby --version")
|
23
|
-
cmd2 = Command.new('')
|
24
|
-
expect(cmd2[:input]).to eq('')
|
25
|
-
|
26
|
-
# Output
|
27
|
-
expect(cmd[:output]).to eq('')
|
28
|
-
cmd[:output]='test'
|
29
|
-
expect(cmd[:output]).to eq('test')
|
30
|
-
|
31
|
-
# Error
|
32
|
-
expect(cmd[:error]).to eq('')
|
33
|
-
cmd[:error]='error_test'
|
34
|
-
expect(cmd[:error]).to eq('error_test')
|
35
|
-
|
36
|
-
# MachineName
|
37
|
-
expect(cmd[:machine_name]).to eq('')
|
38
|
-
cmd[:machine_name]='machine_name_test'
|
39
|
-
expect(cmd[:machine_name]).to eq('machine_name_test')
|
40
|
-
|
41
|
-
# UserName
|
42
|
-
expect(cmd[:user_name]).to eq('')
|
43
|
-
cmd[:user_name]='user_name_test'
|
44
|
-
expect(cmd[:user_name]).to eq('user_name_test')
|
45
|
-
|
46
|
-
# StartTime
|
47
|
-
expect(cmd[:start_time]).to eq(nil)
|
48
|
-
cmd[:start_time]=Time.now
|
49
|
-
expect(cmd[:start_time]).not_to eq(nil)
|
50
|
-
|
51
|
-
# EndTime
|
52
|
-
expect(cmd[:end_time]).to eq(nil)
|
53
|
-
cmd[:end_time]=Time.now
|
54
|
-
expect(cmd[:end_time]).not_to eq(nil)
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should be able to write to/load from JSON" do
|
59
|
-
cmd=Command.new("ruby --version")
|
60
|
-
expect(cmd[:timeout]).to eq(0)
|
61
|
-
expect(cmd[:input]).to eq("ruby --version")
|
62
|
-
cmd2=Command.new(JSON.parse(cmd.to_json))
|
63
|
-
expect(cmd2[:timeout]).to eq(0)
|
64
|
-
expect(cmd2[:input]).to eq("ruby --version")
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should be able to execute rake command in specific directory" do
|
68
|
-
dir="#{DEV[:dev_root]}/tmp/rake_test"
|
69
|
-
FileUtils.mkdir_p(dir) if(!File.exists?(dir))
|
70
|
-
File.open("#{dir}/rakefile.rb","w") { |f|
|
71
|
-
f.puts "task :default do"
|
72
|
-
f.puts " puts 'rake_test'"
|
73
|
-
f.puts "end"
|
74
|
-
}
|
75
|
-
cmd=Command.new("rake")
|
76
|
-
cmd[:directory]=dir
|
77
|
-
cmd.execute
|
78
|
-
expect(cmd[:output].include?('rake_test')).to eq(true)
|
79
|
-
end
|
80
|
-
end
|