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.
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/dev/Commands.rb', line 6
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
self[:pull]=Dev::Cmd::Pull.new
self[:deep_pull]=Dev::Cmd::DeepPull.new
refresh
end
|
Class Method Details
.execute_cmd(c) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/dev/Commands.rb', line 64
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/dev/Commands.rb', line 86
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/dev/Commands.rb', line 118
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/dev/Commands.rb', line 102
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 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
34
|
# File 'lib/dev/Commands.rb', line 34
def compile; execute_method "compile"; end
|
#deep_pull ⇒ Object
38
|
# File 'lib/dev/Commands.rb', line 38
def deep_pull; Dev::Cmd::DeepPull.execute; end
|
#execute(c) ⇒ Object
61
62
63
|
# File 'lib/dev/Commands.rb', line 61
def execute(c)
Dev::Commands::execute_cmd(c)
end
|
#execute_method(name) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/dev/Commands.rb', line 44
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
# File 'lib/dev/Commands.rb', line 146
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
32
|
# File 'lib/dev/Commands.rb', line 32
def info; Dev::Cmd::Info.execute; end
|
#pull ⇒ Object
37
|
# File 'lib/dev/Commands.rb', line 37
def pull; Dev::Cmd::Pull.execute; end
|
#push ⇒ Object
36
|
# File 'lib/dev/Commands.rb', line 36
def push; Dev::Cmd::Push.execute; end
|
#refresh ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/dev/Commands.rb', line 18
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")
self[:pull].refresh if self[:pull].respond_to?("refresh")
self[:deep_pull].refresh if self[:deep_pull].respond_to?("refresh")
puts_debug "Commands refresh elapsed time " + (Time.now-start_time).to_s
end
|
#replace ⇒ Object
40
41
42
|
# File 'lib/dev/Commands.rb', line 40
def replace
self[:replace].execute if self[:replace].respond_to?("execute")
end
|
#setup ⇒ Object
33
|
# File 'lib/dev/Commands.rb', line 33
def setup; execute_method "setup"; end
|
#test ⇒ Object
35
|
# File 'lib/dev/Commands.rb', line 35
def test; execute_method "test"; end
|
#update ⇒ Object
39
|
# File 'lib/dev/Commands.rb', line 39
def update;execute_method("update");end
|