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.
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/dev/Commands.rb', line 17
def initialize
self[:setup]=Dev::Cmd::Setup.new
self[:replace]=Dev::Cmd::Replace.new
self[:compile]=Dev::Cmd::Compile.new
self[:test]=Dev::Cmd::Test.new
self[:commit]=Dev::Cmd::Commit.new
self[:update]=Dev::Cmd::Update.new
if(RUBY_VERSION != "1.8.7")
self[:pull]=Dev::Cmd::Pull.new
self[:deep_pull]=Dev::Cmd::DeepPull.new
end
refresh
end
|
Class Method Details
.execute_cmd(c) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/dev/Commands.rb', line 79
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/dev/Commands.rb', line 101
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/dev/Commands.rb', line 133
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/dev/Commands.rb', line 117
def commit
scm = Dev::Scm.new
return if scm.scm_type == "none"
puts " no differences detected" unless has_diff
execute_method("commit")
if Scm.get_default_scm_type == "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
49
|
# File 'lib/dev/Commands.rb', line 49
def compile; execute_method "compile"; end
|
#deep_pull ⇒ Object
53
|
# File 'lib/dev/Commands.rb', line 53
def deep_pull; Dev::Cmd::DeepPull.execute; end
|
#execute(c) ⇒ Object
76
77
78
|
# File 'lib/dev/Commands.rb', line 76
def execute(c)
Dev::Commands::execute_cmd(c)
end
|
#execute_method(name) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/dev/Commands.rb', line 59
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/dev/Commands.rb', line 161
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 Scm.get_default_scm_type == "svn"
unless call.nil? || call.output.length==0
puts_debug call.output
return true
else
return false
end
end
|
#info ⇒ Object
47
|
# File 'lib/dev/Commands.rb', line 47
def info; Dev::Cmd::Info.execute; end
|
#pull ⇒ Object
52
|
# File 'lib/dev/Commands.rb', line 52
def pull; Dev::Cmd::Pull.execute; end
|
#push ⇒ Object
51
|
# File 'lib/dev/Commands.rb', line 51
def push; Dev::Cmd::Push.execute; end
|
#refresh ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/dev/Commands.rb', line 31
def refresh
puts_debug "Dev::Command.refresh"
start_time=Time.now
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")
if(RUBY_VERSION != "1.8.7")
self[:pull].refresh if self[:pull].respond_to?("refresh")
self[:deep_pull].refresh if self[:deep_pull].respond_to?("refresh")
end
puts_debug "Commands refresh elapsed time " + (Time.now-start_time).to_s
end
|
#replace ⇒ Object
55
56
57
|
# File 'lib/dev/Commands.rb', line 55
def replace
self[:replace].execute if self[:replace].respond_to?("execute")
end
|
#setup ⇒ Object
48
|
# File 'lib/dev/Commands.rb', line 48
def setup; execute_method "setup"; end
|
#test ⇒ Object
50
|
# File 'lib/dev/Commands.rb', line 50
def test; execute_method "test"; end
|
#update ⇒ Object
54
|
# File 'lib/dev/Commands.rb', line 54
def update;execute_method("update");end
|