automateit 0.71031 → 0.71031.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/lib/automateit/edit_manager.rb +15 -17
- data/lib/automateit/root.rb +1 -1
- data/spec/unit/edit_manager_spec.rb +8 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
@@ -183,10 +183,12 @@ class AutomateIt::EditManager::EditSession < AutomateIt::Common
|
|
183
183
|
# # Won't prepend line because Regexp matches exisint line in buffer.
|
184
184
|
# prepend("add this line", :unless => /add\s*this\*line/)
|
185
185
|
def prepend(line, opts={})
|
186
|
-
query =
|
187
|
-
|
186
|
+
query = opts[:unless] || line
|
187
|
+
if query.is_a?(String)
|
188
|
+
query = Regexp.new(Regexp.escape(query))
|
189
|
+
end
|
188
190
|
return if contains?(query)
|
189
|
-
@contents = "%s\n%s" % [line, @contents]
|
191
|
+
@contents = "%s\n%s" % [line.chomp, @contents]
|
190
192
|
end
|
191
193
|
|
192
194
|
# Append +line+ to the bottom of the buffer, but only if it's not in
|
@@ -207,16 +209,14 @@ class AutomateIt::EditManager::EditSession < AutomateIt::Common
|
|
207
209
|
end
|
208
210
|
|
209
211
|
# Does the buffer contain anything that matches the String or Regexp +query+?
|
210
|
-
def contains?(
|
211
|
-
|
212
|
-
query = Regexp.new(Regexp.escape(query))
|
213
|
-
end
|
212
|
+
def contains?(line)
|
213
|
+
query = line.is_a?(String) ? Regexp.new(Regexp.escape(line)) : line
|
214
214
|
! @contents.match(query).nil?
|
215
215
|
end
|
216
216
|
|
217
217
|
# Delete lines matching the String or Regexp +query+
|
218
|
-
def delete(
|
219
|
-
query =
|
218
|
+
def delete(line, opts={})
|
219
|
+
query = line.is_a?(String) ? Regexp.escape(line) : line
|
220
220
|
query = Regexp.new("^[^\n]*%s[^\n]*\n?" % query)
|
221
221
|
@contents.gsub!(query, "")
|
222
222
|
end
|
@@ -232,26 +232,24 @@ class AutomateIt::EditManager::EditSession < AutomateIt::Common
|
|
232
232
|
end
|
233
233
|
|
234
234
|
# Comment out lines matching the String or Regexp +query+.
|
235
|
-
def comment(
|
236
|
-
query =
|
235
|
+
def comment(line, opts={})
|
236
|
+
query = line.is_a?(String) ? Regexp.escape(line) : line
|
237
237
|
query = Regexp.new("^(?!#{comment_prefix})([^\n]*%s[^\n]*)(\n*)" % query)
|
238
238
|
return false unless @contents.match(query)
|
239
239
|
@contents.gsub!(query, "%s%s%s%s" % [@comment_prefix, $1, @comment_suffix, $2])
|
240
240
|
end
|
241
241
|
|
242
242
|
# Uncomment lines matching the String or Regexp +query+.
|
243
|
-
def uncomment(
|
244
|
-
query =
|
243
|
+
def uncomment(line, opts={})
|
244
|
+
query = line.is_a?(String) ? Regexp.escape(line) : line
|
245
245
|
query = Regexp.new("^(%s)([^\n]*%s[^\n]*)(%s)(\n*)" % [@comment_prefix, query, @comment_suffix])
|
246
246
|
return false unless @contents.match(query)
|
247
247
|
@contents.gsub!(query, "%s%s" % [$2, $4])
|
248
248
|
end
|
249
249
|
|
250
250
|
# Replace contents matching the String or Regexp +query+ with the +string+.
|
251
|
-
def replace(
|
252
|
-
|
253
|
-
query = Regexp.new(Regexp.escape(query))
|
254
|
-
end
|
251
|
+
def replace(line, string, opts={})
|
252
|
+
query = line.is_a?(String) ? Regexp.new(Regexp.escape(line)) : line
|
255
253
|
@contents.gsub!(query, string)
|
256
254
|
end
|
257
255
|
|
data/lib/automateit/root.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# See AutomateIt::Interpreter for usage information.
|
2
2
|
module AutomateIt # :nodoc:
|
3
3
|
# AutomateIt version
|
4
|
-
VERSION=Gem::Version.new("0.71031")
|
4
|
+
VERSION=Gem::Version.new("0.71031.1")
|
5
5
|
|
6
6
|
# Instantiates a new Interpreter. See documentation for
|
7
7
|
# Interpreter#setup.
|
@@ -41,6 +41,14 @@ describe "AutomateIt::EditManager for strings" do
|
|
41
41
|
output.should =~ /\APREPEND\nThis/s
|
42
42
|
end
|
43
43
|
|
44
|
+
it "should prepend strings to the top even if they have regexp-like characters" do
|
45
|
+
output = @a.edit(:text => @input) do
|
46
|
+
prepend "@ini_set('memory_limit', '32M');"
|
47
|
+
prepend "@ini_set('memory_limit', '32M');" # Will be ignored
|
48
|
+
end
|
49
|
+
output.should == "@ini_set('memory_limit', '32M');"+"\n"+@input
|
50
|
+
end
|
51
|
+
|
44
52
|
it "should prepend lines to the top unless they match an expression" do
|
45
53
|
output = @a.edit(:text => @input) do
|
46
54
|
prepend "PREPEND", :unless => /PR.+ND/
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: automateit
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version:
|
6
|
+
version: 0.71031.1
|
7
7
|
date: 2007-10-31 00:00:00 -07:00
|
8
8
|
summary: AutomateIt is an open source tool for automating the setup and maintenance of servers, applications and their dependencies.
|
9
9
|
require_paths:
|
metadata.gz.sig
CHANGED
Binary file
|