cowtech-lib 1.9.1 → 1.9.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/cowtech-lib.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cowtech-lib}
8
- s.version = "1.9.1"
8
+ s.version = "1.9.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Shogun"]
@@ -27,9 +27,9 @@
27
27
 
28
28
  require "rexml/document"
29
29
 
30
- class String
31
- def to_a
32
- [self]
30
+ class Object
31
+ def force_array
32
+ self.is_a?(Array) ? self : [self]
33
33
  end
34
34
  end
35
35
 
@@ -285,7 +285,7 @@ module Cowtech
285
285
  msg += " " unless msg =~ / ^/
286
286
 
287
287
  # Turn choices into regular expressions
288
- regexps = (args[:valids] || []).to_a.collect do |valid|
288
+ regexps = (args[:valids] || []).force_array.collect do |valid|
289
289
  unless valid.is_a?(Regexp) then
290
290
  valid = Regexp.new((valid !~ /^\^/ ? "^" : "") + valid + (valid !~ /\$$/ ? "$" : ""), Regexp::EXTENDED + (args[:case_sensitive] ? Regexp::IGNORECASE : 0), "U")
291
291
  else
@@ -82,7 +82,7 @@ module Cowtech
82
82
  # * <em>dots</em>: If show dots after message
83
83
  def task(args)
84
84
  if args.fetch(:show_msg, true) then
85
- @console.write(:begin => args[:msg], :dots => args[:dots]) if args.fetch(:show_msg, true)
85
+ @console.write(:begin => args[:msg], :dots => args[:dots])
86
86
  @console.indent_set(3)
87
87
  end
88
88
 
@@ -93,7 +93,7 @@ module Cowtech
93
93
 
94
94
  # Show the result
95
95
  if args.fetch(:show_result, true) then
96
- @console.status(:status => rv[0], :fatal => false) if args.fetch(:show_result, true)
96
+ @console.status(:status => rv[0], :fatal => false)
97
97
  @console.indent_set(-3)
98
98
  end
99
99
 
@@ -105,7 +105,7 @@ module Cowtech
105
105
  # Returns: <em>true</em> if any of tests had success, <em>false</em> otherwise
106
106
  def file_check?(args)
107
107
  rv = false
108
- tests = (args[:tests] || [:exists]).to_a
108
+ tests = (args[:tests] || [:exists]).force_array
109
109
 
110
110
  if args[:file] then
111
111
  rv = true
@@ -127,7 +127,7 @@ module Cowtech
127
127
  # Returns: <em>true</em> if operation had success, <em>false</em> otherwise.
128
128
  def delete_files!(args)
129
129
  rv = true
130
- files = args[:files].to_a
130
+ files = args[:files].force_array
131
131
 
132
132
  begin
133
133
  FileUtils.rm_r(files, {:noop => @console.skip_commands, :verbose => @console.skip_commands, :secure => true})
@@ -169,7 +169,7 @@ module Cowtech
169
169
  # Returns: <em>true</em> if operation had success, <em>false</em> otherwise.
170
170
  def create_directories(args)
171
171
  rv = true
172
- files = args[:files].to_a
172
+ files = args[:files].force_array
173
173
 
174
174
  files.each do |file|
175
175
  if self.file_check?(:files => file, :tests => :exists) then
@@ -229,7 +229,7 @@ module Cowtech
229
229
 
230
230
  # If we are copy or moving to a directory
231
231
  if args[:destination_is_directory] then
232
- files = (args[:files] || []).to_a
232
+ files = (args[:files] || []).force_array
233
233
  dest = args[:dest]
234
234
  dest += "/" if self.file_check?(dest, :directory) and dest !~ /\/$/
235
235
 
@@ -325,8 +325,8 @@ module Cowtech
325
325
  # TODO: E se patterns è vuoto?
326
326
  rv = []
327
327
 
328
- paths = args[:paths].to_a
329
- string_patterns = args[:patterns].to_a
328
+ paths = args[:paths].force_array
329
+ string_patterns = args[:patterns].force_array
330
330
 
331
331
  if paths.length > 0 then
332
332
  # Convert patterns to regexp
@@ -362,7 +362,7 @@ module Cowtech
362
362
  #
363
363
  # Returns: List of found files.
364
364
  def find_by_extension(args)
365
- args[:patterns] = (args[:extensions] || "").to_a.collect do |extension|
365
+ args[:patterns] = (args[:extensions] || "").force_array.collect do |extension|
366
366
  Regexp.new(extension + "$", Regexp::IGNORECASE)
367
367
  end
368
368
 
@@ -4,7 +4,7 @@ module Cowtech
4
4
  MAJOR = 1
5
5
  MINOR = 9
6
6
  PATCH = 1
7
- BUILD = nil
7
+ BUILD = 1
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
10
10
  end
metadata CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 1
7
7
  - 9
8
8
  - 1
9
- version: 1.9.1
9
+ - 1
10
+ version: 1.9.1.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Shogun