facets 2.6.0 → 2.7.0
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/HISTORY.rdoc +331 -35
- data/MANIFEST +685 -826
- data/{doc/guide/notes.rd → NOTES} +0 -0
- data/README.rdoc +73 -25
- data/Rakefile +245 -2
- data/TODO +5 -0
- data/demo/hook.rd +47 -0
- data/demo/scenario_require.rd +9 -0
- data/doc/README.more +24 -6
- data/doc/manual/about.rb +47 -0
- data/doc/manual/annotations.rdoc +60 -0
- data/doc/manual/associations.rdoc +55 -0
- data/doc/manual/blockups.rdoc +101 -0
- data/doc/manual/capsule.rdoc +34 -0
- data/doc/manual/command.rdoc +177 -0
- data/doc/manual/core.rdoc +37 -0
- data/doc/manual/faq.rdoc +32 -0
- data/doc/manual/typecast.html +112 -0
- data/lib/core/facets.rb +359 -11
- data/lib/core/facets/array/combination.rb +3 -3
- data/lib/core/facets/array/index.rb +4 -1
- data/lib/core/facets/array/permutation.rb +2 -2
- data/lib/core/facets/array/product.rb +1 -1
- data/lib/core/facets/binding/eval.rb +1 -1
- data/lib/core/facets/denumerable.rb +76 -0
- data/lib/core/facets/duplicable.rb +34 -0
- data/lib/core/facets/enumerable/count.rb +10 -4
- data/lib/core/facets/enumerable/defer.rb +77 -0
- data/lib/core/facets/enumerable/each_by.rb +1 -1
- data/lib/core/facets/enumerable/every.rb +35 -0
- data/lib/{more/facets/elementwise.rb → core/facets/enumerable/ewise.rb} +0 -0
- data/lib/core/facets/enumerable/filter.rb +25 -0
- data/lib/core/facets/enumerable/group_by.rb +1 -1
- data/lib/core/facets/enumerable/none.rb +3 -2
- data/lib/core/facets/enumerable/one.rb +3 -2
- data/lib/core/facets/enumerable/per.rb +61 -0
- data/lib/core/facets/exception/raised.rb +14 -0
- data/lib/core/facets/integer/odd.rb +5 -1
- data/lib/core/facets/kernel/__dir__.rb +13 -3
- data/lib/core/facets/kernel/__here__.rb +14 -0
- data/lib/core/facets/kernel/__method__.rb +9 -3
- data/lib/core/facets/kernel/ask.rb +1 -0
- data/lib/core/facets/kernel/equate.rb +13 -0
- data/lib/core/facets/kernel/extension.rb +9 -0
- data/lib/core/facets/kernel/identical.rb +4 -0
- data/lib/core/facets/kernel/instance_exec.rb +2 -1
- data/lib/core/facets/kernel/method.rb +49 -0
- data/lib/core/facets/kernel/object_send.rb +2 -2
- data/lib/core/facets/kernel/{state.rb → object_state.rb} +23 -12
- data/lib/core/facets/kernel/require_all.rb +6 -1
- data/lib/core/facets/kernel/require_local.rb +8 -1
- data/lib/core/facets/kernel/require_relative.rb +52 -0
- data/lib/core/facets/kernel/source_location.rb +13 -0
- data/lib/core/facets/kernel/tap.rb +13 -6
- data/lib/core/facets/module/attr_setter.rb +57 -0
- data/lib/core/facets/module/instance_method.rb +24 -0
- data/lib/core/facets/module/module_load.rb +60 -44
- data/lib/core/facets/module/module_require.rb +1 -0
- data/lib/core/facets/nilclass/to_f.rb +1 -1
- data/lib/core/facets/objectspace/op_fetch.rb +3 -0
- data/lib/core/facets/proc/curry.rb +4 -3
- data/lib/core/facets/string/bytes.rb +10 -4
- data/lib/core/facets/string/camelcase.rb +6 -5
- data/lib/core/facets/string/chars.rb +5 -1
- data/lib/core/facets/string/each_char.rb +1 -1
- data/lib/core/facets/string/each_word.rb +1 -1
- data/lib/core/facets/string/lines.rb +11 -4
- data/lib/core/facets/string/start_with.rb +9 -2
- data/lib/core/facets/string/unfold.rb +27 -0
- data/lib/core/facets/symbol/succ.rb +3 -3
- data/lib/core/facets/symbol/thrown.rb +20 -0
- data/lib/core/facets/symbol/to_proc.rb +3 -2
- data/lib/core/facets/time/to_time.rb +1 -1
- data/lib/core/facets/to_hash.rb +41 -100
- data/lib/core/facets/unboundmethod/name.rb +20 -23
- data/lib/more/facets/ansicode.rb +1 -10
- data/lib/more/facets/autoarray.rb +3 -31
- data/lib/more/facets/basicobject.rb +73 -0
- data/lib/more/facets/blankslate.rb +2 -66
- data/lib/{lore → more}/facets/cgi.rb +0 -0
- data/lib/more/facets/class_extend.rb +1 -0
- data/lib/{lore → more}/facets/continuation.rb +0 -0
- data/lib/{lore → more}/facets/date.rb +3 -3
- data/lib/more/facets/enumargs.rb +192 -0
- data/lib/more/facets/enumerablepass.rb +2 -216
- data/lib/more/facets/enumerator.rb +62 -0
- data/lib/more/facets/{equatable.rb → equitable.rb} +11 -11
- data/lib/more/facets/expirable.rb +13 -41
- data/lib/{lore → more}/facets/fileutils.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/head.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/safe_ln.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/slice.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/tail.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/wc.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/whereis.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/which.rb +0 -0
- data/lib/{lore → more}/facets/getoptlong.rb +0 -0
- data/lib/more/facets/hook.rb +2 -29
- data/lib/more/facets/inheritor.rb +2 -2
- data/lib/more/facets/instance_eval.rb +50 -0
- data/lib/more/facets/instance_function.rb +78 -0
- data/lib/more/facets/main.rb +20 -15
- data/lib/more/facets/memoize.rb +1 -113
- data/lib/more/facets/module/attr.rb +83 -0
- data/lib/more/facets/module/attr_tester.rb +44 -0
- data/lib/more/facets/module/attr_toggler.rb +59 -0
- data/lib/more/facets/module/attr_validator.rb +34 -0
- data/lib/more/facets/{class_extension.rb → module/class_extend.rb} +21 -13
- data/lib/more/facets/once.rb +59 -0
- data/lib/more/facets/openmodule.rb +1 -0
- data/lib/more/facets/orderedhash.rb +1 -33
- data/lib/{lore → more}/facets/ostruct.rb +0 -0
- data/lib/more/facets/ostructable.rb +1 -4
- data/lib/more/facets/partial.rb +18 -16
- data/lib/{lore → more}/facets/pathname.rb +0 -0
- data/lib/more/facets/preinitialize.rb +157 -0
- data/lib/{lore → more}/facets/rbconfig.rb +0 -0
- data/lib/more/facets/recorder.rb +1 -2
- data/lib/{lore → more}/facets/set.rb +0 -0
- data/lib/{lore → more}/facets/shellwords.rb +0 -0
- data/lib/{lore → more}/facets/uri.rb +0 -0
- data/lib/{lore → more}/facets/yaml.rb +0 -0
- data/lib/{lore → more}/facets/zlib.rb +0 -0
- data/meta/loadpath +0 -1
- data/meta/sitemap +4 -0
- data/meta/version +1 -1
- data/test/core/enumerable/test_count.rb +1 -1
- data/test/{more/test_filter.rb → core/enumerable/test_defer.rb} +24 -22
- data/test/{more/test_elementor.rb → core/enumerable/test_every.rb} +2 -15
- data/test/core/enumerable/test_ewise.rb +23 -0
- data/test/core/enumerable/test_per.rb +18 -0
- data/test/core/enumerable/test_take.rb +13 -0
- data/test/core/kernel/test_deepcopy.rb +1 -1
- data/test/{more/test_1stclassmethod.rb → core/kernel/test_method.rb} +2 -7
- data/test/core/kernel/test_tap.rb +1 -1
- data/test/core/proc/test_curry.rb +11 -0
- data/test/core/string/test_bytes.rb +1 -1
- data/test/core/string/test_camelcase.rb +23 -6
- data/test/core/string/test_lines.rb +1 -1
- data/test/core/string/test_unfold.rb +14 -0
- data/test/{more → core}/test_blank.rb +0 -0
- data/test/{more → core}/test_boolean.rb +0 -0
- data/test/{more → core}/test_functor.rb +0 -0
- data/test/{lore → more}/test_basicobject.rb +0 -0
- data/test/more/{test_class_extension.rb → test_class_extend.rb} +6 -6
- data/test/{lore → more}/test_continuation.rb +0 -0
- data/test/{lore → more}/test_date.rb +0 -0
- data/test/more/{test_enumerablepass.rb → test_enumargs.rb} +2 -4
- data/test/more/{test_equatable.rb → test_equitable.rb} +2 -2
- data/test/more/{test_instantise.rb → test_instance_function.rb} +3 -2
- data/test/more/test_memoize.rb +1 -1
- data/test/{lore → more}/test_ostruct.rb +0 -0
- metadata +865 -1016
- data/RELEASE +0 -38
- data/doc/README.lore +0 -51
- data/doc/log/basic_stats/index.html +0 -39
- data/doc/log/changelog.html +0 -648
- data/doc/log/changelog.txt +0 -217
- data/doc/log/stats/index.html +0 -39
- data/doc/log/testlog.txt +0 -278
- data/doc/notes/CHANGES +0 -2529
- data/doc/rdoc/lore/classes/Array.html +0 -176
- data/doc/rdoc/lore/classes/CGI.html +0 -191
- data/doc/rdoc/lore/classes/Config.html +0 -135
- data/doc/rdoc/lore/classes/Continuation.html +0 -113
- data/doc/rdoc/lore/classes/Date.html +0 -631
- data/doc/rdoc/lore/classes/DateTime.html +0 -583
- data/doc/rdoc/lore/classes/Enumerable.html +0 -89
- data/doc/rdoc/lore/classes/Enumerable/Enumerator.html +0 -147
- data/doc/rdoc/lore/classes/File.html +0 -128
- data/doc/rdoc/lore/classes/FileUtils.html +0 -434
- data/doc/rdoc/lore/classes/GetoptLong.html +0 -118
- data/doc/rdoc/lore/classes/GetoptLong/DSL.html +0 -208
- data/doc/rdoc/lore/classes/Kernel.html +0 -135
- data/doc/rdoc/lore/classes/Logger.html +0 -229
- data/doc/rdoc/lore/classes/Logger/Ansicolor.html +0 -277
- data/doc/rdoc/lore/classes/Logger/LogDevice.html +0 -121
- data/doc/rdoc/lore/classes/NilClass.html +0 -119
- data/doc/rdoc/lore/classes/OpenStruct.html +0 -432
- data/doc/rdoc/lore/classes/Pathname.html +0 -353
- data/doc/rdoc/lore/classes/Set.html +0 -117
- data/doc/rdoc/lore/classes/Shellwords.html +0 -111
- data/doc/rdoc/lore/classes/String.html +0 -140
- data/doc/rdoc/lore/classes/Time.html +0 -154
- data/doc/rdoc/lore/classes/URI.html +0 -454
- data/doc/rdoc/lore/classes/URI/Hash.html +0 -105
- data/doc/rdoc/lore/classes/URI/Kernel.html +0 -122
- data/doc/rdoc/lore/classes/Zlib.html +0 -188
- data/doc/rdoc/lore/created.rid +0 -1
- data/doc/rdoc/lore/files/README.html +0 -286
- data/doc/rdoc/lore/files/doc/README_lore.html +0 -155
- data/doc/rdoc/lore/files/lib/lore/facets/basicobject_rb.html +0 -118
- data/doc/rdoc/lore/files/lib/lore/facets/cgi_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/continuation_rb.html +0 -147
- data/doc/rdoc/lore/files/lib/lore/facets/date_rb.html +0 -97
- data/doc/rdoc/lore/files/lib/lore/facets/enumerator_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/head_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/safe_ln_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/slice_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/tail_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/wc_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/whereis_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/which_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils_rb.html +0 -131
- data/doc/rdoc/lore/files/lib/lore/facets/getoptlong_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/logger_rb.html +0 -142
- data/doc/rdoc/lore/files/lib/lore/facets/ostruct_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/pathname_rb.html +0 -145
- data/doc/rdoc/lore/files/lib/lore/facets/rbconfig_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/set_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/shellwords_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/uri_rb.html +0 -125
- data/doc/rdoc/lore/files/lib/lore/facets/yaml_rb.html +0 -146
- data/doc/rdoc/lore/files/lib/lore/facets/zlib_rb.html +0 -97
- data/doc/rdoc/lore/fr_class_index.html +0 -73
- data/doc/rdoc/lore/fr_file_index.html +0 -71
- data/doc/rdoc/lore/fr_method_index.html +0 -177
- data/doc/rdoc/lore/index.html +0 -26
- data/doc/rdoc/lore/rdoc-style.css +0 -177
- data/doc/release-notes/RELEASE-2.0.5 +0 -8
- data/doc/release-notes/RELEASE-2.1.0 +0 -9
- data/doc/release-notes/RELEASE-2.1.1 +0 -5
- data/doc/release-notes/RELEASE-2.1.2 +0 -6
- data/doc/release-notes/RELEASE-2.1.3 +0 -5
- data/doc/release-notes/RELEASE-2.2.0 +0 -14
- data/doc/release-notes/RELEASE-2.2.1 +0 -4
- data/doc/release-notes/RELEASE-2.3.0 +0 -6
- data/doc/release-notes/RELEASE-2.4.0 +0 -70
- data/doc/release-notes/RELEASE-2.4.1 +0 -8
- data/doc/release-notes/RELEASE-2.4.2 +0 -4
- data/doc/release-notes/RELEASE-2.4.3 +0 -78
- data/doc/release-notes/RELEASE-2.4.4 +0 -38
- data/doc/release-notes/RELEASE-2.4.5 +0 -37
- data/doc/release-notes/RELEASE-2.5.0 +0 -83
- data/lib/core/facets/kernel/instance.rb +0 -19
- data/lib/lore/facets/basicobject.rb +0 -14
- data/lib/lore/facets/enumerator.rb +0 -67
- data/lib/lore/facets/logger.rb +0 -291
- data/lib/more/facets/1stclassmethod.rb +0 -140
- data/lib/more/facets/advisable.rb +0 -162
- data/lib/more/facets/association.rb +0 -210
- data/lib/more/facets/attr.rb +0 -209
- data/lib/more/facets/basex.rb +0 -37
- data/lib/more/facets/bbcode.rb +0 -397
- data/lib/more/facets/bicrypt.rb +0 -265
- data/lib/more/facets/binreadable.rb +0 -221
- data/lib/more/facets/censor.rb +0 -97
- data/lib/more/facets/classmethods.rb +0 -199
- data/lib/more/facets/consoleutils.rb +0 -99
- data/lib/more/facets/crypt.rb +0 -166
- data/lib/more/facets/dependency.rb +0 -151
- data/lib/more/facets/downloader.rb +0 -281
- data/lib/more/facets/duplicable.rb +0 -43
- data/lib/more/facets/elementor.rb +0 -133
- data/lib/more/facets/filter.rb +0 -121
- data/lib/more/facets/heap.rb +0 -22
- data/lib/more/facets/infinity.rb +0 -193
- data/lib/more/facets/ini.rb +0 -264
- data/lib/more/facets/instantise.rb +0 -1
- data/lib/more/facets/instantize.rb +0 -95
- data/lib/more/facets/interval.rb +0 -282
- data/lib/more/facets/iteration.rb +0 -65
- data/lib/more/facets/linkedlist.rb +0 -222
- data/lib/more/facets/lrucache.rb +0 -157
- data/lib/more/facets/matcher.rb +0 -140
- data/lib/more/facets/memoizer.rb +0 -74
- data/lib/more/facets/minitar.rb +0 -1063
- data/lib/more/facets/nackclass.rb +0 -41
- data/lib/more/facets/net/smtp_tls.rb +0 -131
- data/lib/more/facets/nilstatus.rb +0 -48
- data/lib/more/facets/overload.rb +0 -94
- data/lib/more/facets/paramix.rb +0 -202
- data/lib/more/facets/pool.rb +0 -91
- data/lib/more/facets/pqueue.rb +0 -449
- data/lib/more/facets/pry.rb +0 -32
- data/lib/more/facets/reflection.rb +0 -145
- data/lib/more/facets/semaphore.rb +0 -92
- data/lib/more/facets/settings.rb +0 -248
- data/lib/more/facets/snapshot.rb +0 -209
- data/lib/more/facets/sparse_array.rb +0 -809
- data/lib/more/facets/string/mask.rb +0 -278
- data/lib/more/facets/string/obfuscate.rb +0 -65
- data/lib/more/facets/string/stylize.rb +0 -169
- data/lib/more/facets/string/words.rb +0 -167
- data/lib/more/facets/syncarray.rb +0 -114
- data/lib/more/facets/synchash.rb +0 -157
- data/lib/more/facets/typecast.rb +0 -261
- data/lib/more/facets/uninheritable.rb +0 -50
- data/lib/more/facets/xmlhash.rb +0 -112
- data/lib/more/facets/xoxo.rb +0 -259
- data/lib/more/facets/ziputils.rb +0 -490
- data/task/conflicts +0 -63
- data/task/coverage.rake +0 -37
- data/task/methods +0 -49
- data/task/rdoc.rake +0 -17
- data/task/setup.rake +0 -38
- data/task/test.rake +0 -145
- data/test/more/test_advisable.rb +0 -71
- data/test/more/test_association.rb +0 -38
- data/test/more/test_bbcode.rb +0 -21
- data/test/more/test_binreadable.rb +0 -50
- data/test/more/test_buildable.rb +0 -73
- data/test/more/test_classmethods.rb +0 -56
- data/test/more/test_crypt.rb +0 -32
- data/test/more/test_dependency.rb +0 -69
- data/test/more/test_elementwise.rb +0 -25
- data/test/more/test_infinity.rb +0 -40
- data/test/more/test_interval.rb +0 -151
- data/test/more/test_linkedlist.rb +0 -41
- data/test/more/test_lrucache.rb +0 -14
- data/test/more/test_overload.rb +0 -160
- data/test/more/test_paramix.rb +0 -170
- data/test/more/test_prototype.rb +0 -35
- data/test/more/test_snapshot.rb +0 -21
- data/test/more/test_sparsearray.rb +0 -279
- data/test/more/test_syncarray.rb +0 -15
- data/test/more/test_synchash.rb +0 -16
- data/test/more/test_typecast.rb +0 -54
- data/test/more/test_uninheritable.rb +0 -31
- data/test/more/test_xoxo.rb +0 -274
- data/test/test_facets.rb +0 -9
@@ -1,50 +0,0 @@
|
|
1
|
-
# = Uninheritable
|
2
|
-
#
|
3
|
-
# Allows an object to declare itself as unable to be subclassed. The
|
4
|
-
# technique behind this is very simple (redefinition of #inherited), so this
|
5
|
-
# just provides an easier way to do the same thing with a consistent error
|
6
|
-
# message.
|
7
|
-
#
|
8
|
-
# == Usage
|
9
|
-
#
|
10
|
-
# class A
|
11
|
-
# extend Uninheritable
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# class B < A; end # => raises TypeError
|
15
|
-
#
|
16
|
-
# == AUTHORS
|
17
|
-
#
|
18
|
-
# * Austin Ziegler
|
19
|
-
#
|
20
|
-
# == COPYRIGHT
|
21
|
-
#
|
22
|
-
# Copyright (c) 2003 Austin Ziegler
|
23
|
-
#
|
24
|
-
# == LICENSE
|
25
|
-
#
|
26
|
-
# Ruby License
|
27
|
-
#
|
28
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
29
|
-
# software under the same terms as Ruby.
|
30
|
-
#
|
31
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
32
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
33
|
-
# FOR A PARTICULAR PURPOSE.
|
34
|
-
#
|
35
|
-
|
36
|
-
# = Uninheritable
|
37
|
-
#
|
38
|
-
# Allows an object to declare itself as unable to be subclassed. The
|
39
|
-
# technique behind this is very simple (redefinition of #inherited), so this
|
40
|
-
# just provides an easier way to do the same thing with a consistent error
|
41
|
-
# message.
|
42
|
-
#
|
43
|
-
module Uninheritable
|
44
|
-
# Redefines a class's #inherited definition to prevent subclassing of the
|
45
|
-
# class extended by this module.
|
46
|
-
def inherited(klass)
|
47
|
-
raise TypeError, "Class #{self} cannot be subclassed."
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
data/lib/more/facets/xmlhash.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
# = XmlHash
|
2
|
-
#
|
3
|
-
# WARNING: This is a work in progress!!!
|
4
|
-
|
5
|
-
#
|
6
|
-
module Hash2Xml
|
7
|
-
extend self
|
8
|
-
|
9
|
-
def convert(root, content)
|
10
|
-
convert_tag(root, '*' => content)
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
#
|
16
|
-
|
17
|
-
def convert_tag(tag, node)
|
18
|
-
subn = node.delete('*')
|
19
|
-
atts = node.collect{ |k,v| %[#{k}="#{v}"] }
|
20
|
-
body = convert_body(subn)
|
21
|
-
|
22
|
-
start_tag = "#{tag} #{atts}".strip
|
23
|
-
|
24
|
-
if body.to_s.empty?
|
25
|
-
"<#{start_tag}/>"
|
26
|
-
else
|
27
|
-
"<#{start_tag}>#{body}</#{tag}>"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
#
|
32
|
-
|
33
|
-
def convert_body(node)
|
34
|
-
case node
|
35
|
-
when Array
|
36
|
-
node.collect do |subn|
|
37
|
-
convert_body(subn)
|
38
|
-
end
|
39
|
-
when Hash
|
40
|
-
node.collect do |tag, subn|
|
41
|
-
case subn
|
42
|
-
when Hash
|
43
|
-
convert_tag(tag, subn)
|
44
|
-
when Array
|
45
|
-
subn.collect do |e|
|
46
|
-
case e
|
47
|
-
when Hash
|
48
|
-
convert_tag(tag, e)
|
49
|
-
else
|
50
|
-
convert_tag(tag, '*' => e)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
else
|
54
|
-
convert_tag(tag, '*' => subn)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
else
|
58
|
-
node.to_s
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
class Hash
|
66
|
-
|
67
|
-
def to_xml(root='root')
|
68
|
-
Blow::Hash2Xml.convert(root, self)
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
if $0 == __FILE__
|
76
|
-
|
77
|
-
# case 1
|
78
|
-
|
79
|
-
h = { 'a' => 1, 'b' => 2 }
|
80
|
-
|
81
|
-
puts Blow::Hash2Xml.convert('root', h)
|
82
|
-
|
83
|
-
# case 2
|
84
|
-
|
85
|
-
h = { 'a' => [ 1, 2 ], 'b' => 2 }
|
86
|
-
|
87
|
-
puts Blow::Hash2Xml.convert('root', h)
|
88
|
-
|
89
|
-
# case 3
|
90
|
-
|
91
|
-
h = {
|
92
|
-
'a' => [ 'x', 'y' ],
|
93
|
-
'b' => [ '1', '2' ],
|
94
|
-
'c' => [
|
95
|
-
{ 'k' => 'hi', '*' => 'fudge' }
|
96
|
-
]
|
97
|
-
}
|
98
|
-
|
99
|
-
puts Blow::Hash2Xml.convert('root', h)
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
data/lib/more/facets/xoxo.rb
DELETED
@@ -1,259 +0,0 @@
|
|
1
|
-
# = XOXO
|
2
|
-
#
|
3
|
-
# XOXO is a Ruby XOXO parser and generator. It provides
|
4
|
-
# a Ruby API similar to Marshal and YAML (though more
|
5
|
-
# specific) to load and dump XOXO[http://microformats.org/wiki/xoxo],
|
6
|
-
# an simple, open outline format written in standard XHTML and
|
7
|
-
# suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
|
8
|
-
#
|
9
|
-
# == Author
|
10
|
-
#
|
11
|
-
# * Christian Neukirchen
|
12
|
-
#
|
13
|
-
# == Thanks
|
14
|
-
#
|
15
|
-
# Special thanks go to Christian Neukirchen for xoxo.rb.
|
16
|
-
# http://chneukirchen.org/repos/xoxo-rb/.
|
17
|
-
#
|
18
|
-
# == Copyright
|
19
|
-
#
|
20
|
-
# Copyright (C) 2006 Christian Neukirchen
|
21
|
-
#
|
22
|
-
# Ruby License
|
23
|
-
#
|
24
|
-
# This module is free software. You may use, modify, and/or redistribute this
|
25
|
-
# software under the same terms as Ruby.
|
26
|
-
#
|
27
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
28
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
29
|
-
# FOR A PARTICULAR PURPOSE.
|
30
|
-
|
31
|
-
require 'rexml/parsers/pullparser'
|
32
|
-
|
33
|
-
# = XOXO
|
34
|
-
#
|
35
|
-
# XOXO is a Ruby XOXO parser and generator. It provides
|
36
|
-
# a Ruby API similar to Marshal and YAML (though more
|
37
|
-
# specific) to load and dump XOXO[http://microformats.org/wiki/xoxo],
|
38
|
-
# an simple, open outline format written in standard XHTML and
|
39
|
-
# suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.
|
40
|
-
#
|
41
|
-
module XOXO
|
42
|
-
|
43
|
-
# xoxo.rb version number
|
44
|
-
#VERSION = "0.1"
|
45
|
-
|
46
|
-
# Load and return a XOXO structure from the String, IO or StringIO or _xoxo_.
|
47
|
-
#
|
48
|
-
def self.load(xoxo)
|
49
|
-
structs = Parser.new(xoxo).parse.structs
|
50
|
-
while structs.kind_of?(Array) && structs.size == 1
|
51
|
-
structs = structs.first
|
52
|
-
end
|
53
|
-
structs
|
54
|
-
end
|
55
|
-
|
56
|
-
# Return a XOXO string corresponding to the Ruby object +struct+,
|
57
|
-
# translated to the following rules:
|
58
|
-
#
|
59
|
-
# * Arrays become ordered lists <tt><ol></tt>.
|
60
|
-
# * Hashes become definition lists <tt><dl></tt>, keys are
|
61
|
-
# stringified with +to_s+.
|
62
|
-
# * Everything else becomes stringified with +to_s+ and wrapped in
|
63
|
-
# appropriate list elements (<tt><li></tt> or <tt><dt></tt>/<tt><dd></tt>).
|
64
|
-
#
|
65
|
-
# Additionally, you can pass these options on the _options_ hash:
|
66
|
-
# <tt>:html_wrap</tt> => +true+:: Wrap the XOXO with a basic XHTML 1.0
|
67
|
-
# Transitional header.
|
68
|
-
# <tt>:css</tt> => _css_:: Reference _css_ as stylesheet for the
|
69
|
-
# wrapped XOXO document.
|
70
|
-
#
|
71
|
-
def self.dump(struct, options={})
|
72
|
-
struct = [struct] unless struct.kind_of? Array
|
73
|
-
|
74
|
-
if options[:html_wrap]
|
75
|
-
result = <<EOF.strip
|
76
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
|
77
|
-
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
78
|
-
<html xmlns="http://www.w3.org/1999/xhtml"><head profile=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
79
|
-
EOF
|
80
|
-
if options[:css]
|
81
|
-
result << %Q[<style type="text/css" >@import "#{options[:css]}";</style>]
|
82
|
-
end
|
83
|
-
|
84
|
-
result << "</head><body>" << make_xoxo(struct, 'xoxo') << "</body></html>"
|
85
|
-
else
|
86
|
-
result = make_xoxo(struct, 'xoxo')
|
87
|
-
end
|
88
|
-
|
89
|
-
result
|
90
|
-
end
|
91
|
-
|
92
|
-
private
|
93
|
-
|
94
|
-
def self.make_xoxo(struct, class_name=nil)
|
95
|
-
s = ''
|
96
|
-
case struct
|
97
|
-
when Array
|
98
|
-
if class_name
|
99
|
-
s << %Q[<ol class="#{class_name}">]
|
100
|
-
else
|
101
|
-
s << "<ol>"
|
102
|
-
end
|
103
|
-
struct.each { |item|
|
104
|
-
s << "<li>" << make_xoxo(item) << "</li>"
|
105
|
-
}
|
106
|
-
s << "</ol>"
|
107
|
-
|
108
|
-
when Hash
|
109
|
-
d = struct.dup
|
110
|
-
if d.has_key? 'url'
|
111
|
-
s << '<a href="' << d['url'].to_s << '" '
|
112
|
-
text = d.fetch('text') { d.fetch('title', d['url']) }
|
113
|
-
%w[title rel type].each { |tag|
|
114
|
-
if d.has_key? tag
|
115
|
-
s << tag.to_s << '="' << make_xoxo(d.delete(tag)) << '" '
|
116
|
-
end
|
117
|
-
}
|
118
|
-
s << '>' << make_xoxo(text) << '</a>'
|
119
|
-
d.delete 'text'
|
120
|
-
d.delete 'url'
|
121
|
-
end
|
122
|
-
|
123
|
-
unless d.empty?
|
124
|
-
s << "<dl>"
|
125
|
-
d.each { |key, value|
|
126
|
-
s << "<dt>" << key.to_s << "</dt><dd>" << make_xoxo(value) << "</dd>"
|
127
|
-
}
|
128
|
-
s << "</dl>"
|
129
|
-
end
|
130
|
-
|
131
|
-
when String
|
132
|
-
s << struct
|
133
|
-
|
134
|
-
else
|
135
|
-
s << struct.to_s # too gentle?
|
136
|
-
end
|
137
|
-
|
138
|
-
s
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
class XOXO::Parser # :nodoc:
|
143
|
-
CONTAINER_TAGS = %w{dl ol ul}
|
144
|
-
|
145
|
-
attr_reader :structs
|
146
|
-
|
147
|
-
def initialize(xoxo)
|
148
|
-
@parser = REXML::Parsers::PullParser.new(xoxo)
|
149
|
-
|
150
|
-
@textstack = ['']
|
151
|
-
@xostack = []
|
152
|
-
@structs = []
|
153
|
-
@tags = []
|
154
|
-
end
|
155
|
-
|
156
|
-
def parse
|
157
|
-
while @parser.has_next?
|
158
|
-
res = @parser.pull
|
159
|
-
|
160
|
-
if res.start_element?
|
161
|
-
@tags << res[0]
|
162
|
-
|
163
|
-
case res[0]
|
164
|
-
when "a"
|
165
|
-
attrs = normalize_attrs res[1]
|
166
|
-
attrs['url'] = attrs['href']
|
167
|
-
attrs.delete 'href'
|
168
|
-
push attrs
|
169
|
-
@textstack << ''
|
170
|
-
|
171
|
-
when "dl"
|
172
|
-
push({})
|
173
|
-
|
174
|
-
when "ol", "ul"
|
175
|
-
push []
|
176
|
-
|
177
|
-
when "li", "dt", "dd"
|
178
|
-
@textstack << ''
|
179
|
-
|
180
|
-
end
|
181
|
-
elsif res.end_element?
|
182
|
-
@tags.pop
|
183
|
-
|
184
|
-
case res[0]
|
185
|
-
when "a"
|
186
|
-
val = @textstack.pop
|
187
|
-
unless val.empty?
|
188
|
-
val = '' if @xostack.last['title'] == val
|
189
|
-
val = '' if @xostack.last['url'] == val
|
190
|
-
@xostack.last['text'] = val unless val.empty?
|
191
|
-
end
|
192
|
-
@xostack.pop
|
193
|
-
|
194
|
-
when "dl", "ol", "ul"
|
195
|
-
@xostack.pop
|
196
|
-
|
197
|
-
when "li"
|
198
|
-
val = @textstack.pop
|
199
|
-
while @structs.last != @xostack.last
|
200
|
-
val = @structs.pop
|
201
|
-
@xostack.last << val
|
202
|
-
end
|
203
|
-
@xostack.last << val if val.kind_of? String
|
204
|
-
|
205
|
-
when "dt"
|
206
|
-
# skip
|
207
|
-
|
208
|
-
when "dd"
|
209
|
-
val = @textstack.pop
|
210
|
-
key = @textstack.pop
|
211
|
-
|
212
|
-
val = @structs.pop if @structs.last != @xostack.last
|
213
|
-
@xostack.last[key] = val
|
214
|
-
|
215
|
-
end
|
216
|
-
elsif res.text?
|
217
|
-
unless @tags.empty? || CONTAINER_TAGS.include?(@tags.last)
|
218
|
-
@textstack.last << res[0]
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
self
|
224
|
-
end
|
225
|
-
|
226
|
-
private
|
227
|
-
|
228
|
-
def normalize_attrs(attrs)
|
229
|
-
attrs.keys.find_all { |k, v| k != k.downcase }.each { |k, v|
|
230
|
-
v = v.downcase if k == "rel" || k == "type"
|
231
|
-
attrs.delete k
|
232
|
-
attrs[k.downcase] = v
|
233
|
-
}
|
234
|
-
attrs
|
235
|
-
end
|
236
|
-
|
237
|
-
def push(struct)
|
238
|
-
if struct == {} && @structs.last.kind_of?(Hash) &&
|
239
|
-
@structs.last.has_key?('url') &&
|
240
|
-
@structs.last != @xostack.last
|
241
|
-
# put back the <a>-made one for extra def's
|
242
|
-
@xostack << @structs.last
|
243
|
-
else
|
244
|
-
@structs << struct
|
245
|
-
@xostack << @structs.last
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
|
251
|
-
class Object
|
252
|
-
|
253
|
-
# Dump object as XOXO.
|
254
|
-
|
255
|
-
def to_xoxo(*args)
|
256
|
-
XOXO.dump(self,*args)
|
257
|
-
end
|
258
|
-
|
259
|
-
end
|
data/lib/more/facets/ziputils.rb
DELETED
@@ -1,490 +0,0 @@
|
|
1
|
-
#require 'zlib'
|
2
|
-
#require 'facets/minitar'
|
3
|
-
|
4
|
-
# = ZipUtils
|
5
|
-
#
|
6
|
-
# Function module for compression methods.
|
7
|
-
#
|
8
|
-
# TODO: Much of this shells out. It would be best to internalize.
|
9
|
-
#
|
10
|
-
module ZipUtils
|
11
|
-
|
12
|
-
COMPRESS_FORMAT = {
|
13
|
-
'.tar.gz' => 'tar_gzip',
|
14
|
-
'.tgz' => 'tar_gzip',
|
15
|
-
'.tar.bz2' => 'tar_bzip2',
|
16
|
-
'.zip' => 'zip'
|
17
|
-
}
|
18
|
-
|
19
|
-
###############
|
20
|
-
module_function
|
21
|
-
###############
|
22
|
-
|
23
|
-
# Compress folder or file based on given extension.
|
24
|
-
# Supported extensions are:
|
25
|
-
# * .tar.gz
|
26
|
-
# * .tgz
|
27
|
-
# * .tar.bz2
|
28
|
-
# * .zip
|
29
|
-
#
|
30
|
-
# TODO: support gzip and bzip2 as well.
|
31
|
-
def compress(folder, file, options={})
|
32
|
-
format = COMPRESS_FORMAT[File.extname(file)]
|
33
|
-
if format
|
34
|
-
send(format, folder, file, options)
|
35
|
-
else
|
36
|
-
raise ArgumentError, "unknown compression format -- #{format_extension}"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
#
|
42
|
-
def gzip(file, option={})
|
43
|
-
require 'zlib'
|
44
|
-
fname = File.basename(file) + '.gz'
|
45
|
-
if options[:dryrun] or options[:verbose]
|
46
|
-
puts "gzip #{file}"
|
47
|
-
end
|
48
|
-
Zlib::GzipWriter.open(fname) do |gz|
|
49
|
-
gz.write(File.read(file))
|
50
|
-
end unless options[:dryrun] or options[:noop]
|
51
|
-
return File.expand_path(fname)
|
52
|
-
end
|
53
|
-
|
54
|
-
#
|
55
|
-
#
|
56
|
-
def ungzip(file, options={})
|
57
|
-
require 'zlib'
|
58
|
-
fname = File.basename(file).chomp(File.extname(file))
|
59
|
-
if options[:dryrun] or options[:verbose]
|
60
|
-
puts "ungzip #{file}"
|
61
|
-
end
|
62
|
-
Zlib::GzipReader.open(file) do |gz|
|
63
|
-
File.open(fname, 'wb'){ |f| f << gz.read }
|
64
|
-
end unless options[:dryrun] or options[:noop]
|
65
|
-
return File.expand_path(fname)
|
66
|
-
end
|
67
|
-
|
68
|
-
#
|
69
|
-
#
|
70
|
-
def bzip2(file, option={})
|
71
|
-
cmd = "bzip2 #{file}"
|
72
|
-
puts cmd if options[:dryrun] or options[:verbose]
|
73
|
-
system cmd unless options[:dryrun] or options[:noop]
|
74
|
-
return File.expand_path(file + '.bz2')
|
75
|
-
end
|
76
|
-
|
77
|
-
alias_method :bzip, :bzip2
|
78
|
-
|
79
|
-
#
|
80
|
-
#
|
81
|
-
def unbzip2(file, options={})
|
82
|
-
cmd = "unbzip2 #{file}"
|
83
|
-
puts cmd if options[:dryrun] or options[:verbose]
|
84
|
-
system cmd unless options[:dryrun] or options[:noop]
|
85
|
-
return File.expand_path(file.chomp(File.extname(file)))
|
86
|
-
end
|
87
|
-
|
88
|
-
alias_method :unbzip, :unbzip2
|
89
|
-
|
90
|
-
#
|
91
|
-
#
|
92
|
-
def tar(folder, file=nil, options={})
|
93
|
-
require 'facets/minitar'
|
94
|
-
file ||= File.basename(File.expand_path(folder)) + '.tar'
|
95
|
-
cmd = "tar -cf #{file} #{folder}"
|
96
|
-
puts cmd if options[:verbose] or options[:dryrun]
|
97
|
-
unless options[:noop] or options[:dryrun]
|
98
|
-
gzIO = File.open(file, 'wb')
|
99
|
-
Archive::Tar::Minitar.pack(folder, gzIO)
|
100
|
-
end
|
101
|
-
return File.expand_path(file)
|
102
|
-
end
|
103
|
-
|
104
|
-
#
|
105
|
-
#
|
106
|
-
def untar(file, options={})
|
107
|
-
require 'facets/minitar'
|
108
|
-
#file ||= File.basename(File.expand_path(folder)) + '.tar'
|
109
|
-
cmd = "untar #{file}"
|
110
|
-
puts cmd if options[:verbose] or options[:dryrun]
|
111
|
-
unless options[:noop] or options[:dryrun]
|
112
|
-
gzIO = File.open(file, 'wb')
|
113
|
-
Archive::Tar::Minitar.unpack(gzIO)
|
114
|
-
end
|
115
|
-
return File.expand_path(file)
|
116
|
-
end
|
117
|
-
|
118
|
-
# Tar Gzip
|
119
|
-
#
|
120
|
-
def tar_gzip(folder, file=nil, options={})
|
121
|
-
require 'zlib'
|
122
|
-
require 'facets/minitar'
|
123
|
-
file ||= File.basename(File.expand_path(folder)) + '.tar.gz' # '.tgz' which ?
|
124
|
-
cmd = "tar --gzip -czf #{file} #{folder}"
|
125
|
-
puts cmd if options[:verbose] or options[:dryrun]
|
126
|
-
unless options[:noop] or options[:dryrun]
|
127
|
-
gzIO = Zlib::GzipWriter.new(File.open(file, 'wb'))
|
128
|
-
Archive::Tar::Minitar.pack(folder, gzIO)
|
129
|
-
end
|
130
|
-
return File.expand_path(file)
|
131
|
-
end
|
132
|
-
|
133
|
-
alias_method :tar_z, :tar_gzip
|
134
|
-
|
135
|
-
#def tgz(folder, file=nil, options={})
|
136
|
-
# file ||= File.basename(File.expand_path(folder)) + '.tgz'
|
137
|
-
# tar_gzip(folder, file, options)
|
138
|
-
#end
|
139
|
-
|
140
|
-
# Untar Gzip
|
141
|
-
#
|
142
|
-
# TODO: Write unified untar_gzip function.
|
143
|
-
def untar_gzip(file, options={})
|
144
|
-
untar(ungzip(file, options), options)
|
145
|
-
end
|
146
|
-
|
147
|
-
alias_method :untar_z, :untar_gzip
|
148
|
-
|
149
|
-
# Tar Bzip2
|
150
|
-
#
|
151
|
-
def tar_bzip2(folder, file=nil, options={})
|
152
|
-
# name of file to create
|
153
|
-
file ||= File.basename(File.expand_path(folder)) + '.tar.bz2'
|
154
|
-
cmd = "tar --bzip2 -cf #{file} #{folder}"
|
155
|
-
puts cmd if options[:dryrun] or options[:verbose]
|
156
|
-
system cmd unless options[:dryrun] or options[:noop]
|
157
|
-
return File.expand_path(file)
|
158
|
-
end
|
159
|
-
|
160
|
-
alias_method :tar_bzip, :tar_bzip2
|
161
|
-
|
162
|
-
alias_method :tar_j, :tar_bzip2
|
163
|
-
|
164
|
-
# Untar Bzip2
|
165
|
-
#
|
166
|
-
def untar_bzip2(file, options={})
|
167
|
-
cmd = "tar --bzip2 -xf #{file}"
|
168
|
-
puts cmd if options[:dryrun] or options[:verbose]
|
169
|
-
system cmd unless options[:dryrun] or options[:noop]
|
170
|
-
end
|
171
|
-
|
172
|
-
alias_method :untar_bzip, :untar_bzip2
|
173
|
-
|
174
|
-
alias_method :untar_j, :untar_bzip2
|
175
|
-
|
176
|
-
# Zip
|
177
|
-
#
|
178
|
-
def zip(folder, file=nil, options={})
|
179
|
-
raise ArgumentError if folder == '.*'
|
180
|
-
file ||= File.basename(File.expand_path(folder)) + '.zip'
|
181
|
-
cmd = "zip -rqu #{file} #{folder}"
|
182
|
-
puts cmd if options[:dryrun] or options[:verbose]
|
183
|
-
system cmd unless options[:dryrun] or options[:noop]
|
184
|
-
return File.expand_path(file)
|
185
|
-
end
|
186
|
-
|
187
|
-
# Unzip
|
188
|
-
#
|
189
|
-
def unzip(file, options={})
|
190
|
-
cmd = "unzip #{file}"
|
191
|
-
puts cmd if options[:dryrun] or options[:verbose]
|
192
|
-
system cmd unless options[:dryrun] or options[:noop]
|
193
|
-
end
|
194
|
-
|
195
|
-
end #module ZipUtils
|
196
|
-
|
197
|
-
# Verbose version of ZipUtils.
|
198
|
-
#
|
199
|
-
# This is the same as passing :verbose flag to ZipUtils methods.
|
200
|
-
|
201
|
-
module ZipUtils::Verbose
|
202
|
-
module_function
|
203
|
-
|
204
|
-
def compress(format_extension, folder, file=nil, options={})
|
205
|
-
options[:verbose] = true
|
206
|
-
ZipUtils.tar_gzip(format_extension, folder, file, options)
|
207
|
-
end
|
208
|
-
|
209
|
-
def gzip(file, options={})
|
210
|
-
options[:verbose] = true
|
211
|
-
ZipUtils.gzip(file, options)
|
212
|
-
end
|
213
|
-
|
214
|
-
def ungzip(file, options={})
|
215
|
-
options[:verbose] = true
|
216
|
-
ZipUtils.ungzip(file, options)
|
217
|
-
end
|
218
|
-
|
219
|
-
def bzip2(file, options={})
|
220
|
-
options[:verbose] = true
|
221
|
-
ZipUtils.bzip2(file, options)
|
222
|
-
end
|
223
|
-
|
224
|
-
alias_method :bzip, :bzip2
|
225
|
-
|
226
|
-
def unbzip2(file, options={})
|
227
|
-
options[:verbose] = true
|
228
|
-
ZipUtils.unbzip2(file, options)
|
229
|
-
end
|
230
|
-
|
231
|
-
alias_method :unbzip, :unbzip2
|
232
|
-
|
233
|
-
def tar(folder, file=nil, options={})
|
234
|
-
options[:verbose] = true
|
235
|
-
ZipUtils.tar(folder, file, options)
|
236
|
-
end
|
237
|
-
|
238
|
-
def untar(file, options={})
|
239
|
-
options[:verbose] = true
|
240
|
-
ZipUtils.untar(file, options)
|
241
|
-
end
|
242
|
-
|
243
|
-
def tar_gzip(folder, file=nil, options={})
|
244
|
-
options[:verbose] = true
|
245
|
-
ZipUtils.tar_gzip(folder, file, options)
|
246
|
-
end
|
247
|
-
|
248
|
-
def untar_gzip(file, options={})
|
249
|
-
options[:verbose] = true
|
250
|
-
ZipUtils.untar_gzip(file, options)
|
251
|
-
end
|
252
|
-
|
253
|
-
def tar_bzip2(folder, file=nil, options={})
|
254
|
-
options[:verbose] = true
|
255
|
-
ZipUtils.untar_bzip2(folder, file, options)
|
256
|
-
end
|
257
|
-
|
258
|
-
def untar_bzip2(file, options={})
|
259
|
-
options[:verbose] = true
|
260
|
-
ZipUtils.untar_bzip2(file, options)
|
261
|
-
end
|
262
|
-
|
263
|
-
def zip(folder, file=nil, options={})
|
264
|
-
options[:verbose] = true
|
265
|
-
ZipUtils.unzip(folder, file, options)
|
266
|
-
end
|
267
|
-
|
268
|
-
def unzip(file, options={})
|
269
|
-
options[:verbose] = true
|
270
|
-
ZipUtils.unzip(file, options)
|
271
|
-
end
|
272
|
-
end
|
273
|
-
|
274
|
-
# NoWrite Version of ZipUtils.
|
275
|
-
#
|
276
|
-
# This is the same as passing :noop flag to ZipUtils methods.
|
277
|
-
|
278
|
-
module ZipUtils::NoWrite
|
279
|
-
module_function
|
280
|
-
|
281
|
-
def compress(format_extension, folder, file=nil, options={})
|
282
|
-
options[:noop] = true
|
283
|
-
ZipUtils.tar_gzip(format_extension, folder, file, options)
|
284
|
-
end
|
285
|
-
|
286
|
-
def gzip(file, options={})
|
287
|
-
options[:noop] = true
|
288
|
-
ZipUtils.gzip(file, options)
|
289
|
-
end
|
290
|
-
|
291
|
-
def ungzip(file, options={})
|
292
|
-
options[:noop] = true
|
293
|
-
ZipUtils.ungzip(file, options)
|
294
|
-
end
|
295
|
-
|
296
|
-
def bzip2(file, options={})
|
297
|
-
options[:noop] = true
|
298
|
-
ZipUtils.bzip2(file, options)
|
299
|
-
end
|
300
|
-
|
301
|
-
alias_method :bzip, :bzip2
|
302
|
-
|
303
|
-
def unbzip2(file, options={})
|
304
|
-
options[:noop] = true
|
305
|
-
ZipUtils.unbzip2(file, options)
|
306
|
-
end
|
307
|
-
|
308
|
-
alias_method :unbzip, :unbzip2
|
309
|
-
|
310
|
-
def tar(folder, file=nil, options={})
|
311
|
-
options[:noop] = true
|
312
|
-
ZipUtils.tar(folder, file, options)
|
313
|
-
end
|
314
|
-
|
315
|
-
def untar(file, options={})
|
316
|
-
options[:noop] = true
|
317
|
-
ZipUtils.untar(file, options)
|
318
|
-
end
|
319
|
-
|
320
|
-
def tar_gzip(folder, file=nil, options={})
|
321
|
-
options[:noop] = true
|
322
|
-
ZipUtils.tar_gzip(folder, file, options)
|
323
|
-
end
|
324
|
-
|
325
|
-
def untar_gzip(file, options={})
|
326
|
-
options[:noop] = true
|
327
|
-
ZipUtils.untar_gzip(file, options)
|
328
|
-
end
|
329
|
-
|
330
|
-
def tar_bzip2(folder, file=nil, options={})
|
331
|
-
options[:noop] = true
|
332
|
-
ZipUtils.untar_bzip2(folder, file, options)
|
333
|
-
end
|
334
|
-
|
335
|
-
alias_method :tar_bzip, :tar_bzip2
|
336
|
-
|
337
|
-
def untar_bzip2(file, options={})
|
338
|
-
options[:noop] = true
|
339
|
-
ZipUtils.untar_bzip2(file, options)
|
340
|
-
end
|
341
|
-
|
342
|
-
alias_method :untar_bzip, :untar_bzip2
|
343
|
-
|
344
|
-
def zip(folder, file=nil, options={})
|
345
|
-
options[:noop] = true
|
346
|
-
ZipUtils.unzip(folder, file, options)
|
347
|
-
end
|
348
|
-
|
349
|
-
def unzip(file, options={})
|
350
|
-
options[:noop] = true
|
351
|
-
ZipUtils.unzip(file, options)
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
|
-
# Dry-run verions of ZipUtils.
|
356
|
-
#
|
357
|
-
# This is the same as passing the :dryrun flag to ZipUtils.
|
358
|
-
# Which is also equivalent to passing :noop and :verbose together.
|
359
|
-
|
360
|
-
module ZipUtils::DryRun
|
361
|
-
module_function
|
362
|
-
|
363
|
-
def compress(format_extension, folder, file=nil, options={})
|
364
|
-
options[:dryrun] = true
|
365
|
-
ZipUtils.tar_gzip(format_extension, folder, file, options)
|
366
|
-
end
|
367
|
-
|
368
|
-
def gzip(file, options={})
|
369
|
-
options[:dryrun] = true
|
370
|
-
ZipUtils.gzip(file, options)
|
371
|
-
end
|
372
|
-
|
373
|
-
def ungzip(file, options={})
|
374
|
-
options[:dryrun] = true
|
375
|
-
ZipUtils.ungzip(file, options)
|
376
|
-
end
|
377
|
-
|
378
|
-
def bzip2(file, options={})
|
379
|
-
options[:dryrun] = true
|
380
|
-
ZipUtils.bzip2(file, options)
|
381
|
-
end
|
382
|
-
|
383
|
-
alias_method :bzip, :bzip2
|
384
|
-
|
385
|
-
def unbzip2(file, options={})
|
386
|
-
options[:dryrun] = true
|
387
|
-
ZipUtils.unbzip2(file, options)
|
388
|
-
end
|
389
|
-
|
390
|
-
alias_method :unbzip, :unbzip2
|
391
|
-
|
392
|
-
def tar(folder, file=nil, options={})
|
393
|
-
options[:dryrun] = true
|
394
|
-
ZipUtils.tar(folder, file, options)
|
395
|
-
end
|
396
|
-
|
397
|
-
def untar(file, options={})
|
398
|
-
options[:dryrun] = true
|
399
|
-
ZipUtils.untar(file, options)
|
400
|
-
end
|
401
|
-
|
402
|
-
def tar_gzip(folder, file=nil, options={})
|
403
|
-
options[:dryrun] = true
|
404
|
-
ZipUtils.tar_gzip(folder, file, options)
|
405
|
-
end
|
406
|
-
|
407
|
-
def untar_gzip(file, options={})
|
408
|
-
options[:dryrun] = true
|
409
|
-
ZipUtils.untar_gzip(file, options)
|
410
|
-
end
|
411
|
-
|
412
|
-
def tar_bzip2(folder, file=nil, options={})
|
413
|
-
options[:dryrun] = true
|
414
|
-
ZipUtils.untar_bzip2(folder, file, options)
|
415
|
-
end
|
416
|
-
|
417
|
-
alias_method :tar_bzip, :tar_bzip2
|
418
|
-
|
419
|
-
def untar_bzip2(file, options={})
|
420
|
-
options[:dryrun] = true
|
421
|
-
ZipUtils.untar_bzip2(file, options)
|
422
|
-
end
|
423
|
-
|
424
|
-
alias_method :untar_bzip, :untar_bzip2
|
425
|
-
|
426
|
-
def zip(folder, file=nil, options={})
|
427
|
-
options[:dryrun] = true
|
428
|
-
ZipUtils.unzip(folder, file, options)
|
429
|
-
end
|
430
|
-
|
431
|
-
def unzip(file, options={})
|
432
|
-
options[:dryrun] = true
|
433
|
-
ZipUtils.unzip(file, options)
|
434
|
-
end
|
435
|
-
end
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
# OLD VERSION
|
440
|
-
# #
|
441
|
-
# # DryRun version of ZipUtils.
|
442
|
-
# #
|
443
|
-
#
|
444
|
-
# module DryRun
|
445
|
-
# module_function
|
446
|
-
#
|
447
|
-
# def compress( format, folder, to_file=nil )
|
448
|
-
# send(FORMAT_TO_COMPRESS[format], folder, to_file)
|
449
|
-
# end
|
450
|
-
#
|
451
|
-
# # Tar Gzip
|
452
|
-
#
|
453
|
-
# def tar_gzip( folder, to_file=nil )
|
454
|
-
# to_file ||= File.basename(File.expand_path(folder)) + '.tar.gz'
|
455
|
-
# puts "tar --gzip -czf #{to_file} #{folder}"
|
456
|
-
# end
|
457
|
-
#
|
458
|
-
# # Untar Gzip
|
459
|
-
#
|
460
|
-
# def untar_gzip( file )
|
461
|
-
# puts "tar --gzip -xzf #{file}"
|
462
|
-
# end
|
463
|
-
#
|
464
|
-
# # Tar Bzip2
|
465
|
-
#
|
466
|
-
# def tar_bzip( folder, to_file=nil )
|
467
|
-
# puts "tar --bzip2 -cf #{to_file} #{folder}"
|
468
|
-
# end
|
469
|
-
# alias_method :tar_bz2, :tar_bzip
|
470
|
-
#
|
471
|
-
# # Untar Bzip2
|
472
|
-
#
|
473
|
-
# def untar_bzip( file )
|
474
|
-
# puts "tar --bzip2 -xf #{file}"
|
475
|
-
# end
|
476
|
-
# alias_method :untar_bz2, :untar_bzip
|
477
|
-
#
|
478
|
-
# # Zip
|
479
|
-
#
|
480
|
-
# def zip( folder, to_file=nil )
|
481
|
-
# puts "zip -cf #{to_file} #{folder}"
|
482
|
-
# end
|
483
|
-
#
|
484
|
-
# # Unzip
|
485
|
-
#
|
486
|
-
# def unzip( file )
|
487
|
-
# puts "zip -xf #{file}"
|
488
|
-
# end
|
489
|
-
#
|
490
|
-
# end
|