csd 0.0.15 → 0.0.16
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/.gitignore +1 -0
- data/COPYING +367 -0
- data/Rakefile +10 -10
- data/VERSION +1 -1
- data/bin/ai +19 -0
- data/csd.gemspec +257 -35
- data/lib/active_support.rb +75 -0
- data/lib/active_support/all.rb +3 -0
- data/lib/active_support/backtrace_cleaner.rb +94 -0
- data/lib/active_support/base64.rb +42 -0
- data/lib/active_support/basic_object.rb +21 -0
- data/lib/active_support/benchmarkable.rb +60 -0
- data/lib/active_support/buffered_logger.rb +132 -0
- data/lib/active_support/builder.rb +6 -0
- data/lib/active_support/cache.rb +626 -0
- data/lib/active_support/cache/compressed_mem_cache_store.rb +13 -0
- data/lib/active_support/cache/file_store.rb +188 -0
- data/lib/active_support/cache/mem_cache_store.rb +191 -0
- data/lib/active_support/cache/memory_store.rb +159 -0
- data/lib/active_support/cache/strategy/local_cache.rb +164 -0
- data/lib/active_support/cache/synchronized_memory_store.rb +11 -0
- data/lib/active_support/callbacks.rb +600 -0
- data/lib/active_support/concern.rb +29 -0
- data/lib/active_support/configurable.rb +36 -0
- data/lib/active_support/core_ext.rb +3 -0
- data/lib/active_support/core_ext/array.rb +7 -0
- data/lib/active_support/core_ext/array/access.rb +46 -0
- data/lib/active_support/core_ext/array/conversions.rb +164 -0
- data/lib/active_support/core_ext/array/extract_options.rb +29 -0
- data/lib/active_support/core_ext/array/grouping.rb +100 -0
- data/lib/active_support/core_ext/array/random_access.rb +20 -0
- data/lib/active_support/core_ext/array/uniq_by.rb +17 -0
- data/lib/active_support/core_ext/array/wrap.rb +22 -0
- data/lib/active_support/core_ext/benchmark.rb +7 -0
- data/lib/active_support/core_ext/big_decimal.rb +1 -0
- data/lib/active_support/core_ext/big_decimal/conversions.rb +27 -0
- data/lib/active_support/core_ext/cgi.rb +1 -0
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +19 -0
- data/lib/active_support/core_ext/class.rb +4 -0
- data/lib/active_support/core_ext/class/attribute.rb +67 -0
- data/lib/active_support/core_ext/class/attribute_accessors.rb +63 -0
- data/lib/active_support/core_ext/class/delegating_attributes.rb +44 -0
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +232 -0
- data/lib/active_support/core_ext/class/subclasses.rb +55 -0
- data/lib/active_support/core_ext/date/acts_like.rb +8 -0
- data/lib/active_support/core_ext/date/calculations.rb +240 -0
- data/lib/active_support/core_ext/date/conversions.rb +99 -0
- data/lib/active_support/core_ext/date/freeze.rb +31 -0
- data/lib/active_support/core_ext/date_time/acts_like.rb +13 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +113 -0
- data/lib/active_support/core_ext/date_time/conversions.rb +102 -0
- data/lib/active_support/core_ext/date_time/zones.rb +17 -0
- data/lib/active_support/core_ext/enumerable.rb +119 -0
- data/lib/active_support/core_ext/exception.rb +3 -0
- data/lib/active_support/core_ext/file.rb +2 -0
- data/lib/active_support/core_ext/file/atomic.rb +41 -0
- data/lib/active_support/core_ext/file/path.rb +5 -0
- data/lib/active_support/core_ext/float.rb +1 -0
- data/lib/active_support/core_ext/float/rounding.rb +19 -0
- data/lib/active_support/core_ext/hash.rb +8 -0
- data/lib/active_support/core_ext/hash/conversions.rb +150 -0
- data/lib/active_support/core_ext/hash/deep_merge.rb +16 -0
- data/lib/active_support/core_ext/hash/diff.rb +13 -0
- data/lib/active_support/core_ext/hash/except.rb +24 -0
- data/lib/active_support/core_ext/hash/indifferent_access.rb +14 -0
- data/lib/active_support/core_ext/hash/keys.rb +45 -0
- data/lib/active_support/core_ext/hash/reverse_merge.rb +28 -0
- data/lib/active_support/core_ext/hash/slice.rb +38 -0
- data/lib/active_support/core_ext/integer.rb +3 -0
- data/lib/active_support/core_ext/integer/inflections.rb +14 -0
- data/lib/active_support/core_ext/integer/multiple.rb +6 -0
- data/lib/active_support/core_ext/integer/time.rb +39 -0
- data/lib/active_support/core_ext/kernel.rb +5 -0
- data/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
- data/lib/active_support/core_ext/kernel/debugger.rb +16 -0
- data/lib/active_support/core_ext/kernel/reporting.rb +62 -0
- data/lib/active_support/core_ext/kernel/requires.rb +26 -0
- data/lib/active_support/core_ext/kernel/singleton_class.rb +13 -0
- data/lib/active_support/core_ext/load_error.rb +23 -0
- data/lib/active_support/core_ext/logger.rb +146 -0
- data/lib/active_support/core_ext/module.rb +12 -0
- data/lib/active_support/core_ext/module/aliasing.rb +70 -0
- data/lib/active_support/core_ext/module/anonymous.rb +24 -0
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
- data/lib/active_support/core_ext/module/attr_internal.rb +32 -0
- data/lib/active_support/core_ext/module/attribute_accessors.rb +66 -0
- data/lib/active_support/core_ext/module/delegation.rb +146 -0
- data/lib/active_support/core_ext/module/deprecation.rb +9 -0
- data/lib/active_support/core_ext/module/introspection.rb +88 -0
- data/lib/active_support/core_ext/module/method_names.rb +14 -0
- data/lib/active_support/core_ext/module/reachable.rb +10 -0
- data/lib/active_support/core_ext/module/remove_method.rb +6 -0
- data/lib/active_support/core_ext/module/synchronization.rb +42 -0
- data/lib/active_support/core_ext/name_error.rb +18 -0
- data/lib/active_support/core_ext/numeric.rb +2 -0
- data/lib/active_support/core_ext/numeric/bytes.rb +44 -0
- data/lib/active_support/core_ext/numeric/time.rb +77 -0
- data/lib/active_support/core_ext/object.rb +14 -0
- data/lib/active_support/core_ext/object/acts_like.rb +10 -0
- data/lib/active_support/core_ext/object/blank.rb +76 -0
- data/lib/active_support/core_ext/object/conversions.rb +4 -0
- data/lib/active_support/core_ext/object/duplicable.rb +65 -0
- data/lib/active_support/core_ext/object/extending.rb +11 -0
- data/lib/active_support/core_ext/object/instance_variables.rb +67 -0
- data/lib/active_support/core_ext/object/misc.rb +2 -0
- data/lib/active_support/core_ext/object/returning.rb +42 -0
- data/lib/active_support/core_ext/object/to_param.rb +49 -0
- data/lib/active_support/core_ext/object/to_query.rb +27 -0
- data/lib/active_support/core_ext/object/try.rb +36 -0
- data/lib/active_support/core_ext/object/with_options.rb +26 -0
- data/lib/active_support/core_ext/proc.rb +14 -0
- data/lib/active_support/core_ext/process.rb +1 -0
- data/lib/active_support/core_ext/process/daemon.rb +23 -0
- data/lib/active_support/core_ext/range.rb +4 -0
- data/lib/active_support/core_ext/range/blockless_step.rb +29 -0
- data/lib/active_support/core_ext/range/conversions.rb +21 -0
- data/lib/active_support/core_ext/range/include_range.rb +21 -0
- data/lib/active_support/core_ext/range/overlaps.rb +8 -0
- data/lib/active_support/core_ext/regexp.rb +5 -0
- data/lib/active_support/core_ext/rexml.rb +46 -0
- data/lib/active_support/core_ext/string.rb +12 -0
- data/lib/active_support/core_ext/string/access.rb +99 -0
- data/lib/active_support/core_ext/string/behavior.rb +7 -0
- data/lib/active_support/core_ext/string/conversions.rb +61 -0
- data/lib/active_support/core_ext/string/encoding.rb +11 -0
- data/lib/active_support/core_ext/string/exclude.rb +6 -0
- data/lib/active_support/core_ext/string/filters.rb +49 -0
- data/lib/active_support/core_ext/string/inflections.rb +149 -0
- data/lib/active_support/core_ext/string/interpolation.rb +2 -0
- data/lib/active_support/core_ext/string/multibyte.rb +72 -0
- data/lib/active_support/core_ext/string/output_safety.rb +109 -0
- data/lib/active_support/core_ext/string/starts_ends_with.rb +4 -0
- data/lib/active_support/core_ext/string/xchar.rb +18 -0
- data/lib/active_support/core_ext/time/acts_like.rb +8 -0
- data/lib/active_support/core_ext/time/calculations.rb +282 -0
- data/lib/active_support/core_ext/time/conversions.rb +85 -0
- data/lib/active_support/core_ext/time/marshal.rb +56 -0
- data/lib/active_support/core_ext/time/publicize_conversion_methods.rb +10 -0
- data/lib/active_support/core_ext/time/zones.rb +78 -0
- data/lib/active_support/core_ext/uri.rb +22 -0
- data/lib/active_support/dependencies.rb +628 -0
- data/lib/active_support/dependencies/autoload.rb +50 -0
- data/lib/active_support/deprecation.rb +18 -0
- data/lib/active_support/deprecation/behaviors.rb +38 -0
- data/lib/active_support/deprecation/method_wrappers.rb +29 -0
- data/lib/active_support/deprecation/proxy_wrappers.rb +74 -0
- data/lib/active_support/deprecation/reporting.rb +56 -0
- data/lib/active_support/duration.rb +105 -0
- data/lib/active_support/gzip.rb +25 -0
- data/lib/active_support/hash_with_indifferent_access.rb +145 -0
- data/lib/active_support/i18n.rb +8 -0
- data/lib/active_support/inflections.rb +56 -0
- data/lib/active_support/inflector.rb +7 -0
- data/lib/active_support/inflector/inflections.rb +211 -0
- data/lib/active_support/inflector/methods.rb +141 -0
- data/lib/active_support/inflector/transliterate.rb +97 -0
- data/lib/active_support/json.rb +2 -0
- data/lib/active_support/json/backends/jsongem.rb +43 -0
- data/lib/active_support/json/backends/yajl.rb +40 -0
- data/lib/active_support/json/backends/yaml.rb +90 -0
- data/lib/active_support/json/decoding.rb +51 -0
- data/lib/active_support/json/encoding.rb +254 -0
- data/lib/active_support/json/variable.rb +11 -0
- data/lib/active_support/lazy_load_hooks.rb +27 -0
- data/lib/active_support/locale/en.yml +36 -0
- data/lib/active_support/memoizable.rb +103 -0
- data/lib/active_support/message_encryptor.rb +71 -0
- data/lib/active_support/message_verifier.rb +62 -0
- data/lib/active_support/multibyte.rb +44 -0
- data/lib/active_support/multibyte/chars.rb +480 -0
- data/lib/active_support/multibyte/exceptions.rb +8 -0
- data/lib/active_support/multibyte/unicode.rb +393 -0
- data/lib/active_support/multibyte/utils.rb +60 -0
- data/lib/active_support/notifications.rb +81 -0
- data/lib/active_support/notifications/fanout.rb +93 -0
- data/lib/active_support/notifications/instrumenter.rb +56 -0
- data/lib/active_support/option_merger.rb +25 -0
- data/lib/active_support/ordered_hash.rb +158 -0
- data/lib/active_support/ordered_options.rb +27 -0
- data/lib/active_support/railtie.rb +100 -0
- data/lib/active_support/rescuable.rb +114 -0
- data/lib/active_support/ruby/shim.rb +22 -0
- data/lib/active_support/secure_random.rb +199 -0
- data/lib/active_support/string_inquirer.rb +21 -0
- data/lib/active_support/test_case.rb +42 -0
- data/lib/active_support/testing/assertions.rb +82 -0
- data/lib/active_support/testing/declarative.rb +40 -0
- data/lib/active_support/testing/default.rb +9 -0
- data/lib/active_support/testing/deprecation.rb +55 -0
- data/lib/active_support/testing/isolation.rb +154 -0
- data/lib/active_support/testing/pending.rb +48 -0
- data/lib/active_support/testing/performance.rb +455 -0
- data/lib/active_support/testing/setup_and_teardown.rb +111 -0
- data/lib/active_support/time.rb +34 -0
- data/lib/active_support/time/autoload.rb +5 -0
- data/lib/active_support/time_with_zone.rb +341 -0
- data/lib/active_support/values/time_zone.rb +377 -0
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +10 -0
- data/lib/active_support/whiny_nil.rb +60 -0
- data/lib/active_support/xml_mini.rb +158 -0
- data/lib/active_support/xml_mini/jdom.rb +168 -0
- data/lib/active_support/xml_mini/libxml.rb +80 -0
- data/lib/active_support/xml_mini/libxmlsax.rb +85 -0
- data/lib/active_support/xml_mini/nokogiri.rb +78 -0
- data/lib/active_support/xml_mini/nokogirisax.rb +83 -0
- data/lib/active_support/xml_mini/rexml.rb +129 -0
- data/lib/csd.rb +82 -2
- data/lib/csd/application.rb +2 -0
- data/lib/csd/application/default.rb +51 -0
- data/lib/csd/application/default/base.rb +15 -0
- data/lib/csd/application/minisip.rb +25 -0
- data/lib/csd/application/minisip/about.yml +14 -0
- data/lib/csd/application/minisip/base.rb +161 -0
- data/lib/csd/application/minisip/error.rb +11 -0
- data/lib/csd/application/minisip/options/common.rb +0 -0
- data/lib/csd/application/minisip/options/compile.rb +59 -0
- data/lib/csd/{applications → application}/minisip/unix/base.rb +10 -11
- data/lib/csd/application/opensips/about.yml +2 -0
- data/lib/csd/applications.rb +55 -0
- data/lib/csd/commands.rb +88 -65
- data/lib/csd/error.rb +31 -0
- data/lib/csd/extensions.rb +1 -0
- data/lib/{extensions → csd/extensions}/core/array.rb +2 -2
- data/lib/csd/extensions/core/dir.rb +46 -0
- data/lib/{extensions → csd/extensions}/core/file.rb +2 -2
- data/lib/{extensions → csd/extensions}/core/object.rb +2 -2
- data/lib/csd/extensions/core/option_parser.rb +33 -0
- data/lib/{extensions → csd/extensions}/core/pathname.rb +12 -3
- data/lib/{extensions → csd/extensions}/core/string.rb +2 -2
- data/lib/{extensions → csd/extensions}/gem/platform.rb +6 -2
- data/lib/csd/global_open_struct.rb +18 -0
- data/lib/csd/options.rb +124 -95
- data/lib/csd/path.rb +31 -0
- data/lib/csd/ui.rb +1 -0
- data/lib/csd/ui/cli.rb +7 -0
- data/lib/csd/ui/ui.rb +46 -0
- data/lib/csd/version.rb +9 -0
- data/lib/term/ansicolor.rb +102 -0
- data/lib/term/ansicolor/.keep +0 -0
- data/lib/term/ansicolor/version.rb +10 -0
- data/test/functional/test_applications.rb +86 -0
- data/test/functional/test_commands.rb +42 -29
- data/test/functional/test_options.rb +98 -0
- data/test/helper.rb +14 -0
- data/test/unit/test_dir.rb +38 -0
- data/test/unit/test_pathname.rb +32 -0
- metadata +253 -40
- data/LICENSE +0 -20
- data/bin/csd +0 -8
- data/lib/csd/applications/base.rb +0 -33
- data/lib/csd/applications/minisip/base.rb +0 -125
- data/lib/csd/applications/minisip/init.rb +0 -20
- data/lib/csd/init.rb +0 -69
- data/lib/csd/path_container.rb +0 -15
- data/publish +0 -29
data/lib/csd/path.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'global_open_struct')
|
2
|
+
|
3
|
+
module CSD
|
4
|
+
class Path < GlobalOpenStruct
|
5
|
+
|
6
|
+
def self.root
|
7
|
+
@@root ||= Dir.pwd
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.root=(path)
|
11
|
+
@@root = path
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.gem
|
15
|
+
@@gem ||= File.expand_path(File.join(File.dirname(__FILE__), '..' ,'..'))
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.vendor
|
19
|
+
@@vendor ||= File.join(gem, 'vendor')
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.applications
|
23
|
+
@@applications ||= File.expand_path(File.join(gem, 'lib', 'csd', 'application'))
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.applications=(path)
|
27
|
+
@@applications = File.expand_path(path)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/lib/csd/ui.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'ui', '*.rb')) { |file| require file }
|
data/lib/csd/ui/cli.rb
ADDED
data/lib/csd/ui/ui.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module CSD
|
2
|
+
class UI
|
3
|
+
|
4
|
+
include Gem::UserInteraction
|
5
|
+
|
6
|
+
# These are all possible user interactions provided by the UI
|
7
|
+
#
|
8
|
+
INTERACTIONS = %w{ separator debug info warn error ask ask_yes_no }
|
9
|
+
|
10
|
+
def separator
|
11
|
+
say
|
12
|
+
end
|
13
|
+
|
14
|
+
def debug(message)
|
15
|
+
say "DEBUG: #{message}".magenta if Options.debug and !Options.silent
|
16
|
+
end
|
17
|
+
|
18
|
+
def info(message)
|
19
|
+
say message if !Options.silent
|
20
|
+
end
|
21
|
+
|
22
|
+
def warn(message)
|
23
|
+
say message.red if !Options.silent
|
24
|
+
end
|
25
|
+
|
26
|
+
def error(message)
|
27
|
+
if !Options.silent
|
28
|
+
say 'ERROR: '.red.blink + message.red
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def die(message)
|
33
|
+
say message.red.blink if !Options.silent
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
# This is just a convenience wrapper so that +UI.myinteraction+ will map to +CSD.ui.myinteraction+
|
40
|
+
#
|
41
|
+
def self.method_missing(meth, *args, &block)
|
42
|
+
INTERACTIONS.include?(meth.to_s) ? CSD.ui.send(meth.to_sym, *args, &block) : super
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/lib/csd/version.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'term/ansicolor/version'
|
2
|
+
|
3
|
+
module Term
|
4
|
+
# The ANSIColor module can be used for namespacing and mixed into your own
|
5
|
+
# classes.
|
6
|
+
module ANSIColor
|
7
|
+
# :stopdoc:
|
8
|
+
ATTRIBUTES = [
|
9
|
+
[ :clear , 0 ],
|
10
|
+
[ :reset , 0 ], # synonym for :clear
|
11
|
+
[ :bold , 1 ],
|
12
|
+
[ :dark , 2 ],
|
13
|
+
[ :italic , 3 ], # not widely implemented
|
14
|
+
[ :underline , 4 ],
|
15
|
+
[ :underscore , 4 ], # synonym for :underline
|
16
|
+
[ :blink , 5 ],
|
17
|
+
[ :rapid_blink , 6 ], # not widely implemented
|
18
|
+
[ :negative , 7 ], # no reverse because of String#reverse
|
19
|
+
[ :concealed , 8 ],
|
20
|
+
[ :strikethrough, 9 ], # not widely implemented
|
21
|
+
[ :black , 30 ],
|
22
|
+
[ :red , 31 ],
|
23
|
+
[ :green , 32 ],
|
24
|
+
[ :yellow , 33 ],
|
25
|
+
[ :blue , 34 ],
|
26
|
+
[ :magenta , 35 ],
|
27
|
+
[ :cyan , 36 ],
|
28
|
+
[ :white , 37 ],
|
29
|
+
[ :on_black , 40 ],
|
30
|
+
[ :on_red , 41 ],
|
31
|
+
[ :on_green , 42 ],
|
32
|
+
[ :on_yellow , 43 ],
|
33
|
+
[ :on_blue , 44 ],
|
34
|
+
[ :on_magenta , 45 ],
|
35
|
+
[ :on_cyan , 46 ],
|
36
|
+
[ :on_white , 47 ],
|
37
|
+
]
|
38
|
+
|
39
|
+
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
|
40
|
+
# :startdoc:
|
41
|
+
|
42
|
+
# Returns true, if the coloring function of this module
|
43
|
+
# is switched on, false otherwise.
|
44
|
+
def self.coloring?
|
45
|
+
@coloring
|
46
|
+
end
|
47
|
+
|
48
|
+
# Turns the coloring on or off globally, so you can easily do
|
49
|
+
# this for example:
|
50
|
+
# Term::ANSIColor::coloring = STDOUT.isatty
|
51
|
+
def self.coloring=(val)
|
52
|
+
@coloring = val
|
53
|
+
end
|
54
|
+
self.coloring = true
|
55
|
+
|
56
|
+
ATTRIBUTES.each do |c, v|
|
57
|
+
eval %Q{
|
58
|
+
def #{c}(string = nil)
|
59
|
+
result = ''
|
60
|
+
result << "\e[#{v}m" if Term::ANSIColor.coloring?
|
61
|
+
if block_given?
|
62
|
+
result << yield
|
63
|
+
elsif string
|
64
|
+
result << string
|
65
|
+
elsif respond_to?(:to_str)
|
66
|
+
result << to_str
|
67
|
+
else
|
68
|
+
return result #only switch on
|
69
|
+
end
|
70
|
+
result << "\e[0m" if Term::ANSIColor.coloring?
|
71
|
+
result
|
72
|
+
end
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
# Regular expression that is used to scan for ANSI-sequences while
|
77
|
+
# uncoloring strings.
|
78
|
+
COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
|
79
|
+
|
80
|
+
# Returns an uncolored version of the string, that is all
|
81
|
+
# ANSI-sequences are stripped from the string.
|
82
|
+
def uncolored(string = nil) # :yields:
|
83
|
+
if block_given?
|
84
|
+
yield.gsub(COLORED_REGEXP, '')
|
85
|
+
elsif string
|
86
|
+
string.gsub(COLORED_REGEXP, '')
|
87
|
+
elsif respond_to?(:to_str)
|
88
|
+
to_str.gsub(COLORED_REGEXP, '')
|
89
|
+
else
|
90
|
+
''
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
module_function
|
95
|
+
|
96
|
+
# Returns an array of all Term::ANSIColor attributes as symbols.
|
97
|
+
def attributes
|
98
|
+
ATTRIBUTE_NAMES
|
99
|
+
end
|
100
|
+
extend self
|
101
|
+
end
|
102
|
+
end
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Term
|
2
|
+
module ANSIColor
|
3
|
+
# Term::ANSIColor version
|
4
|
+
VERSION = '1.0.5'
|
5
|
+
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
|
6
|
+
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
7
|
+
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
8
|
+
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
class TestApplications < Test::Unit::TestCase
|
5
|
+
|
6
|
+
include CSD
|
7
|
+
|
8
|
+
context "When analyzing arguments" do
|
9
|
+
|
10
|
+
setup do
|
11
|
+
ARGV.clear
|
12
|
+
assert ARGV.empty?
|
13
|
+
Options.clear
|
14
|
+
end
|
15
|
+
|
16
|
+
context "and considering a valid application" do
|
17
|
+
|
18
|
+
setup do
|
19
|
+
@app = 'minisip'
|
20
|
+
assert Applications.find(@app)
|
21
|
+
end
|
22
|
+
|
23
|
+
context "the find function" do
|
24
|
+
|
25
|
+
should "find an application in the first argument" do
|
26
|
+
ARGV.push(@app)
|
27
|
+
assert_equal @app, Applications.current!.name
|
28
|
+
end
|
29
|
+
|
30
|
+
should "find an application in the second argument" do
|
31
|
+
ARGV.push('dummy')
|
32
|
+
ARGV.push(@app)
|
33
|
+
assert_equal @app, Applications.current!.name
|
34
|
+
end
|
35
|
+
|
36
|
+
should "find an application in the third argument" do
|
37
|
+
ARGV.push('foo')
|
38
|
+
ARGV.push('bar')
|
39
|
+
ARGV.push(@app)
|
40
|
+
assert_equal @app, Applications.current!.name
|
41
|
+
end
|
42
|
+
|
43
|
+
should "set nothing, if there is no valid app" do
|
44
|
+
ARGV.push('foo')
|
45
|
+
ARGV.push('bar')
|
46
|
+
ARGV.push('bob')
|
47
|
+
assert !Applications.current!
|
48
|
+
end
|
49
|
+
|
50
|
+
end # context "the find function"
|
51
|
+
|
52
|
+
context "the application module" do
|
53
|
+
|
54
|
+
should "know its name" do
|
55
|
+
assert_equal @app, Applications.find(@app).name
|
56
|
+
end
|
57
|
+
|
58
|
+
should "respond to options with a string" do
|
59
|
+
assert_kind_of(String, Applications.find(@app).options)
|
60
|
+
assert_kind_of(String, Applications.find(@app).options('install'))
|
61
|
+
assert_kind_of(String, Applications.find(@app).options('not_a_valid_action'))
|
62
|
+
end
|
63
|
+
|
64
|
+
end # context "the application module"
|
65
|
+
|
66
|
+
end # context "and considering a valid application, find"
|
67
|
+
|
68
|
+
end # context "When analyzing arguments"
|
69
|
+
|
70
|
+
#context "all" do
|
71
|
+
|
72
|
+
#should "return all apropriete Application objects as an array" do
|
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
|
81
|
+
|
82
|
+
#end # context "directories"
|
83
|
+
|
84
|
+
#end # context "As a Dir function"
|
85
|
+
|
86
|
+
end
|
@@ -1,58 +1,55 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'ostruct'
|
3
3
|
|
4
|
-
class Cmd
|
5
|
-
include Csd::Commands
|
6
|
-
attr_accessor :options
|
7
|
-
def initialize
|
8
|
-
@options = OpenStruct.new({ :silent => true, :quiet => true, :dry => false })
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
4
|
class TestCommands < Test::Unit::TestCase
|
13
5
|
|
6
|
+
include CSD
|
7
|
+
|
14
8
|
context "As a directory function" do
|
15
9
|
|
16
10
|
setup do
|
17
|
-
|
11
|
+
Options.silent = true
|
12
|
+
Options.reveal = false
|
13
|
+
Options.dry = false
|
18
14
|
@tmp = Dir.mktmpdir
|
19
15
|
@dir = Pathname.new File.join(@tmp, 'folder')
|
20
16
|
@subdir = Pathname.new File.join(@dir, 'subfolder')
|
21
17
|
end
|
22
18
|
|
23
19
|
teardown do
|
24
|
-
FileUtils.rm_r(@tmp)
|
20
|
+
assert FileUtils.rm_r(@tmp)
|
25
21
|
end
|
26
22
|
|
27
23
|
context "mkdir" do
|
28
24
|
|
29
25
|
should "return the proper CommandResult if the directory already existed" do
|
30
26
|
ensure_mkdir(@dir)
|
31
|
-
assert_kind_of(
|
27
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.mkdir(@dir))
|
32
28
|
assert result.success?
|
33
29
|
assert result.already_existed?
|
34
30
|
assert result.writable?
|
35
31
|
end
|
36
32
|
|
37
|
-
should "return
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
should "return a successful CommandResult but not actually do anything in reveal mode" do
|
34
|
+
Options.reveal = true
|
35
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.mkdir(@dir))
|
36
|
+
assert !@dir.directory?
|
41
37
|
assert result.success?
|
42
|
-
assert result.already_existed?
|
38
|
+
assert !result.already_existed?
|
43
39
|
assert result.writable?
|
44
40
|
end
|
45
41
|
|
46
|
-
should "
|
47
|
-
|
48
|
-
|
42
|
+
should "return a failing CommandResult but not actually do anything in dry mode" do
|
43
|
+
Options.dry = true
|
44
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.mkdir(@dir))
|
45
|
+
assert !@dir.directory?
|
46
|
+
assert !result.success?
|
49
47
|
assert !result.already_existed?
|
50
|
-
assert result.writable?
|
48
|
+
assert !result.writable?
|
51
49
|
end
|
52
50
|
|
53
|
-
should "create the directory if it doesn't exist yet
|
54
|
-
|
55
|
-
assert_kind_of(Cmd::CommandResult, result = @cmd.mkdir(@dir))
|
51
|
+
should "create the directory if it doesn't exist yet" do
|
52
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.mkdir(@dir))
|
56
53
|
assert result.success?
|
57
54
|
assert !result.already_existed?
|
58
55
|
assert result.writable?
|
@@ -61,11 +58,11 @@ class TestCommands < Test::Unit::TestCase
|
|
61
58
|
should "notify if there is no permission to create the directory" do
|
62
59
|
ensure_mkdir(@dir)
|
63
60
|
@dir.chmod(0000)
|
64
|
-
assert_kind_of(
|
61
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.mkdir(@dir))
|
65
62
|
assert result.success?
|
66
63
|
assert result.already_existed?
|
67
64
|
assert !result.writable?
|
68
|
-
|
65
|
+
@dir.chmod(0777) # Cleanup
|
69
66
|
end
|
70
67
|
|
71
68
|
end # context "mkdir"
|
@@ -73,24 +70,40 @@ class TestCommands < Test::Unit::TestCase
|
|
73
70
|
context "cd" do
|
74
71
|
|
75
72
|
should "return a CommanResult with success? if the directory was changed successfully" do
|
76
|
-
assert_kind_of(
|
73
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.cd('/'))
|
77
74
|
assert result.success?
|
78
|
-
assert_kind_of(
|
75
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.cd(@tmp))
|
79
76
|
assert result.success?
|
80
77
|
end
|
81
78
|
|
82
79
|
should "realize when the target is not a directory, but a file or something" do
|
83
80
|
testfile_path = File.join(@tmp, 'testfile')
|
84
81
|
File.new(testfile_path, 'w')
|
85
|
-
assert_kind_of(
|
82
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.cd(testfile_path))
|
86
83
|
assert !result.success?
|
87
84
|
end
|
88
85
|
|
89
86
|
should "realize when the target doesn't exist" do
|
90
|
-
assert_kind_of(
|
87
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.cd('/i/for/sure/dont/exist'))
|
91
88
|
assert !result.success?
|
92
89
|
end
|
93
90
|
|
91
|
+
should "fake changing the directory in reveal mode" do
|
92
|
+
Options.reveal = true
|
93
|
+
current_pwd = Dir.pwd
|
94
|
+
assert_kind_of(Commands::CommandResult, result = Cmd.cd('/i/for/sure/dont/exist'))
|
95
|
+
assert result.success?
|
96
|
+
assert_equal current_pwd, Dir.pwd
|
97
|
+
end
|
98
|
+
|
99
|
+
should "actually change the directory in dry mode" do
|
100
|
+
Options.dry = true
|
101
|
+
assert_not_equal '/', Dir.pwd
|
102
|
+
assert result = Cmd.cd('/')
|
103
|
+
assert result.success?
|
104
|
+
assert_equal '/', Dir.pwd
|
105
|
+
end
|
106
|
+
|
94
107
|
end # context "cd"
|
95
108
|
|
96
109
|
end # context "As a directory function"
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestOptions < Test::Unit::TestCase
|
4
|
+
|
5
|
+
include CSD
|
6
|
+
|
7
|
+
context "When analyzing arguments" do
|
8
|
+
|
9
|
+
setup do
|
10
|
+
ARGV.clear
|
11
|
+
assert ARGV.empty?
|
12
|
+
Options.clear
|
13
|
+
end
|
14
|
+
|
15
|
+
context "and identifying just help/action/application, parse_literals" do
|
16
|
+
|
17
|
+
teardown do
|
18
|
+
assert ARGV.empty?
|
19
|
+
end
|
20
|
+
|
21
|
+
should "not set anything if there is nothing" do
|
22
|
+
Options.parse_literals
|
23
|
+
assert !Options.help
|
24
|
+
assert !Options.application
|
25
|
+
assert !Options.action
|
26
|
+
end
|
27
|
+
|
28
|
+
should "find a lonely help parameter" do
|
29
|
+
ARGV.push 'help'
|
30
|
+
Options.parse_literals
|
31
|
+
assert Options.help
|
32
|
+
assert !Options.application
|
33
|
+
assert !Options.action
|
34
|
+
end
|
35
|
+
|
36
|
+
context "together with a valid application" do
|
37
|
+
|
38
|
+
setup do
|
39
|
+
@app = 'minisip'
|
40
|
+
assert Applications.find(@app)
|
41
|
+
end
|
42
|
+
|
43
|
+
should "find the lonely application" do
|
44
|
+
ARGV.push @app
|
45
|
+
Options.parse_literals
|
46
|
+
assert !Options.help
|
47
|
+
assert_equal @app, Options.application
|
48
|
+
assert !Options.action
|
49
|
+
end
|
50
|
+
|
51
|
+
should "find an action along with the application" do
|
52
|
+
ARGV.push 'myaction'
|
53
|
+
ARGV.push @app
|
54
|
+
Options.parse_literals
|
55
|
+
assert !Options.help
|
56
|
+
assert_equal 'myaction', Options.action
|
57
|
+
assert_equal @app, Options.application
|
58
|
+
end
|
59
|
+
|
60
|
+
should "find an action along with the application in help mode" do
|
61
|
+
ARGV.push 'help'
|
62
|
+
ARGV.push 'myaction'
|
63
|
+
ARGV.push @app
|
64
|
+
Options.parse_literals
|
65
|
+
assert Options.help
|
66
|
+
assert_equal 'myaction', Options.action
|
67
|
+
assert_equal @app, Options.application
|
68
|
+
end
|
69
|
+
|
70
|
+
should "understand whether an action is invalid" do
|
71
|
+
ARGV.push 'help'
|
72
|
+
ARGV.push 'invalid_action'
|
73
|
+
ARGV.push @app
|
74
|
+
Options.parse_literals
|
75
|
+
Options.actions = {'valid_action' => 'I am valid'}
|
76
|
+
assert_includes 'valid_action', Options.actions
|
77
|
+
assert !Options.valid_action?
|
78
|
+
end
|
79
|
+
|
80
|
+
end # context "together with a valid application"
|
81
|
+
|
82
|
+
end # context "and identifying help/action/application, parse_literals"
|
83
|
+
|
84
|
+
context "and identifying help/action/application together with scopes, parse_literals" do
|
85
|
+
|
86
|
+
should "know when it is a lonely non-application literal parameter" do
|
87
|
+
ARGV.push('myaction')
|
88
|
+
Options.parse_literals
|
89
|
+
assert !Options.help
|
90
|
+
assert !Options.application
|
91
|
+
assert !Options.action
|
92
|
+
end
|
93
|
+
|
94
|
+
end # context "and identifying help/action/application together with scopes, parse_literals"
|
95
|
+
|
96
|
+
end # context "When analyzing the options"
|
97
|
+
|
98
|
+
end
|