Class: Dev::Commands
- Inherits:
-
Hash
- Object
- Hash
- Dev::Commands
show all
- Defined in:
- lib/dev/Commands.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Hash
get_hash_value, #get_value, print_hash, set_hash_value, #set_value, #strip_auto_entries
Constructor Details
Returns a new instance of Commands.
Class Method Details
.execute_cmd(c) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/dev/Commands.rb', line 57
def self.execute_cmd(c)
command=Dev::Environment.expand_command(c)
puts_debug "command: " + command.to_s + " (in Project.execute_cmd)"
if c.include?('<%') && c.include?('%>')
eval(c.gsub("<%","").gsub("%>",""))
else
hash=c if c.kind_of?(Hash)
hash=Dev::Environment.s_to_hash(command) if hash.nil?
call=nil
if(hash.nil?)
call=Dev::SystemCall.new(command)
else
call=Dev::SystemCall.new(hash)
end
call.puts_summary
end
end
|
Instance Method Details
#add ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/dev/Commands.rb', line 79
def add
unless DEV[:src_glob].nil?
scm = Dev::Scm.new
return if scm.scm_type == "none"
if DEV[:src_glob].kind_of?(Hash)
DEV[:src_glob].each do |name,value|
puts " adding files " + value.to_s
scm.add_file_glob(value)
end
else
puts " adding files " + DEV[:src_glob].to_s
scm.add_file_glob(DEV[:src_glob])
end
end
end
|
#check ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/dev/Commands.rb', line 110
def check
puts " default.taskstamp." + DEV.context + " exists." if File.exists?("default.taskstamp."+ DEV.context)
puts " default.taskstamp." + DEV.context + " does not exist" unless File.exists?("default.taskstamp." +DEV.context)
begin
hasdiff = has_diff
rescue
puts "has_diff threw an exception."
end
puts " no differences detected." unless hasdiff
puts " detected differences." if hasdiff
if File.exists?("default.taskstamp."+DEV.context) && !hasdiff
update
exit
end
end
|
#commit ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/dev/Commands.rb', line 95
def commit
scm = Dev::Scm.new
return if scm.scm_type == "none"
puts " no differences detected" unless has_diff
execute_method("commit") if has_diff
if File.exists?(".svn")
call=Dev::SystemCall.new('svn update')
call=Dev::SystemCall.new('svn info')
url = call.output.match(/URL: ([\d\w\.\:\/-]+)/)[1]
rev = call.output.match(/Last Changed Rev: ([\d]+)/)[1]
puts " #{url}@#{rev}"
end
FileUtils.rm "commit.message" if File.exists?("commit.message")
end
|
#compile ⇒ Object
30
|
# File 'lib/dev/Commands.rb', line 30
def compile; execute_method "compile"; end
|
#execute_method(name) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/dev/Commands.rb', line 37
def execute_method(name)
string_name=name.to_s
puts_debug "method_missing name=" + string_name
puts " no directives defined for #{string_name}" if self.get_value(string_name).nil? && string_name=="pull"
return if(self.get_value(string_name).nil?)
puts " no directives defined for #{string_name}" if self.get_value(string_name).length < 1
return if self.get_value(string_name).length < 1
value=self.get_value(string_name)
if value.kind_of?(Hash)
value.each { |name,value| Dev::Commands.execute_cmd(value); sleep(0.5) }
else
value.each { |c| Dev::Commands.execute_cmd(c); sleep(0.5) }
end
end
|
#has_diff ⇒ Object
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/dev/Commands.rb', line 138
def has_diff
call=nil
if DEV[:scm_type] == "git"
call=Dev::SystemCall.new('git status')
return true if call.output.include?("new file:")
return true if call.output.include?("deleted:")
return true if call.output.include?("modified:")
return false
end
call=Dev::SystemCall.new('svn diff') if File.exists?(".svn")
unless call.nil? || call.output.length==0
puts_debug call.output
return true else
return false end
end
|
#refresh ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/dev/Commands.rb', line 17
def refresh
puts_debug "Dev::Command.refresh"
self[:setup].refresh(DEV[:dep]) if self[:setup].respond_to?("refresh")
self[:replace].refresh(DEV[:dep]) if self[:replace].respond_to?("refresh")
self[:compile].refresh if self[:compile].respond_to?("refresh")
self[:test].refresh if self[:test].respond_to?("refresh")
self[:commit].refresh if self[:commit].respond_to?("refresh")
self[:update].refresh if self[:update].respond_to?("refresh")
self[:pull].refresh if self[:pull].respond_to?("refresh")
end
|
#replace ⇒ Object
33
34
35
|
# File 'lib/dev/Commands.rb', line 33
def replace
self[:replace].execute if self[:replace].respond_to?("execute")
end
|
#setup ⇒ Object
29
|
# File 'lib/dev/Commands.rb', line 29
def setup; execute_method "setup"; end
|
#test ⇒ Object
31
|
# File 'lib/dev/Commands.rb', line 31
def test; execute_method "test"; end
|
#update ⇒ Object
32
|
# File 'lib/dev/Commands.rb', line 32
def update;execute_method("update");end
|