csd 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +1 -2
- data/README.rdoc +7 -1
- data/Rakefile +7 -2
- data/VERSION +1 -1
- data/csd.gemspec +18 -216
- data/lib/csd.rb +6 -16
- data/lib/csd/application.rb +2 -2
- data/lib/csd/application/default.rb +15 -14
- data/lib/csd/application/default/base.rb +1 -1
- data/lib/csd/application/minisip.rb +43 -11
- data/lib/csd/application/minisip/about.yml +5 -5
- data/lib/csd/application/minisip/base.rb +82 -70
- data/lib/csd/application/minisip/error.rb +1 -1
- data/lib/csd/application/minisip/options/common.rb +1 -1
- data/lib/csd/application/minisip/options/compile.rb +1 -1
- data/lib/csd/application/minisip/options/package.rb +1 -1
- data/lib/csd/application/minisip/unix.rb +40 -27
- data/lib/csd/application/minisip/unix/darwin.rb +12 -0
- data/lib/csd/application/minisip/unix/linux.rb +1 -11
- data/lib/csd/application/minisip/unix/linux/debian.rb +14 -25
- data/lib/csd/application/minisip/unix/linux/debian/ubuntu10.rb +12 -13
- data/lib/csd/applications.rb +5 -5
- data/lib/csd/commands.rb +164 -89
- data/lib/csd/container.rb +61 -0
- data/lib/csd/error.rb +10 -1
- data/lib/csd/extensions.rb +3 -2
- data/lib/csd/extensions/core/array.rb +29 -1
- data/lib/csd/extensions/core/dir.rb +15 -24
- data/lib/csd/extensions/core/object.rb +10 -2
- data/lib/csd/extensions/core/option_parser.rb +22 -3
- data/lib/csd/extensions/core/pathname.rb +30 -2
- data/lib/csd/extensions/core/string.rb +51 -4
- data/lib/csd/extensions/gem/platform.rb +18 -3
- data/lib/csd/{options.rb → options_parser.rb} +16 -20
- data/lib/csd/path_container.rb +24 -0
- data/lib/csd/user_interface.rb +2 -0
- data/lib/csd/user_interface/base.rb +26 -0
- data/lib/csd/user_interface/cli.rb +37 -0
- data/lib/csd/vendor/active_support/MIT-LICENSE +20 -0
- data/lib/csd/vendor/active_support/inflector.rb +155 -0
- data/lib/csd/vendor/term/GPL2-LICENSE +339 -0
- data/lib/csd/vendor/term/ansicolor.rb +113 -0
- data/lib/csd/version.rb +13 -4
- data/test/application/test_minisip.rb +45 -0
- data/test/functional/test_applications.rb +10 -16
- data/test/functional/test_commands.rb +260 -23
- data/test/unit/test_string.rb +1 -1
- metadata +18 -216
- data/lib/active_support.rb +0 -75
- data/lib/active_support/all.rb +0 -3
- data/lib/active_support/backtrace_cleaner.rb +0 -94
- data/lib/active_support/base64.rb +0 -42
- data/lib/active_support/basic_object.rb +0 -21
- data/lib/active_support/benchmarkable.rb +0 -60
- data/lib/active_support/buffered_logger.rb +0 -132
- data/lib/active_support/builder.rb +0 -6
- data/lib/active_support/cache.rb +0 -626
- data/lib/active_support/cache/compressed_mem_cache_store.rb +0 -13
- data/lib/active_support/cache/file_store.rb +0 -188
- data/lib/active_support/cache/mem_cache_store.rb +0 -191
- data/lib/active_support/cache/memory_store.rb +0 -159
- data/lib/active_support/cache/strategy/local_cache.rb +0 -164
- data/lib/active_support/cache/synchronized_memory_store.rb +0 -11
- data/lib/active_support/callbacks.rb +0 -600
- data/lib/active_support/concern.rb +0 -29
- data/lib/active_support/configurable.rb +0 -36
- data/lib/active_support/core_ext.rb +0 -3
- data/lib/active_support/core_ext/array.rb +0 -7
- data/lib/active_support/core_ext/array/access.rb +0 -46
- data/lib/active_support/core_ext/array/conversions.rb +0 -164
- data/lib/active_support/core_ext/array/extract_options.rb +0 -29
- data/lib/active_support/core_ext/array/grouping.rb +0 -100
- data/lib/active_support/core_ext/array/random_access.rb +0 -20
- data/lib/active_support/core_ext/array/uniq_by.rb +0 -17
- data/lib/active_support/core_ext/array/wrap.rb +0 -22
- data/lib/active_support/core_ext/benchmark.rb +0 -7
- data/lib/active_support/core_ext/big_decimal.rb +0 -1
- data/lib/active_support/core_ext/big_decimal/conversions.rb +0 -27
- data/lib/active_support/core_ext/cgi.rb +0 -1
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +0 -19
- data/lib/active_support/core_ext/class.rb +0 -4
- data/lib/active_support/core_ext/class/attribute.rb +0 -67
- data/lib/active_support/core_ext/class/attribute_accessors.rb +0 -63
- data/lib/active_support/core_ext/class/delegating_attributes.rb +0 -44
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +0 -232
- data/lib/active_support/core_ext/class/subclasses.rb +0 -55
- data/lib/active_support/core_ext/date/acts_like.rb +0 -8
- data/lib/active_support/core_ext/date/calculations.rb +0 -240
- data/lib/active_support/core_ext/date/conversions.rb +0 -99
- data/lib/active_support/core_ext/date/freeze.rb +0 -31
- data/lib/active_support/core_ext/date_time/acts_like.rb +0 -13
- data/lib/active_support/core_ext/date_time/calculations.rb +0 -113
- data/lib/active_support/core_ext/date_time/conversions.rb +0 -102
- data/lib/active_support/core_ext/date_time/zones.rb +0 -17
- data/lib/active_support/core_ext/enumerable.rb +0 -119
- data/lib/active_support/core_ext/exception.rb +0 -3
- data/lib/active_support/core_ext/file.rb +0 -2
- data/lib/active_support/core_ext/file/atomic.rb +0 -41
- data/lib/active_support/core_ext/file/path.rb +0 -5
- data/lib/active_support/core_ext/float.rb +0 -1
- data/lib/active_support/core_ext/float/rounding.rb +0 -19
- data/lib/active_support/core_ext/hash.rb +0 -8
- data/lib/active_support/core_ext/hash/conversions.rb +0 -150
- data/lib/active_support/core_ext/hash/deep_merge.rb +0 -16
- data/lib/active_support/core_ext/hash/diff.rb +0 -13
- data/lib/active_support/core_ext/hash/except.rb +0 -24
- data/lib/active_support/core_ext/hash/indifferent_access.rb +0 -14
- data/lib/active_support/core_ext/hash/keys.rb +0 -45
- data/lib/active_support/core_ext/hash/reverse_merge.rb +0 -28
- data/lib/active_support/core_ext/hash/slice.rb +0 -38
- data/lib/active_support/core_ext/integer.rb +0 -3
- data/lib/active_support/core_ext/integer/inflections.rb +0 -14
- data/lib/active_support/core_ext/integer/multiple.rb +0 -6
- data/lib/active_support/core_ext/integer/time.rb +0 -39
- data/lib/active_support/core_ext/kernel.rb +0 -5
- data/lib/active_support/core_ext/kernel/agnostics.rb +0 -11
- data/lib/active_support/core_ext/kernel/debugger.rb +0 -16
- data/lib/active_support/core_ext/kernel/reporting.rb +0 -62
- data/lib/active_support/core_ext/kernel/requires.rb +0 -26
- data/lib/active_support/core_ext/kernel/singleton_class.rb +0 -13
- data/lib/active_support/core_ext/load_error.rb +0 -23
- data/lib/active_support/core_ext/logger.rb +0 -146
- data/lib/active_support/core_ext/module.rb +0 -12
- data/lib/active_support/core_ext/module/aliasing.rb +0 -70
- data/lib/active_support/core_ext/module/anonymous.rb +0 -24
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +0 -31
- data/lib/active_support/core_ext/module/attr_internal.rb +0 -32
- data/lib/active_support/core_ext/module/attribute_accessors.rb +0 -66
- data/lib/active_support/core_ext/module/delegation.rb +0 -146
- data/lib/active_support/core_ext/module/deprecation.rb +0 -9
- data/lib/active_support/core_ext/module/introspection.rb +0 -88
- data/lib/active_support/core_ext/module/method_names.rb +0 -14
- data/lib/active_support/core_ext/module/reachable.rb +0 -10
- data/lib/active_support/core_ext/module/remove_method.rb +0 -6
- data/lib/active_support/core_ext/module/synchronization.rb +0 -42
- data/lib/active_support/core_ext/name_error.rb +0 -18
- data/lib/active_support/core_ext/numeric.rb +0 -2
- data/lib/active_support/core_ext/numeric/bytes.rb +0 -44
- data/lib/active_support/core_ext/numeric/time.rb +0 -77
- data/lib/active_support/core_ext/object.rb +0 -14
- data/lib/active_support/core_ext/object/acts_like.rb +0 -10
- data/lib/active_support/core_ext/object/blank.rb +0 -76
- data/lib/active_support/core_ext/object/conversions.rb +0 -4
- data/lib/active_support/core_ext/object/duplicable.rb +0 -65
- data/lib/active_support/core_ext/object/extending.rb +0 -11
- data/lib/active_support/core_ext/object/instance_variables.rb +0 -67
- data/lib/active_support/core_ext/object/misc.rb +0 -2
- data/lib/active_support/core_ext/object/returning.rb +0 -42
- data/lib/active_support/core_ext/object/to_param.rb +0 -49
- data/lib/active_support/core_ext/object/to_query.rb +0 -27
- data/lib/active_support/core_ext/object/try.rb +0 -36
- data/lib/active_support/core_ext/object/with_options.rb +0 -26
- data/lib/active_support/core_ext/proc.rb +0 -14
- data/lib/active_support/core_ext/process.rb +0 -1
- data/lib/active_support/core_ext/process/daemon.rb +0 -23
- data/lib/active_support/core_ext/range.rb +0 -4
- data/lib/active_support/core_ext/range/blockless_step.rb +0 -29
- data/lib/active_support/core_ext/range/conversions.rb +0 -21
- data/lib/active_support/core_ext/range/include_range.rb +0 -21
- data/lib/active_support/core_ext/range/overlaps.rb +0 -8
- data/lib/active_support/core_ext/regexp.rb +0 -5
- data/lib/active_support/core_ext/rexml.rb +0 -46
- data/lib/active_support/core_ext/string.rb +0 -12
- data/lib/active_support/core_ext/string/access.rb +0 -99
- data/lib/active_support/core_ext/string/behavior.rb +0 -7
- data/lib/active_support/core_ext/string/conversions.rb +0 -61
- data/lib/active_support/core_ext/string/encoding.rb +0 -11
- data/lib/active_support/core_ext/string/exclude.rb +0 -6
- data/lib/active_support/core_ext/string/filters.rb +0 -49
- data/lib/active_support/core_ext/string/inflections.rb +0 -149
- data/lib/active_support/core_ext/string/interpolation.rb +0 -2
- data/lib/active_support/core_ext/string/multibyte.rb +0 -72
- data/lib/active_support/core_ext/string/output_safety.rb +0 -109
- data/lib/active_support/core_ext/string/starts_ends_with.rb +0 -4
- data/lib/active_support/core_ext/string/xchar.rb +0 -18
- data/lib/active_support/core_ext/time/acts_like.rb +0 -8
- data/lib/active_support/core_ext/time/calculations.rb +0 -282
- data/lib/active_support/core_ext/time/conversions.rb +0 -85
- data/lib/active_support/core_ext/time/marshal.rb +0 -56
- data/lib/active_support/core_ext/time/publicize_conversion_methods.rb +0 -10
- data/lib/active_support/core_ext/time/zones.rb +0 -78
- data/lib/active_support/core_ext/uri.rb +0 -22
- data/lib/active_support/dependencies.rb +0 -628
- data/lib/active_support/dependencies/autoload.rb +0 -50
- data/lib/active_support/deprecation.rb +0 -18
- data/lib/active_support/deprecation/behaviors.rb +0 -38
- data/lib/active_support/deprecation/method_wrappers.rb +0 -29
- data/lib/active_support/deprecation/proxy_wrappers.rb +0 -74
- data/lib/active_support/deprecation/reporting.rb +0 -56
- data/lib/active_support/duration.rb +0 -105
- data/lib/active_support/gzip.rb +0 -25
- data/lib/active_support/hash_with_indifferent_access.rb +0 -145
- data/lib/active_support/i18n.rb +0 -8
- data/lib/active_support/inflections.rb +0 -56
- data/lib/active_support/inflector.rb +0 -7
- data/lib/active_support/inflector/inflections.rb +0 -211
- data/lib/active_support/inflector/methods.rb +0 -141
- data/lib/active_support/inflector/transliterate.rb +0 -97
- data/lib/active_support/json.rb +0 -2
- data/lib/active_support/json/backends/jsongem.rb +0 -43
- data/lib/active_support/json/backends/yajl.rb +0 -40
- data/lib/active_support/json/backends/yaml.rb +0 -90
- data/lib/active_support/json/decoding.rb +0 -51
- data/lib/active_support/json/encoding.rb +0 -254
- data/lib/active_support/json/variable.rb +0 -11
- data/lib/active_support/lazy_load_hooks.rb +0 -27
- data/lib/active_support/locale/en.yml +0 -36
- data/lib/active_support/memoizable.rb +0 -103
- data/lib/active_support/message_encryptor.rb +0 -71
- data/lib/active_support/message_verifier.rb +0 -62
- data/lib/active_support/multibyte.rb +0 -44
- data/lib/active_support/multibyte/chars.rb +0 -480
- data/lib/active_support/multibyte/exceptions.rb +0 -8
- data/lib/active_support/multibyte/unicode.rb +0 -393
- data/lib/active_support/multibyte/utils.rb +0 -60
- data/lib/active_support/notifications.rb +0 -81
- data/lib/active_support/notifications/fanout.rb +0 -93
- data/lib/active_support/notifications/instrumenter.rb +0 -56
- data/lib/active_support/option_merger.rb +0 -25
- data/lib/active_support/ordered_hash.rb +0 -158
- data/lib/active_support/ordered_options.rb +0 -27
- data/lib/active_support/railtie.rb +0 -100
- data/lib/active_support/rescuable.rb +0 -114
- data/lib/active_support/ruby/shim.rb +0 -22
- data/lib/active_support/secure_random.rb +0 -199
- data/lib/active_support/string_inquirer.rb +0 -21
- data/lib/active_support/test_case.rb +0 -42
- data/lib/active_support/testing/assertions.rb +0 -82
- data/lib/active_support/testing/declarative.rb +0 -40
- data/lib/active_support/testing/default.rb +0 -9
- data/lib/active_support/testing/deprecation.rb +0 -55
- data/lib/active_support/testing/isolation.rb +0 -154
- data/lib/active_support/testing/pending.rb +0 -48
- data/lib/active_support/testing/performance.rb +0 -455
- data/lib/active_support/testing/setup_and_teardown.rb +0 -111
- data/lib/active_support/time.rb +0 -34
- data/lib/active_support/time/autoload.rb +0 -5
- data/lib/active_support/time_with_zone.rb +0 -341
- data/lib/active_support/values/time_zone.rb +0 -377
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +0 -10
- data/lib/active_support/whiny_nil.rb +0 -60
- data/lib/active_support/xml_mini.rb +0 -158
- data/lib/active_support/xml_mini/jdom.rb +0 -168
- data/lib/active_support/xml_mini/libxml.rb +0 -80
- data/lib/active_support/xml_mini/libxmlsax.rb +0 -85
- data/lib/active_support/xml_mini/nokogiri.rb +0 -78
- data/lib/active_support/xml_mini/nokogirisax.rb +0 -83
- data/lib/active_support/xml_mini/rexml.rb +0 -129
- data/lib/csd/extensions/core/file.rb +0 -14
- data/lib/csd/global_open_struct.rb +0 -19
- data/lib/csd/path.rb +0 -32
- data/lib/csd/ui.rb +0 -2
- data/lib/csd/ui/cli.rb +0 -8
- data/lib/csd/ui/ui.rb +0 -45
- data/lib/term/ansicolor.rb +0 -102
- data/lib/term/ansicolor/.keep +0 -0
- data/lib/term/ansicolor/version.rb +0 -10
@@ -1,42 +0,0 @@
|
|
1
|
-
class Object
|
2
|
-
# Returns +value+ after yielding +value+ to the block. This simplifies the
|
3
|
-
# process of constructing an object, performing work on the object, and then
|
4
|
-
# returning the object from a method. It is a Ruby-ized realization of the K
|
5
|
-
# combinator, courtesy of Mikael Brockman.
|
6
|
-
#
|
7
|
-
# ==== Examples
|
8
|
-
#
|
9
|
-
# # Without returning
|
10
|
-
# def foo
|
11
|
-
# values = []
|
12
|
-
# values << "bar"
|
13
|
-
# values << "baz"
|
14
|
-
# return values
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# foo # => ['bar', 'baz']
|
18
|
-
#
|
19
|
-
# # returning with a local variable
|
20
|
-
# def foo
|
21
|
-
# returning values = [] do
|
22
|
-
# values << 'bar'
|
23
|
-
# values << 'baz'
|
24
|
-
# end
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
# foo # => ['bar', 'baz']
|
28
|
-
#
|
29
|
-
# # returning with a block argument
|
30
|
-
# def foo
|
31
|
-
# returning [] do |values|
|
32
|
-
# values << 'bar'
|
33
|
-
# values << 'baz'
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# foo # => ['bar', 'baz']
|
38
|
-
def returning(value)
|
39
|
-
yield(value)
|
40
|
-
value
|
41
|
-
end
|
42
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Object
|
4
|
-
# Alias of <tt>to_s</tt>.
|
5
|
-
def to_param
|
6
|
-
to_s
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class NilClass
|
11
|
-
def to_param
|
12
|
-
self
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class TrueClass
|
17
|
-
def to_param
|
18
|
-
self
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class FalseClass
|
23
|
-
def to_param
|
24
|
-
self
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class Array
|
29
|
-
# Calls <tt>to_param</tt> on all its elements and joins the result with
|
30
|
-
# slashes. This is used by <tt>url_for</tt> in Action Pack.
|
31
|
-
def to_param
|
32
|
-
collect { |e| e.to_param }.join '/'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Hash
|
37
|
-
# Converts a hash into a string suitable for use as a URL query string. An optional <tt>namespace</tt> can be
|
38
|
-
# passed to enclose the param names (see example below).
|
39
|
-
#
|
40
|
-
# ==== Examples
|
41
|
-
# { :name => 'David', :nationality => 'Danish' }.to_param # => "name=David&nationality=Danish"
|
42
|
-
#
|
43
|
-
# { :name => 'David', :nationality => 'Danish' }.to_param('user') # => "user[name]=David&user[nationality]=Danish"
|
44
|
-
def to_param(namespace = nil)
|
45
|
-
collect do |key, value|
|
46
|
-
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
47
|
-
end.sort * '&'
|
48
|
-
end
|
49
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/object/to_param'
|
2
|
-
|
3
|
-
class Object
|
4
|
-
# Converts an object into a string suitable for use as a URL query string, using the given <tt>key</tt> as the
|
5
|
-
# param name.
|
6
|
-
#
|
7
|
-
# Note: This method is defined as a default implementation for all Objects for Hash#to_query to work.
|
8
|
-
def to_query(key)
|
9
|
-
require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
|
10
|
-
"#{CGI.escape(key.to_s).gsub(/%(5B|5D)/n) { [$1].pack('H*') }}=#{CGI.escape(to_param.to_s)}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Array
|
15
|
-
# Converts an array into a string suitable for use as a URL query string,
|
16
|
-
# using the given +key+ as the param name.
|
17
|
-
#
|
18
|
-
# ['Rails', 'coding'].to_query('hobbies') # => "hobbies[]=Rails&hobbies[]=coding"
|
19
|
-
def to_query(key)
|
20
|
-
prefix = "#{key}[]"
|
21
|
-
collect { |value| value.to_query(prefix) }.join '&'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class Hash
|
26
|
-
alias_method :to_query, :to_param
|
27
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
class Object
|
2
|
-
# Invokes the method identified by the symbol +method+, passing it any arguments
|
3
|
-
# and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does.
|
4
|
-
#
|
5
|
-
# *Unlike* that method however, a +NoMethodError+ exception will *not* be raised
|
6
|
-
# and +nil+ will be returned instead, if the receiving object is a +nil+ object or NilClass.
|
7
|
-
#
|
8
|
-
# ==== Examples
|
9
|
-
#
|
10
|
-
# Without try
|
11
|
-
# @person && @person.name
|
12
|
-
# or
|
13
|
-
# @person ? @person.name : nil
|
14
|
-
#
|
15
|
-
# With try
|
16
|
-
# @person.try(:name)
|
17
|
-
#
|
18
|
-
# +try+ also accepts arguments and/or a block, for the method it is trying
|
19
|
-
# Person.try(:find, 1)
|
20
|
-
# @people.try(:collect) {|p| p.name}
|
21
|
-
#--
|
22
|
-
# This method definition below is for rdoc purposes only. The alias_method call
|
23
|
-
# below overrides it as an optimization since +try+ behaves like +Object#send+,
|
24
|
-
# unless called on +NilClass+.
|
25
|
-
def try(method, *args, &block)
|
26
|
-
send(method, *args, &block)
|
27
|
-
end
|
28
|
-
remove_method :try
|
29
|
-
alias_method :try, :__send__
|
30
|
-
end
|
31
|
-
|
32
|
-
class NilClass #:nodoc:
|
33
|
-
def try(*args)
|
34
|
-
nil
|
35
|
-
end
|
36
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'active_support/option_merger'
|
2
|
-
|
3
|
-
class Object
|
4
|
-
# An elegant way to factor duplication out of options passed to a series of
|
5
|
-
# method calls. Each method called in the block, with the block variable as
|
6
|
-
# the receiver, will have its options merged with the default +options+ hash
|
7
|
-
# provided. Each method called on the block variable must take an options
|
8
|
-
# hash as its final argument.
|
9
|
-
#
|
10
|
-
# with_options :order => 'created_at', :class_name => 'Comment' do |post|
|
11
|
-
# post.has_many :comments, :conditions => ['approved = ?', true], :dependent => :delete_all
|
12
|
-
# post.has_many :unapproved_comments, :conditions => ['approved = ?', false]
|
13
|
-
# post.has_many :all_comments
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# Can also be used with an explicit receiver:
|
17
|
-
#
|
18
|
-
# map.with_options :controller => "people" do |people|
|
19
|
-
# people.connect "/people", :action => "index"
|
20
|
-
# people.connect "/people/:id", :action => "show"
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
def with_options(options)
|
24
|
-
yield ActiveSupport::OptionMerger.new(self, options)
|
25
|
-
end
|
26
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "active_support/core_ext/kernel/singleton_class"
|
2
|
-
|
3
|
-
class Proc #:nodoc:
|
4
|
-
def bind(object)
|
5
|
-
block, time = self, Time.now
|
6
|
-
object.class_eval do
|
7
|
-
method_name = "__bind_#{time.to_i}_#{time.usec}"
|
8
|
-
define_method(method_name, &block)
|
9
|
-
method = instance_method(method_name)
|
10
|
-
remove_method(method_name)
|
11
|
-
method
|
12
|
-
end.bind(object)
|
13
|
-
end
|
14
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/process/daemon'
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Process
|
2
|
-
def self.daemon(nochdir = nil, noclose = nil)
|
3
|
-
exit if fork # Parent exits, child continues.
|
4
|
-
Process.setsid # Become session leader.
|
5
|
-
exit if fork # Zap session leader. See [1].
|
6
|
-
|
7
|
-
unless nochdir
|
8
|
-
Dir.chdir "/" # Release old working directory.
|
9
|
-
end
|
10
|
-
|
11
|
-
File.umask 0000 # Ensure sensible umask. Adjust as needed.
|
12
|
-
|
13
|
-
unless noclose
|
14
|
-
STDIN.reopen "/dev/null" # Free file descriptors and
|
15
|
-
STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
|
16
|
-
STDERR.reopen '/dev/null', 'a'
|
17
|
-
end
|
18
|
-
|
19
|
-
trap("TERM") { exit }
|
20
|
-
|
21
|
-
return 0
|
22
|
-
end unless respond_to?(:daemon)
|
23
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/module/aliasing'
|
2
|
-
|
3
|
-
class Range
|
4
|
-
begin
|
5
|
-
(1..2).step
|
6
|
-
# Range#step doesn't return an Enumerator
|
7
|
-
rescue LocalJumpError
|
8
|
-
# Return an array when step is called without a block.
|
9
|
-
def step_with_blockless(*args, &block)
|
10
|
-
if block_given?
|
11
|
-
step_without_blockless(*args, &block)
|
12
|
-
else
|
13
|
-
array = []
|
14
|
-
step_without_blockless(*args) { |step| array << step }
|
15
|
-
array
|
16
|
-
end
|
17
|
-
end
|
18
|
-
else
|
19
|
-
def step_with_blockless(*args, &block) #:nodoc:
|
20
|
-
if block_given?
|
21
|
-
step_without_blockless(*args, &block)
|
22
|
-
else
|
23
|
-
step_without_blockless(*args).to_a
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
alias_method_chain :step, :blockless
|
29
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class Range
|
2
|
-
RANGE_FORMATS = {
|
3
|
-
:db => Proc.new { |start, stop| "BETWEEN '#{start.to_s(:db)}' AND '#{stop.to_s(:db)}'" }
|
4
|
-
}
|
5
|
-
|
6
|
-
# Gives a human readable format of the range.
|
7
|
-
#
|
8
|
-
# ==== Example
|
9
|
-
#
|
10
|
-
# [1..100].to_formatted_s # => "1..100"
|
11
|
-
def to_formatted_s(format = :default)
|
12
|
-
if formatter = RANGE_FORMATS[format]
|
13
|
-
formatter.call(first, last)
|
14
|
-
else
|
15
|
-
to_default_s
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
alias_method :to_default_s, :to_s
|
20
|
-
alias_method :to_s, :to_formatted_s
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class Range
|
2
|
-
# Extends the default Range#include? to support range comparisons.
|
3
|
-
# (1..5).include?(1..5) # => true
|
4
|
-
# (1..5).include?(2..3) # => true
|
5
|
-
# (1..5).include?(2..6) # => false
|
6
|
-
#
|
7
|
-
# The native Range#include? behavior is untouched.
|
8
|
-
# ("a".."f").include?("c") # => true
|
9
|
-
# (5..9).include?(11) # => false
|
10
|
-
def include_with_range?(value)
|
11
|
-
if value.is_a?(::Range)
|
12
|
-
operator = exclude_end? ? :< : :<=
|
13
|
-
end_value = value.exclude_end? ? last.succ : last
|
14
|
-
include_without_range?(value.first) && (value.last <=> end_value).send(operator, 0)
|
15
|
-
else
|
16
|
-
include_without_range?(value)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
alias_method_chain :include?, :range
|
21
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/kernel/reporting'
|
2
|
-
|
3
|
-
# Fixes the rexml vulnerability disclosed at:
|
4
|
-
# http://www.ruby-lang.org/en/news/2008/08/23/dos-vulnerability-in-rexml/
|
5
|
-
# This fix is identical to rexml-expansion-fix version 1.0.1.
|
6
|
-
#
|
7
|
-
# We still need to distribute this fix because albeit the REXML
|
8
|
-
# in recent 1.8.7s is patched, it wasn't in early patchlevels.
|
9
|
-
require 'rexml/rexml'
|
10
|
-
|
11
|
-
# Earlier versions of rexml defined REXML::Version, newer ones REXML::VERSION
|
12
|
-
unless (defined?(REXML::VERSION) ? REXML::VERSION : REXML::Version) > "3.1.7.2"
|
13
|
-
silence_warnings { require 'rexml/document' }
|
14
|
-
|
15
|
-
# REXML in 1.8.7 has the patch but early patchlevels didn't update Version from 3.1.7.2.
|
16
|
-
unless REXML::Document.respond_to?(:entity_expansion_limit=)
|
17
|
-
silence_warnings { require 'rexml/entity' }
|
18
|
-
|
19
|
-
module REXML #:nodoc:
|
20
|
-
class Entity < Child #:nodoc:
|
21
|
-
undef_method :unnormalized
|
22
|
-
def unnormalized
|
23
|
-
document.record_entity_expansion! if document
|
24
|
-
v = value()
|
25
|
-
return nil if v.nil?
|
26
|
-
@unnormalized = Text::unnormalize(v, parent)
|
27
|
-
@unnormalized
|
28
|
-
end
|
29
|
-
end
|
30
|
-
class Document < Element #:nodoc:
|
31
|
-
@@entity_expansion_limit = 10_000
|
32
|
-
def self.entity_expansion_limit= val
|
33
|
-
@@entity_expansion_limit = val
|
34
|
-
end
|
35
|
-
|
36
|
-
def record_entity_expansion!
|
37
|
-
@number_of_expansions ||= 0
|
38
|
-
@number_of_expansions += 1
|
39
|
-
if @number_of_expansions > @@entity_expansion_limit
|
40
|
-
raise "Number of entity expansions exceeded, processing aborted."
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/string/conversions'
|
2
|
-
require 'active_support/core_ext/string/filters'
|
3
|
-
require 'active_support/core_ext/string/multibyte'
|
4
|
-
require 'active_support/core_ext/string/starts_ends_with'
|
5
|
-
require 'active_support/core_ext/string/inflections'
|
6
|
-
require 'active_support/core_ext/string/access'
|
7
|
-
require 'active_support/core_ext/string/xchar'
|
8
|
-
require 'active_support/core_ext/string/behavior'
|
9
|
-
require 'active_support/core_ext/string/interpolation'
|
10
|
-
require 'active_support/core_ext/string/output_safety'
|
11
|
-
require 'active_support/core_ext/string/exclude'
|
12
|
-
require 'active_support/core_ext/string/encoding'
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require "active_support/multibyte"
|
2
|
-
|
3
|
-
class String
|
4
|
-
unless '1.9'.respond_to?(:force_encoding)
|
5
|
-
# Returns the character at the +position+ treating the string as an array (where 0 is the first character).
|
6
|
-
#
|
7
|
-
# Examples:
|
8
|
-
# "hello".at(0) # => "h"
|
9
|
-
# "hello".at(4) # => "o"
|
10
|
-
# "hello".at(10) # => ERROR if < 1.9, nil in 1.9
|
11
|
-
def at(position)
|
12
|
-
mb_chars[position, 1].to_s
|
13
|
-
end
|
14
|
-
|
15
|
-
# Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character).
|
16
|
-
#
|
17
|
-
# Examples:
|
18
|
-
# "hello".from(0) # => "hello"
|
19
|
-
# "hello".from(2) # => "llo"
|
20
|
-
# "hello".from(10) # => "" if < 1.9, nil in 1.9
|
21
|
-
def from(position)
|
22
|
-
mb_chars[position..-1].to_s
|
23
|
-
end
|
24
|
-
|
25
|
-
# Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character).
|
26
|
-
#
|
27
|
-
# Examples:
|
28
|
-
# "hello".to(0) # => "h"
|
29
|
-
# "hello".to(2) # => "hel"
|
30
|
-
# "hello".to(10) # => "hello"
|
31
|
-
def to(position)
|
32
|
-
mb_chars[0..position].to_s
|
33
|
-
end
|
34
|
-
|
35
|
-
# Returns the first character of the string or the first +limit+ characters.
|
36
|
-
#
|
37
|
-
# Examples:
|
38
|
-
# "hello".first # => "h"
|
39
|
-
# "hello".first(2) # => "he"
|
40
|
-
# "hello".first(10) # => "hello"
|
41
|
-
def first(limit = 1)
|
42
|
-
if limit == 0
|
43
|
-
''
|
44
|
-
elsif limit >= size
|
45
|
-
self
|
46
|
-
else
|
47
|
-
mb_chars[0...limit].to_s
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# Returns the last character of the string or the last +limit+ characters.
|
52
|
-
#
|
53
|
-
# Examples:
|
54
|
-
# "hello".last # => "o"
|
55
|
-
# "hello".last(2) # => "lo"
|
56
|
-
# "hello".last(10) # => "hello"
|
57
|
-
def last(limit = 1)
|
58
|
-
if limit == 0
|
59
|
-
''
|
60
|
-
elsif limit >= size
|
61
|
-
self
|
62
|
-
else
|
63
|
-
mb_chars[(-limit)..-1].to_s
|
64
|
-
end
|
65
|
-
end
|
66
|
-
else
|
67
|
-
def at(position)
|
68
|
-
self[position]
|
69
|
-
end
|
70
|
-
|
71
|
-
def from(position)
|
72
|
-
self[position..-1]
|
73
|
-
end
|
74
|
-
|
75
|
-
def to(position)
|
76
|
-
self[0..position]
|
77
|
-
end
|
78
|
-
|
79
|
-
def first(limit = 1)
|
80
|
-
if limit == 0
|
81
|
-
''
|
82
|
-
elsif limit >= size
|
83
|
-
self
|
84
|
-
else
|
85
|
-
to(limit - 1)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def last(limit = 1)
|
90
|
-
if limit == 0
|
91
|
-
''
|
92
|
-
elsif limit >= size
|
93
|
-
self
|
94
|
-
else
|
95
|
-
from(-limit)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|