dev_commands 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
data/lib/add.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class Add < Array
2
2
  def update
3
3
  if(File.exists?('.gitignore'))
4
- add 'git add --all'
4
+ add 'git add --all :/'
5
5
  else
6
6
  if(defined?(SOURCE))
7
7
  if(File.exists?('.svn'))
@@ -9,7 +9,6 @@ class Add < Array
9
9
 
10
10
  add "svn add #{f} --parents" if Command.output("svn status #{f}").include?('?')
11
11
  add "svn add #{f} --parents" if Command.exit_code("svn status #{f}") != 0
12
- #add "svn add #{f} --parents" if status.include?('?') || status.include?(n)
13
12
  }
14
13
  end
15
14
  if(File.exists?('.git'))
data/lib/analyze.rb ADDED
@@ -0,0 +1,8 @@
1
+ class Analyze < Array
2
+ def update
3
+ if(`gem list countloc`.include?('countloc ('))
4
+ FileUtils.mkdir('doc') if(!File.exists?('doc'))
5
+ add 'countloc -r * --html doc/countloc.html'
6
+ end
7
+ end
8
+ end
data/lib/array.rb CHANGED
@@ -1,25 +1,25 @@
1
- class Array
2
- def execute
3
- i=0
4
- while i < self.length
5
- self[i]=Command.new(self[i]) if(self[i].is_a?(String))
6
- self[i]=Command.new(self[i]) if(self[i].is_a?(Hash) && !self[i].is_a?(Command))
7
- self[i].execute if(self[i].is_a?(Command))
8
- i=i+1
9
- end
10
- end
11
-
12
- def add command
13
- self << command if(!include?(command))
14
- end
15
-
16
- def to_html
17
- html=Array.new
18
- html << '<div>'
19
- self.each{|e|
20
- html << e.to_html if e.respond_to?(:to_html)
21
- }
22
- html << '</div>'
23
- html.join
24
- end
1
+ class Array
2
+ def execute
3
+ i=0
4
+ while i < self.length
5
+ self[i]=Command.new(self[i]) if(self[i].is_a?(String))
6
+ self[i]=Command.new(self[i]) if(self[i].is_a?(Hash) && !self[i].is_a?(Command))
7
+ self[i].execute if(self[i].is_a?(Command))
8
+ i=i+1
9
+ end
10
+ end
11
+
12
+ def add command
13
+ self << command if(!include?(command))
14
+ end
15
+
16
+ def to_html
17
+ html=Array.new
18
+ html << '<div>'
19
+ self.each{|e|
20
+ html << e.to_html if e.respond_to?(:to_html)
21
+ }
22
+ html << '</div>'
23
+ html.join
24
+ end
25
25
  end
data/lib/build.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require_relative('msbuild.rb')
2
+
1
3
  class Build < Array
2
4
  def update
3
5
  Dir.glob('*.gemspec'){|gemspec|
@@ -5,16 +7,16 @@ class Build < Array
5
7
  }
6
8
  Dir.glob('**/*.sln'){|sln_file|
7
9
  vs_version=MSBuild.get_vs_version(sln_file)
8
- if(defined?(MSBUILD))
9
- if(MSBUILD.has_key?(vs_version))
10
- MSBuild.get_configurations(f).each{ |configuration|
11
- MSBuild.get_platforms(f).each{|platform|
12
- Console.debug "configuration='#{configuration}', platform='#{platform}'"
13
- self.add "\"#{MSBUILD[vs_version]}\" \"#{f}\" /nologo /p:Configuration=#{configuration} /p:Platform=\"#{platform}\""
14
- }
15
- }
16
- end
17
- end
10
+ if(MSBuild.has_version?(vs_version))
11
+ MSBuild.get_configurations(sln_file).each{ |configuration|
12
+ MSBuild.get_platforms(sln_file).each{|platform|
13
+ #Console.debug "configuration='#{configuration}', platform='#{platform}'"
14
+ self.add "\"#{MSBuild.get_version(vs_version)}\" \"#{sln_file}\" /nologo /p:Configuration=#{configuration} /p:Platform=\"#{platform}\""
15
+ }
16
+ }
17
+ else
18
+ "puts version #{vs_version} not found for MsBuild"
19
+ end
18
20
  }
19
21
  end
20
22
  end
data/lib/command.rb CHANGED
@@ -1,133 +1,152 @@
1
- require 'open3'
2
- require_relative('./array.rb')
3
- require_relative('./hash.rb')
4
- require_relative('./timer.rb')
5
-
6
- class Command < Hash
7
- def initialize command
8
-
9
- self[:input] = ''
10
- self[:timeout] = 0
11
- self[:directory] = ''
12
- self[:exit_code] = 0
13
- self[:output] = ''
14
- self[:error] = ''
15
- self[:machine] = ''
16
- self[:user] = ''
17
- self[:start_time] = nil
18
- self[:end_time] = nil
19
-
20
- if(command.kind_of?(String))
21
- self[:input] = command
22
- end
23
-
24
- if(command.kind_of?(Hash))
25
- command.each{|k,v|
26
- self[k.to_sym]=v
27
- }
28
- end
29
- end
30
-
31
- def execute
32
- puts "#{self[:input]}" if(!self.has_key?(:quiet) || !self[:quiet])
33
- pwd=Dir.pwd
34
- Dir.chdir(self[:directory]) if(self.has_key?(:directory) && File.exists?(self[:directory]))
35
- self[:directory] = pwd if(self[:directory].length==0)
36
-
37
- self[:machine] = Command.machine
38
- self[:user] = Command.user
39
-
40
- self[:start_time]=Time.now
41
- timer=Timer.new
42
- if self[:input].include?('<%') && self[:input].include?('%>')
43
- ruby = self[:input].gsub("<%","").gsub("%>","")
44
-
45
- begin
46
- self[:output]=eval(ruby)
47
- rescue
48
- self[:exit_code]=1
49
- self[:error]="unable to eval(#{ruby})"
50
- end
51
-
52
- self[:elapsed] = timer.elapsed_str
53
- self[:end_time] = Time.now
54
- else
55
- begin
56
- self[:output],self[:error],status= Open3.capture3(self[:input])
57
- self[:exit_code]=status.to_i
58
- self[:elapsed] = timer.elapsed_str
59
- self[:end_time] = Time.now
60
- rescue Exception => e
61
- self[:elapsed] = timer.elapsed_str
62
- self[:end_time] = Time.now
63
- self[:error] = "Exception: " + e.to_s
64
- self[:exit_code]=1
65
- end
66
- end
67
-
68
- Dir.chdir(pwd) if pwd != Dir.pwd
69
-
70
- if(self[:exit_code] != 0)
71
- if(!self.has_key?(:quiet) || !self[:quiet])
72
- puts ' '
73
- puts "exit_code=#{self[:exit_code]}"
74
- puts ' '
75
- puts self[:output]
76
- puts self[:error]
77
- puts ' '
78
- end
79
- if(!self.has_key?(:ignore_failure) || !self[:ignore_failure])
80
- raise "#{self[:input]} failed"
81
- end #unless (self.has_key?(:ignore_failure) && self[:ignore_failure]==true)
82
- end
83
- end
84
-
85
- def self.machine
86
- if !ENV['COMPUTERNAME'].nil?
87
- return ENV['COMPUTERNAME']
88
- end
89
-
90
- machine = `hostname`
91
- machine = machine.split('.')[0] if machine.include?('.')
92
- return machine.strip
93
- end
94
-
95
- def self.user
96
- ENV['USER'].nil? ? ENV['USERNAME'] : ENV['USER']
97
- end
98
-
99
- def self.exit_code command
100
- cmd = Command.new(command)
101
- cmd[:ignore_failure]=true
102
- cmd[:quiet]=true
103
- cmd.execute
104
- cmd[:exit_code]
105
- end
106
-
107
- def self.output command
108
- cmd = Command.new(command)
109
- cmd[:ignore_failure]=true
110
- cmd[:quiet]=true
111
- cmd.execute
112
- cmd[:output]
113
- end
114
-
115
- def to_html
116
- if self[:exit_code] == 0
117
- [
118
- '<div><table><tr><td width="20"></td><td><pre>',
119
- self[:input],
120
- '</pre></td></tr></table></div>'
121
- ].join
122
- else
123
- [
124
- '<div><table><tr><td width="20"></td><td><pre>',
125
- self[:input],
126
- '</pre><table><tr><td width="20"></td><td><table>',
127
- map { |k, v| ["<tr><td><strong>#{k}</strong></td>", v.respond_to?(:to_html) ? v.to_html : "<td><span><pre>#{v}</pre></span></td></tr>"] },
128
- '</table>',
129
- '</td></tr></table></td></tr></table></div>'
130
- ].join
131
- end
132
- end
1
+ require 'open3'
2
+ require_relative('./array.rb')
3
+ require_relative('./hash.rb')
4
+ require_relative('./timer.rb')
5
+
6
+ class Command < Hash
7
+ def initialize command
8
+
9
+ self[:input] = ''
10
+ self[:timeout] = 0
11
+ self[:directory] = ''
12
+ self[:exit_code] = 0
13
+ self[:output] = ''
14
+ self[:error] = ''
15
+ self[:machine] = ''
16
+ self[:user] = ''
17
+ self[:start_time] = nil
18
+ self[:end_time] = nil
19
+
20
+ if(command.kind_of?(String))
21
+ self[:input] = command
22
+ end
23
+
24
+ if(command.kind_of?(Hash))
25
+ command.each{|k,v|
26
+ self[k.to_sym]=v
27
+ }
28
+ end
29
+ end
30
+
31
+ def execute
32
+ puts "#{self[:input]}" if(!self.has_key?(:quiet) || !self[:quiet])
33
+ pwd=Dir.pwd
34
+ Dir.chdir(self[:directory]) if(self.has_key?(:directory) && File.exists?(self[:directory]))
35
+ self[:directory] = pwd if(self[:directory].length==0)
36
+
37
+ self[:machine] = Command.machine
38
+ self[:user] = Command.user
39
+
40
+ self[:start_time]=Time.now
41
+ timer=Timer.new
42
+ if self[:input].include?('<%') && self[:input].include?('%>')
43
+ ruby = self[:input].gsub("<%","").gsub("%>","")
44
+
45
+ begin
46
+ self[:output]=eval(ruby)
47
+ rescue
48
+ self[:exit_code]=1
49
+ self[:error]="unable to eval(#{ruby})"
50
+ end
51
+
52
+ self[:elapsed] = timer.elapsed_str
53
+ self[:end_time] = Time.now
54
+ else
55
+ begin
56
+ self[:output],self[:error],status= Open3.capture3(self[:input])
57
+ self[:exit_code]=status.to_i
58
+ self[:elapsed] = timer.elapsed_str
59
+ self[:end_time] = Time.now
60
+ rescue Exception => e
61
+ self[:elapsed] = timer.elapsed_str
62
+ self[:end_time] = Time.now
63
+ self[:error] = "Exception: " + e.to_s
64
+ self[:exit_code]=1
65
+ end
66
+ end
67
+
68
+ Dir.chdir(pwd) if pwd != Dir.pwd
69
+
70
+ if(self[:exit_code] != 0)
71
+ if(!self.has_key?(:quiet) || !self[:quiet])
72
+ puts ' '
73
+ puts "exit_code=#{self[:exit_code]}"
74
+ puts ' '
75
+ puts self[:output]
76
+ puts self[:error]
77
+ puts ' '
78
+ end
79
+ if(!self.has_key?(:ignore_failure) || !self[:ignore_failure])
80
+ raise "#{self[:input]} failed"
81
+ end #unless (self.has_key?(:ignore_failure) && self[:ignore_failure]==true)
82
+ end
83
+ end
84
+
85
+ def self.machine
86
+ if !ENV['COMPUTERNAME'].nil?
87
+ return ENV['COMPUTERNAME']
88
+ end
89
+
90
+ machine = `hostname`
91
+ machine = machine.split('.')[0] if machine.include?('.')
92
+ return machine.strip
93
+ end
94
+
95
+ def self.user
96
+ ENV['USER'].nil? ? ENV['USERNAME'] : ENV['USER']
97
+ end
98
+
99
+ def self.home
100
+ ["USERPROFILE","HOME"].each {|v|
101
+ return ENV[v].gsub('\\','/') unless ENV[v].nil?
102
+ }
103
+ dir="~"
104
+ dir=ENV["HOME"] unless ENV["HOME"].nil?
105
+ dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
106
+ return dir
107
+ end
108
+
109
+ def self.dev_root
110
+ ["DEV_HOME","DEV_ROOT"].each {|v|
111
+ return ENV[v].gsub('\\','/') unless ENV[v].nil?
112
+ }
113
+ dir=home
114
+ #dir=ENV["DEV_ROOT"].gsub('\\','/') unless ENV["DEV_ROOT"].nil?
115
+ return dir
116
+ end
117
+
118
+ def self.exit_code command
119
+ cmd = Command.new(command)
120
+ cmd[:ignore_failure]=true
121
+ cmd[:quiet]=true
122
+ cmd.execute
123
+ cmd[:exit_code]
124
+ end
125
+
126
+ def self.output command
127
+ cmd = Command.new(command)
128
+ cmd[:ignore_failure]=true
129
+ cmd[:quiet]=true
130
+ cmd.execute
131
+ cmd[:output]
132
+ end
133
+
134
+ def to_html
135
+ if self[:exit_code] == 0
136
+ [
137
+ '<div><table><tr><td width="20"></td><td><pre>',
138
+ self[:input],
139
+ '</pre></td></tr></table></div>'
140
+ ].join
141
+ else
142
+ [
143
+ '<div><table><tr><td width="20"></td><td><pre>',
144
+ self[:input],
145
+ '</pre><table><tr><td width="20"></td><td><table>',
146
+ map { |k, v| ["<tr><td><strong>#{k}</strong></td>", v.respond_to?(:to_html) ? v.to_html : "<td><span><pre>#{v}</pre></span></td></tr>"] },
147
+ '</table>',
148
+ '</td></tr></table></td></tr></table></div>'
149
+ ].join
150
+ end
151
+ end
133
152
  end
data/lib/commands.rb CHANGED
@@ -4,6 +4,7 @@ require_relative('update.rb')
4
4
  require_relative('setup.rb')
5
5
  require_relative('build.rb')
6
6
  require_relative('test.rb')
7
+ require_relative('analyze.rb')
7
8
  require_relative('publish.rb')
8
9
  require_relative('doc.rb')
9
10
  require_relative('clean.rb')
@@ -21,6 +22,7 @@ class Commands < Hash
21
22
  self[:setup]=Setup.new
22
23
  self[:build]=Build.new
23
24
  self[:test]=Test.new
25
+ self[:analyze]=Analyze.new
24
26
  self[:doc]=Doc.new
25
27
  self[:clean]=Clean.new
26
28
  self[:publish]=Publish.new
data/lib/commit.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require_relative('internet.rb')
2
+
1
3
  class Commit < Array
2
4
  def update
3
5
  if(File.exists?('.git') && `git config --list`.include?('user.name='))
@@ -11,7 +13,7 @@ class Commit < Array
11
13
  add "<%FileUtils.rm('commit.message')%>" if File.exists?('commit.message')
12
14
  end
13
15
  end
14
- if(File.exists?('.svn'))
16
+ if(File.exists?('.svn') && Internet.available?)
15
17
  add 'svn commit -m"commit all"'
16
18
  end
17
19
  end
data/lib/dev_commands.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'json'
2
2
  require 'rake/clean'
3
3
 
4
- #CLEAN.include('.yardoc','log','tmp','*.gem','obj')
5
- #CLEAN.include('**/*.{suo,sdf}')
6
- CLOBBER.include('bin','doc')
4
+ CLEAN.include('obj')
5
+ CLEAN.include('**/*.{sdf,sud,ncb,cache,user}')
6
+ CLOBBER.include('bin','doc','*.gem','tmp')
7
+ CLOBBER.include('**/*.{dll,pdb}')
7
8
 
8
9
  SOURCE=FileList.new('LICENSE','README','README.md',"Gemfile")
9
10
  SOURCE.include('**/*.{gitignore,yml,gemspec,rb}')
@@ -20,4 +21,4 @@ require_relative('git.rb')
20
21
  require_relative('msbuild.rb')
21
22
 
22
23
  COMMANDS=Commands.new
23
- MSBUILD=MSBuild.new
24
+ MSBUILD=MSBuild.new
data/lib/doc.rb CHANGED
@@ -1,9 +1,9 @@
1
- class Doc < Array
2
- def update
3
- #cmd=Command.new ({ :input => 'yard --version', :ignore_failure => true})
4
- #cmd.execute
5
- if(Command.exit_code('yard --version'))
6
- add 'yard doc - LICENSE' if File.exists?('README.md') && File.exists?('LICENSE')
7
- end
8
- end
1
+ class Doc < Array
2
+ def update
3
+ #cmd=Command.new ({ :input => 'yard --version', :ignore_failure => true})
4
+ #cmd.execute
5
+ if(Command.exit_code('yard --version'))
6
+ add 'yard doc - LICENSE' if File.exists?('README.md') && File.exists?('LICENSE')
7
+ end
8
+ end
9
9
  end