tagen 1.1.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -1
- data/.travis.yml +5 -0
- data/CHANGELOG +6 -0
- data/Gemfile +2 -3
- data/Gemfile.lock +13 -15
- data/README.md +20 -39
- data/Rakefile +2 -1
- data/benchmark/a.rb +14 -0
- data/lib/tagen/core.rb +17 -22
- data/lib/tagen/core/array.rb +5 -109
- data/lib/tagen/core/array/append.rb +3 -0
- data/lib/tagen/core/array/delete_values.rb +43 -0
- data/lib/tagen/core/array/extract_options.rb +35 -94
- data/lib/tagen/core/class.rb +1 -0
- data/lib/tagen/core/enumerable.rb +15 -18
- data/lib/tagen/core/enumerator.rb +22 -12
- data/lib/tagen/core/exception.rb +5 -3
- data/lib/tagen/core/file.rb +1 -0
- data/lib/tagen/core/hash.rb +4 -39
- data/lib/tagen/core/integer.rb +2 -0
- data/lib/tagen/core/io.rb +59 -26
- data/lib/tagen/core/kernel.rb +5 -64
- data/lib/tagen/core/kernel/deprecate.rb +5 -0
- data/lib/tagen/core/kernel/platform.rb +46 -0
- data/lib/tagen/core/kernel/shell.rb +45 -0
- data/lib/tagen/core/module.rb +9 -11
- data/lib/tagen/core/numeric.rb +4 -2
- data/lib/tagen/core/object.rb +6 -21
- data/lib/tagen/core/process.rb +6 -4
- data/lib/tagen/core/re.rb +2 -2
- data/lib/tagen/core/string.rb +12 -47
- data/lib/tagen/core/time.rb +30 -38
- data/lib/tagen/erb.rb +10 -8
- data/lib/tagen/net/http.rb +33 -29
- data/lib/tagen/pathname.rb +1 -5
- data/lib/tagen/rbconfig.rb +8 -0
- data/lib/tagen/socket.rb +8 -2
- data/lib/tagen/uri.rb +9 -0
- data/lib/tagen/version.rb +1 -1
- data/lib/tagen/vim.rb +8 -8
- data/lib/tagen/xmpp4r.rb +23 -23
- data/spec/spec_helper.rb +23 -17
- data/spec/tagen/core/array/delete_values_spec.rb +19 -0
- data/spec/tagen/core/array/extract_options_spec.rb +9 -29
- data/spec/tagen/core/enumerable_spec.rb +9 -0
- data/spec/tagen/core/enumerator_spec.rb +10 -12
- data/spec/tagen/core/exception_spec.rb +14 -9
- data/spec/tagen/core/io_spec.rb +20 -0
- data/spec/tagen/core/kernel/platform_spec.rb +92 -0
- data/spec/tagen/core/kernel/shell_spec.rb +27 -0
- data/spec/tagen/core/numeric_spec.rb +10 -0
- data/spec/tagen/core/process_spec.rb +14 -0
- data/spec/tagen/core/re_spec.rb +9 -0
- data/spec/tagen/core/string_spec.rb +9 -0
- data/spec/tagen/core/time_spec.rb +6 -51
- data/spec/tagen/erb_spec.rb +3 -10
- data/spec/tagen/pathname_spec.rb +11 -0
- data/spec/tagen/rbconfig_spec.rb +11 -0
- data/spec/tagen/socket_spec.rb +7 -5
- data/spec/tagen/uri_spec.rb +13 -0
- data/tagen.gemspec +3 -4
- metadata +45 -51
- data/TODO +0 -1
- data/docs/Architecture.md +0 -17
- data/docs/CoreExtensions.md +0 -40
- data/docs/ExtraExtensions.md +0 -20
- data/lib/tagen/RMagick.rb +0 -12
- data/lib/tagen/audioinfo.rb +0 -22
- data/lib/tagen/cairo.rb +0 -811
- data/lib/tagen/core/extend_hash.rb +0 -46
- data/lib/tagen/core/marshal.rb +0 -34
- data/lib/tagen/core/open_option.rb +0 -161
- data/lib/tagen/core/string/pyformat.rb +0 -336
- data/lib/tagen/core/symbol.rb +0 -8
- data/lib/tagen/date.rb +0 -80
- data/lib/tagen/gdk_pixbuf2.rb +0 -26
- data/lib/tagen/gtk2.rb +0 -122
- data/lib/tagen/ncurses.rb +0 -246
- data/lib/tagen/poppler.rb +0 -48
- data/lib/tagen/tree.rb +0 -77
- data/lib/tagen/xmpp4r/roster.rb +0 -20
- data/lib/tagen/yaml.rb +0 -38
- data/spec/tagen/cairo_spec.rb +0 -137
- data/spec/tagen/core/array_spec.rb +0 -42
- data/spec/tagen/core/extend_hash_spec.rb +0 -54
- data/spec/tagen/core/hash_spec.rb +0 -10
- data/spec/tagen/core/module_spec.rb +0 -14
- data/spec/tagen/core/open_option_spec.rb +0 -83
- data/spec/tagen/core/string/pyformat_spec.rb +0 -98
- data/spec/tagen/core/symbol_spec.rb +0 -15
- data/spec/tagen/core_spec.rb +0 -6
- data/spec/tagen/date_spec.rb +0 -146
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CHANGELOG
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,30 +1,28 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (3.
|
4
|
+
activesupport (3.2.8)
|
5
|
+
i18n (~> 0.6)
|
5
6
|
multi_json (~> 1.0)
|
6
|
-
awesome_print (1.0.2)
|
7
7
|
diff-lcs (1.1.3)
|
8
8
|
i18n (0.6.0)
|
9
|
-
multi_json (1.
|
10
|
-
pd (1.0
|
11
|
-
rspec (2.
|
12
|
-
rspec-core (~> 2.
|
13
|
-
rspec-expectations (~> 2.
|
14
|
-
rspec-mocks (~> 2.
|
15
|
-
rspec-core (2.
|
16
|
-
rspec-expectations (2.
|
17
|
-
diff-lcs (~> 1.1.
|
18
|
-
rspec-mocks (2.
|
9
|
+
multi_json (1.3.6)
|
10
|
+
pd (1.1.0)
|
11
|
+
rspec (2.11.0)
|
12
|
+
rspec-core (~> 2.11.0)
|
13
|
+
rspec-expectations (~> 2.11.0)
|
14
|
+
rspec-mocks (~> 2.11.0)
|
15
|
+
rspec-core (2.11.1)
|
16
|
+
rspec-expectations (2.11.2)
|
17
|
+
diff-lcs (~> 1.1.3)
|
18
|
+
rspec-mocks (2.11.2)
|
19
19
|
watchr (0.7)
|
20
20
|
|
21
21
|
PLATFORMS
|
22
22
|
ruby
|
23
23
|
|
24
24
|
DEPENDENCIES
|
25
|
-
activesupport (~> 3.
|
26
|
-
awesome_print
|
27
|
-
i18n
|
25
|
+
activesupport (~> 3.2.8)
|
28
26
|
pd
|
29
27
|
rspec
|
30
28
|
watchr
|
data/README.md
CHANGED
@@ -1,57 +1,31 @@
|
|
1
|
-
Tagen, a core and extra extension
|
2
|
-
==========================================
|
1
|
+
# Tagen, a core and extra extension for Ruby [![Build Status](https://secure.travis-ci.org/GutenYe/tagen.png)](http://travis-ci.org/GutenYe/tagen)
|
3
2
|
|
4
|
-
|
|
3
|
+
| | |
|
5
4
|
|----------------|-----------------------------------------|
|
5
|
+
| Homepage: | https://github.com/GutenYe/tagen |
|
6
6
|
| Author: | Guten |
|
7
7
|
| License: | MIT LICENSE |
|
8
|
-
| Documentation: |
|
8
|
+
| Documentation: | https://github.com/GutenYe/tagen/wiki |
|
9
9
|
| Issue Tracker: | https://github.com/GutenYe/tagen/issues |
|
10
|
+
| Versions: | Ruby 1.9.3, Rubinius |
|
10
11
|
|
11
|
-
|
12
|
-
--------
|
13
|
-
|
14
|
-
extensions defined in "active_support" will not appear in here, so you can use it with "active_support".
|
15
|
-
|
16
|
-
Ruby has an 'Open Class' feature, so we can extend any class by ourself.
|
17
|
-
|
18
|
-
This library provides some usefull Ruby core extension. some comes from ActiveSupport. ActiveSupport is mainly target to Rails, but tagen is target to generic ruby development, and tagen is smaller. It is a colletion of most common core,extra extensions.
|
19
|
-
|
20
|
-
This library comes with a string format lib named {PyFormat}.
|
12
|
+
It based on "active_support", but it focus on generic ruby programming.
|
21
13
|
|
22
14
|
Usage
|
23
15
|
-----
|
24
16
|
|
25
|
-
|
26
|
-
|
27
|
-
require "tagen/core"
|
28
|
-
|
29
|
-
then we have Time.time method, for a list of core extensions, see {file:docs/CoreExtensions.md docs/CoreExtensions}.
|
30
|
-
|
31
|
-
use extra extension
|
17
|
+
Cherry-picking a Definition
|
32
18
|
|
33
|
-
require "tagen/
|
19
|
+
require "tagen/core/array/delete_values"
|
34
20
|
|
35
|
-
|
21
|
+
a = [1,2,3]
|
22
|
+
a.delete_values(1, 3) -> [1, 3]
|
23
|
+
a -> [2]
|
36
24
|
|
37
|
-
|
38
|
-
---------------------------
|
25
|
+
Load All Core Extensions
|
39
26
|
|
40
27
|
require "tagen/core"
|
41
|
-
"I like %{fruit} and %{sport}".format('apple', 'football')
|
42
|
-
"I like %{fruit} and %{sport}".format(fruit: 'apple', sport: 'football')
|
43
28
|
|
44
|
-
"it costs %{howmatch:.2f} dollars".format(1.123) #=> "it costs 1.12 dollars"
|
45
|
-
|
46
|
-
more see API doc
|
47
|
-
|
48
|
-
|
49
|
-
Documentation
|
50
|
-
-------------
|
51
|
-
|
52
|
-
* {file:docs/CoreExtensions.md CoreExtensions} A list of core extensions.
|
53
|
-
* {file:docs/ExtraExtensions.md ExtraExtensions} A list of extra extensions.
|
54
|
-
* {file:docs/Architecture.md Architecture} Source code architecture.
|
55
29
|
|
56
30
|
Install
|
57
31
|
----------
|
@@ -70,12 +44,19 @@ Contributors
|
|
70
44
|
|
71
45
|
* [contributors](https://github.com/GutenYe/tagen/contributors)
|
72
46
|
|
47
|
+
Resources
|
48
|
+
---------
|
49
|
+
|
50
|
+
* [activesupport](https://github.com/rails/rails/tree/master/activesupport): Utility classes and Ruby extensions from Rails
|
51
|
+
* [hashie](https://github.com/intridea/hashie): is a simple collection of useful Hash extensions.
|
52
|
+
* [facets](https://github.com/rubyworks/facets): is the premiere collection of general purpose method extensions and standard additions for the Ruby programming language.
|
53
|
+
|
73
54
|
Copyright
|
74
55
|
---------
|
75
56
|
|
76
57
|
(the MIT License)
|
77
58
|
|
78
|
-
Copyright (c) 2011 Guten
|
59
|
+
Copyright (c) 2011-2012 Guten
|
79
60
|
|
80
61
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
81
62
|
|
data/Rakefile
CHANGED
data/benchmark/a.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
dir = File.expand_path("../..", __FILE__)
|
4
|
+
$:.unshift File.join(dir, "lib")
|
5
|
+
ENV["BUNDLE_GEMFILE"] = File.join(dir, "Gemfile")
|
6
|
+
|
7
|
+
require "bundler/setup"
|
8
|
+
require "benchmark"
|
9
|
+
|
10
|
+
Benchmark.bm do |b|
|
11
|
+
b.report %[require "tagen/core"] do
|
12
|
+
require "tagen/core"
|
13
|
+
end
|
14
|
+
end
|
data/lib/tagen/core.rb
CHANGED
@@ -1,26 +1,21 @@
|
|
1
1
|
require "pd"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
core/module
|
3
|
+
require "tagen/core/object"
|
4
|
+
require "tagen/core/kernel"
|
5
|
+
require "tagen/core/module"
|
6
|
+
require "tagen/core/class"
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
require "tagen/core/numeric"
|
9
|
+
require "tagen/core/integer"
|
10
|
+
require "tagen/core/string"
|
11
|
+
require "tagen/core/enumerable"
|
12
|
+
require "tagen/core/enumerator"
|
13
|
+
require "tagen/core/array"
|
14
|
+
require "tagen/core/hash"
|
15
|
+
require "tagen/core/time"
|
16
|
+
require "tagen/core/exception"
|
17
|
+
require "tagen/core/io"
|
18
|
+
require "tagen/core/process"
|
19
|
+
require "tagen/core/re"
|
17
20
|
|
18
|
-
|
19
|
-
core/io
|
20
|
-
core/process
|
21
|
-
|
22
|
-
core/open_option
|
23
|
-
).each {|n| require_relative n }
|
24
|
-
|
25
|
-
# from active_support
|
26
|
-
require "active_support/core_ext"
|
21
|
+
require "active_support/concern"
|
data/lib/tagen/core/array.rb
CHANGED
@@ -1,109 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
* `#append` _alias from push_
|
7
|
-
|
8
|
-
=end
|
9
|
-
class Array
|
10
|
-
alias append push
|
11
|
-
|
12
|
-
alias original_delete delete
|
13
|
-
|
14
|
-
# support delete more than one values.
|
15
|
-
#
|
16
|
-
# original: delete(v)
|
17
|
-
# currrent: delete(*v)
|
18
|
-
#
|
19
|
-
# @return [Array]
|
20
|
-
def delete *values, &blk
|
21
|
-
indexs = values.each.with_object [] do |v,m|
|
22
|
-
m << original_delete(v, &blk)
|
23
|
-
end
|
24
|
-
values.length==1 ? indexs[0] : indexs
|
25
|
-
end
|
26
|
-
|
27
|
-
alias original_delete_at delete_at
|
28
|
-
|
29
|
-
# support delate_at more than one index.
|
30
|
-
#
|
31
|
-
# original: delete_at(i)
|
32
|
-
# current: delte_at(*i)
|
33
|
-
#
|
34
|
-
# @return [Array]
|
35
|
-
def delete_at *indexs, &blk
|
36
|
-
values = indexs.each.with_object [] do |i,m|
|
37
|
-
m << original_delete_at(i, &blk)
|
38
|
-
end
|
39
|
-
indexs.length==1 ? values[0] : values
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
# first n values, not works at Range, Range don't have #replace method
|
44
|
-
# @note modify IN PLACE
|
45
|
-
#
|
46
|
-
# @example
|
47
|
-
# a = %w(1 2 3)
|
48
|
-
# a.first!(2) #=> [1, 2]
|
49
|
-
# a #=> [3]
|
50
|
-
# @return Array
|
51
|
-
def first! n=1
|
52
|
-
i = 0
|
53
|
-
j = i + n
|
54
|
-
k = -1
|
55
|
-
|
56
|
-
ret = self[i...j]
|
57
|
-
self.replace self[j..k]
|
58
|
-
ret
|
59
|
-
end
|
60
|
-
|
61
|
-
# last n values
|
62
|
-
# @see first!
|
63
|
-
def last! n=1
|
64
|
-
i = -1
|
65
|
-
j = -1 - n + 1
|
66
|
-
k = 0
|
67
|
-
|
68
|
-
ret = self[j..i]
|
69
|
-
self.replace self[k...j]
|
70
|
-
ret
|
71
|
-
end
|
72
|
-
|
73
|
-
# same as find, but delete the finded value
|
74
|
-
def find! &blk
|
75
|
-
idx = self.find_index(&blk)
|
76
|
-
if idx
|
77
|
-
self.delete_at(idx)
|
78
|
-
else
|
79
|
-
nil
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# same as find_all, but delete all finded values
|
84
|
-
def find_all! &blk
|
85
|
-
ret, rest = [], []
|
86
|
-
self.each do |k|
|
87
|
-
if blk.call(k)
|
88
|
-
ret << k
|
89
|
-
else
|
90
|
-
rest << k
|
91
|
-
end
|
92
|
-
end
|
93
|
-
self.replace rest
|
94
|
-
ret
|
95
|
-
end
|
96
|
-
|
97
|
-
# confict with gem
|
98
|
-
#alias original_grep grep
|
99
|
-
|
100
|
-
# confict with awesome_print.
|
101
|
-
# add grep(arr rb/tage)
|
102
|
-
#def grep(pat_s, &blk)
|
103
|
-
#pats = Array===pat_s ? pat_s : [pat_s]
|
104
|
-
#pats.each.with_object([]) { |k, memo|
|
105
|
-
#memo.push *self.original_grep(k)
|
106
|
-
#}
|
107
|
-
#end
|
108
|
-
|
109
|
-
end # class Array
|
1
|
+
require "tagen/core/array/append"
|
2
|
+
require "tagen/core/array/delete_values"
|
3
|
+
require "tagen/core/array/extract_options"
|
4
|
+
require "active_support/core_ext/array/wrap"
|
5
|
+
require "active_support/core_ext/array/uniq_by"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Array
|
2
|
+
# Deletes items from self.
|
3
|
+
#
|
4
|
+
# @example
|
5
|
+
#
|
6
|
+
# a = [1, 2, 3]
|
7
|
+
# a.delete_values(1, 3) -> [1, 3]
|
8
|
+
# a -> [2]
|
9
|
+
#
|
10
|
+
# @return [Array]
|
11
|
+
# @see Array#delete
|
12
|
+
def delete_values(*values, &blk)
|
13
|
+
values.each.with_object([]) {|v,m|
|
14
|
+
m << delete(v, &blk)
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
# Deletes the element at the specified indexes.
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
#
|
22
|
+
# a = [1, 2, 3]
|
23
|
+
# a.delete_values_at(0, 2) -> [1, 3]
|
24
|
+
# a -> [2]
|
25
|
+
#
|
26
|
+
# @return [Array]
|
27
|
+
# @see Array#delete_at
|
28
|
+
def delete_values_at(*indexs, &blk)
|
29
|
+
offset = 0
|
30
|
+
|
31
|
+
# convert to positve index
|
32
|
+
indexs.map { |i| i < 0 ? length + i : i }
|
33
|
+
|
34
|
+
indexs.each.with_object([]) {|i,m|
|
35
|
+
if i > length
|
36
|
+
m << nil
|
37
|
+
else
|
38
|
+
m << delete_at(i-offset, &blk)
|
39
|
+
offset += 1
|
40
|
+
end
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
@@ -1,104 +1,45 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# extend options are symbols and hash, symbol as a boolean option.
|
4
|
-
#
|
5
|
-
# :a #=> { a: true }
|
6
|
-
# :_a #=> { a: false}
|
7
|
-
#
|
8
|
-
# @example
|
9
|
-
# def foo(*args)
|
10
|
-
# paths, o = args.extract_extend_options
|
11
|
-
# end
|
12
|
-
#
|
13
|
-
# foo(1, :a, :_b, :c => 2)
|
14
|
-
# #=> paths is [1]
|
15
|
-
# #=> o is {a: true, b: false, c: 2}
|
16
|
-
#
|
17
|
-
# @param [Symbol, Hash] *defaults
|
18
|
-
# @return [Array<Object>, Hash] \[args, options]
|
19
|
-
def extract_extend_options *defaults
|
20
|
-
args, o = _parse_o(defaults)
|
21
|
-
args1, o1 = _parse_o(self)
|
22
|
-
[args+args1, o.merge(o1)]
|
23
|
-
end
|
1
|
+
require "active_support/core_ext/array/extract_options"
|
24
2
|
|
25
|
-
|
26
|
-
|
27
|
-
|
3
|
+
class Array
|
4
|
+
# Extracts options from a set of arguments.
|
5
|
+
#
|
28
6
|
# @example
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
#
|
37
|
-
# @
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
# @param [Array,Hash] args
|
46
|
-
def _parse_o args
|
47
|
-
args = args.dup
|
48
|
-
# name:1
|
49
|
-
o1 = Hash === args.last ? args.pop : {}
|
50
|
-
# :force :_force
|
51
|
-
rst = args.select{|v| Symbol===v}
|
52
|
-
args.delete_if{|v| Symbol===v}
|
53
|
-
o2={}
|
54
|
-
rst.each do |k|
|
55
|
-
v = true
|
56
|
-
if k=~/^_/
|
57
|
-
k = k[1..-1].to_sym
|
58
|
-
v = false
|
59
|
-
end
|
60
|
-
o2[k] = v
|
7
|
+
#
|
8
|
+
# dirs, o = ["foo", "bar", {a: 1}].extract_options(b: 2)
|
9
|
+
# -> ["foo", "bar"], {a: 1, b: 2}
|
10
|
+
#
|
11
|
+
# (dir,), o = ["foo", {a: 1}].extract_options
|
12
|
+
# -> "foo", {a: 1}
|
13
|
+
#
|
14
|
+
# @return [Array<Array,Hash>]
|
15
|
+
# @see extract_options!
|
16
|
+
def extract_options(default={})
|
17
|
+
if last.is_a?(Hash) && last.extractable_options?
|
18
|
+
[self[0...-1], default.merge(self[-1])]
|
19
|
+
else
|
20
|
+
[self, default]
|
61
21
|
end
|
62
|
-
[args, o1.merge(o2)]
|
63
22
|
end
|
64
|
-
private :_parse_o
|
65
23
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
24
|
+
# Extracts options from a set of arguments. Removes and returns the last
|
25
|
+
# element in the array if it's a hash, otherwise returns a blank hash.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
#
|
29
|
+
# def options(*args)
|
30
|
+
# args.extract_options!(a: 1)
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# options(1, 2) -> {a: 1}
|
34
|
+
# options(1, 2, a: 2) -> {a: 2}
|
77
35
|
#
|
78
36
|
# @param [Hash] default default options
|
79
37
|
# @return [Hash]
|
80
|
-
def extract_options!
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
38
|
+
def extract_options!(default={})
|
39
|
+
if last.is_a?(Hash) && last.extractable_options?
|
40
|
+
default.merge pop
|
41
|
+
else
|
42
|
+
default
|
43
|
+
end
|
86
44
|
end
|
87
|
-
|
88
|
-
# extract options
|
89
|
-
# @see extract_options!
|
90
|
-
# @example
|
91
|
-
# def mkdir(*args)
|
92
|
-
# paths, o = args.extract_options
|
93
|
-
# end
|
94
|
-
#
|
95
|
-
# @return [Array<Array,Hash>]
|
96
|
-
def extract_options default={}
|
97
|
-
if self.last.is_a?(Hash) && self.last.instance_of?(Hash)
|
98
|
-
[self[0...-1], self[-1].merge(default)]
|
99
|
-
else
|
100
|
-
[self, default]
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
45
|
end
|