dev 2.0.41 → 2.0.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/add.rb +22 -0
- data/lib/analyze.rb +8 -0
- data/lib/array.rb +30 -0
- data/lib/build.rb +33 -0
- data/lib/clean.rb +12 -0
- data/lib/clobber.rb +15 -0
- data/lib/command.rb +208 -0
- data/lib/commands.rb +36 -0
- data/lib/commit.rb +20 -0
- data/lib/dev.rb +11 -6
- data/lib/dev_commands.rb +21 -0
- data/lib/dev_environment.rb +1 -0
- data/lib/dev_git.rb +4 -0
- data/lib/dev_msbuild.rb +0 -0
- data/lib/dev_projects.rb +11 -0
- data/lib/dev_svn.rb +2 -0
- data/lib/dev_tasks.rb +4 -0
- data/lib/doc.rb +9 -0
- data/lib/environment.rb +49 -0
- data/lib/gemspec.rb +40 -0
- data/lib/git.rb +51 -0
- data/lib/hash.rb +21 -0
- data/lib/info.rb +3 -0
- data/lib/internet.rb +24 -0
- data/lib/msbuild.rb +70 -0
- data/lib/project.rb +66 -0
- data/lib/projects.rb +67 -0
- data/lib/publish.rb +21 -0
- data/lib/pull.rb +12 -0
- data/lib/push.rb +9 -0
- data/lib/setup.rb +25 -0
- data/lib/svn.rb +99 -0
- data/lib/tasks.rb +82 -0
- data/lib/test.rb +58 -0
- data/lib/text.rb +16 -0
- data/lib/timeout.rb +81 -0
- data/lib/timer.rb +41 -0
- data/lib/update.rb +6 -0
- data/lib/upgrade.rb +6 -0
- metadata +45 -43
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: adaaa19844b16b0478ed357c97680559fb7648d8
|
4
|
+
data.tar.gz: dc8e4a5461bc18ff549e171920cebf1b2b7e77b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f07af8db1a88631dbec9dff9471a5104f20a58d3f3ee9afebbdaabfae0e7caa32a87530a69d2a3231927cb2b26ab150a0298457581d4652c691b8761d6e94016
|
7
|
+
data.tar.gz: eb9096f114f582df88766b57d3b7c852bf8cea443a0a4b365ae0e05ae90d26c65f5ac96c51effc0b736b2ed451d3afa41138485e07f3f78c0bafc5e12e8db145
|
data/lib/add.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class Add < Array
|
2
|
+
def update
|
3
|
+
if(File.exists?('.git') && File.exists?('.gitignore'))
|
4
|
+
add 'git add --all'
|
5
|
+
else
|
6
|
+
if(defined?(SOURCE))
|
7
|
+
if(File.exists?('.svn'))
|
8
|
+
SOURCE.each{|f|
|
9
|
+
|
10
|
+
add "svn add #{f} --parents" if Command.output("svn status #{f}").include?('?')
|
11
|
+
add "svn add #{f} --parents" if Command.exit_code("svn status #{f}") != 0
|
12
|
+
}
|
13
|
+
end
|
14
|
+
if(File.exists?('.git'))
|
15
|
+
SOURCE.each{|f|
|
16
|
+
add "git add #{f} -v" if `git status #{f}`.include?('untracked')
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/analyze.rb
ADDED
data/lib/array.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class Array
|
2
|
+
def execute value=nil
|
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
|
+
|
8
|
+
if(!value.nil? && value.is_a?(Hash))
|
9
|
+
value.each{|k,v|self[i][k]=v}
|
10
|
+
end
|
11
|
+
|
12
|
+
self[i].execute if(self[i].is_a?(Command))
|
13
|
+
i=i+1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def add command
|
18
|
+
self << command if(!include?(command))
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_html
|
22
|
+
html=Array.new
|
23
|
+
html << '<div>'
|
24
|
+
self.each{|e|
|
25
|
+
html << e.to_html if e.respond_to?(:to_html)
|
26
|
+
}
|
27
|
+
html << '</div>'
|
28
|
+
html.join
|
29
|
+
end
|
30
|
+
end
|
data/lib/build.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative('msbuild.rb')
|
2
|
+
require_relative('gemspec.rb')
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
SLN_FILES=FileList.new('*.sln','*/*.sln','*/*/*.sln')
|
6
|
+
|
7
|
+
class Build < Array
|
8
|
+
def update
|
9
|
+
|
10
|
+
changed = true
|
11
|
+
#changed = Git.has_changes? if(File.exists?('.git') && defined?(Git))
|
12
|
+
#changed = Svn.has_changes? if(File.exists?('.svn') && defined?(Svn))
|
13
|
+
if(changed)
|
14
|
+
Dir.glob('*.gemspec'){|gemspec|
|
15
|
+
add "gem build #{gemspec}" if !File.exist?(Gemspec.gemfile gemspec)
|
16
|
+
}
|
17
|
+
|
18
|
+
SLN_FILES.each{|sln_file|
|
19
|
+
vs_version=MSBuild.get_vs_version(sln_file)
|
20
|
+
if(MSBuild.has_version?(vs_version))
|
21
|
+
MSBuild.get_configurations(sln_file).each{ |configuration|
|
22
|
+
MSBuild.get_platforms(sln_file).each{|platform|
|
23
|
+
#Console.debug "configuration='#{configuration}', platform='#{platform}'"
|
24
|
+
self.add "\"#{MSBuild.get_version(vs_version)}\" \"#{sln_file}\" /nologo /p:Configuration=#{configuration} /p:Platform=\"#{platform}\""
|
25
|
+
}
|
26
|
+
}
|
27
|
+
else
|
28
|
+
"puts version #{vs_version} not found for MsBuild"
|
29
|
+
end
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/clean.rb
ADDED
data/lib/clobber.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class Clobber < Array
|
2
|
+
def update
|
3
|
+
['bin'].each{|dir|
|
4
|
+
CLOBBER.include(dir) if File.exists?(dir)
|
5
|
+
}
|
6
|
+
|
7
|
+
clean=Clean.new
|
8
|
+
clean.update
|
9
|
+
|
10
|
+
CLOBBER.include('*.gem')
|
11
|
+
|
12
|
+
#add '<%Rake::Task[:clobber].reenable%>'
|
13
|
+
add '<%Rake::Task[:clobber].invoke%>'
|
14
|
+
end
|
15
|
+
end
|
data/lib/command.rb
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require_relative('./array.rb')
|
3
|
+
require_relative('./hash.rb')
|
4
|
+
require_relative('./timer.rb')
|
5
|
+
|
6
|
+
BUFFER_SIZE=1024 if(!defined?(BUFFER_SIZE))
|
7
|
+
|
8
|
+
# = Command
|
9
|
+
#
|
10
|
+
# execution of system commands
|
11
|
+
#
|
12
|
+
# = Keys
|
13
|
+
#
|
14
|
+
# - :input The input of the commands.
|
15
|
+
# - :timeout The timeout in seconds.
|
16
|
+
# a value of zero is to infinite timeout.
|
17
|
+
# defaults to zero
|
18
|
+
# - :directory The working directory for the command.
|
19
|
+
# defaults to the current directory
|
20
|
+
# - :exit_code The exit code of the command
|
21
|
+
# - :output The output contains the stdout output of the command
|
22
|
+
# - :error The error contains stderr output of the command
|
23
|
+
# - :machine The name of the machine the command executed on
|
24
|
+
# - :user The user name
|
25
|
+
# - :start_time
|
26
|
+
# - :end_time
|
27
|
+
#
|
28
|
+
class Command < Hash
|
29
|
+
def initialize command
|
30
|
+
|
31
|
+
self[:input] = ''
|
32
|
+
self[:timeout] = 0
|
33
|
+
self[:directory] = ''
|
34
|
+
self[:exit_code] = 0
|
35
|
+
self[:output] = ''
|
36
|
+
self[:error] = ''
|
37
|
+
self[:machine] = ''
|
38
|
+
self[:user] = ''
|
39
|
+
self[:start_time] = nil
|
40
|
+
self[:end_time] = nil
|
41
|
+
|
42
|
+
if(command.kind_of?(String))
|
43
|
+
self[:input] = command
|
44
|
+
end
|
45
|
+
|
46
|
+
if(command.kind_of?(Hash))
|
47
|
+
command.each{|k,v|
|
48
|
+
self[k.to_sym]=v
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def quiet?
|
54
|
+
(self.has_key?(:quiet) && self[:quiet])
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute value=nil
|
58
|
+
|
59
|
+
if(!value.nil? && value.is_a?(Hash))
|
60
|
+
value.each{|k,v|self[k]=v}
|
61
|
+
end
|
62
|
+
|
63
|
+
pwd=Dir.pwd
|
64
|
+
self[:directory] = pwd if(!self.has_key?(:directory) || self[:directory].length==0)
|
65
|
+
|
66
|
+
if(self[:timeout] > 0)
|
67
|
+
puts "#{self[:input]} (#{self[:directory]}) timeout #{self[:timeout].to_s}" if(!quiet?)
|
68
|
+
else
|
69
|
+
puts "#{self[:input]} (#{self[:directory]})" if(!quiet?)
|
70
|
+
end
|
71
|
+
|
72
|
+
self[:machine] = Command.machine
|
73
|
+
self[:user] = Command.user
|
74
|
+
|
75
|
+
self[:start_time]=Time.now
|
76
|
+
timer=Timer.new
|
77
|
+
|
78
|
+
Dir.chdir(self[:directory]) do
|
79
|
+
if self[:input].include?('<%') && self[:input].include?('%>')
|
80
|
+
ruby = self[:input].gsub("<%","").gsub("%>","")
|
81
|
+
|
82
|
+
begin
|
83
|
+
self[:output]=eval(ruby)
|
84
|
+
rescue
|
85
|
+
self[:exit_code]=1
|
86
|
+
self[:error]="unable to eval(#{ruby})"
|
87
|
+
end
|
88
|
+
|
89
|
+
self[:elapsed] = timer.elapsed_str
|
90
|
+
self[:end_time] = Time.now
|
91
|
+
else
|
92
|
+
begin
|
93
|
+
if(self[:timeout] <= 0)
|
94
|
+
self[:output],self[:error],status= Open3.capture3(self[:input])
|
95
|
+
self[:exit_code]=status.to_i
|
96
|
+
self[:elapsed] = timer.elapsed_str
|
97
|
+
self[:end_time] = Time.now
|
98
|
+
else
|
99
|
+
require_relative 'timeout.rb'
|
100
|
+
#puts run_with_timeout(self[:input], self[:timeout], 1).to_s
|
101
|
+
#self[:output] = run_with_timeout(self[:input], self[:timeout], 1)
|
102
|
+
result=run_with_timeout(self[:directory],self[:input], self[:timeout], 2)
|
103
|
+
self[:output]=result[0]
|
104
|
+
self[:exit_code]=result[1]
|
105
|
+
|
106
|
+
self[:elapsed] = timer.elapsed_str
|
107
|
+
self[:end_time] = Time.now
|
108
|
+
|
109
|
+
if(timer.elapsed >= self[:timeout])
|
110
|
+
self[:exit_code]=1
|
111
|
+
self[:error] = self[:error] + "timed out"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
rescue Exception => e
|
115
|
+
self[:elapsed] = timer.elapsed_str
|
116
|
+
self[:end_time] = Time.now
|
117
|
+
self[:error] = "Exception: " + e.to_s
|
118
|
+
self[:exit_code]=1
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
if(self[:exit_code] != 0)
|
125
|
+
if(!quiet?)
|
126
|
+
puts "exit_code=#{self[:exit_code]}"
|
127
|
+
puts self[:output]
|
128
|
+
puts self[:error]
|
129
|
+
end
|
130
|
+
if(!self.has_key?(:ignore_failure) || !self[:ignore_failure])
|
131
|
+
raise "#{self[:input]} failed"
|
132
|
+
end #unless (self.has_key?(:ignore_failure) && self[:ignore_failure]==true)
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.machine
|
138
|
+
if !ENV['COMPUTERNAME'].nil?
|
139
|
+
return ENV['COMPUTERNAME']
|
140
|
+
end
|
141
|
+
|
142
|
+
machine = `hostname`
|
143
|
+
machine = machine.split('.')[0] if machine.include?('.')
|
144
|
+
return machine.strip
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.user
|
148
|
+
ENV['USER'].nil? ? ENV['USERNAME'] : ENV['USER']
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.home
|
152
|
+
["USERPROFILE","HOME"].each {|v|
|
153
|
+
return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
154
|
+
}
|
155
|
+
dir="~"
|
156
|
+
dir=ENV["HOME"] unless ENV["HOME"].nil?
|
157
|
+
dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
|
158
|
+
return dir
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.dev_root
|
162
|
+
["DEV_HOME","DEV_ROOT"].each {|v|
|
163
|
+
return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
164
|
+
}
|
165
|
+
dir=home
|
166
|
+
#dir=ENV["DEV_ROOT"].gsub('\\','/') unless ENV["DEV_ROOT"].nil?
|
167
|
+
return dir
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.exit_code command
|
171
|
+
cmd = Command.new(command)
|
172
|
+
cmd[:ignore_failure]=true
|
173
|
+
cmd[:quiet]=true
|
174
|
+
cmd.execute
|
175
|
+
cmd[:exit_code]
|
176
|
+
end
|
177
|
+
|
178
|
+
def self.output command
|
179
|
+
cmd = Command.new(command)
|
180
|
+
cmd[:ignore_failure]=true
|
181
|
+
cmd[:quiet]=true
|
182
|
+
cmd.execute
|
183
|
+
cmd[:output]
|
184
|
+
end
|
185
|
+
|
186
|
+
def summary
|
187
|
+
"#{self[:exit_code].to_s} #{self[:input]} (#{self[:directory]})"
|
188
|
+
end
|
189
|
+
|
190
|
+
def to_html
|
191
|
+
if self[:exit_code] == 0
|
192
|
+
[
|
193
|
+
'<div><table><tr><td width="20"></td><td><pre>',
|
194
|
+
self[:input],
|
195
|
+
'</pre></td></tr></table></div>'
|
196
|
+
].join
|
197
|
+
else
|
198
|
+
[
|
199
|
+
'<div><table><tr><td width="20"></td><td><pre>',
|
200
|
+
self[:input],
|
201
|
+
'</pre><table><tr><td width="20"></td><td><table>',
|
202
|
+
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>"] },
|
203
|
+
'</table>',
|
204
|
+
'</td></tr></table></td></tr></table></div>'
|
205
|
+
].join
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
data/lib/commands.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative('hash.rb')
|
2
|
+
require_relative('pull.rb')
|
3
|
+
require_relative('update.rb')
|
4
|
+
require_relative('setup.rb')
|
5
|
+
require_relative('build.rb')
|
6
|
+
require_relative('test.rb')
|
7
|
+
require_relative('analyze.rb')
|
8
|
+
require_relative('publish.rb')
|
9
|
+
require_relative('doc.rb')
|
10
|
+
require_relative('clean.rb')
|
11
|
+
require_relative('clobber.rb')
|
12
|
+
require_relative('add.rb')
|
13
|
+
require_relative('commit.rb')
|
14
|
+
require_relative('push.rb')
|
15
|
+
|
16
|
+
class Commands < Hash
|
17
|
+
|
18
|
+
def initialize directory=Dir.pwd
|
19
|
+
Dir.chdir(directory) do
|
20
|
+
self[:pull]=Pull.new
|
21
|
+
self[:update]=Update.new
|
22
|
+
self[:setup]=Setup.new
|
23
|
+
self[:build]=Build.new
|
24
|
+
self[:test]=Test.new
|
25
|
+
self[:analyze]=Analyze.new
|
26
|
+
self[:doc]=Doc.new
|
27
|
+
self[:clean]=Clean.new
|
28
|
+
self[:publish]=Publish.new
|
29
|
+
self[:clobber]=Clobber.new
|
30
|
+
self[:add]=Add.new
|
31
|
+
self[:commit]=Commit.new
|
32
|
+
self[:push]=Push.new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/commit.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative('internet.rb')
|
2
|
+
|
3
|
+
class Commit < Array
|
4
|
+
def update
|
5
|
+
if(File.exists?('.git') && `git config --list`.include?('user.name='))
|
6
|
+
if(!`git status`.include?('nothing to commit') &&
|
7
|
+
!`git status`.include?('untracked files present'))
|
8
|
+
if(File.exists?('commit.message') && File.read('commit.message').gsub(/\s+/,"").length >0)
|
9
|
+
add "git commit -a -v -m \"#{File.read('commit.message')}\""
|
10
|
+
else
|
11
|
+
add "git commit -m'all'"
|
12
|
+
end
|
13
|
+
add "<%FileUtils.rm('commit.message')%>" if File.exists?('commit.message')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
if(File.exists?('.svn') && Internet.available?)
|
17
|
+
add 'svn commit -m"commit all"'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/dev.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
require 'dev_environment'
|
2
|
-
require 'dev_commands'
|
3
|
-
require 'dev_git'
|
4
|
-
require 'dev_svn'
|
5
|
-
require 'dev_tasks'
|
6
|
-
require 'dev_projects'
|
1
|
+
#require 'dev_environment'
|
2
|
+
#require 'dev_commands'
|
3
|
+
#require 'dev_git'
|
4
|
+
#require 'dev_svn'
|
5
|
+
#require 'dev_tasks'
|
6
|
+
#require 'dev_projects'
|
7
7
|
require 'rake/clean'
|
8
8
|
|
9
|
+
Dir.glob("#{File.dirname(__FILE__)}/*.rb").each{|rb|
|
10
|
+
puts rb
|
11
|
+
require_relative(rb)
|
12
|
+
}
|
13
|
+
|
9
14
|
CLOBBER.include('*.gem')
|
10
15
|
|
11
16
|
|
data/lib/dev_commands.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rake/clean'
|
3
|
+
|
4
|
+
CLEAN.include('obj','tmp')
|
5
|
+
CLEAN.include('*.{sdf,sud,ncb,cache,user}')
|
6
|
+
CLOBBER.include('bin','doc','*.gem','tmp')
|
7
|
+
CLOBBER.include('*.{dll,pdb}')
|
8
|
+
|
9
|
+
SOURCE=FileList.new('LICENSE','README','README.md',"Gemfile")
|
10
|
+
SOURCE.include('*.{gitignore,yml,gemspec,rb}')
|
11
|
+
SOURCE.include('*.{cs}')
|
12
|
+
SOURCE.include('*.{c,h}')
|
13
|
+
SOURCE.include('*.{cpp,hpp}')
|
14
|
+
|
15
|
+
Dir.glob("#{File.dirname(__FILE__)}/commands/*.rb").each{|rb|
|
16
|
+
require(rb)
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
COMMANDS=Commands.new
|
21
|
+
MSBUILD=MSBuild.new
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'environment.rb'
|
data/lib/dev_git.rb
ADDED
data/lib/dev_msbuild.rb
ADDED
File without changes
|
data/lib/dev_projects.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
Dir.glob("#{File.dirname(__FILE__)}/*.rb").each{|rb|
|
3
|
+
require_relative(rb)
|
4
|
+
}
|
5
|
+
|
6
|
+
PROJECTS=Projects.new
|
7
|
+
PROJECTS.open Projects.user_projects_filename if File.exists? Projects.user_projects_filename
|
8
|
+
PROJECTS.save Projects.user_projects_filename if !File.exists? Projects.user_projects_filename
|
9
|
+
|
10
|
+
class DevProjects
|
11
|
+
end
|
data/lib/dev_svn.rb
ADDED
data/lib/dev_tasks.rb
ADDED
data/lib/doc.rb
ADDED
@@ -0,0 +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
|
9
|
+
end
|
data/lib/environment.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
class Environment < Hash
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
self[:home]=Environment.home
|
5
|
+
self[:machine]=Environment.machine
|
6
|
+
self[:user]=Environment.user
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.home
|
10
|
+
["USERPROFILE","HOME"].each {|v|
|
11
|
+
return ENV[v].gsub('\\','/') unless ENV[v].nil?
|
12
|
+
}
|
13
|
+
dir="~"
|
14
|
+
dir=ENV["HOME"] unless ENV["HOME"].nil?
|
15
|
+
dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
|
16
|
+
return dir
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.machine
|
20
|
+
if !ENV['COMPUTERNAME'].nil?
|
21
|
+
return ENV['COMPUTERNAME']
|
22
|
+
end
|
23
|
+
|
24
|
+
machine = `hostname`
|
25
|
+
machine = machine.split('.')[0] if machine.include?('.')
|
26
|
+
return machine.strip
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.user
|
30
|
+
return ENV['USER'] if !ENV['USER'].nil? #on Unix
|
31
|
+
ENV['USERNAME']
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.dev_root
|
35
|
+
["DEV_HOME","DEV_ROOT"].each {|v|
|
36
|
+
if !ENV[v].nil?
|
37
|
+
if(ENV[v].include?(';'))
|
38
|
+
ENV[v].split(';').each{|d|
|
39
|
+
return d if File.exists?(d)
|
40
|
+
}
|
41
|
+
else
|
42
|
+
return ENV[v].gsub('\\','/')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
}
|
46
|
+
dir=home
|
47
|
+
return dir
|
48
|
+
end
|
49
|
+
end
|
data/lib/gemspec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
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" if !spec.nil?
|
11
|
+
return ""
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.version gemspec_file
|
15
|
+
spec=Gem::Specification.load(gemspec_file)
|
16
|
+
return spec.version.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.published_version gemspec_file
|
20
|
+
published_version=''
|
21
|
+
spec=Gem::Specification.load(gemspec_file)
|
22
|
+
begin
|
23
|
+
published_version = `gem list -r #{spec.name}`.scan(/\((\d+.\d+.\d+)\)/)[0][0]
|
24
|
+
rescue
|
25
|
+
published_version=''
|
26
|
+
end
|
27
|
+
published_version
|
28
|
+
end
|
29
|
+
def self.published? gemspec_file
|
30
|
+
published_version(gemspec_file)==version(gemspec_file) ? true : false
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.normalize gemspec_file
|
34
|
+
spec=Gem::Specification.load(gemspec_file)
|
35
|
+
File.open(gemspec_file,'w'){|f|f.write(spec.to_ruby)}
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.upgrade gemspec_file
|
39
|
+
end
|
40
|
+
end
|
data/lib/git.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
class Git
|
2
|
+
def self.branch directory=''
|
3
|
+
directory=Dir.pwd if directory.length == 0
|
4
|
+
Dir.chdir(directory) do
|
5
|
+
begin
|
6
|
+
`git branch`.scan(/\* ([.\w-]+)/)[0][0] if(File.exists?('.git'))
|
7
|
+
rescue
|
8
|
+
''
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.remote_origin directory=''
|
14
|
+
url=''
|
15
|
+
directory=Dir.pwd if directory.length == 0
|
16
|
+
Dir.chdir(directory) do
|
17
|
+
begin
|
18
|
+
url=`git remote show origin`.scan(/Fetch URL: ([\.\-:\/\w\d]+)/)[0][0] if(File.exists?('.git'))
|
19
|
+
rescue
|
20
|
+
url=''
|
21
|
+
end
|
22
|
+
end
|
23
|
+
url
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.has_changes? directory=''
|
27
|
+
directory=Dir.pwd if directory.length==0
|
28
|
+
Dir.chdir(directory) do
|
29
|
+
if(File.exists?('.git'))
|
30
|
+
return true if `git status`.include?('modified:')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.init directory=''
|
37
|
+
directory=Dir.pwd if directory.length==0
|
38
|
+
FileUtils.mkpath directory if !File.exists?(directory)
|
39
|
+
if(!File.exists?("#{directory}/.git"))
|
40
|
+
Dir.chdir(directory) do
|
41
|
+
`git init`
|
42
|
+
File.open('.gitignore','w'){|f|
|
43
|
+
f.puts '### Mac ###'
|
44
|
+
f.puts '*.DS_Store'
|
45
|
+
}
|
46
|
+
`git add .gitignore`
|
47
|
+
`git commit -m'added .gitignore'`
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/hash.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
class Hash
|
2
|
+
def execute value=nil
|
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(value) 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
|
+
end
|
data/lib/info.rb
ADDED
data/lib/internet.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
#require 'net/http'
|
3
|
+
require 'timeout'
|
4
|
+
class Internet
|
5
|
+
|
6
|
+
@@available=true
|
7
|
+
|
8
|
+
def self.available?
|
9
|
+
return @@available if !@@available.nil?
|
10
|
+
|
11
|
+
begin
|
12
|
+
index=open('http://www.google.com').read
|
13
|
+
if index.include?('<Title>Google')
|
14
|
+
@@available = true
|
15
|
+
else
|
16
|
+
puts "open('http://www.google.com') returned false"
|
17
|
+
end
|
18
|
+
rescue Exception => e
|
19
|
+
puts "open('http://www.google.com') raised an exception: #{e.to_s}"
|
20
|
+
@@available = false
|
21
|
+
end
|
22
|
+
@@available
|
23
|
+
end
|
24
|
+
end
|