dev 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README ADDED
@@ -0,0 +1,16 @@
1
+ Copyright 2012 Lou Parslow
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+ dev is a ruby gem that provide functionality supporting common
16
+ software development tasks.;
data/lib/dev.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+ require 'rainbow'
3
+ require 'semver'
4
+ require 'bundler'
5
+
6
+ # if DEV_DEBUG is defined, puts_debug will send message to the console
7
+ def puts_debug msg
8
+ if(defined?(DEV_DEBUG))
9
+ puts msg
10
+ end
11
+ end
12
+
13
+ puts_debug "read " + __FILE__.foreground(:green)
14
+
15
+ require "#{File.dirname(__FILE__)}/dev/Hash.rb"
16
+
17
+ Dir["#{File.dirname(__FILE__)}/dev/**/*.rb"].each{ |f| require f }
18
+
19
+ DEV_ROOT=Dev::Environment.dev_root
20
+
21
+
22
+
@@ -0,0 +1,34 @@
1
+ puts_debug "read " + __FILE__.foreground(:green)
2
+
3
+ #def exec_in_dir(cmd,dir)
4
+ # Dir.chdir(dir) { |path|
5
+ # call=Dev::SystemCall.new(cmd)
6
+ # call.puts_summary
7
+ # }
8
+ #end
9
+
10
+ module Dev
11
+
12
+ class Environment
13
+ def self.replace_text_in_file(filename,search,replace)
14
+ text1 = File.read(filename)
15
+ text2 = text1.gsub(search) { |str| str=replace }
16
+ File.open(filename,"w") { |f| f.puts text2 } unless text1==text2
17
+ end
18
+
19
+ def self.dev_root
20
+ dir="~"
21
+ dir=ENV["HOME"] unless ENV["HOME"].nil?
22
+ dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
23
+ dir=ENV["DEV_ROOT"].gsub('\\','/') unless ENV["DEV_ROOT"].nil?
24
+
25
+ return dir
26
+ end
27
+
28
+ def self.expand_string_variables(str)
29
+ eval("\"#{str.gsub('"','\"')}\"")
30
+ end
31
+ end
32
+
33
+ end # module Dev
34
+
data/lib/dev/Hash.rb ADDED
@@ -0,0 +1,84 @@
1
+ class Hash
2
+
3
+ def get_value(key)
4
+ return Hash.get_hash_value(self,key)
5
+ end
6
+
7
+ def set_value(key,value)
8
+ Hash.set_hash_value(self,key,value)
9
+ end
10
+
11
+ def self.get_hash_value(hash,key)
12
+ return hash[key] if(hash.has_key?(key))
13
+ if key.kind_of?(String)
14
+ if key.include?(',')
15
+ keys=key.split(',')
16
+ value=get_hash_value(hash,keys.shift)
17
+ unless value.nil?
18
+ if value.kind_of?(Hash)
19
+ return Hash.get_hash_value(value,keys.join(','))
20
+ end
21
+ end
22
+ else
23
+ value=nil
24
+ ruby="value=hash[:#{key}]"
25
+ eval(ruby)
26
+ return value
27
+ end
28
+ end
29
+ nil
30
+ end
31
+
32
+ def self.set_hash_value(hash,key,value)
33
+ if key.kind_of?(String)
34
+ if key.include?(',')
35
+ keys=key.split(',')
36
+ hval=get_hash_value(hash,keys[0])
37
+ if(hval.nil?)
38
+ ruby="hash[:#{keys[0]}]=Hash.new"
39
+ eval(ruby)
40
+ end
41
+ hval=get_hash_value(hash,keys[0])
42
+ if hval.kind_of?(Hash)
43
+ keys.shift
44
+ if keys.length == 1
45
+ Hash.set_hash_value(hval,keys[0],value)
46
+ else
47
+ Hash.set_hash_value(hval,keys.join(','),value)
48
+ end
49
+ end
50
+ else
51
+ eval("hash[:#{key}]=value")
52
+ end
53
+ else
54
+ hash[key]=value
55
+ end
56
+ end
57
+
58
+ def self.print_hash(indent,hash)
59
+ max_length=0
60
+ hash.each { |name,value| max_length=name.to_s.length if name.to_s.length > max_length }
61
+ max_length=max_length+1
62
+ index=0
63
+ hash.each do |name,value|
64
+
65
+ prefix = "#{indent}#{name.to_s}".rjust(max_length)
66
+ if value.kind_of?(Hash)
67
+ print_hash(prefix+",",value)
68
+ elsif value.kind_of?(Array)
69
+ value.each do |v|
70
+ if v.kind_of?(Hash)
71
+ puts prefix.foreground(:yellow).bright
72
+ print_hash( prefix + " ".rjust(max_length),v)
73
+ end
74
+ puts prefix.foreground(:yellow).bright + " " + v.to_s.foreground(:green) if v.kind_of?(String)
75
+ prefix = indent + " ".rjust(max_length-1)
76
+ end
77
+ else
78
+ puts prefix.foreground(:yellow).bright + " " + value.to_s.foreground(:green)
79
+ end
80
+ index+=1
81
+ indent=" ".rjust(indent.length)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,228 @@
1
+ puts_debug "read " + __FILE__.foreground(:green)
2
+ require 'semver'
3
+
4
+ UNITTESTS=Array.new
5
+
6
+ module Dev
7
+
8
+ class Project < Hash
9
+
10
+ def initialize(hash,init_defaults=true)
11
+ hash.each { |name,value| self[name]=value }
12
+ update_default_values if init_defaults
13
+ end
14
+
15
+ def array_method(name)
16
+ string_name=name.to_s
17
+ puts_debug "method_missing name=" + string_name
18
+ if(self.get_value(string_name).nil? || self.get_value(string_name).length < 1)
19
+ puts_debug "no directives defined for method #{string_name}"
20
+ return
21
+ end
22
+ puts_debug "found directives for #{string_name}: #{self.get_value(string_name).to_s}"
23
+ puts string_name.foreground(:yellow).bright
24
+ self.get_value(string_name).each{ |c|
25
+ # expand the command here....
26
+ command=expand_command(c)
27
+ if c.include?('<%') && c.include?('%>')
28
+ puts "Command: " + c
29
+ eval(c.gsub("<%","").gsub("%>",""))
30
+ else
31
+ call=Dev::SystemCall.new(command)
32
+ call.puts_summary
33
+ end
34
+ }
35
+ end
36
+
37
+ def method_missing( name, *args )
38
+ array_method(name)
39
+ end
40
+
41
+ def expand_command(command)
42
+ result=expand_project_variables(command)
43
+ return result
44
+ end
45
+
46
+ def expand_project_variables(str)
47
+ result=Dev::Environment.expand_string_variables(str) # expands ruby variables, e.g. '#{name}' to 'widget'
48
+ if result.include?('<') && result.include?('>')
49
+ result.scan(/(<[\w,]+>)/).each { |pvar| # expand project variables, e.g. '<name>' to 'widget
50
+ key = pvar[0].gsub("<","").gsub(">","") # '<paths,nunit>' to 'C:/wherever/NUnit.exe'
51
+ result = result.gsub(pvar[0],get_value(key))
52
+ }
53
+ end
54
+ result
55
+ end
56
+
57
+ def loc_cmd
58
+ cmd="countloc --recurse ."
59
+ cmd="countloc --recurse --mode ruby ." if self[:type]=="ruby" || self[:type]=="gem"
60
+ cmd="countloc --recurse --mode csharp ." if self[:type]=="C#"
61
+ cmd="countloc --recurse --mode cpp ." if self[:type]=="c++"
62
+ return cmd
63
+ end
64
+
65
+ def loc
66
+ system(loc_cmd)
67
+ end
68
+
69
+ def loc_total
70
+ # parse the output for TOTAL LOC
71
+ call=Dev::SystemCall.new(loc_cmd)
72
+ words=call.output.split
73
+ if(words.length>6)
74
+ return words[words.length-6]
75
+ end
76
+ "?"
77
+ end
78
+
79
+ def features
80
+ if self[:type]=="C#" && File.exists?("bin/x86/Release/#{self[:name]}.Features.dll")
81
+ call=Dev::SystemCall.new(expand_project_variables("<paths,nunit> /nologo bin/x86/Release/#{self[:name]}.Features.dll"))
82
+ puts call.command
83
+ puts call.output
84
+ raise "exit_code=#{call.status.to_s}" + call.error unless call.status==0
85
+ end
86
+
87
+ array_method("features")
88
+ end
89
+
90
+ def commit
91
+ call=nil
92
+ call=Dev::SystemCall.new('git diff') if File.exists?(".git")
93
+ call=Dev::SystemCall.new('svn diff') if File.exists?(".svn")
94
+ unless call.nil? || call.output.length==0
95
+ array_method("commit")
96
+ else
97
+ puts " no differences detected"
98
+ end
99
+ end
100
+
101
+ def info
102
+ puts " "
103
+ Hash.print_hash("",self)
104
+ puts " "
105
+ end
106
+
107
+ def bundle_gems
108
+ if(File.exists?("Gemfile"))
109
+ call=Dev::SystemCall.new("bundle install")
110
+ puts call.Summary
111
+ elsif(File.exists?("lib/Gemfile"))
112
+ pwd=Dir.pwd
113
+ Dir.chdir("lib")
114
+ call=Dev::SystemCall.new("bundle install")
115
+ Dir.chdir(pwd)
116
+ call.puts_summary
117
+ else
118
+ throw "no Gemfile found to bundle"
119
+ end
120
+ end
121
+
122
+ def set_default_value(key)
123
+ set_value(key,get_default_value(key)) if get_value(key).nil? && !get_default_value(key).nil?
124
+ end
125
+
126
+ def get_default_value(key)
127
+ system_call = Dev::SystemCall.new("semver init") if(!File.exist?(".semver"))
128
+ version = SemVer.find
129
+
130
+ value="#{Dev::Environment.dev_root}" if key=="dev_root"
131
+ value="C#" if key=="type"
132
+ value="**/*.{cs,xaml,rb,resx,settings,feature,semver}" if self[:type]=="C#" && key=="src_glob"
133
+ value="**/*.{rb,feature,semver}" if self[:type]=="ruby" && key=="src_glob"
134
+ value="**/*.{rb,feature,gemspec,semver}" if self[:type]=="gem" && key=="src_glob"
135
+ value=Dir.glob(self[:src_glob]).length.to_s if key=="file_count"
136
+ value=loc_total if key=="loc"
137
+ value="svn" if key=="scm_type" && File.exists?(".svn")
138
+ value="git" if key=="scm_type" && File.exists?(".git")
139
+ value="#{version.major}.#{version.minor}.#{version.patch}" if key=="version"
140
+
141
+ hash=Hash.new
142
+
143
+ if(key=="paths")
144
+ if(self[:type]=="C#")
145
+ hash.set_value("msbuild","C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe")
146
+ nunit_version="2.5.10.11092"
147
+ hash.set_value("nunit","#{Dev::Environment.dev_root}/dep/ThirdParty/NUnit/#{nunit_version}/bin/net-2.0/nunit-console-x86.exe")
148
+ end
149
+ end
150
+ value=hash if hash.length > 0
151
+
152
+ array=Array.new
153
+ if(key=="bootstrap")
154
+ #array=Array.new
155
+ array << "bundle install" if File.exists?("Gemfile")
156
+
157
+ # dep,svn directives
158
+ dep_hash=self.get_value("dep")
159
+ unless dep_hash.nil?
160
+ dep_hash.each do |key,value|
161
+ if value.kind_of?(Hash)
162
+ # potential hash keys: uri, dir
163
+ # uri is required
164
+ unless value.get_value("uri").nil?
165
+ uri=expand_project_variables(value.get_value("uri"))
166
+ uri_words=uri.split('/')
167
+ while(uri_words.length > 3) do
168
+ uri_words.shift
169
+ end
170
+ dir=uri_words.join('/')
171
+ dir=expand_project_variables(value.get_value("dir")) unless value.get_value("dir").nil?
172
+ dir=self[:dev_root] + "/dep/" + dir unless dir.include?(self[:dev_root])
173
+
174
+ array << "svn export " + expand_project_variables(value.get_value("uri")) + " " + dir unless File.exists?(dir)
175
+ array << "<%puts ' #{dir} exists.'%>" if File.exists?(dir)
176
+ end
177
+ end
178
+ end
179
+ end
180
+
181
+ #bootstrap << "cd lib" if File.exists?("lib/Gemfile")
182
+ #bootstrap << "cd lib;bundle install;cd .." if File.exists?("lib/Gemfile")
183
+ #bootstrap << "cd .." if File.exists?("lib/Gemfile")
184
+ #bootstrap << "<%exec_in_dir('bundle install','lib')%>" if File.exists?("lib/Gemfile")
185
+ end
186
+ if(key=="compile")
187
+ Dir.glob("*.gemspec").each { |gs| array << "gem build #{gs}" } if self[:type]=="gem"
188
+
189
+ if self[:type]=="C#"
190
+ if(!has_key?(:x86_release_compile_flags))
191
+ self[:x86_release_compile_flags]="/property:Configuration=Release /property:Platform=\"x86\" /p:OutputPath=./bin/x86/Release"
192
+ end
193
+ end
194
+ Dir.glob("*.csproj").each{|cs|array<<"<paths,msbuild> #{cs} <x86_release_compile_flags>"}
195
+ end
196
+ if(key=="test")
197
+ Dir.glob("*.gemspec").each { |gs| array << "gem uninstall #{gs.gsub('.gemspec','')} -v #{self[:version]}" } if self[:type]=="gem"
198
+ Dir.glob("*.gemspec").each { |gs| array << "gem install ./#{gs.gsub('.gemspec','')}-#{self[:version]}.gem" } if self[:type]=="gem"
199
+ if self[:type]=="C#"
200
+ Dir.glob("*.{Test.csproj,Features.csproj}").each { |cs|
201
+ dll_name="bin/x86/Release/#{File.basename(cs,'.csproj')}.dll"
202
+ array << "<paths,nunit> /nologo #{dll_name} /xml:#{dll_name}.nunit-results.xml"
203
+ }
204
+ end
205
+ end
206
+ if(key=="features")
207
+ array << "cucumber features" if File.exists?("features") && Dir.glob("features/**/*.rb").length > 0
208
+ end
209
+ if(key=="has_diff")
210
+ array << 'git diff' if File.exists?(".git")
211
+ array << 'svn diff' if File.exists?(".svn")
212
+ end
213
+ if(key=="commit")
214
+ array << 'git commit -a -m "rake commit all"' if File.exists?(".git")
215
+ array << 'svn commit -m "rake commit all"' if File.exists?(".svn")
216
+ end
217
+
218
+ value=array if array.length > 0
219
+
220
+ return value
221
+ end
222
+
223
+ def update_default_values
224
+ [ "type","version","dev_root","src_glob","file_count","loc","scm_type",
225
+ "paths","bootstrap","compile","test","features","commit" ].each { |k| set_default_value(k) }
226
+ end
227
+ end
228
+ end # module Dev
@@ -0,0 +1,56 @@
1
+ puts_debug "read " + __FILE__.foreground(:green)
2
+
3
+ require 'tmpdir'
4
+
5
+ module Dev
6
+
7
+ class SystemCall
8
+ attr_accessor :output,:error,:status,:command,:start_time,:end_time,:timed_out
9
+
10
+ def initialize(cmd); execute(cmd); end
11
+ def elapsed; @end_time-@start_time; end
12
+ def execute(cmd)
13
+ @command=cmd
14
+ @start_time=Time.now
15
+ filename=Dir.tmpdir + "/" + (0...8).map{65.+(rand(25)).chr}.join
16
+ begin
17
+ system("#{@command} >#{filename}.out 2>#{filename}.err")
18
+ File.open("#{filename}.out",'r') {|f|
19
+ @output = f.read
20
+ f.close
21
+ }
22
+ File.open("#{filename}.err",'r') {|f|
23
+ @error = f.read
24
+ f.close
25
+ }
26
+ @status=$?.exitstatus
27
+ @end_time=Time.now
28
+ rescue
29
+ puts "error executing ruby code"
30
+ ensure
31
+ begin
32
+ File.delete("#{filename}.out") if File.exists?("#{filename}.out")
33
+ File.delete("#{filename}.err") if File.exists?("#{filename}.err")
34
+ rescue
35
+ puts "temp directory file was not cleaned up."
36
+ end
37
+ end
38
+ end
39
+
40
+
41
+
42
+ def puts_summary
43
+ if(@status != 0)
44
+ puts " [".foreground(:cyan) + "X".foreground(:red).bright + "]".foreground(:cyan) + " system(\"" + @command.foreground(:green) + "\") has exit status of " + @status.to_s
45
+ puts @output
46
+ warn @error
47
+ throw "exit status was " + @status.to_s
48
+ else
49
+ elapsed_str="[" + "%.0f" %(elapsed) + "s]"
50
+ puts " [".foreground(:cyan) + "+".foreground(:green) + "]".foreground(:cyan) + " system(\"" + @command.foreground(:green) + "\") " + elapsed_str.foreground(:cyan)
51
+ end
52
+ end
53
+
54
+ end # class SystemCall
55
+
56
+ end # module Dev
data/lib/dev/Tasks.rb ADDED
@@ -0,0 +1,59 @@
1
+ puts_debug "read " + __FILE__.foreground(:green)
2
+
3
+ require 'rake'
4
+
5
+ desc "checks for a sane environment"
6
+ task :sanity do
7
+ if(!defined?(PROJECT))
8
+ throw "PROJECT must be defined"
9
+ end
10
+ PROJECT.sanity
11
+ end
12
+
13
+ task :clean do
14
+ #puts "cleaning".foreground(:yellow)
15
+ end
16
+ require 'rake/clean'
17
+ CLEAN.include('*.gem','doc/*','obj/*')
18
+ CLOBBER.include('bin','doc','obj')
19
+
20
+ desc "bootstrap environment"
21
+ task :bootstrap do
22
+ PROJECT.bootstrap
23
+ end
24
+
25
+ desc "tests cucumber features"
26
+ task :features do
27
+ PROJECT.features
28
+ end
29
+
30
+ desc "display information about the rakefile"
31
+ task :info do
32
+ PROJECT.info
33
+ end
34
+
35
+ desc "compile"
36
+ task :compile do
37
+ PROJECT.compile
38
+ end
39
+
40
+ desc "run unit tests"
41
+ task :test do
42
+ PROJECT.test # we want an exception raised here if PROJECT is undefined or nil
43
+ end
44
+
45
+ desc "commit"
46
+ task :commit do
47
+ PROJECT.commit # we want an exception raised here if PROJECT is undefined or nil
48
+ end
49
+
50
+ desc "deploy"
51
+ task :deploy do
52
+ PROJECT.deploy
53
+ end
54
+
55
+ desc "count the lines of code"
56
+ task :loc do
57
+ PROJECT.loc
58
+ end
59
+
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dev
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Lou Parslow
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-03 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: development tasks
15
+ email: lou.parslow@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE
21
+ - README
22
+ - lib/dev/Environment.rb
23
+ - lib/dev/Hash.rb
24
+ - lib/dev/Project.rb
25
+ - lib/dev/SystemCall.rb
26
+ - lib/dev/Tasks.rb
27
+ - lib/dev.rb
28
+ homepage: http://rubygems.org/gems/dev
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 1.8.7
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project: dev
48
+ rubygems_version: 1.8.11
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: dev
52
+ test_files: []