csd 0.1.5 → 0.1.6
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/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
@@ -0,0 +1,113 @@
|
|
1
|
+
module CSD
|
2
|
+
module Vendor
|
3
|
+
# Author
|
4
|
+
#
|
5
|
+
# Florian Frank <flori@ping.de>
|
6
|
+
#
|
7
|
+
# License
|
8
|
+
#
|
9
|
+
# This is free software; you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License Version 2
|
11
|
+
# as published by the Free Software Foundation: GNU GPL. module Term
|
12
|
+
#
|
13
|
+
module Term
|
14
|
+
# The ANSIColor module can be used for namespacing and mixed into your own classes.
|
15
|
+
#
|
16
|
+
module ANSIColor
|
17
|
+
# :stopdoc:
|
18
|
+
ATTRIBUTES = [
|
19
|
+
[ :clear , 0 ],
|
20
|
+
[ :reset , 0 ], # synonym for :clear
|
21
|
+
[ :bold , 1 ],
|
22
|
+
[ :dark , 2 ],
|
23
|
+
[ :italic , 3 ], # not widely implemented
|
24
|
+
[ :underline , 4 ],
|
25
|
+
[ :blink , 5 ],
|
26
|
+
[ :rapid_blink , 6 ], # not widely implemented
|
27
|
+
[ :negative , 7 ], # no reverse because of String#reverse
|
28
|
+
[ :concealed , 8 ],
|
29
|
+
[ :strikethrough, 9 ], # not widely implemented
|
30
|
+
[ :black , 30 ],
|
31
|
+
[ :red , 31 ],
|
32
|
+
[ :green , 32 ],
|
33
|
+
[ :yellow , 33 ],
|
34
|
+
[ :blue , 34 ],
|
35
|
+
[ :magenta , 35 ],
|
36
|
+
[ :cyan , 36 ],
|
37
|
+
[ :white , 37 ],
|
38
|
+
[ :on_black , 40 ],
|
39
|
+
[ :on_red , 41 ],
|
40
|
+
[ :on_green , 42 ],
|
41
|
+
[ :on_yellow , 43 ],
|
42
|
+
[ :on_blue , 44 ],
|
43
|
+
[ :on_magenta , 45 ],
|
44
|
+
[ :on_cyan , 46 ],
|
45
|
+
[ :on_white , 47 ],
|
46
|
+
]
|
47
|
+
|
48
|
+
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
|
49
|
+
# :startdoc:
|
50
|
+
|
51
|
+
# Returns true, if the coloring function of this module
|
52
|
+
# is switched on, false otherwise.
|
53
|
+
def self.coloring?
|
54
|
+
@coloring
|
55
|
+
end
|
56
|
+
|
57
|
+
# Turns the coloring on or off globally, so you can easily do
|
58
|
+
# this for example:
|
59
|
+
# Term::ANSIColor::coloring = STDOUT.isatty
|
60
|
+
def self.coloring=(val)
|
61
|
+
@coloring = val
|
62
|
+
end
|
63
|
+
self.coloring = true
|
64
|
+
|
65
|
+
ATTRIBUTES.each do |c, v|
|
66
|
+
eval %Q{
|
67
|
+
def #{c}(string = nil)
|
68
|
+
result = ''
|
69
|
+
result << "\e[#{v}m" if Term::ANSIColor.coloring?
|
70
|
+
if block_given?
|
71
|
+
result << yield
|
72
|
+
elsif string
|
73
|
+
result << string
|
74
|
+
elsif respond_to?(:to_str)
|
75
|
+
result << to_str
|
76
|
+
else
|
77
|
+
return result #only switch on
|
78
|
+
end
|
79
|
+
result << "\e[0m" if Term::ANSIColor.coloring?
|
80
|
+
result
|
81
|
+
end
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
# Regular expression that is used to scan for ANSI-sequences while
|
86
|
+
# uncoloring strings.
|
87
|
+
COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
|
88
|
+
|
89
|
+
# Returns an uncolored version of the string, that is all
|
90
|
+
# ANSI-sequences are stripped from the string.
|
91
|
+
def uncolored(string = nil) # :yields:
|
92
|
+
if block_given?
|
93
|
+
yield.gsub(COLORED_REGEXP, '')
|
94
|
+
elsif string
|
95
|
+
string.gsub(COLORED_REGEXP, '')
|
96
|
+
elsif respond_to?(:to_str)
|
97
|
+
to_str.gsub(COLORED_REGEXP, '')
|
98
|
+
else
|
99
|
+
''
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
module_function
|
104
|
+
|
105
|
+
# Returns an array of all Term::ANSIColor attributes as symbols.
|
106
|
+
def attributes
|
107
|
+
ATTRIBUTE_NAMES
|
108
|
+
end
|
109
|
+
extend self
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/lib/csd/version.rb
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
-
# encoding:
|
2
|
-
require
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
require 'csd/container'
|
3
3
|
|
4
4
|
module CSD
|
5
5
|
|
6
|
-
# This global variable holds the version number of this gem by
|
6
|
+
# This global variable holds the version number of this gem by trying to read the VERSION file.
|
7
|
+
# If the VERSION file cannot be read, it will be defined to 0.0.0 as a fallback.
|
8
|
+
# Ideally it would be hardcoded in this file, because it cannot be guaranteed that the VERSION
|
9
|
+
# file exists (see http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices). But we
|
10
|
+
# use it anyway, because Jeweler (a gem to create gems more easily) needs it and the risk is not that big.
|
7
11
|
#
|
8
|
-
Version = VERSION =
|
12
|
+
Version = VERSION = begin
|
13
|
+
File.read(File.join(Path.gem, 'VERSION'))
|
14
|
+
rescue Errno::ENOENT => e
|
15
|
+
UI.debug "The VERSION file could not be found. Setting `Version´ to 0.0.0"
|
16
|
+
'0.0.0'
|
17
|
+
end
|
9
18
|
|
10
19
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'csd/application/minisip'
|
3
|
+
|
4
|
+
class TestDir < Test::Unit::TestCase
|
5
|
+
|
6
|
+
include CSD
|
7
|
+
|
8
|
+
context "The Minisip application" do
|
9
|
+
|
10
|
+
setup do
|
11
|
+
Options.clear
|
12
|
+
@app = Application::Minisip::Base.new
|
13
|
+
end
|
14
|
+
|
15
|
+
teardown do
|
16
|
+
end
|
17
|
+
|
18
|
+
should "respond to valid actions" do
|
19
|
+
assert @app.respond_to?(:compile)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "know how to identify a subset of libraries with --only" do
|
23
|
+
Options.only = nil
|
24
|
+
assert_equal Application::Minisip::Base::LIBRARIES, @app.libraries
|
25
|
+
Options.only = %w{ libmcrypto }
|
26
|
+
assert_equal %w{ libmcrypto }, @app.libraries
|
27
|
+
Options.only = %w{ does-not-exist }
|
28
|
+
assert @app.libraries == []
|
29
|
+
Options.only = Application::Minisip::Base::LIBRARIES
|
30
|
+
assert_equal Application::Minisip::Base::LIBRARIES, @app.libraries
|
31
|
+
Options.only = %w{ minisip libmutil }
|
32
|
+
assert_equal %w{ libmutil minisip }, @app.libraries
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when downloading source code" do
|
36
|
+
|
37
|
+
should "dummy" do
|
38
|
+
assert true
|
39
|
+
end
|
40
|
+
|
41
|
+
end # context "when downloading source code"
|
42
|
+
|
43
|
+
end # context "The Minisip application"
|
44
|
+
|
45
|
+
end
|
@@ -64,23 +64,17 @@ class TestApplications < Test::Unit::TestCase
|
|
64
64
|
end # context "the application module"
|
65
65
|
|
66
66
|
end # context "and considering a valid application, find"
|
67
|
+
|
68
|
+
context "find" do
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
# dirs = Dir.directories(Path.applications)
|
74
|
-
# apps = Applications.all
|
75
|
-
# assert_equal dirs.size, apps.size
|
76
|
-
# Applications.all do |app|
|
77
|
-
# assert_includes directories, 'app'
|
78
|
-
# end
|
79
|
-
#
|
80
|
-
#end
|
70
|
+
should "do not evaluate to +true+ for an invalid application search term" do
|
71
|
+
assert !Applications.find(nil)
|
72
|
+
assert !Applications.find('')
|
73
|
+
assert !Applications.find('i-for-sure-do-not-exist')
|
74
|
+
end
|
81
75
|
|
82
|
-
|
83
|
-
|
84
|
-
|
76
|
+
end
|
77
|
+
|
78
|
+
end # context "When analyzing arguments"
|
85
79
|
|
86
80
|
end
|
@@ -5,13 +5,35 @@ class TestCommands < Test::Unit::TestCase
|
|
5
5
|
|
6
6
|
include CSD
|
7
7
|
|
8
|
+
DUMMY_TEXT = %q{PART I
|
9
|
+
|
10
|
+
NIGHT
|
11
|
+
|
12
|
+
A high vaulted narrow Gothic chamber.
|
13
|
+
FAUST, restless, seated at his desk.
|
14
|
+
|
15
|
+
FAUST
|
16
|
+
|
17
|
+
I HAVE, alas! Philosophy,
|
18
|
+
Medicine, Jurisprudence too,
|
19
|
+
And to my cost Theology,
|
20
|
+
With ardent labour, studied through.
|
21
|
+
And here I stand, with all my lore,
|
22
|
+
Poor fool, no wiser than before.
|
23
|
+
Magister, doctor styled, indeed,
|
24
|
+
Already these ten years I lead,
|
25
|
+
Up, down, across, and to and fro,
|
26
|
+
My pupils by the nose,--and learn,
|
27
|
+
That we in truth can nothing know!}
|
28
|
+
|
29
|
+
DUMMY_GIT = 'http://github.com/csd/dummy.git'
|
30
|
+
|
8
31
|
context "As a directory function" do
|
9
32
|
|
10
33
|
setup do
|
11
34
|
Options.silent = true
|
12
35
|
Options.reveal = false
|
13
|
-
|
14
|
-
@tmp = Dir.mktmpdir
|
36
|
+
@tmp = Pathname.new Dir.mktmpdir
|
15
37
|
@dir = Pathname.new File.join(@tmp, 'folder')
|
16
38
|
@subdir = Pathname.new File.join(@dir, 'subfolder')
|
17
39
|
end
|
@@ -24,7 +46,7 @@ class TestCommands < Test::Unit::TestCase
|
|
24
46
|
|
25
47
|
should "return the proper CommandResult if the directory already existed" do
|
26
48
|
ensure_mkdir(@dir)
|
27
|
-
assert_kind_of(
|
49
|
+
assert_kind_of(CommandResult, result = Cmd.mkdir(@dir))
|
28
50
|
assert result.success?
|
29
51
|
assert result.already_existed?
|
30
52
|
assert result.writable?
|
@@ -32,33 +54,43 @@ class TestCommands < Test::Unit::TestCase
|
|
32
54
|
|
33
55
|
should "return a successful CommandResult but not actually do anything in reveal mode" do
|
34
56
|
Options.reveal = true
|
35
|
-
assert_kind_of(
|
57
|
+
assert_kind_of(CommandResult, result = Cmd.mkdir(@dir))
|
36
58
|
assert !@dir.directory?
|
37
59
|
assert result.success?
|
38
60
|
assert !result.already_existed?
|
39
61
|
assert result.writable?
|
40
62
|
end
|
41
63
|
|
42
|
-
should "
|
43
|
-
|
44
|
-
|
45
|
-
assert
|
64
|
+
should "create the directory if it doesn't exist yet" do
|
65
|
+
assert_kind_of(CommandResult, result = Cmd.mkdir(@dir))
|
66
|
+
assert result.success?
|
67
|
+
assert !result.already_existed?
|
68
|
+
assert result.writable?
|
69
|
+
end
|
70
|
+
|
71
|
+
should "notify if there is no permission to create a new directory without die_on_failure" do
|
72
|
+
ensure_mkdir(@dir)
|
73
|
+
@dir.chmod(0000)
|
74
|
+
assert_kind_of(CommandResult, result = Cmd.mkdir(File.join(@dir, 'subdir_in_readonly_dir'), :die_on_failure => false))
|
46
75
|
assert !result.success?
|
47
76
|
assert !result.already_existed?
|
48
77
|
assert !result.writable?
|
78
|
+
@dir.chmod(0777) # Cleanup
|
49
79
|
end
|
50
80
|
|
51
|
-
should "
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
81
|
+
should "notify if there is no permission to create a new directory with die_on_failure" do
|
82
|
+
ensure_mkdir(@dir)
|
83
|
+
@dir.chmod(0000)
|
84
|
+
assert_raise(Error::UI::Die) {
|
85
|
+
Cmd.mkdir(File.join(@dir, 'subdir_in_readonly_dir'), :die_on_failure => true)
|
86
|
+
}
|
87
|
+
@dir.chmod(0777) # Cleanup
|
56
88
|
end
|
57
89
|
|
58
|
-
should "notify if there is no permission to create
|
90
|
+
should "notify if there is no permission to create an existing directory" do
|
59
91
|
ensure_mkdir(@dir)
|
60
92
|
@dir.chmod(0000)
|
61
|
-
assert_kind_of(
|
93
|
+
assert_kind_of(CommandResult, result = Cmd.mkdir(@dir))
|
62
94
|
assert result.success?
|
63
95
|
assert result.already_existed?
|
64
96
|
assert !result.writable?
|
@@ -70,34 +102,46 @@ class TestCommands < Test::Unit::TestCase
|
|
70
102
|
context "cd" do
|
71
103
|
|
72
104
|
should "return a CommanResult with success? if the directory was changed successfully" do
|
73
|
-
assert_kind_of(
|
105
|
+
assert_kind_of(CommandResult, result = Cmd.cd('/'))
|
74
106
|
assert result.success?
|
75
|
-
assert_kind_of(
|
107
|
+
assert_kind_of(CommandResult, result = Cmd.cd(@tmp))
|
76
108
|
assert result.success?
|
77
109
|
end
|
78
110
|
|
79
|
-
should "realize when the target is not a directory, but a file or something" do
|
111
|
+
should "realize when the target is not a directory, but a file or something without die_on_failure" do
|
80
112
|
testfile_path = File.join(@tmp, 'testfile')
|
81
113
|
File.new(testfile_path, 'w')
|
82
|
-
assert_kind_of(
|
114
|
+
assert_kind_of(CommandResult, result = Cmd.cd(testfile_path, :die_on_failure => false))
|
83
115
|
assert !result.success?
|
84
116
|
end
|
85
117
|
|
86
|
-
should "realize when the target
|
87
|
-
|
118
|
+
should "realize when the target is not a directory, but a file or something with die_on_failure" do
|
119
|
+
testfile_path = File.join(@tmp, 'testfile')
|
120
|
+
assert_raise(Error::UI::Die) {
|
121
|
+
Cmd.cd(testfile_path, :die_on_failure => true)
|
122
|
+
}
|
123
|
+
end
|
124
|
+
|
125
|
+
should "realize when the target doesn't exist without die_on_failure" do
|
126
|
+
assert_kind_of(CommandResult, result = Cmd.cd('/i/for/sure/dont/exist', :die_on_failure => false))
|
88
127
|
assert !result.success?
|
89
128
|
end
|
129
|
+
|
130
|
+
should "realize when the target doesn't exist with die_on_failure" do
|
131
|
+
assert_raise(Error::UI::Die) {
|
132
|
+
Cmd.cd('/i/for/sure/dont/exist', :die_on_failure => true)
|
133
|
+
}
|
134
|
+
end
|
90
135
|
|
91
136
|
should "fake changing the directory in reveal mode" do
|
92
137
|
Options.reveal = true
|
93
138
|
current_pwd = Dir.pwd
|
94
|
-
assert_kind_of(
|
139
|
+
assert_kind_of(CommandResult, result = Cmd.cd('/i/for/sure/dont/exist'))
|
95
140
|
assert result.success?
|
96
141
|
assert_equal current_pwd, Dir.pwd
|
97
142
|
end
|
98
143
|
|
99
144
|
should "actually change the directory in dry mode" do
|
100
|
-
Options.dry = true
|
101
145
|
assert_not_equal '/', Dir.pwd
|
102
146
|
assert result = Cmd.cd('/')
|
103
147
|
assert result.success?
|
@@ -106,6 +150,199 @@ class TestCommands < Test::Unit::TestCase
|
|
106
150
|
|
107
151
|
end # context "cd"
|
108
152
|
|
153
|
+
context "when working with files" do
|
154
|
+
|
155
|
+
setup do
|
156
|
+
ensure_mkdir(@dir)
|
157
|
+
ensure_mkdir(@subdir)
|
158
|
+
@file1 = Pathname.new File.join(@tmp, 'file1')
|
159
|
+
@file2 = Pathname.new File.join(@tmp, 'file2')
|
160
|
+
@file3 = Pathname.new File.join(@dir, 'file3')
|
161
|
+
[@file1, @file2, @file3].each { |file| assert FileUtils.touch(file) }
|
162
|
+
end
|
163
|
+
|
164
|
+
teardown do
|
165
|
+
assert FileUtils.rm_r(@tmp)
|
166
|
+
@tmp = Pathname.new Dir.mktmpdir
|
167
|
+
end
|
168
|
+
|
169
|
+
context "copy" do
|
170
|
+
|
171
|
+
should "copy one file into another folder" do
|
172
|
+
assert_kind_of(CommandResult, result = Cmd.copy(@file1, @subdir))
|
173
|
+
assert result.success?
|
174
|
+
assert File.exist?(File.join(@subdir, File.basename(@file1)))
|
175
|
+
end
|
176
|
+
|
177
|
+
should "copy several files into another folder" do
|
178
|
+
assert_kind_of(CommandResult, result = Cmd.copy([@file1, @file2, @file3], @subdir))
|
179
|
+
assert result.success?
|
180
|
+
[@file1, @file2, @file3].each do |file|
|
181
|
+
assert File.exist?(File.join(@subdir, File.basename(file)))
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
should "know when a source file doesn't exist without die_on_failure" do
|
186
|
+
assert_kind_of(CommandResult, result = Cmd.copy('/no/source', @subdir, :die_on_failure => false))
|
187
|
+
assert !result.success?
|
188
|
+
end
|
189
|
+
|
190
|
+
should "know when a source file doesn't exist with die_on_failure" do
|
191
|
+
assert_raise(Error::UI::Die) {
|
192
|
+
Cmd.copy('/no/source', @subdir, :die_on_failure => true)
|
193
|
+
}
|
194
|
+
end
|
195
|
+
|
196
|
+
should "know when a destination directory doesn't exist without die_on_failure" do
|
197
|
+
assert_kind_of(CommandResult, result = Cmd.copy(@file1, '/no/destination', :die_on_failure => false))
|
198
|
+
assert !result.success?
|
199
|
+
end
|
200
|
+
|
201
|
+
should "know when a destination directory doesn't exist with die_on_failure" do
|
202
|
+
assert_raise(Error::UI::Die) {
|
203
|
+
Cmd.copy(@file1, '/no/destination', :die_on_failure => true)
|
204
|
+
}
|
205
|
+
end
|
206
|
+
|
207
|
+
end # context "copy"
|
208
|
+
|
209
|
+
context "move" do
|
210
|
+
|
211
|
+
should "move one file into another folder" do
|
212
|
+
assert_kind_of(CommandResult, result = Cmd.move(@file1, @subdir))
|
213
|
+
assert result.success?
|
214
|
+
assert !File.exist?(@file1)
|
215
|
+
assert File.exist?(File.join(@subdir, File.basename(@file1)))
|
216
|
+
end
|
217
|
+
|
218
|
+
should "move several files into another folder" do
|
219
|
+
assert_kind_of(CommandResult, result = Cmd.move([@file1, @file2, @file3], @subdir))
|
220
|
+
assert result.success?
|
221
|
+
[@file1, @file2, @file3].each do |file|
|
222
|
+
assert !File.exist?(file)
|
223
|
+
assert File.exist?(File.join(@subdir, File.basename(file)))
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
should "know when a source file doesn't exist without die_on_failure" do
|
228
|
+
assert_kind_of(CommandResult, result = Cmd.move('/no/source', @subdir, :die_on_failure => false))
|
229
|
+
assert !result.success?
|
230
|
+
end
|
231
|
+
|
232
|
+
should "know when a source file doesn't exist with die_on_failure" do
|
233
|
+
assert_raise(Error::UI::Die) {
|
234
|
+
Cmd.move('/no/source', @subdir, :die_on_failure => true)
|
235
|
+
}
|
236
|
+
end
|
237
|
+
|
238
|
+
should "not mind when a destination doesn't exist even with die_on_failure" do
|
239
|
+
assert_kind_of(CommandResult, result = Cmd.move(@file1, File.join(@subdir, 'newfile'), :die_on_failure => true))
|
240
|
+
assert result.success?
|
241
|
+
assert !File.exist?(@file1)
|
242
|
+
assert File.exist?(File.join(@subdir, 'newfile'))
|
243
|
+
end
|
244
|
+
|
245
|
+
end # context "move"
|
246
|
+
|
247
|
+
context "replace" do
|
248
|
+
|
249
|
+
setup do
|
250
|
+
File.open(@file1, 'w') { |f| assert f.write(DUMMY_TEXT) }
|
251
|
+
end
|
252
|
+
|
253
|
+
should "be unsuccessful if the file doesn't exist without die_on_failure" do
|
254
|
+
assert_kind_of(CommandResult, result = Cmd.replace('/i/am/not/there', 'FAUST', 'GOETHE', :die_on_failure => false))
|
255
|
+
assert !result.success?
|
256
|
+
end
|
257
|
+
|
258
|
+
should "be unsuccessful if the file doesn't exist with die_on_failure" do
|
259
|
+
assert_raise(Error::UI::Die) {
|
260
|
+
Cmd.replace('/i/am/not/there', 'FAUST', 'GOETHE')
|
261
|
+
}
|
262
|
+
end
|
263
|
+
|
264
|
+
should "do a simple replacement in a file" do
|
265
|
+
assert_kind_of(CommandResult, result = Cmd.replace(@file1, 'FAUST', 'GOETHE'))
|
266
|
+
assert result.success?
|
267
|
+
assert_equal DUMMY_TEXT.gsub('FAUST', 'GOETHE'), File.read(@file1)
|
268
|
+
end
|
269
|
+
|
270
|
+
should "do nothing if the file doesnt have anything to replace" do
|
271
|
+
assert_kind_of(CommandResult, result = Cmd.replace(@file1, 'ASDF', 'FDSA'))
|
272
|
+
assert_equal DUMMY_TEXT, File.read(@file1)
|
273
|
+
assert result.success?
|
274
|
+
end
|
275
|
+
|
276
|
+
should "replace multiple items in one file" do
|
277
|
+
Cmd.replace @file1 do |r|
|
278
|
+
assert_kind_of(CommandResult, r.replace('FAUST', 'GOETHE'))
|
279
|
+
assert_equal DUMMY_TEXT.gsub('FAUST', 'GOETHE'), File.read(@file1)
|
280
|
+
assert_kind_of(CommandResult, r.replace("Philosophy,\n", 'Philosophy, '))
|
281
|
+
assert File.read(@file1).scan('Philosophy, Medicine')
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
end # context "replace"
|
286
|
+
|
287
|
+
end # context "when working with files"
|
288
|
+
|
109
289
|
end # context "As a directory function"
|
290
|
+
|
291
|
+
context "run" do
|
292
|
+
|
293
|
+
setup do
|
294
|
+
Options.silent = true
|
295
|
+
Options.reveal = false
|
296
|
+
end
|
297
|
+
|
298
|
+
should "return a successfull CommandResult if the command was OK" do
|
299
|
+
assert_kind_of(CommandResult, result = Cmd.run('cd'))
|
300
|
+
assert result.success?
|
301
|
+
end
|
302
|
+
|
303
|
+
should "return a non-successfull CommandResult if the command was bad without die_on_failure" do
|
304
|
+
assert_kind_of(CommandResult, result = Cmd.run('this-command-does-not-exist', :die_on_failure => false))
|
305
|
+
assert !result.success?
|
306
|
+
end
|
307
|
+
|
308
|
+
end
|
309
|
+
|
310
|
+
context "git_clone" do
|
311
|
+
|
312
|
+
setup do
|
313
|
+
# For some gross reasons the Jeweler::Tasks.new instance modifies the ENV, trying to tell GIT some things
|
314
|
+
# that disturb our testing here. We need to undo this here, and it is not a nice solution, but it works.
|
315
|
+
ENV.keys.select { |k| k =~ /^GIT_/ }.each { |k| ENV.delete(k) }
|
316
|
+
Options.silent = true
|
317
|
+
Options.reveal = false
|
318
|
+
@tmp = Pathname.new Dir.mktmpdir
|
319
|
+
@dir = Pathname.new(File.join(@tmp, 'dummy'))
|
320
|
+
Dir.chdir @tmp # Since we're removing the directory in the teardown, we should better not be in it
|
321
|
+
end
|
322
|
+
|
323
|
+
teardown do
|
324
|
+
assert FileUtils.rm_r(@tmp)
|
325
|
+
end
|
326
|
+
|
327
|
+
should "not successfully download a non-existent git repository without die_on_failure" do
|
328
|
+
assert_kind_of(CommandResult, result = Cmd.git_clone('an invalid git repository', 'invalid_git_repository.git', @dir, :die_on_failure => false))
|
329
|
+
assert !result.success?
|
330
|
+
end
|
331
|
+
|
332
|
+
should "download a simple git repository" do
|
333
|
+
assert_kind_of(CommandResult, result = Cmd.git_clone('a sample git repository', DUMMY_GIT, @dir))
|
334
|
+
assert result.success?
|
335
|
+
assert @dir.directory?
|
336
|
+
assert File.exist?(File.join(@dir, 'dummy.txt'))
|
337
|
+
end
|
338
|
+
|
339
|
+
should "do nothing at the destination in reveal mode" do
|
340
|
+
Options.reveal = true
|
341
|
+
assert_kind_of(CommandResult, result = Cmd.git_clone('a sample git repository', DUMMY_GIT, @dir))
|
342
|
+
assert result.success?
|
343
|
+
assert !@dir.directory?
|
344
|
+
end
|
345
|
+
|
346
|
+
end
|
110
347
|
|
111
348
|
end
|